In my three.js scene, there is an object positioned at {x: 0, y: 0, z: -150}
, while the camera is placed at {x: 0, y: 0, z: 75}
. I am trying to allow the user to drag the camera around the object, keeping it in view at all times.
https://i.sstatic.net/dp6fA.png
The camera should move along the circular path when dragged to the left or right.
I attempted to achieve this by using the OrbitControls
and setting a pivotPoint
:
const controls = new OrbitControls(camera, renderer.domElement);
controls.update();
object.position.set(0, 0, -150);
pivotPoint = new THREE.Object3D();
object.add(pivotPoint);
camera.position.set(0, 0, 75);
camera.lookAt(object.position);
However, I am facing an issue where the camera is rotating around itself rather than around the object.