center of the box on the horizontal axis
center of the box on the vertical axis
center of the box on the depth axis
width of the box
height of the box
depth of the box
half the box size on each axis. Always non-negative; a negative extent passed to Box3d#setShape is stored as its magnitude, since a box with a mirrored axis has no meaning to the narrowphase.
the center of the box, as an offset from the owning body's position
the shape type (used internally)
depth of the box
height of the box
width of the box
true if this box contains the given point
point x, or a vector carrying the whole point
Optionaly: number = 0
point y
Optionalz: number = 0
point z
the 2D XY footprint of this box.
Deliberately 2D: this is the Renderable#getBounds contract that Body and the broadphase pre-gate already speak. For the depth extent use Box3d#getBounds3d.
the XY footprint
set new position and size for this box
center of the box on the horizontal axis
center of the box on the vertical axis
center of the box on the depth axis
width of the box
height of the box
depth of the box
this box, for chaining
An axis-aligned 3D box, usable as a Body collision shape.
This is the shape that lets a body collide along Z as well as X and Y. Every other built-in shape (Polygon, Rect, RoundRect, Ellipse) is planar and is resolved by the 2D SAT narrowphase, which can only ever produce a 2D pushback — see ResponseObject#overlapV. A
Box3dpair is instead resolved by an AABB-vs-AABB narrowphase that also fills ResponseObject#overlapZ.Coordinate convention matches the rest of melonJS 3D code (see Camera3d): Y-down, +Z forward / away from the camera.
Position is the CENTER
Unlike Rect (top-left) and like Ellipse (center),
posis the box center. That matches how 3D objects are placed everywhere else in the engine — Mesh, Sprite3d and the ground-shadow footprint all work from a center plus half-extents — and it keeps the narrowphase free of corner/center conversions on the hot path.Mixing with 2D shapes
A
Box3dcan collide with a planar shape. The planar shape is treated as unbounded along Z (an infinitely extruded prism of its own outline), so the pair degrades to the ordinary 2D test on the XY footprint and the box's z never causes it to miss. This keeps an existing 2D game working unchanged when a singleBox3dbody is introduced: its world shapes go on colliding exactly as before. UsecollisionType/collisionMaskto opt specific shapes out of a 3D body.Example