Jump to content

Two scenes


Okavango
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...