How to snap a 3D box on a grid

How to snap a 3D box on a grid.
like minecraft.

The same way you snap to a grid, but with one more position axis. Usually it’s done using “x = trunc(x/50)*50” to snap to a 50 pixel grid. You’ll just have to apply it to the x, y & z values.