I'm using PointerLockControls
in Three.js
.
On mouse click, I want to update a sphere position to the position the camera is facing, at the same z-position
of a certain object. I've read about getDirection()
, but can't seem to implement it the right way. Here's what I tried:
var mouse3D = new THREE.Vector3();
mouse3D.normalize();
controls.getDirection( mouse3D );
sphere.position.x = mouse3D.x;
sphere.position.y = mouse3D.y;
sphere.position.z = object.position.z;
The z-position
is fine, but x and y are so close to 0 that the sphere stays "on the ground" and doesn't go "left or right".
Any help is much appreciated!