Reputation: 191
This is most likely a math issue. I have a line geometry that feeds its vertices positions to an arrow helper. The arrow helper runs normalize() on its direction vector to render its output. If I lay them over each other in the view the arrow vector shoots upward while the line is perfectly drawing to the right of the screen. I am expecting the arrow helper to be in sync with the line geometry.
var origin = new THREE.Vector3(0, 10, 0);
var direction = new THREE.Vector3(80, 10, 0);
direction.normalize();
/*
direction after its normalized
Object
x: 0.9922778767136676
y: 0.12403473458920845
z: 0
*/
http://jsbin.com/nazapabaxaco/1/edit?html,js,output
Mathematically this is actually correct for the arrow helper vector. But its not the expected result. If I increase the distance X to say 500 the two converge again but not completely, they are still out of sync and just shooting apart at a really long distance.
The vector in use would be coming from a moving object and not the camera's unproject method so the points need to remain dynamically fed into.
Upvotes: 2
Views: 6006
Reputation: 104843
You compute the direction vector by subtracting one line segment endpoint from the other, and then normalizing.
Upvotes: 4