Accesing information of points in a model to calculate things like gradient etc

@JohnK

John this is a fantastic explanation, thank you very much
for your help and really again this is the best community of
this kind that i have ever seen, stunning

so the theory seems quite clear now, lets see if i understand
how to actually implement this

  • user clicks on a point in the model

  • I can then get that point:
    var pickInfo = scene.pick(scene.pointerX, scene.pointerY);

  • and the normal there:
    const normal=pickInfo.getNormal();

  • If I understand well, because that point is of course part of the tangent plane that includes it, I could calculate that plane doing:
    const plane = BABYLON.Plane.FromPositionAndNormal(P, N)

  • then doing plane.asArray() I can get the a,b,c,d from there, which provides the equation for the plane

  • in theory then the gradient at that point would be given as you calculated by:
    (-a / b, -c / b), which would be a 2d direction within the plane set in the 3d space

  • Now, if I wanted to provide the user with 2 things:

  • a) the actual direction of steepest ascent or descent within the 3d space, then I would need to actually provide a 3d vector right? how would I get that?

  • b) most importantly, and the final objective, if I wanted to actually visualize for the user an arrow that pointed in the direction of steepest ascent or descent, how would I do it, given that I am getting again a 2d vector but to represent that arrow in 3d space i need a 3d vector right?

thank you again for your help :slight_smile: