Box

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.

Constructors

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})

Functions

Box Copy ( )

Returns a copy of the Box.

nil Fit ( Object target, boolean recursive optional )

Sets the box to a bounding box fitting the given target's model and all its descendants if the optional parameter recursive is true.

nil Merge ( Box b )

Sets the box to the combination of both boxes.

Properties

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 This.Max.