3D bin packing algorithm