Control Rotation in 2D and 3D
master2D Rotation
To prevent a box from being rotated to fit, set constrainRotation: true on the box object.
3D Rotation
To restrict an item to specific orientations, use the allowedRotations option with values from the RotationType enum.
Available RotationType values:
WHD, HWD, HDW, DHW, DWH, WDH.
// 2D Example
pack2D({
bins: [{ width: 100, height: 50 }],
boxes: [
{ width: 50, height: 100, constrainRotation: true },
],
});
// 3D Example
import { pack3D, RotationType } from 'binpackingjs/3d';
pack3D({
bins: [{ name: 'Bin', width: 100, height: 100, depth: 300, maxWeight: 1500 }],
items: [{
name: 'Fragile Item',
width: 150, height: 50, depth: 50, weight: 20,
allowedRotations: [RotationType.WHD, RotationType.DHW],
}],
});