shannon Posted February 5, 2016 Share Posted February 5, 2016 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 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 7, 2016 Share Posted February 7, 2016 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?) 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. Quote Link to comment Share on other sites More sharing options...
shannon Posted February 7, 2016 Author Share Posted February 7, 2016 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) Wingnut 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 8, 2016 Share Posted February 8, 2016 BABYLON.Tools.CreateScreenshot(engine, camera, size) will be the right choice Especially due to the first reason you stated. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.