Jump to content

Instances and Multiple Cameras


 Share

Recommended Posts

Hi!

So I want to have a mini-me view of a mesh that will always be present in a little bubble in the lower left of my screen.

I figured the best way to do that is to have two active cameras. One is my regular camera as per usual, and the other is in a small viewport in the lower left with a layer mask that filters out everything except an extra instance of my mesh.

However, I'm noticing some strange behavior where only the first active camera will actually show the mesh and the instance. That is to say, I create the instance, and all is well, but then I push the new camera on the active cameras array and the new camera does not see either the mesh or the instance. If I switch the order of the active cameras (that is to say us unshift instead of push on the activeCameras), then the mesh and it's instance are both visible in the new camera, but not the old.

Do any of you have insight to how mesh instances work with cameras? I assumed it would be the same, but there seems to be some magic going on.

Thanks.

Link to comment
Share on other sites

Hiya @ZackMFleischman, welcome to the forum, good to have you here!  Sorry for the slow reply.

Yeah, activeCamera (with no 's') and activeCameras (with 's')... they are funnnnn.  (no, not really)  :)

We got a thing here called a 'renderTargetTexture'.  It... does just that... grabs a renderTarget, and makes it a texture... which can then be used on a near-camera plane (parented to camera to make a corner panel)... or use it with Babylon.Layer to make a foreground layer... or use it with our new Canvas2D system. 

RenderTargetTextures are super-handy.  Let's take a search of the playground database... http://doc.babylonjs.com/playground?q=renderTargetTexture&page=1&max=400&bf=all

Wowzers, we have results! 

Here's a weird/complicated demo, but it uses a renderTargetTexture nicely, in lines 51-55. 
http://www.babylonjs-playground.com/#5RGDQ#13

That also uses our new Canvas2D system... so it's fresh.  Whomever coded this... knows what they are doing, and this might be a benchmark/proof-of-concept demo.  Nice code.  I bookmarked it violently, for my own future learning.

http://www.babylonjs-playground.com/#1WROZH#6

1 main view, 4 sub-views.  Crazy!  Lines 39-57 do the dirty deed.  :)  I hope this helps.  A forum search might help, too.  Again, welcome to the forum... let us know your thoughts on ANYthing... (like project ideas and "can it be done?" questions.)  We love that stuff... 'round these parts.

Link to comment
Share on other sites

  • 3 months later...

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...