Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Block Collisions

Block collisions define the physical shape of a block. The engine uses the shape for collision, movement and selection. The collidable and selectable fields of the block definition decide whether the engine uses the shape for physics and for raycasts. These models are separate from render geometry.

Lighting reads the same shape. A cell face counts as covered when the collision bounds reach that face and fill the cell on both perpendicular axes. A shape whose bounds fill the cell closes all six faces, even when its geometry has a notch, which is what a stairs shape does. A slab closes its bottom face only, so light passes through its sides and its top.

Block collisions live under: namespace:collisions/block

Top-level fields

FieldTypeRequiredDefaultDescription
elementsobject[]yesN/DList of axis-aligned boxes that form the model. An empty list gives a shape with no boxes

Element object

FieldTypeRequiredDefaultDescription
minnumber[3]yesN/DAABB start in 1/16ths of a block
maxnumber[3]yesN/DAABB end in 1/16ths of a block

Examples

The figure shows the three shapes that follow. Each shape fills its cell in a different way.

Example: cube collision

{
  "elements": [
    {
      "min": [0, 0, 0],
      "max": [16, 16, 16]
    }
  ]
}

Example: slab collision

{
  "elements": [
    {
      "min": [0, 0, 0],
      "max": [16, 8, 16]
    }
  ]
}

Example: stairs collision

{
  "elements": [
    {
      "min": [0, 0, 0],
      "max": [16, 8, 16]
    },
    {
      "min": [0, 8, 0],
      "max": [8, 16, 16]
    }
  ]
}