Runtime configuration knobs.
Loop walks are NOT configured here. Every .next walk is bounded
by loopWalkBound (the half-edge count), which only a
corrupt chain can exceed — an earlier change retired the old fixed
maxFaceDetectionDepth (50), which capped legitimate loop LENGTH
and so refused every face of more than 50 edges.
ADR-058 Path Y's two flags (useInnerLoopRegistry,
enablePathYPromotion) retired with Path Y (ADR-109 phase 4): a
slit or bridge inside a face is a wire in the vertex rings and in
no face loop, and the face it lies in is read off the rings
(FaceRegion.ts).
Note: the ADR-053 useSectorCycleSort flag was retired in step 4
(2026-05-15). sortEdgesAtVertex now always uses the face-loop-
direction-canonical sector-cycle splice; the legacy tangent-plane
sort survives only as a fallback for all-wire fans and transient
mid-construction states (see sortEdgesAtVertex and
sectorCycleSortAndRelink).
routeInscribedLoopsAsHoles — ADR-006 H2. When true (the
default), a closed loop drawn inside a face becomes a pane plus
an inner loop of that face. Shell builders (CuboidBuilder)
turn it off around the closing edge of their base wire, which is
transient (it is extruded, and its twin cycle closed as the
bottom cap, in the next two calls) and must not become a hole of
whatever face it happens to lie on.Unique identifier for this kernel instance.
Typically corresponds to a context definition ID in the scene graph, allowing commands and the undo system to locate the correct kernel after deserialization.
Optional callback invoked when the kernel encounters a non-fatal condition (e.g. degenerate face, dangling half-edge).
Set to null to suppress warnings.
ReadonlyrecordsPlan 122 H3 — the feature history (revolve, loft, sweep, patch fill records). Saved.
ReadonlytypeDiscriminant that identifies the kernel implementation. Reserved
for future variants; the only value today is 'half-edge'.
StaticdebugDebug postcondition hook for the edge-construction
path. When installed (see DevEdgeConstructionValidation.ts), it is
invoked after every mutating exit of makeFaceEdge, after each
full makeFaceEdgeWithCrossings chain, and — per a 2026-07-25
review — after makeArcEdge (both
the wire-pair and splitFace exits), splitEdge, killVertex,
killEdge, and splitFaceByExistingWireChain, giving per-OP
write-time attribution (the per-COMMAND DevCommandValidation layer
only attributes to the whole gesture). Held as an injected hook —
not a direct validateMesh call — because HalfEdgeMesh must not
import MeshValidator (dependency direction). null (the default)
is zero-cost.
Adds a standalone vertex to the mesh.
Optionalopts: { point?: boolean }
Optionalpoint?: booleantrue marks the vertex as a plotted point
(Vertex.isPoint) so the renderer draws its cross. Omitted
or false adds the plain construction vertex every kernel
operator has always added, with no own isPoint key.
A copy of this mesh sharing no entity or value with it: what
fromJSON(toJSON()) gives, made directly (MeshClone.ts).
Compute an average "face normal" over a vertex path via Newell's method. Semantics and caller contract:
The full contract is on computePathNormal, which this calls.
Number of connected manifold components (disjoint shells) in the mesh. Two faces belong to the same component when they share at least one edge — i.e. one face's half-edge has a twin whose face is the other. Inner loops participate in adjacency the same way as outer loops, so a plug face inside an annulus' hole is counted in the same component as the annulus.
The full contract is on countConnectedComponents, which this calls.
Deletes a set of entities (faces, edges, and/or vertices) from the mesh.
Processes deletions in dependency order: faces first, then half-edges, then vertices. Deleting a vertex cascades to all its connected half-edges. Pointer cleanup ensures remaining topology stays consistent.
Set of entity IDs (face, half-edge, or vertex) to remove.
Duplicates a set of vertices and all edges/faces fully contained within that set, in place (the copy is coincident with its source; the caller moves it).
"Fully contained" means: an edge is duplicated only if both its
endpoints are in the vertex set; a face is duplicated only if every
vertex of its outer loop is in the vertex set, with each of its
inner loops whose vertices are. A copied edge has its own copy of
the source edge's curve and a copied face of its surface; see
DuplicateEntities.ts for how the copy is built and for what a
surface-trim edge or host-patch face becomes when its host is
left behind.
Reports which copy each original became: vertex → vertex, half-edge → the copy running the same way, face → the copied face. A caller holding edge or face ids (a selection) can follow them onto the copy. An entity with no copy has no entry.
IDs of the vertices to duplicate.
Extrudes a face along its normal, creating side walls and a new top face.
Builds pillar edges from each base vertex to a new top vertex, connects the top vertices into a closed loop (top face), and stitches quad side faces between the base and top. The original face is consumed.
Arc edges (ADR-002): when a base edge carries an arc curve, the
corresponding top edge receives an independent clone of that arc with
the same radius/sweep/normal, and the side face is tagged as a ruled
surface. The top arc's center is translated
by the extrude offset so that the top face geometry matches the base
face geometry. For interactive drag (distance === 0 at call time), the
caller must receive the list of top arc curves via the out parameter
and translate their centers in lockstep with the top vertex positions.
Tapered extrude (ADR-002 Level 2): when scale !== 1, each top
vertex is moved toward/away from the base loop's taperPivot (the
center its arcs share, else its area centroid) by scale,
producing a frustum whose top cross-section is a scaled copy of the
base. Scaled top arcs have their center and radius scaled around the
same pivot. Arc-bounded side faces are tagged as ruled surfaces.
Straight-edge side faces remain planar
trapezoids (not tagged as ruled). scale === 1 is Level 1 behavior
exactly.
Apex collapse (ADR-002 Level 2b): when scale === 0 (within
tolerance), rail B degenerates to a single apex vertex. The top face
disappears; each side face becomes a triangle sharing the apex.
A FREE face (no neighbor across any edge) is reused as the bottom
cap with reversed winding, so the result is a closed pyramid/cone
solid. A face that has a neighbor (the top of a closed box) is
removed and the fan takes its place. The apex vertex is
published on the out parameter as apexVertex, and topFace is
undefined (no top face exists). Callers can also retrieve the
apex from the returned vertex array (length 1 in this case).
scale < 0 is still rejected.
The face to extrude.
Offset distance along the face normal. Zero creates topology only (useful for interactive drag).
Optionalout: {Optional out-parameter receiving the top face, top arc curves, and (for apex collapse) the apex vertex. Safe to omit.
Uniform scale factor applied to the top cross-section
around the base loop's taperPivot. Default 1 (parallel extrude).
Must be >= 0. scale === 0 triggers the apex-collapse path.
The newly created top vertices, in the same winding order as the original face vertices. For apex collapse, returns a single-element array containing the apex vertex.
Remove an inner loop (hole) from a face. The half-edges of the
loop have their face set to null (they become boundary / wire
edges).
The full contract is on fillHole, which this calls.
Restores the mesh from a JSON snapshot previously created by toJSON.
Clears all existing data, then reconstructs vertices, half-edges, faces, and all pointer relationships. The spatial index is rebuilt from the restored vertices.
The JSON object produced by toJSON().
Computes the axis-aligned bounding box of all vertices in the mesh.
A Box3-like object with min/max corners and helper methods, or null if the mesh has no vertices.
Returns all half-edges forming the boundary loop of a face (the
outer loop by default, or innerLoops[loop], or 'all').
The face to query.
An ordered array of half-edges around the face boundary.
Planarity check on a face's outer-loop vertices: do they all lie
within tol of the Newell plane? Called by pointInFaceTrimmed
to pick between the planar ray-cast branch and the ruled UV-space
branch.
Also used by the offset tool as the geometric planarity
gate for the offset gesture (ADR-003 quad invariant — every quad
carries a ruled descriptor, even when its four corners are
coplanar; the descriptor alone is not a reliable curvature signal
post-ADR-003). The offset tool needs a single face plane to offset
perpendicular to; a face whose outer loop is geometrically planar
has one, regardless of whether its surface descriptor is planar
or ruled. Twisted ruled surfaces (cylinder sides, half-disk
extrude sides) fail this test and are correctly refused.
Lazily-cached simplicity check for a face's outer
boundary loop. Reads face.isSimpleCache; if null/undefined,
recomputes via isLoopSimple(face.outerLoop) and stores the
result. Returns true for faces with a null outerLoop (no
loop = vacuously simple; rule 2 already catches null-outer-loop).
The full contract is on isFaceOuterLoopSimple, which this calls.
Test whether the half-edge loop starting at startEdge is "simple":
it closes within loopWalkBound steps without revisiting a
half-edge, and no edge has both halves on it.
The full contract is on isLoopSimple, which this calls.
Whether v is on the outer region of f: its outer loop, a wire
lying in it off that loop (a slit), or an island a wire joins to it
(a bridge) — what the threaded outer loop visited while ADR-058
Path Y threaded slits into it. Read off the vertex rings
(FaceRegion.traceRegionCycle). Bounded.
Inverse Euler Operator: Kill Edge (KEF-like).
The full contract is on killEdge, which this calls.
Inverse Euler Operator: Kill Vertex (KEV-like).
Removes a degree-2 vertex and merges its two incident edges into a single edge. Commonly used to clean up collinear subdivisions after edge splits. Isolated vertices (degree 0) are simply deleted.
The vertex to remove. Must have exactly 0 or 2 incident edges.
True if the vertex was successfully removed, false if its
degree is not 0 or 2 (including a vertex whose halfEdge
pointer is null while a half-edge is still headed at it).
Creates a general ruled surface face between two existing boundary half-edges (the "rails"). The resulting face is bounded by the two rail edges plus two new straight "ruling" edges connecting their endpoints.
The full contract is on loftBetweenEdges, which this calls.
Create one or more arc edges between two existing vertices, auto- splitting any existing edge that the new arc crosses and partitioning the input arc into sub-arcs at every intersection point. The arc sibling of makeFaceEdgeWithCrossings — closes an earlier bug.
The full contract is on makeArcEdgeWithCrossings, which this calls.
Create a cubic Bezier edge pair between v1 and v2, attaching
the same BezierCurve object reference to both halves
(twin-sharing, per ADR-009 F1 / ADR-008 Phase 3 precedent).
The full contract is on makeBezierEdge, which this calls.
F5b-kernel — create a general-degree non-rational Bezier wire edge
between two existing vertices. Mirrors makeBezierEdge for
the new BezierGeneralEdgeCurve variant of EdgeCurve (any
degree n ≥ 1).
The full contract is on makeBezierGeneralEdge, which this calls.
Creates a closed circular arc edge as a single-vertex monogon and builds the enclosed disk face directly.
Topology produced:
The full ArcCurve has sweepAngle = 2π and is shared by both halves of the pair (same convention as ordinary arc edges).
Bypasses detectFace entirely — the face is constructed directly because length-1 cycles are otherwise rejected as degenerate by the generic detector.
The new vertex, edge, and face.
ADR-035 Phase 1 — author a free-standing face carrying a full
NurbsSurfaceBicubic as its interior surface (the "single-source
NURBS face" design).
The full contract is on makeNurbsSurfaceBicubicFace, which this calls.
ADR-009 F5a Phase 3d-kernel — create a free-standing face whose interior surface is a rational bicubic Bezier patch.
The patch carries a 4×4 net of control points and a 4×4 net of
positive weights, both stored row-major in flat arrays of length
16. With i indexing the u-direction and j the v-direction,
the surface is
S(u, v) = (Σ_{i,j} B_i(u) B_j(v) w_{i,j} P_{i,j}) / (Σ_{i,j} B_i(u) B_j(v) w_{i,j})
for (u, v) ∈ [0, 1]². The four corner controls coincide with
the surface corners:
P_{0,0} = S(0, 0) P_{3,0} = S(1, 0)
P_{0,3} = S(0, 1) P_{3,3} = S(1, 1)
Boundary derivation. The four boundary curves are themselves rational cubic Beziers extracted directly from the rows / columns of the 4×4 net. The face's outer loop is a 4-edge cycle whose half-edge curves are exactly those derived rational cubics. The boundary walk (CCW from the surface's outward normal) is:
(u=0,v=0) → (u=1,v=0) via row v = 0 — edgeV0
(u=1,v=0) → (u=1,v=1) via column u = 1 — edgeU1
(u=1,v=1) → (u=0,v=1) via row v = 1 (reversed) — edgeV1
(u=0,v=1) → (u=0,v=0) via column u = 0 (reversed) — edgeU0
The half-edges walk the boundary; their twins walk the outside
loop. Each curve object is shared between a half-edge pair via
the EdgeCurve twin-sharing convention (same pattern as
ArcCurve / BezierCurve / RationalBezierCubic).
Free-standing. No twin half-edge is wired into any other
face; the face is created standalone with its twins left in the
outside loop. Mirrors makeTangentDevelopableFace /
makeDevelopableBezierFaceFromRail's "fresh free face" pattern.
Rejection paths. Returns null if any precondition fails;
the mesh is left untouched.
controls.length !== 16 or weights.length !== 16.≤ 0 or non-finite (rational evaluation
requires positive weights; see RationalBezierSurfaceMath).Caller-side mutation of the passed-in controls / weights
arrays does NOT affect the face: the builder snapshots both into
freshly allocated arrays of fresh Vector3 instances. The
boundary curves' control points are likewise fresh clones so the
mesh owns its full geometric state.
Row-major 4×4 weight net (length 16, all > 0).
The newly created face, or null on any precondition
failure.
F5a Phase 2a — create a rational cubic Bezier wire edge between
two existing vertices. Mirrors makeBezierEdge for the
RationalBezierCubic variant of EdgeCurve.
The full contract is on makeRationalBezierEdge, which this calls.
F5b-kernel — create a general-degree rational Bezier wire edge
between two existing vertices. Mirrors makeRationalBezierEdge
for the new RationalBezierGeneralEdgeCurve variant of
EdgeCurve (any degree n ≥ 1).
The full contract is on makeRationalBezierGeneralEdge, which this calls.
ADR-031 F5c-kernel — create a tangent-developable face from a
cubic directrix and a constant ruling parameter range. The
directrix may be any of BezierCurve (non-rational cubic),
RationalBezierCubic, or NurbsCurveCubic (cubic clamped) —
§7 admits the first; §8 extends to the latter two.
The full contract is on makeTangentDevelopableFace, which this calls.
The point of edge nearest point, on its true curve: the segment
for a line, the arc or ellipse itself, the nearest point of a Bezier
or a trim. null when the curve cannot be evaluated (as
findEdgeAtPoint skips such an edge).
A caller that splits an edge found NEAR a point (within
findEdgeAtPoint's tolerance) splits it here: splitEdge cuts an
arc or ellipse at the point's angle and puts the new vertex at the
point given, so a point off the curve left the sub-arcs' ends off
their vertex (found by the tool fuzzer, offset-disc-and-chord-arc-gap).
Offsets a planar face inward (or outward for negative distance), creating an inner face and connecting "frame" quads between the original boundary and the new offset boundary.
The face to offset.
Positive = inset, negative = outset.
The newly created inner face and its vertices, or null on failure.
Public ADR-026 Phase 2(a-curved) — project a world-space point
onto a ruled (or developable-bezier) face's (u, v) parameter
space, returning the parameter pair that minimizes the residual
distance to the patch.
Thin wrapper over invertRuledBilinear (PointLocation.ts) so the
sub-region bump path (SubRegionExtrude.extrudeFaceSubRegionBump)
can locate each inscribed-loop vertex's host (u, v) and ask
RuledSurface.normalAt for the true surface normal there.
Centralizing the monogon self-loop flip resolution (the G2
useFlippedB xy-distance heuristic) in this one place — rather
than re-deriving it in the bump module — keeps the parameter
convention single-sourced.
A face whose surface exposes a (railA, railB)
rail pair (kind: 'ruled' or 'developable-bezier'). The
rail pair is read directly; the bilinear blend
S(u, v) = (1 − v)·A(u) + v·B(1 − u) is the same for both
kinds (only the rail curve TYPE differs, which the rail
samplers already dispatch on).
{ u, v, distSq } — the best parameter pair (with v
clamped to [0, 1]; u unclamped) and the squared residual
distance — or null when the face is not ruled-with-rails
or the inverse cannot be computed (every sampled ruling
degenerate).
Public alias for indexFace so external helpers can refresh the spatial index after mutating face topology in place.
Reverses the winding of a face's outer loop (and every inner loop, per ADR-006 orientation convention). If the face belongs to a 2D sheet component with neighbors reachable through its inner loops (e.g. an annulus face whose hole contains a plug face), the whole component is reversed atomically so orientation stays consistent across the shared edges.
The full contract is on reverseFaceWinding, which this calls.
ADR-028 Phase R2 — build a faceted surface of revolution from an OPEN profile, collapsing axis-touching endpoints to a single pole apex (sphere / dome construction).
This is the open-wire-chain sibling of revolveProfileFaceted
(which consumes a closed Face). Where the closed path extrudes a
cap ring N times, an open profile has no cap to extrude — so this
builds the station rings of vertices explicitly and wires every band
face from scratch in one consistent DCEL pass (the same manual-wiring
idiom as extrudeFaceApexCollapse and
weldSeamRingsToTube: no sortEdgesAtVertex mid-construction,
which would read half-built loops — ADR-053 Risk #1).
A profile endpoint flagged on the axis (poleFlags[j] === true)
sweeps to zero radius: instead of an N-fold ring of coincident
vertices (a non-manifold zero-radius spike), all its rotated copies
collapse to ONE shared apex vertex. The band adjacent to a pole
is then a triangle fan converging on the apex (one quad rail
degenerates because both its endpoints are the apex); non-pole bands
are ordinary ruled quads. Both endpoints on the axis → two poles
(sphere); one endpoint → one pole (dome).
For a full 2π sweep the last station IS station 0 (the same ring vertices are reused for the wrap-around band), so the seam carries no duplicate vertices — the structural equivalent of the R1.1 weldSeamRingsToTube guarantee, achieved here by construction rather than by welding two pre-existing free rings (an open build has none to weld). For a partial sweep the two angular end stations get planar cap faces closing the wedge (the profile polyline closed by a chord from the last profile vertex back to the first).
χ = V − E + F = 2. Two triangle fans + M−3 quad bands.χ = 1.χ = 1.The ordered open profile vertices P[0..M-1]
(M ≥ 2), already present in the mesh. Walk order defines the
band correspondence; the chain is treated as open (no segment
between P[M-1] and P[0]).
Per-vertex axis-touch flags, parallel to
profileVerts. Only the two endpoints (0 and M−1) may be
flagged; an interior pole would split the surface and is
rejected.
Angular subdivisions N (≥ 3 for a full revolve, ≥ 1 otherwise).
true for a full-2π closure (stations
0..N−1, wrap band N−1 → 0, no caps); false for a partial
sweep (stations 0..N, caps at stations 0 and N).
false leaves a partial sweep open at its ends.
The created faces split into sideFaces (the band quads /
fan triangles) and capFaces (the two angular end caps, or
[] for a full revolve), plus the apexVertices actually
created (0, 1, or 2).
Set or clear the color of a face. Pass null to remove a custom color (revert to default rendering).
Finds and splits any edges that intersect with the segment [start, end].
Thin wrapper around splitEdgesByCutter with a LineCutter.
Preserves the legacy Vertex[] return type for callers that don't need
the parameter / pre-existing flags.
Sorted list of intersection vertices (existing or newly-created),
ordered by distance along the segment from start to end.
ADR-026 Phase 4 — decide whether the straight chord originPos → destPos across an explicit ruled host face should be carried as a
curvature-following SurfaceTrim (uv-line) or left as an
exact straight LINE_CURVE, and return the trim to attach
when it should curve.
The host is passed in explicitly (rather than discovered via
findCommonFace) because the authoring tools know the host
from the host's snapping face hit, and the window-authoring
gesture draws wire edges that are not yet on the host's
boundary loop at creation time (they become an inner loop via
ADR-006 H2 only when the loop closes) — so findCommonFace would
return null mid-gesture. A position-based, explicit-host
decision is robust to that ordering and to the trims being
attached as a post-pass.
Both endpoints are projected into the host's (u, v) parameter
space via projectPointToRuledUV. The candidate uv-line
trim is tessellated on the host (the same rail-pair evaluation
tessellateSurfaceTrim uses for rendering) and the maximum
perpendicular deviation of those on-surface samples from the
straight chord is measured:
Δu ≈ 0 on a cylinder — a vertical window edge). The
straight LineCurve is geometrically exact, so we return
null and the caller keeps the line. This is the §Decision-3
carve-out: "vertical edges ARE surface rulings → already
straight in 3D → keep LineCurve."SurfaceTrim whose uvCurve
interpolates uvA → uvB in parameter space, so rendering /
selection follow the host curvature.Returns null (keep the straight line) when:
ruled face
that is flat (isEffectivelyPlanar),(u, v) (degenerate), orPure decision helper — performs no topology mutation.
The SurfaceTrim to attach (curving edge), or null
to keep an exact straight LINE_CURVE.
Serializes the entire mesh topology and geometry to a plain JSON object.
Vertex positions are stored as [x, y, z] arrays. All pointer relationships (twin, next, prev, face, halfEdge) are stored as IDs for later reconstruction via fromJSON.
A JSON-serializable snapshot of the mesh.
Shared warning for the step-cap guard family.
The ADR-080 Phase 0 fuzz harness observed one probabilistic
~9-minute non-termination in the kernel draw path (unpinned
UUIDs; an id-order-sensitive corruption feeding an unbounded
.next / rotation walk). Every loop walk on the draw / erase
cascade is therefore budgeted at halfEdges.size + 1 steps —
a VALID loop visits each half-edge at most once, so the cap
can only fire on an already-corrupted chain (rho-shaped walk
that never returns to its start). On exhaustion the walk bails
out of just that sub-operation instead of hanging the tab.
Structural fix: ADR-080 Phases 2–3 (arrangement-derived faces).
Public (not private) because the same guard pattern covers the
out-of-band walks in EulerOperators.ts (KEF / getVertexDegree)
and DisjointShells.ts (shellAabb) — one warning format for
every cap site.
Half-edge mesh data structure implementing the IGeometryKernel interface.
Uses the doubly-connected edge list (DCEL) representation to store vertices, directed half-edges, and faces with full adjacency information. Provides Euler operators (MEV, MFE, KEV, KFE) for topological editing, automatic face detection via BFS cycle finding with coplanarity checks, and a spatial index for efficient raycasting and proximity queries.
Coordinate system: Z-up, unitless world-space.
Since
2025-Q4
Stability
stable