samples.rebind

Samples carried across a re-cook: each follows its face family and three corners, by persistent id, onto the edited mesh.

GeometricSince 0.11.0

Usage

TypeScript
Samples.rebind(samples: Geometry, geometry: Mesh | Geometry | NurbsSurface, options?: SampleRebindOptions): Result<Geometry>

Parameters

  • samplesGeometry

    Points geometry from Samples.scatter (or an earlier rebind): its id, anchorPrim, anchorPrimFrom, anchorCorners, anchorCornersFrom, anchorBary, P and N are read.

    Required

  • geometryMesh | Geometry | NurbsSurface

    The re-cooked mesh, with the persistent ids (id / idFrom, primId / primIdFrom) its node keeps across edits, or the re-cooked NURBS surface, where each sample moves to the surface’s point at its anchorUv.

    Required

  • options.surfaceId{ primId?, primIdFrom? }

    On a NurbsSurface: which surface the samples belong to; samples with another anchorPrim / anchorPrimFrom, or minter 0, are dropped. Default the samples’ own anchor.

  • options.recomputeFramesboolean

    Run Samples.frames again on the new mesh when the samples had frames (T). Default true.

  • options.framesSampleFramesOptions

    The options of that frames run. Default Samples.frames’ defaults.

Returns

Ok with the kept samples in input order: P on the new surface (the barycentric point of the anchor’s corners, projected onto the family’s current triangles) and N there; every other attribute as it was, except a parent whose sample was dropped, which becomes 0; and, by default, fresh frames.

Errors

Guarantees

  • a sample is kept only when its family and all three corners exist in geometry with the same non-zero minters; minter 0 is never followed
  • ids, seeds, levels, anchors, spacing and thinning are kept as scattered, so rebinding again onto the same mesh gives the same bytes
  • on the unchanged mesh every sample is kept and stays where it was
  • the same input gives the same bytes (geometryContentHash), natively and in WASM
  • The same result on every machine.

Example

TypeScript
const s = Samples.scatter(Mesh.box().value, { scope: 'scatter1', spacing: 0.1 })
s.ok && Samples.rebind(s.value, Mesh.box().value) // → every sample ELEMENT_LOST: a bare box has no minters to follow; a host's mesh keeps its node's ids

See also