I have an initial roll, pitch & yaw for my camera and so I update the camera rotation with the respective values and it seems correct.
When I create and update the OrbitControls() the values are lost and I don't see a way to set the initial direction in the OrbitControls() constructor or methods.
I tried creating the controls after I updated my camera and that didn't help.
Is it possible to do this?
// Molly
You can compute the initial lookAt / target into some Vector3 computed with spherical / cartesian conversion
Then set the Orbit controller's target with it and save the state. It will use this target as a reference from now on
// Your initial target
let sphericalTarget = new THREE.Spherical(1, Math.PI / 2 - pitch, yaw)
let target = new THREE.Vector3().setFromSpherical(sphericalTarget)
controls = new THREE.OrbitControls()
controls.target = target
controls.saveState()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With