3

On a scene I have an object that I'm looking at with a PerspectiveCamera. Using OrbitControls I can move around the object, rotate it, pan it etc.

What I want to do is move the object around to a certain location with a certain angle and then get the camera position and rotation. I would later update the camera with those values. The problem is that three.js doesn't apply some of those values. Here's what I'm doing to get the camera position, rotation, and the lookAt vector

console.log("Position", camera.position)
console.log("Rotation", camera.rotation)
console.log("World Direction", camera.getWorldDirection())

Once I get the vectors, write them down and apply them like this:

camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 2000);
camera.rotation.set(-3.14, -0.44, -3.14);
camera.position.set(-1067.29, 34.23, 205.82);
camera.lookAt(0.43, -7.10, 0.90)

But the problem is that the rotation and position get changed to some other value if I have used pan with OrbitControls

Nenad
  • 3,438
  • 3
  • 28
  • 36

1 Answers1

0

On Orbitcontrols you need to call "controls.update()" after changes to the camera's transform.

See code-example on OrbitControlDokumentation

Update: Attention: orbitcontrols seem to overwrite camera transforms