Normals mesh is misdirected

Hello, I’d like to make sure that every time I click the mouse, it sets a cylinder. So far, everything is working the way I want. But I would also like the cylinder when I place it to be in the same orientation as the ground where it is. So I get the normals to be able to rotate, the cylinder is oriented but not at all as I want…
I’ve tried to condense the playground as much as possible… but for me it only comes from the normals, which are either not recovered properly or I’m doing it wrong. the only places where I use the normals are from line 165 to 197. thank you in advance for your reply.

Wrong orientation and ‘getHeightAtCoordinates’ error ?

no, it’s not the same problem

Hello :slight_smile:

Same description, same playground, like @Joe_Kerr I feel like you are doubling the topic here…


About your issue, the problem is here :

var rotation = pickresult.getNormal();

The function pickresult.getNormal() returns a normal, not a rotation.
You need to convert this normal to a rotation, for example using BABYLON.Vector3.RotationFromAxis :


The above playground solves the rotation issue, but I think if you want to “paint” using the sphere, it’s not the good way, since you are using only the mouse pick, while the sphere is bigger. Best would be to trigger some new Ray Picking, from the points in the sphere, so that each new cylinder is oriented well.


Also, I think you playground has several other issues, such as detaching camera control on click even if no pick hit (no way to rotate, then), etc…

++
Tricotou

thank you very much for your help, for me the calculation was made directly on the fact of returning normals … as I said I have condensed so there is not everything I have in my code. the suggestions that you say and that you have brought moreover is already present in my software.
Thank you again and good luck!

1 Like

Example with using Ray Picking from the sphere itself :
Screencast from 14-11-2024 11:47:54

2 Likes