Skip to main content

CapsuleShape

From v4.2

The convex hull of two spheres centered at [0, -height / 2, 0] and [0, height / 2, 0].

Usageโ€‹

import {CapsuleShape} from '@math.gl/geometry/culling';

const shape = new CapsuleShape({height: 2, radiusBottom: 0.5, radiusTop: 0.5});

Constructorโ€‹

new CapsuleShape(options?)โ€‹

OptionDefaultDescription
height1Distance between the sphere centers; finite and positive.
radiusBottom0.5Lower sphere radius; finite and nonnegative.
radiusTop0.5Upper sphere radius; finite and nonnegative.
matrixidentityOptional invertible affine local-to-world matrix.

The height excludes the rounded caps. At least one radius must be positive. Unequal radii produce a tapered capsule.

Queriesโ€‹

Implements the Shape interface, including containment, distance, ray and plane intersection, transforms, cloning, and enclosing bounds.

Dimensions and defaults align with the glTF 2.1 draft shape specification.