Hey guys im struggling with the maths a little here and or the initial setup.
I have a transformNode with a mesh which also has child transformNodes with meshes.
My idea was to pick a child mesh set the camera target to the child transformNode and then update the camera’s position to match the orbit rotation of the child so you can navigate around the mesh by using the ArcRotateCamera. To make things a little easy the parent transformNode is always at origin.
The missing part of my formula is that I can’t seem to solve keeping the camera at a stable distance from the picked transformNode while orbiting the parent TransformNode.
I have a basic playground I’ve setup which results in the same problem.
However If i set the camera.target to the mesh in the playground and not its position to camera.setTarget() it works. and I have no clue as to why. If I attempt to do that outside the editor I get an ArcCameraRotate error about the target and refToAdd which im assuming is something to do with not getting a Vector.
In fact, TargetCamera has a target setter. This also works for passing a mesh, even if the type is only Vector3. I think this is for historical/backward compatibility reasons. Anyway, there’s the targetHost setter in ArcRotateCamera that lets you set a mesh as the target :
I swear I’ve been all over the camera docs. I can’t believe I missed this. But do you know the reason to limiting it to the Mesh Class? While the Playground demo works my setup is more complex in that I use a TransformNode as a parent and a collection of meshes as assigned to the node as children. So picking one of the meshes I have a method that returns the TransformNode. (Think of them as containers). So It would be awesome to be able to set the targetHost to a TransformNode. Otherwise in order to use targetHost I would need to create a mesh at the root of all the transformNodes and that would mean an additional 1200 meshes.