Okavango Posted March 10, 2016 Share Posted March 10, 2016 Hi, I am a newbie in Babylon.js. I need to render two scenes in one canvas. One scene with it's camera is at left part of the canvas, and the second is at the right. Can't find such an example or figure out in documentation. How I can do this? Quote Link to comment Share on other sites More sharing options...
JohnK Posted March 10, 2016 Share Posted March 10, 2016 Try searching for multi-views in documentation. Cannot paste link at moment Quote Link to comment Share on other sites More sharing options...
iiceman Posted March 10, 2016 Share Posted March 10, 2016 Here we go: http://doc.babylonjs.com/tutorials/How_to_use_Multi-Views Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 11, 2016 Share Posted March 11, 2016 Hi Okavango, welcome to the forum... good to have you with us. Hello to John and Iceman, too! And everyone else. http://playground.babylonjs.com/#13TVWJ There's a multi-viewport demo - one scene, 3 cameras. (Actually, 5 cameras, because... the blue lines are cameras and viewports, too.) But, do you want two different scenes rendered side-by-side? If so, I would just put two canvas side-by-side in the html part. Maybe one will be id="renderCanvas" and another will be id="renderCanvas2". One would be engine.scenes[0] and the other... engine.scenes[1]. I have never tried this, but, it should work. Some mesh will use 'scene' in their parameters, and others might use 'scene2' in their parameters. You'll see a line in the above playground... var scene = new BABYLON.Scene(engine); That places a scene object into engine.scenes[0]. Right after that, maybe do... var scene2 = new BABYLON.Scene(engine); That places a scene object into engine.scenes[1]. I could be wrong. Please clarify if you want two different camera views of the same scene, or view two different scenes rendered-onto what appears to be a single canvas. (but likely would be separate side-by-side canvases) (canvi?). Thx! Again, welcome! Boz and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
JohnK Posted March 11, 2016 Share Posted March 11, 2016 If you wanted two different "scenes" (ie models) would it be possible to put the models far enough apart in a Babylon scene that when viewed from two cameras each camera would show only one of the models? Quote Link to comment Share on other sites More sharing options...
Okavango Posted March 11, 2016 Author Share Posted March 11, 2016 Yes, I need to render two scenes, not just two view of the same scene. 27 minutes ago, JohnK said: If you wanted two different "scenes" (ie models) would it be possible to put the models far enough apart in a Babylon scene that when viewed from two cameras each camera would show only one of the models? This is rather bad variant in my case, I prefer to avoid it. 6 hours ago, Wingnut said: But, do you want two different scenes rendered side-by-side? If so, I would just put two canvas side-by-side in the html part. Maybe one will be id="renderCanvas" and another will be id="renderCanvas2". One would be engine.scenes[0] and the other... engine.scenes[1]. I have never tried this, but, it should work. Some mesh will use 'scene' in their parameters, and others might use 'scene2' in their parameters. You'll see a line in the above playground... var scene = new BABYLON.Scene(engine); That places a scene object into engine.scenes[0]. Right after that, maybe do... var scene2 = new BABYLON.Scene(engine); That places a scene object into engine.scenes[1]. Wingnut, how it is possible to use two canvases with one engine ? I am looking in examples: // load the 3D engine var engine = new BABYLON.Engine(canvas, true); So, engine is initialized using a canvas. How we can add another canvases to it ?? Maybe it is possible to use two engines in such case? Like var engine1 = new BABYLON.Engine(canvas1, true); var engine2 = new BABYLON.Engine(canvas2, true); Have anybody tried this ? Thanks in advance Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 11, 2016 Share Posted March 11, 2016 Hi again, O! Yeah, now you are asking the difficult questions. I have no answers for those questions, and I have not seen a demo/example that applies, here. You might be correct... maybe 1 engine per canvas, and thus you need two engines. Interesting issue. Hopefully, smarter people than I... will respond soon. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 11, 2016 Share Posted March 11, 2016 This works: var engine1 = new BABYLON.Engine(canvas1, true); var engine2 = new BABYLON.Engine(canvas2, true); Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted March 11, 2016 Share Posted March 11, 2016 If you need only one canvas, you can also maintain two different "virtual" scenes by having one single scene, but the list of meshes for sceneA set to different layerMask than those for sceneB, and your two cameras layerMask set accordingly.. 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.