Reputation: 2673
Im trying to simulate laser shooting from moving object to another moving object.
If I have two Vector3
coordinates (x,y) in move and i need to render 3D Object start from X Finnish in Y (laser).
Something like this.
I have fixed height and depth of object, i dont know a length, i can get it by x.distanceTo(y)
. Length will be variable (objects are moving).
It is possible to draw object form X to Y? What is the best practice?
Upvotes: 0
Views: 264
Reputation: 19592
You can just use a cube and compute it's position, rotation and scale like this:
cube.position.addVectors( x, y ).divideScalar( 2 ); // place cube in the middle
cube.lookAt( y ); // rotate cube so it faces the end position
cube.scale.z = x.distanceTo( y ); // stretch cube
Upvotes: 2