# Geometry Nodes - Rotate legos based on Normal Faces

I make a Lego model using Geometry Nodes from this tutorial: https://www.youtube.com/watch?v=LrEHoaq6QFE.

But now all the legos have the same rotation and face in 1 direction. If I want the Lego rotate followed the face normal (like the egg below). Do you guys know how to do it ??? (Lego limits by the 90-degree rotation, can't rotate freely)

• You could probably do this with proximity. For each box you have find the closest face of the original geometry. Get normal of that face. Compare it with the list of the 6 directional vectors you want and find the closest. Finally rotate each box so that top is in the direction of this vector. This is of course gonna be just visual and it won't give you a way to reconstruct it with real lego bricks Apr 14, 2023 at 11:13
• Can you give me the image of the geometry nodes? It really hard to understand. Apr 14, 2023 at 11:31

Ok I recreated my answer from the comment and made some screenshots so that you can Follow. What you need to do is find the closest face of the original geometry to each center point of the instances. This can be done by 'sample nearest' node and pluging 'position' node to sample position socket. The output of this node is an index of the closest face for each center point of instance.

After that you need to retrieve the normal attribute from the original geometry for each center point of the instances based on the index you retrieved in previous step.

And finally you need to align the z vector of the instanced geometry to the normal of the closest face and rotate the instance by it. This will give you this result which is exactly what you are asking for:

Now the thing is - like this it will work only for ortoghonal original geometry (as the normals are always facing the 6 directions you want). To make it work for any geometry you have two ways to go. Either Voxelise the original geometry before applying the geometry nodes. (remesh modifier -> Blocks) This way the normals are always gonna be within the bounds you want. Or you can compare the new normals to the 6 directional vectors you want, find the closest one for each normal and use it instead of it.

• I'd also recommend to delete points that are inside of the geometry before putting instances on them so that blender doesn't have to calculate with them (they are not visible anyway) Apr 14, 2023 at 13:54

Thanks a lot for Jiří Honzák answer. And to be honest, I have used the simple way by using "Sample Nearest Surface" Nodes.

But your last sentence is what I really looking for: " Voxelise the original geometry before applying the geometry nodes. (remesh modifier -> Blocks)".

Thanks a lot bro