How do you click on an OBJ mesh and have the camera move to it?

Hello all, after several hours of getting nowhere I thought it was time for a playground (seen here) This is based on another playground…sorry couldn’t find it again.

I have imported an OBJ file (a cube) that has been broken into small meshes. This cube represents a room (normals facing inside). A small cube (box) sits inside this room. If you click the small box, and have the console open you will see ‘box’. No matter how you orientate the room you will always get ‘box’, even though you are clicking through walls. If you click on a wall you should see something like 'cube.012 or cube.057 ', this is one of the meshes that the large room cube is constructed from.

So here is my question, similar to this playground I would like the camera to move to a segment mesh and be able to rotate around it. I have tried to figure this out, but I am getting nowhere.
Any help would be appreciated…thanks.

Something like this?

I had a similar problem and i’ve started from the last PG you posted too.

You have to use a mesh to which lock the camera and then move this mesh (in the production code you have to make it invisible).
In such a way you have to redefine the panning, because the lockedTarget can’t pan anymore till you don’t move the mesh.

There is only one thing i don’t understand: why did you import such a cube to make a room? You can do the same simply with a BOX and setting sideOrientation: BABYLON.Mesh.BACKSIDE
If i’ve some time i modify the PG :wink:

Here it is:

@Mercurio thanks for your response. No sorry, this is not exactly what I am looking for. The box has been made this way as I want the camera to move to a part of the wall or ceiling of the room. The goal is to have a room, of any shape, that you can move around in (POV).

Ok understood. But i think that with the Cube you’re using is not possible because it seems that all meshes have position (0,0,0). So the movement is always made at the center of the cube.
I think you have to build a cube (or any other shape) with multiple plane/facet, each one with a different position.

@Mercurio Hi there, I have another post here that shows a simplified version of what I am after (posted a couple of days ago). I can’t use this version however as I can’t pick meshes through walls. If you go to my other playground, click a square, the camera will shift. I need every part, of what will be a large room, clickable.

1 Like