@math.gl/geometry
Loading SphereGeometryโฆ
The @math.gl/geometry module provides renderer-independent CPU mesh data and primitive
tessellators. Built-in box, capsule, cylinder, plane and sphere dimensions follow the glTF 2.1
draft shape proposal.
Cube, cone, truncated-cone and icosphere convenience classes are adapted from the corresponding
luma.gl primitives.
All generated meshes use triangle-list topology and expose POSITION, NORMAL and
TEXCOORD_0 typed-array attributes. Index buffers automatically use 32-bit values when a mesh has
more than 65,535 vertices.
Entry pointsโ
| Import path | Use it to |
|---|---|
@math.gl/geometry/primitives | Generate primitive and parametric meshes. |
@math.gl/geometry/curves | Represent and sample curves. |
@math.gl/geometry/polygon | Clip, triangulate, and subdivide polygons and polylines. |
@math.gl/geometry/culling | Query analytic shapes, bounding volumes, and rays. |
@math.gl/geometry/processing | Process meshes, indices, and attributes. |
@math.gl/geometry/spatial-index | Index points, boxes, and triangles. |
@math.gl/geometry/arrow | Tessellate GeoArrow polygons. |
@math.gl/geometry/lighting | Sample photometric profiles. |
Usageโ
import {SphereGeometry} from '@math.gl/geometry/primitives';
const geometry = new SphereGeometry({radius: 1});
const positions = geometry.attributes.POSITION.value;
const indices = geometry.indices?.value;
Pass these CPU buffers to the renderer of your choice. The module does not create GPU resources.
Featuresโ
| Feature | Support | Notes |
|---|---|---|
| Primitive mesh tessellation | โ | Boxes, capsules, cylinders, planes, spheres and convenience shapes produce renderer-independent indexed buffers. |
| Parametric surfaces, lathes and tori | โ | ParametricGeometry, TorusGeometry and LatheGeometry sample explicit surface functions. |
| Normals, UVs and index-width selection | โ | Primitive POSITION/NORMAL/TEXCOORD_0 attributes and automatic Uint32 promotion for large meshes. |
| Projected bounds | โ | Sample edges and interiors with an explicit approximate/conservative qualification. |
| Projected texture coordinates | โ | Prepare image UVs from packed CPU positions without a rendering dependency. |
| Mesh processing | โ | Transform, merge, and weld indexed meshes. |
| Curve evaluation | โ | Sample Cartesian curves and compute transport frames. |
| Rigid articulated panel forests | โ | Experimental HingeTree evaluates hinge transforms with reusable matrix output. |
| Analytic queries | โ | Bounding volumes, rays, and shapes for Euclidean containment and intersection. |
| Polygon processing | โ | Clip, triangulate, and subdivide polygons. |
| Spatial indexing | โ | BoxIndex, PointIndex, and TriangleBVH accelerate repeated queries. |
| General solid modeling and manifold repair | โ | No public 3D Boolean solid, arbitrary remeshing, or general manifold-repair engine. |
| Deformable or constrained rigid-body simulation | โ | HingeTree has no closed-loop constraints, collisions, forces, or bending solver. |
| Photometry and color LUTs | โ | Optional lighting and color utilities sample angular intensity, integrate luminous flux and transform RGB/RGBA buffers. |
| GPU resource allocation and rendering | โ | The module supplies CPU data; GPU buffers, materials, draw calls, and device lifetime belong to rendering libraries. |
Installationโ
npm install @math.gl/geometry
APIโ
Geometrystores CPU attributes, optional indices, topology and draw count.unpackIndexedGeometry()expands an indexed mesh into non-indexed attributes.BoxGeometry,CapsuleGeometry,CylinderGeometry,PlaneGeometry,SphereGeometryimplement the glTF shape conventions.CubeGeometry,ConeGeometry,TruncatedConeGeometry,IcoSphereGeometryprovide additional common tessellators.PrismGeometryprovides closed flat-sided polygons, including hexagonal prisms;RingGeometryprovides solid annuli and capped ring segments.
An infinite glTF plane cannot be tessellated, so PlaneGeometry requires finite sizeX and sizeZ
values. Use PlaneShape from @math.gl/geometry/culling when infinite or partially infinite analytic
planes are required.
Primitive referenceโ
- BoxGeometry
- CubeGeometry
- CapsuleGeometry
- CylinderGeometry
- ConeGeometry
- TruncatedConeGeometry
- PlaneGeometry
- SphereGeometry
- IcoSphereGeometry
- PrismGeometry
- RingGeometry
- Geometry
Parametric surfacesโ
ParametricGeometry, TorusGeometry, and LatheGeometry
provide sampled surface generators from @math.gl/geometry/primitives, with an interactive gallery.
The experimental HingeTree evaluates rigid panels connected by hinges. See the
HingeTree API and
unfolding polyhedra example.