Inspecting an object in the context of the scene without the rest of the scene spinning

TL;DR: I want to be able to inspect an object like this example without the scene around it also spinning.

At first I tried to accomplish this with simply rotating the object (not rotating the camera around the object), but couldn’t get it to work correctly. It would jump around when you picked up the cursor and started spinning again, and the ArcRotateCamera already worked so well…

So then I thought I would place the object I was inspecting below the world, switch to a new ArcRotateCamera that targets that object, make a new plane, make that plane a child of the new camera, give that plane a RenderTargetTexture that showed the view of the original camera showing the unmoving scene, and put the object I was inspecting in front of that plane. However, I tried using the code here to make the plane fit the ArcRotateCamera frustum, but when I went to make the RenderTargetTexture, I didn’t know how set the width/height correctly (you can see the issue here, the texture is too blown up).

However, now I feel like I might be going about this entirely the wrong way, and perhaps the secret is actually with layered viewports?

Anyway, if anyone knows the best way to go about it, or how to fix my previous attempt with the texture/frustum scaling, I would be very grateful.

Ok I did it: https://www.babylonjs-playground.com/#08A2BS#177 (this works, you just need to add another camera to really see it, since the layer matches the current camera view perfectly)

2 Likes