Physics · function

meshShape

Build a static mesh shape.

Explained in Your first game, Rigid bodies.

function meshShape(positions: Float32Array, indices: Uint32Array): ConvexShape
import { meshShape } from '@driftengine/physics';

Parameters

ParameterTypeDescription
positionsFloat32Array
indicesUint32Array

In depth

Returns a ConvexShape whose triangles names the mesh, whose vertices are the eight corners of its bounding box — so shapeBounds, boundRadius and the broad phase need no special case — and whose faceNormals and edgeDirs are empty. That last part is deliberate: a mesh has no separating axes worth enumerating, and handing the kinematic sweep the box's three would make it treat a hollow level as a solid brick.

positions and indices are kept, not copied, the same bargain packSplats makes: a level mesh is megabytes and duplicating it serves nobody. A caller must not go on mutating them, which is stated here because nothing enforces it.