joeBImagine Posted August 27, 2018 Share Posted August 27, 2018 Hello Babylon community!! I have a query concerning implementing a callback in a callback for taking a screenshot of cameras. I have this function call createCameraView: function (camera) { let src; BABYLON.Tools.CreateScreenshot(engine, camera, { width: 293, height: 150 }, function (data) { src = data; }); return src; }, the callback function actually saves out the image for each camera (including the hidden on's) in the scene as a base64 to the images src tag, but that saving part takes time. The part that I am confused about is actually setting up a callback for the callback, that lets me know when the image itself is done rendering. I am sorry I do not have a playground as most of this code is internal. And also please forgive me if this is not enough information to understand my issue. Cheers! Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted August 27, 2018 Share Posted August 27, 2018 If you pass in the function you wish to run as an argument to createCameraView, then call assign it as the callback, then ditch the let, your anonymous function & the return. joeBImagine 1 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted August 27, 2018 Share Posted August 27, 2018 I think he means like a DOM image.onload callback, so when the screenshot has been made and is visible. joeBImagine 1 Quote Link to comment Share on other sites More sharing options...
joeBImagine Posted August 27, 2018 Author Share Posted August 27, 2018 Aww yes! Something similar to a DOM image.onload callback. But mainly for when it is fully made, so that I can update my react toolbar brianzinn 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted August 27, 2018 Share Posted August 27, 2018 So img.onload is not what you need? joeBImagine 1 Quote Link to comment Share on other sites More sharing options...
joeBImagine Posted August 27, 2018 Author Share Posted August 27, 2018 Come to think of it, you are right. I tried that before, but I wasn't implementing it correctly it would seem. let img = new Image(); img.onload = function () { alert("image is loaded"); } img.src = src; Quote Link to comment Share on other sites More sharing options...
Guest Posted August 27, 2018 Share Posted August 27, 2018 Perfect! 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.