Skip to content

Shapemetry API


Shapemetry API / PolygonMeshJSON

Type Alias: PolygonMeshJSON

PolygonMeshJSON = object

Defined in: types.ts:211

Plain-data serialization of PolygonMesh (face-with-holes mesh, SketchUp-style).

  • positions — shared flat XYZ pool [x, y, z, x, y, z, ...].
  • faces[i].loops[0] — outer boundary (CCW), vertex indices into positions. faces[i].loops[1..] — hole boundaries (CW).
  • faces[i].uvMatrix — per-face 4×4 projective matrix (16 numbers, row-major). Apply to (x, y, z, 1)(u, v, _, q); divide by q for projective UV (matches SketchUp's UVQ from Face.get_UVHelper). Affine planar projection = bottom row (0, 0, 0, 1). One matrix per face is enough because SU materials project linearly across the whole face.
  • faces[i].materialMaterialJSON.id keyed into materialPalette.
  • materialPalette — PBR materials referenced by face material id.
  • texturePalette — textures referenced by MaterialJSON.*TextureId. Kept alongside (not inside) the material palette so one image can back many materials without duplication.

Producer dedups vertex sharing across faces (quantize-key); consumer (Mesh.fromPolygonMesh) still runs a tolerance bucket to absorb ULP noise.

Properties

positions

positions: number[]

Defined in: types.ts:212


faces

faces: object[]

Defined in: types.ts:213

loops

loops: number[][]

uvMatrix?

optional uvMatrix?: number[]

material?

optional material?: string | null


materialPalette?

optional materialPalette?: MaterialJSON[]

Defined in: types.ts:218


texturePalette?

optional texturePalette?: TextureAssetJSON[]

Defined in: types.ts:219