Add the ability to hold children
netgfx opened this issue · comments
Is your feature request related to a problem? Please describe.
I'm trying to attach children to the CameraControls in order for them to be "pinned" to the camera
Describe the solution you'd like
Being able to add children to the camera controls, like OrbitControls can
Describe alternatives you've considered
Alligning the camera position on every frame, but it feels like too much work for a simple task
Additional context
No response
How did you do that in OrbitControls?
Also, this might work for you, since Camera classes inherit Object3D.
const pinnedMesh = new THREE.Mesh(
new THREE.BoxGeometry( 1, 1, 1 ),
new THREE.MeshBasicMaterial( { color: 0xff00ff } )
);
scene.add( camera );
camera.add( pinnedMesh );
pinnedMesh.position.z = - 5;
In r3f we just included the Object as a child of the camera like
<PerspectiveCamera>
<mesh></mesh>
</PerspectiveCamera
then I guess I can just add that camera ref as the camera
in CameraControls?
Actually, I'm not sure because I don't really use R3F...
One thing I can say is that PerspectiveCamera must be a child of the rendering Scene.
Just attach them to cameraControls.camera, which is just a ref to the actual camera in the scene.