Compute
The standalone compute substrate: 133 pure geometry/value functions exported by @parashape/parametric/compute — value in, value out, no engine coupling (no registry, no Store, no node classes). This is the surface a node registry wires into its definitions (@parashape/parametric/nodes does exactly that) and the surface another project reuses without adopting the node catalog. Namespaced per domain module — function names are only unique WITHIN a module.
axis (5) · curve (28) · entities (3) · entity (13) · face (19) · faceValue (4) · font (4) · layer (1) · material (1) · parameter (16) · plane (4) · point (5) · solid (8) · surface (6) · surfaceValue (5) · vector (9) · root (2)
axis · 5
import { axis } from "@parashape/parametric/compute" // axis.direction(…)| Function | Signature | Description |
|---|---|---|
direction | direction(axis: Axis): Vector3D | The axis's unit direction vector. |
fromPointDirection | fromPointDirection(origin: Point3D, direction: Vector3D): Axis | ── Constructors ─────────────────────────────────────────────────── Build an axis from an origin point and a direction; the direction is normalized. |
fromTwoPoints | fromTwoPoints(from: Point3D, to: Point3D): Axis | Build an axis from a start point through a second point; direction = (to−from) normalized. |
origin | origin(axis: Axis): Point3D | ── Accessors ────────────────────────────────────────────────────── The axis's origin point. |
pointAt | pointAt(axis: Axis, distance: number): Point3D | The point on the axis at an arc-length distance from the origin. |
curve · 28
import { curve } from "@parashape/parametric/compute" // curve.arcCenterStartEnd(…)| Function | Signature | Description |
|---|---|---|
arcCenterStartEnd | arcCenterStartEnd(center: number[], start: number[], end: number[]): CurveJSON | |
arcTangentEnd | arcTangentEnd(axis: Axis, end: number[]): CurveJSON | Arc defined by a start axis (origin = start point, direction = leaving tangent) and an end point. |
arcThreePoints | arcThreePoints(start: number[], middle: number[], end: number[]): CurveJSON | |
circle | circle(center: number[], radius: number): CurveJSON | |
closestPoint | closestPoint(curve: CurveLike, point: Point3D): Point3D | |
cubicBezier | cubicBezier(start: number[], control1: number[], control2: number[], end: number[]): CurveJSON | |
curveChamfer | curveChamfer(curve: CurveJSON, distance: number, vertexFilter?: (p: Point3D, i: number) => boolean): CurveJSON | Bevel selected polyline corners with a straight setback. |
curveFillet | curveFillet(curve: CurveJSON, radius: number, vertexFilter?: (p: Point3D, i: number) => boolean): CurveJSON | Round selected polyline corners with an arc of the given radius. |
curveIntersect | curveIntersect(self: unknown, curve: unknown): CurveJSON[] | |
curveSelfUnionImpl | curveSelfUnionImpl(curves: unknown): CurveJSON[] | Self-union (reduce n→m): fold the OWN closed curves/regions into merged region boundary loop(s). |
curveSplit | curveSplit(curve: CurveJSON, parameter: number): CurveJSON[] | Split a curve at param t (0–1) → two curves. |
curveSubtract | curveSubtract(self: unknown, curve: unknown): CurveJSON[] | |
curveUnion | curveUnion(self: unknown, curve: unknown): CurveJSON[] | |
divide | divide(curve: CurveLike, count: number): Point3D[] | |
ellipseArc | ellipseArc(center: number[], xAxis: number[] | number, yAxis: number[] | number, angle?: unknown): CurveJSON | Elliptical arc — angle = 360 → full closed ellipse, < 360 → open arc. |
endPoint | endPoint(curve: CurveLike): Point3D | |
length | length(curve: CurveLike): number | |
nurbsCurve | nurbsCurve(points: number[][], degree?: unknown, knots?: number[], weights?: number[]): CurveJSON | |
pointAt | pointAt(curve: CurveLike, parameter: number): Point3D | |
pointAtLength | pointAtLength(curve: CurveLike, distance: number): Point3D | |
polygon | polygon(center: number[], radius: number, sides: number): CurveJSON | |
polyline | polyline(points: number[][], closed?: unknown): CurveJSON | ── Generators (open/closed 1D wires → CurveJSON) ────────────────── |
quadraticBezier | quadraticBezier(start: number[], control: number[], end: number[]): CurveJSON | |
rectangle | rectangle(point1: number[], point2: number[]): CurveJSON | Closed planar loops — fill them with `face.fill` (or feed straight into extrude/loft, which auto-fill a closed curve). |
spline | spline(points: number[][], degree?: unknown): CurveJSON | |
startPoint | startPoint(curve: CurveLike): Point3D | |
tangentAt | tangentAt(curve: CurveLike, parameter: number): Vector3D | |
textCurve | textCurve(font: FontData | null | undefined, content: string, fontSize: number): CurveJSON[] | Text → outline loops (one curve per letter contour, holes as separate loops). |
entities · 3
import { entities } from "@parashape/parametric/compute" // entities.addMesh(…)| Function | Signature | Description |
|---|---|---|
addMesh | addMesh(faces: EntityJSON | EntityJSON[] | null | undefined): EntityJSON[] | ── Mesh (baked entities literal → renderable, transformable) ───── A generator (return "entity") whose `faces` arg is a LITERAL baked entity array (NOT a node ref): the entities travel in the expression itself (`[{geo… |
clone | clone(source: EntityJSON | EntityJSON[] | null | undefined): EntityJSON[] | ── Clone (another node → independent deep copy) ────────────────── A generator (return "entity") whose `source` arg references ANOTHER node's output. |
placeModel | placeModel(source: EntityJSON | EntityJSON[] | string | null | undefined): EntityJSON[] | ── placeModel (string model ID → placed, independent copy) ────── A `placeModel` GENERATOR's `source` arg is a STRING model ID. |
entity · 13
import { entity } from "@parashape/parametric/compute" // entity.entitiesBoundingBox(…)| Function | Signature | Description |
|---|---|---|
entitiesBoundingBox | entitiesBoundingBox(entities: EntityJSON[]): BoundingBox | null | Shared bbox utility — reused by `resize` here and by the lengthX/Y/Z auto-seed helper (Model.ts) and hosts that need a world-space envelope (apps/sketchup's SketchUpHost) instead of each hand-rolling a min/max loop. |
flip | flip(entity: EntityJSON, plane: Plane): EntityJSON | Reflect an entity across a plane (Hessian [nx,ny,nz,d]). |
layer | layer(entity: EntityJSON, name: string): EntityJSON | |
material | material(entity: EntityJSON, name: string): EntityJSON | ── Properties (immutable apply) ─────────────────────────────────── |
move | move(entity: EntityJSON, vector: Vector3D): EntityJSON | |
moveMatrix | moveMatrix(vector: Vector3D): Transformation | ── Transforms (per-entity) ──────────────────────────────────────── Matrix builders — the single source of truth for the move/rotate transforms, reused both as per-entity ops (below) and as whole-array transforms (tra… |
name | name(entity: EntityJSON, text: string): EntityJSON | |
reflectionMatrix | reflectionMatrix(plane: Plane): Transformation | Reflect-across-a-plane matrix builder — the SSOT for both the per-entity `flip` (below) and the Instance-placement `mirror` (entities.ts). |
reverse | reverse(entity: EntityJSON, enabled?: number | boolean): EntityJSON | Reverse a single entity's direction/winding (1→1), flipping its outward normal. |
rotate | rotate(entity: EntityJSON, axis: Axis, degree: number): EntityJSON | Rotate about an axis (origin = pivot point, direction = rotation axis). |
rotateMatrix | rotateMatrix(axis: Axis, degree: number): Transformation | |
transformEntity | transformEntity(e: EntityJSON, tr: Transformation): EntityJSON | |
visible | visible(entity: EntityJSON, enabled: number | boolean): EntityJSON | |
face · 19
import { face } from "@parashape/parametric/compute" // face.asPathShapes(…)| Function | Signature | Description |
|---|---|---|
asPathShapes | asPathShapes(input: unknown): FaceJSON[] | Like asShapes(), but curves keep their own open/closed topology (via asOpenPath) instead of being force-closed — curveThicken strokes a path, it doesn't fill a boundary. |
asShapes | asShapes(input: unknown): FaceJSON[] | |
bakedPath | bakedPath(face: FaceJSON): PolyShape | The 2D PolyShape of a face in its own plane coords. |
coplanarGroups | coplanarGroups(regions: FaceJSON[]): FaceJSON[][] | Partition regions into coplanar groups (first member = the group's plane representative). |
faceOffset | faceOffset(face: FaceJSON, distance: number): FaceJSON | Inset (positive distance) or outset (negative distance) a planar face's boundary. |
fill | fill(curve: CurveJSON | CurveJSON[]): FaceJSON | ── Generators ───────────────────────────────────────────────────── Fill a closed curve loop (or curves forming a loop) into a planar region. |
fromPolyShape | fromPolyShape(shapes2d: Shape2d[], uvMatrix?: Transformation): FaceGeometry | For each result Shape2d, sample its boundary to polygon VERTICES (any arc segment is tessellated at a sane chord tolerance), unproject 2D→3D via the frame, producing 3D world loops. |
newellNormal | newellNormal(loop: Point3D[]): Point3D | ── Plane fitting (when uvMatrix is absent) ──────────────────────── |
planarIntersect | planarIntersect(a: FaceJSON, other: unknown): FaceJSON | |
planarOffsetAll | planarOffsetAll(faces: FaceJSON[], distance: number): FaceJSON | Offset ALL coplanar faces together, in ONE combined PolyShape (the group's shared frame) — same "process the coplanar group as one unit" principle as planarUnionAll: disjoint shapes that grow into overlap after offset… |
planarSubtract | planarSubtract(a: FaceJSON, other: unknown): FaceJSON | ── Modifiers (per-entity) ───────────────────────────────────────── |
planarThickenAll | planarThickenAll(faces: FaceJSON[], distance: number, joinType: OffsetJoinType, endType: OffsetEndType): FaceJSON | Thicken ALL coplanar paths together into one combined closed-strip outline — same grouping principle as planarOffsetAll/planarUnionAll. |
planarUnion | planarUnion(a: FaceJSON, other: unknown): FaceJSON | |
planarUnionAll | planarUnionAll(faces: FaceJSON[]): FaceJSON | Union of MANY coplanar faces in ONE Clipper call (NonZero fill — see normalizedPathIn). |
planeMatrix | planeMatrix(face: FaceJSON): Transformation | The face's frame, as a uvMatrix (used to place boolean results back in 3D). |
planeNormal | planeNormal(face: FaceJSON): Point3D | |
reverseShape | reverseShape(e: FaceJSON): FaceJSON | Reverse loop winding/direction. |
toPolylines3D | toPolylines3D(s: FaceJSON): Ring3D[] | |
toPolyShape | toPolyShape(face: FaceJSON): PolyShape | Build a 2D PolyShape from a face: project each 3D loop to 2D via the face frame (drop z). |
faceValue · 4
import { faceValue } from "@parashape/parametric/compute" // faceValue.area(…)| Function | Signature | Description |
|---|---|---|
area | area(face: FaceGeometry): number | Area of the face (outer loop minus holes). |
centroid | centroid(face: FaceGeometry): Point3D | Centroid of the outer loop vertices. |
contains | contains(face: FaceGeometry, point: Point3D): boolean | True if a point lies inside the face (within the outer loop, outside holes), projected onto the face's plane. |
normal | normal(face: FaceGeometry): Vector3D | Unit outward normal of the face's plane (from the outer loop). |
font · 4
import { font } from "@parashape/parametric/compute" // font.getFallbackFont(…)| Function | Signature | Description |
|---|---|---|
getFallbackFont | getFallbackFont(): FontData | null | |
parse | parse(buffer: ArrayBuffer): FontData | |
setFallbackFont | setFallbackFont(font: FontData): void | |
textClean | textClean(font: FontData, content: string, fontSize: number): Shape2d[] | Convert text to clean (boolean-unioned) Shape2d subpaths. |
layer · 1
import { layer } from "@parashape/parametric/compute" // layer.createLayer(…)| Function | Signature | Description |
|---|---|---|
createLayer | createLayer(name: string): LayerJSON | ── Generators ───────────────────────────────────────────────────── |
material · 1
import { material } from "@parashape/parametric/compute" // material.createMaterial(…)| Function | Signature | Description |
|---|---|---|
createMaterial | createMaterial(name: string, baseColor?: string, opacity?: unknown, texture?: string | null, colorFactor?: unknown): MaterialJSON | ── Generators ───────────────────────────────────────────────────── |
parameter · 16
import { parameter } from "@parashape/parametric/compute" // parameter.angle(…)| Function | Signature | Description |
|---|---|---|
angle | angle(v: unknown): number | |
area | area(v: unknown): number | |
boolean | boolean(v: unknown): boolean | |
color | color(v: unknown): string | ── Color ────────────────────────────────────────────────────────── Color is stored as a hex string (#rrggbb). |
currency | currency(v: unknown): number | |
fn | fn(v: unknown): unknown | ── Pass-through (handled by ParameterNode async) ────────────────── |
font | font(v: unknown): unknown | |
group | group(v: unknown): unknown | |
length | length(v: unknown): number | |
mass | mass(v: unknown): number | |
model | model(v: unknown): unknown | |
number | number(v: unknown): number | ── Scalar ───────────────────────────────────────────────────────── |
object | object(v: unknown): unknown | |
string | string(v: unknown): string | |
text | text(v: unknown): string | |
volume | volume(v: unknown): number | |
plane · 4
import { plane } from "@parashape/parametric/compute" // plane.distance(…)| Function | Signature | Description |
|---|---|---|
distance | distance(plane: Plane, query: Point3D): number | Signed distance from the plane to a query point (positive = normal side). |
fromPointNormal | fromPointNormal(point: Point3D, normal: Vector3D): Plane | ── Constructors ─────────────────────────────────────────────────── Build a plane from a point on it and its normal. |
normal | normal(plane: Plane): Vector3D | ── Accessors ────────────────────────────────────────────────────── The unit normal of the plane. |
point | point(plane: Plane): Point3D | A point on the plane (the one passed to fromPointNormal). |
point · 5
import { point } from "@parashape/parametric/compute" // point.distance(…)| Function | Signature | Description |
|---|---|---|
distance | distance(from: Point3D, to: Point3D): number | Point math (Point.* expression namespace) + a render generator that emits Point marker entities for visualizing positions. |
interpolate | interpolate(from: Point3D, to: Point3D, fraction: number): Point3D | |
midpoint | midpoint(from: Point3D, to: Point3D): Point3D | |
pointEntity | pointEntity(positions: Point3D[]): PointJSON[] | ── Generators (primitive → renderable marker entity) ────────────── |
translate | translate(point: Point3D, offset: Vector3D): Point3D | |
solid · 8
import { solid } from "@parashape/parametric/compute" // solid.asFaces(…)| Function | Signature | Description |
|---|---|---|
asFaces | asFaces(input: unknown): FaceJSON[] | Collect the Face faces from a value (single, array, or nested). |
facesToMesh | facesToMesh(faces: FaceJSON[]): Mesh | A solid's faces → a welded half-edge Mesh — the EXPENSIVE promotion (`toMesh()` = toJSON's 1e-6 vertex weld + fromPolygonMesh's T-junction stitch + half-edge build), required by the topology ops below. |
facesToPolygonMesh | facesToPolygonMesh(faces: FaceJSON[]): PolygonMesh | A solid's faces → a PolygonMesh, constructed DIRECTLY (Point loops, no index pool, no weld — PolygonMesh 0.10 stores faces independently). |
markWholeArray | markWholeArray(fn: T): T & { wholeArray: true } | ── Whole-array modifiers (operate on the parent's whole face-set) ── Marked `.wholeArray` so the engine passes the entire array (one solid) at once instead of mapping per-face. |
meshToFaces | meshToFaces(mesh: Mesh): FaceJSON[] | A Mesh → its faces as Face[]. |
nurbsToFaces | nurbsToFaces(nurbs: NurbsSurfaceJSON): FaceJSON[] | Tessellate a kernel NurbsSurface to a triangle mesh, then emit one planar face per triangle. |
solidSelfUnionImpl | solidSelfUnionImpl(faces: FaceJSON[]): FaceJSON[] | Fold all solids in one Face[] into a single fused solid (n→1). |
sweep | sweep(pathArg: unknown, profileArg: unknown, caps?: unknown): FaceJSON[] | |
surface · 6
import { surface } from "@parashape/parametric/compute" // surface.asPaths(…)| Function | Signature | Description |
|---|---|---|
asPaths | asPaths(input: unknown): CurveJSON[] | |
hydrateCurves | hydrateCurves(input: unknown): NurbsCurve[] | |
loft | loft(curves: unknown, degree?: unknown): FaceJSON[] | ── Generators ───────────────────────────────────────────────────── NurbsSurface is no longer a scene entity. |
patchFromCorners | patchFromCorners(corner0: Point3D, corner1: Point3D, corner2: Point3D, corner3: Point3D): FaceJSON[] | |
patchFromCurve | patchFromCurve(curves: unknown): FaceJSON[] | |
revolve | revolve(curves: unknown, axis: Axis, angle: number): FaceJSON[] | Revolve profile curve(s) about an axis (origin = a point on it, direction = spin axis). |
surfaceValue · 5
import { surfaceValue } from "@parashape/parametric/compute" // surfaceValue.area(…)| Function | Signature | Description |
|---|---|---|
area | area(surface: NurbsSurfaceJSON): number | Total surface area. |
curvature | curvature(surface: NurbsSurfaceJSON, u: number, v: number): number | Mean curvature of the surface at (u, v). |
isocurve | isocurve(surface: NurbsSurfaceJSON, parameter: number, direction: "u" | "v"): CurveJSON | Isocurve at `parameter` (0..1) in the given direction ("u" | "v") → a curve. |
normalAt | normalAt(surface: NurbsSurfaceJSON, u: number, v: number): Vector3D | Unit normal of the surface at (u, v). |
pointAt | pointAt(surface: NurbsSurfaceJSON, u: number, v: number): Point3D | Point on the surface at parameters (u, v) ∈ [0,1]². |
vector · 9
import { vector } from "@parashape/parametric/compute" // vector.add(…)| Function | Signature | Description |
|---|---|---|
add | add(left: Vector3D, right: Vector3D): Vector3D | |
angle | angle(from: Vector3D, to: Vector3D): number | |
between | between(from: Point3D, to: Point3D): Vector3D | |
cross | cross(left: Vector3D, right: Vector3D): Vector3D | |
dot | dot(left: Vector3D, right: Vector3D): number | |
length | length(vector: Vector3D): number | Vector math (Vector.* expression namespace) — pure value→value, clear arg names (no a/b/v). |
normalize | normalize(vector: Vector3D): Vector3D | |
scale | scale(vector: Vector3D, factor: number): Vector3D | |
subtract | subtract(left: Vector3D, right: Vector3D): Vector3D | |
root exports · 2
import { bakeGroup, render } from "@parashape/parametric/compute"| Function | Signature | Description |
|---|---|---|
bakeGroup | bakeGroup(entity: EntityJSON, definitions?: DefinitionMap, inherited?: Inherited, deep?: unknown): EntityJSON[] | Bake a (possibly nested) entity into a flat list of renderable leaf entities by exploding every groupEntity (resolving its definition from `definitions`). |
render | render(e: EntityJSON): SceneEntity | |