freetoplay Posted August 30, 2018 Share Posted August 30, 2018 Hi everyone, I have a question about the best approach to my problem. I am working on a project that requires multiple scenes on one HTML page. My current approach is to create a web component that contains a HTML canvas, an Babylon engine, and a reference to the current Babylon scene. Then I create a N number of those components on the web page. But I am not sure if this is the best approach, since each scene has their own engines and it seems fairly slow. So I am wondering what would be a better approach to my problem? Quote Link to comment Share on other sites More sharing options...
JohnK Posted August 30, 2018 Share Posted August 30, 2018 A search on multiple scenes in the docs lead to http://doc.babylonjs.com/how_to/multi_scenes Quote Link to comment Share on other sites More sharing options...
dbawel Posted August 30, 2018 Share Posted August 30, 2018 Do you use React/Redux? This makes life much easier - unless you have to learn the basics of these frameworks. DB Quote Link to comment Share on other sites More sharing options...
freetoplay Posted August 30, 2018 Author Share Posted August 30, 2018 11 hours ago, JohnK said: A search on multiple scenes in the docs lead to http://doc.babylonjs.com/how_to/multi_scenes Yep, I saw that, but do you know if there is an advantage of this approach of using one render loop over my current approach, where every scene has their own engine loop, would it speed up performance? 11 hours ago, dbawel said: Do you use React/Redux? This makes life much easier - unless you have to learn the basics of these frameworks. DB Nope, I use Vue, but I can most likely translate React code to Vue code without too many changes. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted August 30, 2018 Share Posted August 30, 2018 1 hour ago, freetoplay said: Yep, I saw that, but do you know if there is an advantage of this approach of using one render loop over my current approach, where every scene has their own engine loop, would it speed up performance? Then there would be only one GL context. Not sure about an effect to frame rate, but should be less resources. One other thing you might try is perhaps only actually render a scene, when the mouse is inside a canvas. Kind of application specific, and would not work for scenes with animation. There is only one mouse though, so could be a sneaky cheat for some. Quote Link to comment Share on other sites More sharing options...
Guest Posted August 30, 2018 Share Posted August 30, 2018 Yes this is better to use only one engine as shaders and textures will be shared hence better performance and less resources required. freetoplay 1 Quote Link to comment Share on other sites More sharing options...
freetoplay Posted August 30, 2018 Author Share Posted August 30, 2018 1 hour ago, Deltakosh said: Yes this is better to use only one engine as shaders and textures will be shared hence better performance and less resources required. For scenes that uses similar meshes, are the meshes shared here as well? Quote Link to comment Share on other sites More sharing options...
dbawel Posted August 31, 2018 Share Posted August 31, 2018 @freetoplay Similar perhaps... But instances or clones, absolutely. DB Quote Link to comment Share on other sites More sharing options...
Guest Posted August 31, 2018 Share Posted August 31, 2018 @freetoplay meshes are not share across scenes Quote Link to comment Share on other sites More sharing options...
JohnK Posted August 31, 2018 Share Posted August 31, 2018 For scenes that have shared meshes another possibility is to have these in one scene, with (for want of a better term) multiple scenarios, on swapping scenarios from S1 to S2 use mesh.setEnabled(true) for meshes in S2 and mesh.setEnabled(false) for meshes in S1 but not in S2. Shared meshes will already be enabled. 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.