meshEdits.inset

A copy of a polygon mesh with chosen faces shrunk so each edge moves a set distance inward, framed by rings of new quads.

GeometricSince 0.16.0

Usage

TypeScript
MeshEdits.inset(geometry: Geometry | VerbValue, params?: MeshInsetParams): Result<VerbValue>

Parameters

  • geometryGeometry | VerbValue

    Polygon geometry; the input is not modified.

    Required

  • params.facesnumber[]

    The faces to inset, by index; omit for every face. Default every face.

  • params.amountnumber

    How far each edge moves in, in the face’s plane; negative moves out, 0 returns the input unchanged. Default 0.1. In model.

  • params.scopestring

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

Returns

Ok with a VerbValue (the caller frees it): each chosen n-gon replaced by n ring quads and its inner n-gon, the other faces as they were; data has points and faces.

Errors

Guarantees

  • each chosen n-gon adds n points and n faces
  • each inner edge lies amount from its original edge, unless clamped (limits)
  • the inner face keeps its face’s id; carried ids are unchanged and new ids are unique; lineage records each inset point as generated from its corner and each ring quad from 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.inset(Mesh.box().value, { faces: [1], amount: 0.25 })
r.ok || r.diagnostics[0].code // → 12 points and 10 faces once loadGeometryKernel() has run

See also