arpo - 4 months ago 48

Javascript Question

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?

Answer

A little bit of math : direction = v2 - v1

Plus, a little bit of ThreeJS of documentation : https://threejs.org/docs/index.html?q=vec#Reference/Math/Vector3

Aannd ... Paf ! Solution !

```
var direction = new THREE.Vector3();
direction.subVectors( v2, v1 ) ;
```