I have two points:
v1 = (0, 0, 0);
v2 = (10, 4, -3);
I want to get the direction between these two points so I can rayCast from point v1 to v2.
How do I do that?
The pattern to follow to create a direction vector from v1
to v2
is this:
var dir = new THREE.Vector3(); // create once an reuse it
...
dir.subVectors( v2, v1 ).normalize();
Direction vectors in three.js are assumed to have unit-length. In other words, they must be normalized. If the direction vector you use when raycasting does not have length equal to 1, you will not get accurate results.
three.js r.82
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