How to translate position in the direction of which it is facing

Im trying to create a very light crowd simulation with threejs, but i dont know how to apply the direction it is to the rotation, so that it moves in the right direction. Anyone have any solutions?

If you have the direction Vector3, you can move any Object3D by updating Object3D.position, which is a Vector3 as well.

I would use Vector3.addScaledVector, so that you can pass your direction vector and give a “speed” scalar :

const myObject = new THREE.Object3D();
const myDirection = new THREE.Vector3( 1, 0, 0 );
const speed = 0.1;

myObject.position.addScaledVector( myDirection, speed );
1 Like

Also getWorldDirection, in case you don’t know the direction.

2 Likes