A Box represents a volume axis-aligned to a given space : it is defined with only two Number3, a minimum and a maximum, which represent the extents of the box along the axes of that space.

For example, a Shape.BoundingBox is axis-aligned to the model space of that shape, pertaining to its blocks.
However, an Object.CollisionBox is axis-aligned to the world space of the scene, like most physics-related boxes.

When using or creating an axis-aligned Box, be mindful of what space it is relevant to.


Box ( )
Box ( Number3 min, Number3 max )

Creates a default Box with no volume, or with given minimum and maximum points.

-- creates a box with both min & max = {0,0,0}
local box = Box()

box = Box({0,0,0}, {10,10,10})


Impact Cast ( Number3 direction, number maxDistance optional, CollisionGroups filterIn optional, Object filterOut optional )

Cast the Box along the given direction vector until max distance is reached, if provided.

The box will collide with any objects matching the filterIn collision groups. If nil is provided, the ray collides with all CollisionGroups by default.

Additionally, an object can be provided as filterOut to exclude it as a potential result. However, it is generally a best practice to filter using collision groups.

Box Copy ( )

Returns a copy of the Box.

nil Fit ( Object target, table config optional )

Sets the box to a bounding box fitting the given target's model.

Config table can contain any of the following: { recursive=boolean, local=boolean },
- recursive: the box will also fit all of target's descendants models. Default is false.
- local: result box will be in target's local space. Default is false, returning a box in world space.

nil Merge ( Box b )

Sets the box to the combination of both boxes.


Number3 Center read-only

Box geometric center point.

Box maximum point representing the upper extent along the axes.

Box minimum point representing the lower extent along the axes.

Size of the box from its minimum point. This automatically sets Box.Max.