I managed to write a pretty rudimentry box packing algorithm that laid boxes out from the top and pushing boxes up into the gaps where it would fit. The algorithm works ok but a little bit of randomness is needed to minimize the gap. Maybe I can run a regression over it.

The result is in Observable as a prototype which I’ll move the implementation into my codebase to run for the 3D map.

packing_layout.png