Skip to main content

@math.gl/geometry/culling

From v3.0

@math.gl/geometry/culling tests bounding volumes against planes and provides analytic shape queries. Use it to reject objects outside a view frustum, intersect rays with shapes, and compute enclosing bounds.

Loading Frustum culling…

Usage​

import {BoundingSphere, CullingVolume, Plane} from '@math.gl/geometry/culling';

const volume = new CullingVolume([
new Plane([1, 0, 0], 1), // x >= -1
new Plane([-1, 0, 0], 1) // x <= 1
]);
const visibility = volume.computeVisibility(new BoundingSphere([0, 0, 0], 0.5));
// 'inside'

Features​

FeatureSupportNotes
Bounding spheres, AABBs and OBBs✅Bounding volumes, point-cloud bounds, planes, and ray representations.
Frustum classification and plane masks✅CullingVolume reports inside/intersecting/outside and supports hierarchical plane-mask reuse.
Analytic shape ray and closest-point queries✅Box, capsule, cylinder, plane and sphere queries avoid tessellating the shapes.
Triangle and segment kernels✅Ray/triangle and closest-point kernels include segment/triangle closest pairs.
Rotated 2D rectangle overlap✅intersectOrientedBoxes2D provides allocation-free oriented rectangle queries.
Large-scene acceleration structures◐Static indexes are separate APIs; individual culling kernels do not build or maintain an index.
Continuous collision dynamics❌No time integration, friction, restitution, constraint/contact solver, or general first-impact engine.
Universal exact-predicate certification❌Floating-point kernels retain documented degeneracy and scale limits; no general watertight/exact-arithmetic guarantee.

Installation​

npm install @math.gl/geometry

Choose a primitive​

APIUse it for
CullingVolumeVisibility against a set of inward-facing planes
AxisAlignedBoundingBoxBounds aligned with the coordinate axes
OrientedBoundingBoxBounds with arbitrary orientation
BoundingSphereA center and radius enclosing geometry
PlaneA normalized normal and signed distance
RayAn origin and direction for intersection queries
Analytic shapesBox, capsule, cylinder, plane, and sphere queries without tessellation
intersectOrientedBoxes2DAllocation-free rotated rectangle queries for screen-space labels and other 2D geometry

Test visibility​

Supply planes in the same coordinate space as the bounding volume. Plane normals face inward:

A camera frustum can be represented by six planes. computeVisibility() returns 'outside', 'intersecting', or 'inside'; render or refine intersecting objects as appropriate for the application. Plane masks allow children to skip tests already resolved by a parent's bounds.

Vector inputs can be numeric arrays, including core vectors; no renderer objects are required. This module handles geometric queries, not time-dependent collision simulation.

Attribution​

Bounding-volume and frustum code was ported from Cesium under Apache-2.0. See the source headers and distributed license notices for provenance.

See Attributions for the project-wide source inventory and acknowledgments.

Bounds and query extensions​

See bounds, frusta and geometric queries for closed-boundary bounds operations, depth-aware frustum extraction, ray conveniences, barycentric interpolation, triangle–box overlap and plane–segment intersections.