How to find new coordinates by length and direction = Vector3(0, 0, 0)?

How to find the new coordinates of a point, knowing the initial coordinates, direction and length of the line that the point will move to.
I searched in the documentation, but found only such a complicated way: I create a camera, set the direction, move the camera forward by a length, determine the camera coordinates.
Maybe there is an easier way? Help me please.

Updated: Added a question about Vector3(0, 0, 0)

final = start.add(direction.scale(distance))

where start is your initial coordinates as a Vector3, direction is a unit Vector3, if not already a unit vector do direction.normalize(), distance is the length of the line and final is the final coordinates as a Vector3;

If you are moving a mesh you can use translate, eg

mesh.translate(direction, distance, BABYLON.Space.WORLD);  //or
mesh.translate(direction, distance, BABYLON.Space.LOCAL);

Yes, thanks, move the mesh what I need, only the direction is Vector3(0, 0, 0) it doesn’t work
How to use direction = Vector3(0, 0, 0)?

Zero direction is no direction at all, so no movement.

It works if the direction is not zero

How then to move the mesh towards the origin of the coordinate axis (0,0,0) by a certain length?

Then (0, 0, 0) is not a direction it is a destination.

direction = destination.subtract(start).normalize(),

You need to find out more about position vectors verses direction vectors.

2 Likes

Thanks, this is what I need!