I am importing STL objects into my scene. Once the scene is loaded with the imported STL, I am trying to place “pins” (a sphere and cube joined mesh) on the imported stl item by double clicking in the scene. The problem is currently the “pins” are upright and therefore sometimes hidden inside the imported STL item.
Is there something I can do so that the pins are touching the stl mesh but always point away from it?
For example, the red pin in the upper right of the image is vertical but I want it to be more horizontal so it looks like it is coming out of the side of the imported stl mesh.
i guess you can use scene.pickWithRay in order to find the surface point of contact.
pickWithRay will return a PickingInfo where you can get the surface normal. Then just align your pin with the normal and place it at surface contact point
Is pickWithRay the same as scene.pick? I’m currently using the scene.pick function to get the x,y,z coords on dbl click to know where to place the “pin”.
Okay, making progress. Thanks again. I now have the surface normal but I’m struggling with aligning the pin by placing it at the surface contact point. Can you give me an example of how to do this with a mesh given I have the surface normal?
@jerome has made a BUNCH of posts about “direction to rotation”… which is really what you want, @tjshipe. Aligning the object… to the normal of the clicked face. I’m not very good at it.
In that #2A0HNY playground, look carefully at lines 23+.
I hope I’m helpful. I assume you can already get the normal of the double-clicked point. IF you have that, maybe these playground will teach how to convert the normal’s axis… to an object rotation. Maybe.