I have just added my camera to a group so I can set its position in VR in the demo below:
VR works, which is great, but now OrbitControls doesn’t work.
scene = new THREE.Scene();
scene.background = new THREE.Color(guiSettings.background);
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 5000);
cameraGroup.position.set(-200, 200, 450);
// eslint-disable-next-line no-new
new OrbitControls(camera, renderer.domElement);
// populate the tristogram
tristogram = new ThreeTristogram(scene, guiSettings);
oldImage = guiSettings.image;
Here’s the previous version where it worked:
Is it obvious to any of you why this stopped working? I assume it’s something I just don’t understand.
Oh, this is probably a clue (
object: (required) The camera to be controlled.
The camera must not be a child of another object, unless that object is the scene itself.
So by placing the
camera into a
Group, I probably break it. To me, this implies that
OrbitControls and positioning the VR camera are mutually exclusive. Is there some workaround?
I haven’t come back to this project yet, but I’ve been thinking about solutions. Could I only put the camera in the group when entering VR mode? Or … could I have two cameras, one for 2D and one for 3D and switch between them?