I want to be able to set the apex of a cone so that it points in the positive or negative x, y or z directions. Plus, I want the cone to rotate smoothly to it’s new direction.
Of the examples that ship with three.js, this one seems to demonstrate the technique:
So, I’ve tried to copy the rotation technique of that example.
If I want the cone to point in the +x direction, I create a point to ‘look at’ by adding a unit i3 vector (1,0,0) to the cone position
targetPosition = new THREE.Vector3().copy(cone.position).add(i3)
and then using the technique of the above mentioned example.
rotationMatrix.lookAt(targetPosition, cone.position, j3); //use up = j3=(0,1,0) targetQuaternion.setFromRotationMatrix( rotationMatrix );
Unfortunately, this approach doesn’t work. I can’t really even see what the pattern is in the behaviour I’m getting. In the case of clicking the button twice to look along an axis in a negative direction, whatever action is produced seems to get reversed on 2nd click.
Could anyone point out what my mistake is?