In Three.js, I want a camera to be pointed at a point in 3D space.
For this purpose, I tried using the camera.lookAt
function like so:
camer
I figured it out. To prevent THREE.TrackballControls
or THREE.OrbitControls
from overriding camera.lookAt
upon initialization, you need to change the line that sets the control's target
property to equal the sum of the camera.position
vector and the camera.getWorldDirection()
vector, instead of how it's currently implemented using a new THREE.Vector3()
(which defaults to (0, 0, 0)
).
So, for THREE.TrackballControls, change line 39 to:
this.target = new THREE.Vector3().addVectors(/*new line for readability*/
object.position, object.getWorldDirection());
Same goes for THREE.OrbitControls, on line 36.
I actaully haven't tested it on TrackballControls.js
but it does work on OrbitControls.js
. Hope this helps.