Get line's x,z by y

I need to find full Vector3 coordinate on existing line mesh by specifying y (or in other words - height).
I want to do it so I will be able to place a point (little sphere mesh) there.

Is it possible to do so? I went through docs but couldn’t find any clue how to…

Welcome aboard!

You can use the equation of a line to find x/z knowing y:

x=x0+t*a
y=y0+t*b
z=z0+t*c

(x0, y0, z0) is a point on the line and (a,b,c) the direction of the line.

If you know y, then compute t with the 2nd equation and compute x/z using the 1st and 3rd equations:

https://playground.babylonjs.com/#HMXWIF

3 Likes