Jump to content

taking a 'snapshot' of scene sometimes works, sometimes doesn't


shannon
 Share

Recommended Posts

hello ...

I am trying to take a 'snapshot' of a babylon3d scene ... in other words: I am trying to clone a babylonjs canvas when a user presses a button, and  then append the new <canvas> to the <body> .. Sometimes it works, but other times it does not.

However, if I use a simple canvas (ie. by using fillRect), the cloning/appending always works as expected.

I have set up a test on plunker to demonstrate my problem:plunker demo ... press the button over and over again to see how sporadic it behaves when there is a babylon scene. NOTE: You can toggle between the plain canvas and the babylon canvas from within the _jquery(document).ready(...)   handler .

thanks, Shannon

 

Link to comment
Share on other sites

Hi Shannon!  Welcome to the forum, good to have you with us.
I tried a fork and some experiments...  http://plnkr.co/edit/SSQ97mscP8x4Ds9EbFv5?p=preview

Open your console, I got some reporting happening.

That line 79 .ready() func... should run every click.  I wanted to replace your line 81... with my line 82.  Essentially, I was trying to make sure we were always targeting the LAST canvas in the document.  I thought maybe we were putting the BJS scene into canvas[0] over and over (and thus not filling the new canvas's).   (canvi = plural of canvas?)  :D

I have no real solutions figured, yet.  Just playing.  .ready() should execute every click.  It doesn't.  Not sure why not, yet.   Still learning.  :)  I'm sure smarter people than myself, will comment.  Again, welcome.  Interesting issue.

Link to comment
Share on other sites

solution at stackoverflow

basically: var lvo_engine = new BABYLON.Engine( lvo_canvas , true , {preserveDrawingBuffer : true} ) ;
however, this will affect performance for a complex 3d scene ... so there will need to be a toggle that turns this feature on when the button is clicked, and then turns it off after the clone has succeeded ...

Also, apparently Babylonjs has a BABYLON.Tools.CreateScreenshot(engine, camera, size)
                             

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...