UP_AND_ATOM Posted May 20, 2015 Share Posted May 20, 2015 I have a scene that I update every frame by calling scene.render(). I want to be able to run all the scene calculations, but without drawing to the canvas. How can I update the scene without telling it to draw to the engine's canvas? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 20, 2015 Share Posted May 20, 2015 Hello, I don't know why you would like to do this but I think this should work:scene.autoClear = false;scene.activeCamera.isIntermediate = true; Quote Link to comment Share on other sites More sharing options...
UP_AND_ATOM Posted May 20, 2015 Author Share Posted May 20, 2015 Well what I'd like to do is draw lines on a different canvas based on the position of the 3D objects in the scene. I don't want to actually show the scene, but instead just use it to calculate the locations of objects. When I do what you suggested, it just hides the background of the scene but the objects are still rendering. Is there a method that does everything that scene.render() does, but without actually drawing to the canvas? Quote Link to comment Share on other sites More sharing options...
RaananW Posted May 20, 2015 Share Posted May 20, 2015 I am not sure if I understood the use-case, but I'll give it a shot :-) You have two canvases, one is a webgl and the other is (probably) a simple 2d canvas. the one is on top of the other, probably using CSS. Why wouldn't you use CSS (display hidden for example) to hide the webgl canvas? Quote Link to comment Share on other sites More sharing options...
UP_AND_ATOM Posted May 20, 2015 Author Share Posted May 20, 2015 Sure, but that doesn't reduce the overhead for actually doing the rendering. I can hide it easily but I'm hoping to avoid a performance hit for calculating data that I won't end up needing. Quote Link to comment Share on other sites More sharing options...
RaananW Posted May 20, 2015 Share Posted May 20, 2015 I am not sure if the actual rendering takes so long. Never tested, but I understand that it is not needed, when you don't want to show anything on the webgl canvas.The fastest solution I would have is this:http://www.babylonjs-playground.com/#1WNTNWSimply overwrite the render function of the rendering manager, and it won't render a thing. It will, however, follow the changes in the scene (open your console and move the camera with the arrows, you will see the values change). I am not sure how helpful this is, it is actually just a hack :-) Maybe DK can help more. Quote Link to comment Share on other sites More sharing options...
UP_AND_ATOM Posted May 21, 2015 Author Share Posted May 21, 2015 I actually hadn't thought to override the render function but I'll try doing that next. I'm sure the cost of rendering isn't very high but I did want to run some tests. Thanks for the idea! Quote Link to comment Share on other sites More sharing options...
fenomas Posted May 21, 2015 Share Posted May 21, 2015 What is it that you need that doesn't get done until a render occurs? If you just need an object's updated position etc., calling the method to update its world matrix might do the trick without need of a render. Quote Link to comment Share on other sites More sharing options...
UP_AND_ATOM Posted May 21, 2015 Author Share Posted May 21, 2015 I haven't been able to locate that method. Do you happen to know where I can find it? Quote Link to comment Share on other sites More sharing options...
fenomas Posted May 21, 2015 Share Posted May 21, 2015 The method I was thinking about is computeWorldMatrix. I'm not sure if it would do what you need, but worth a try. The internals have a lot of special cases, so for example if the mesh has a parent I'm not sure if you'd need to call it on the parent first, etc.. Quote Link to comment Share on other sites More sharing options...
MarianG Posted May 21, 2015 Share Posted May 21, 2015 Or you can use "window.requestAnimationFrame(callback)" instead of scene.render() and in callback do all you want. Sorry but I not understand exactly what you are looking for. Quote Link to comment Share on other sites More sharing options...
UP_AND_ATOM Posted May 21, 2015 Author Share Posted May 21, 2015 I want to update the location of each mesh that's visible by the camera, but avoid any overhead from lighting and rendering, since I'm not using Babylon.js to actually do any displaying. I just want to be able to get the x and y (screen) coords of each vertex of certain meshes. I'm familiar with requestAnimationFrame, but I haven't been able to figure out what exactly I need to update every frame to keep the Babylon.js simulation going. Does that make sense? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 21, 2015 Share Posted May 21, 2015 having the right location of a mesh can be done by calling scene.animate() then for every mesh: mesh.computeWorldMatrix() Quote Link to comment Share on other sites More sharing options...
UP_AND_ATOM Posted May 22, 2015 Author Share Posted May 22, 2015 I can't find references to scene.animate in the code or docs. Does it go by another name? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 22, 2015 Share Posted May 22, 2015 Sorry this is scene._animate()https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/babylon.scene.ts#L734 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.