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:
camera.lookAt(new THREE.Vector3(-100,-100,0));
However, I found out that the call has no effect whatsoever. It just does nothing at all. I tried changing the numbers in the vector, and I always get the same look on screen, when it should be changing.
I just found now that if I remove the THREE.TrackballControls
I have in my code, the camera.lookAt()
works as it should. Is there something wrong with how I use THREE.TrackballControls? This is how I initialize them:
controls = new THREE.TrackballControls( camera, renderer.domElement ); controls.rotateSpeed = 10.0; controls.zoomSpeed = 1.2; controls.panSpeed = 0.2; controls.noZoom = false; controls.noPan = false; controls.staticMoving = true; controls.dynamicDampingFactor = 1.0; var radius = 5; controls.minDistance = radius * 1.1; controls.maxDistance = radius * 100; controls.keys = [ 65, 83, 68 ]; // [ rotateKey, zoomKey, panKey ]*/
And then in my render function I do:
function render() { controls.update(); renderer.render(scene, camera); }
Documentation on Three.js is pretty scarce, so I thought I'd ask here. Am I doing something wrong?
Looking at the source code of THREE.TrackballControls
, I figured out that I can make the camera look where I want by setting trackballControls.target
to the THREE.Vector3
I want it to look at, and then rerendering the scene.
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