Position Plane along the surface of picked point

I am trying to move a plane to the clicked point but it should rotate parallel to the picked surface (wall/roof/ground).

For example, imagine a hanging painting on the wall. When you click anywhere in the room then it should hang on the clicked position.

This is what I have done so far, it works well for the ground but on the ceiling & the wall, I get the perpendicular rotation.

https://www.babylonjs-playground.com/#14VWOV#9


Please I need help

You need to use the world-space normals:
var axis1 = pickInfo.getNormal(true);
https://www.babylonjs-playground.com/#14VWOV#10
Another way of doing it:
https://www.babylonjs-playground.com/#14VWOV#11
No idea which one is better, I guess that comes down to testing.

3 Likes

Perfect :ok_hand: Thank you @Raggar

Try this, muchos less code: