Guide
What it is: the COMPUTE tier - pure geometry math over Rust/WASM. Function-only namespaces (Point.*, BrepData.*, Curve2d.*, …). No scene graph, no file I/O.
numbers / JSON in → @huukhanhnguyen/geometry → numbers / JSON out
B-Rep: BrepData.* (solid-root or one-shell loader; no arena free)
2D fill: Curve2d { curves: PolyCurve2d[], transformation? }
3D curve: Curve { curves: PolyCurve[], transformation? }Install
pnpm add @huukhanhnguyen/geometryimport { BrepData, Point, Curve2d, Curve } from '@huukhanhnguyen/geometry'Namespace intros
Curated one-liners the docs generator shows as the guide strip on each namespace reference page. One bullet per namespace, spelled as a bold namespace name, a colon, then the one-liner (see the bullets below). Every namespace in the built package must have exactly one bullet here — the generator fails on a missing intro.
- Axis: The infinite 3D carrier (origin + unit direction, oriented): measurements (
closestPoint/distanceToPoint/shortestSegment) and local frame builders. Wire: length-3 vectors; frames as flattened origin + basis. - Axis2d: The infinite 2D carrier (origin + unit direction):
project/closestPoint/signedDistance/intersect/offset/reflect. Crate prefixline2d_*. - BoundingBox: Axis-aligned 3D box. Type
{ min, max }in@huukhanhnguyen/types; ops wire[minX,minY,minZ,maxX,maxY,maxZ]. - BoundingBox2d: Axis-aligned 2D box. Type
{ minX, minY, maxX, maxY }; ops wire[minX,minY,maxX,maxY]. - ArcCurve: Analytic 3D circular arc (full circle = sweep 2π). Unit F; was Circle.
- LineCurve: Bounded 3D line segment factory (
fromEndpoints). Unit F analytic family. - ArcCurve2d: 2D circular arc factories → the
type-taggedCurve2dJSONenvelope (Unit I; was Circle2d). - Collision: Clash detection over placed B-Rep documents (
[{ id, document, matrix? }]in, overlap pairs out), plus the bare AABB prefilter. - Color: RGB/HSL color math —
rgb/hslconversion,mix,contrast,luminance,lighten/darken/saturate/rotate. Wire:"#rrggbb". - NurbsCurve: 3D NURBS curves. Wire:
NurbsCurveJSON string.fromSubpathtakes a plane chain JSON (untagged segment bag at the wasm door; preferPolyCurve2d/Curve2dat TS call sites). - NurbsCurve2d: 2D curves in the
type-taggedCurve2dJSONenvelope (the tag is spelledtype, neverkind).type: "shape"is a plane chain (Curve2d atom).intersectis exact curve-curve (conic algebraic; NURBS seed+refine on the originals). - PolyCurve: Ordered chain of 3D curve segments (
{ segments: Segment[] }). Curve-entity geometry. Arc-length domain[0,1];addauto-reverses for G0 join (tol 1e-7). Factories:polyline/line/fromPoints/fromNurbs/fromCurveJson. Kind predicates (isLine/isArc/isEllipse/isNurbs/isPolyline/isSingleSegment) are pure segment-tag queries —type: "segment"window arms never match pure kinds. Segments meet end to start; a chain never branches. - PolyCurve2d: Ordered chain of 2D curve segments (
{ segments: Segment2d[] }, flattypetags). Same contract + same kind predicates; Curve2d rings/strokes are this. - EllipseCurve: Analytic 3D ellipse / elliptical arc (always carries angles). Unit F; was Ellipse.
- EllipseCurve2d: 2D ellipse factories →
Curve2dJSON(Unit I; was Ellipse2d). - Font: OpenType font registry (ids for
Text.*). - MeshData: Half-edge polygon mesh arena (handle). Not
TriangleMesh(indexed soup). Planar face UV is a 16-float matrix (uvMatrixon the face wire):MeshData.uvPlanar/MeshData.uvFromOriginbuild it,MeshData.uvApplymaps a world point →[u,v]. Layout:[ux,uy,uz,uOffset, vx,vy,vz,vOffset, 0,0,0,0, 0,0,0,1]. Tessellation bakes UVs into the triangle soup. - Nesting: 2D part nesting; bin/parts are
Curve2ddocuments. - Nurbs: Low-level NURBS basis/sampling shared by NurbsCurve and Surface.
- Plane: Infinite 3D plane (point + normal) and frames.
- Point: 3D point algebra and point-cloud ops. Wire: length-3 or flat xyz cloud.
- Point2d: 2D point algebra.
- Polyline: Open/closed 3D point chain. Wire: flat
[x,y,z,…]. - Curve: 3D multi-polycurve document:
{ curves: PolyCurve[], transformation? }. Construct (empty/fromCurves/fromPolyCurve) +transform. Boolean/offset stay on Curve2d. - Curve2d: Public 2D filled/stroked document:
{ curves: PolyCurve2d[], transformation? }(4×4 plane-in-world). Wasmpath2d_*. Legacy untaggedshapesstill accepted on read at the door. - Projection: Hidden-line classification of view edges.
- Quaternion: Unit quaternion rotations. Wire: length-4
[x,y,z,w]. - BrepData: B-Rep document (four tables): primitives, boolean, fillet, measure, heal,
fromFaces/faceLoops/thicken. Display mesh:BrepData.tessellate→TriangleMesh. Validate:BrepData.validate. - Surface: 3D NURBS surfaces. Wire:
NurbsSurfaceJSON string. - Text: OpenType shaping/outlines. Outlines are untagged segment bags on the wire; convert to
PolyCurve2d/Curve2dat the TS door. - Transformation: 3D 4×4 transforms (row-major length 16).
- Transformation2d: 2D affine 3×2 matrices (length 6).
- TriangleMesh: Indexed triangle soup (not half-edge MeshData).
- Noise: Perlin / Worley / fbm / turbulence.
- Stat: sum / mean / variance / percentile / fitLine.
- Vector: 3D vector algebra. Wire: length-3.
- Vector2d: 2D vector algebra.
Modules
- brepJson
- catalog/axis
- catalog/axis2d
- catalog/brep
- catalog/colorValue
- catalog/curve
- catalog/mesh
- catalog/noiseValue
- catalog/plane
- catalog/point
- catalog/polyCurve
- catalog/projection
- catalog/quaternionValue
- catalog/statValue
- catalog/transformValue
- catalog/triangleMesh
- catalog/types
- catalog/vector
- dual
- namespaces
- namespaces/ArcCurve
- namespaces/ArcCurve2d
- namespaces/Axis
- namespaces/Axis2d
- namespaces/BoundingBox
- namespaces/BoundingBox2d
- namespaces/Brep
- namespaces/Collision
- namespaces/Color
- namespaces/Curve2d
- namespaces/EllipseCurve
- namespaces/EllipseCurve2d
- namespaces/Font
- namespaces/LineCurve
- namespaces/Mesh
- namespaces/Nesting
- namespaces/Noise
- namespaces/Nurbs
- namespaces/NurbsCurve
- namespaces/NurbsCurve2d
- namespaces/Plane
- namespaces/Point
- namespaces/Point2d
- namespaces/PolyCurve
- namespaces/PolyCurve2d
- namespaces/Polyline
- namespaces/Projection
- namespaces/Quaternion
- namespaces/Stat
- namespaces/Surface
- namespaces/Text
- namespaces/Transformation
- namespaces/Transformation2d
- namespaces/TriangleMesh
- namespaces/Vector
- namespaces/Vector2d
- namespaces/Wire
- wasmExport
- wireMaterial