meshEdits.loopCut

A copy of a polygon mesh with new edge loops through the ring of four-corner faces an edge starts.

GeometricSince 0.16.0

Usage

TypeScript
MeshEdits.loopCut(geometry: Geometry | VerbValue, edge: readonly [number, number], params?: MeshLoopCutParams): Result<VerbValue>

Parameters

  • geometryGeometry | VerbValue

    Polygon geometry; the input is not modified.

    Required

  • edge[number, number]

    Two point indices, the ends of an edge of a four-corner face: the ring is walked from there across opposite edges.

    Required

  • params.segmentsnumber

    How many loops, 1–64; several sit at equal fractions along each crossed edge. Default 1. In count.

  • params.factornumber

    Where one loop sits along the edge, from −1 to 1 (0 the middle); ignored for several, and then not part of the ref. Default 0. In ratio.

  • params.scopestring

    The host’s node id, for minted ids. Default none: minted under 'loop_cut' with minter 0 (untrusted).

Returns

Ok with a VerbValue (the caller frees it): each crossed edge split by segments new points, each cut face by segments + 1 strips; data has points, faces and cutPoints.

Errors

Guarantees

  • every crossed edge gains segments points on it and every cut face becomes segments + 1 four-corner faces; the walk stops at a boundary, a face of other than four corners, or where the ring closes
  • neighbouring cut faces share their new points (no cracks)
  • carried ids are unchanged and new ids are unique; lineage records each new point as generated from its edge’s two ends and each strip as a piece of its face
  • the same input and parameters give the same bytes (geometryContentHash), natively and in WASM
  • The same result on every machine.

Example

TypeScript
const r = MeshEdits.loopCut(Mesh.box().value, [0, 1])
r.ok || r.diagnostics[0].code // → the ring around the box cut in the middle once loadGeometryKernel() has run

See also