@huukhanhnguyen/geometry / catalog/mesh
catalog/mesh
MeshData
constMeshData: {bevel: (id,edges,radius,segments,radius2?) =>void;bevelVertices: (id,vertices,radius,segments) =>void;boundingBox: (id) =>Float64Array;box: (width,depth,height) =>number;chamfer: (id,edges,distance1,distance2) =>void;clone: (id) =>number;cone: (radius_bottom,radius_top,height,sides) =>number;containsPoint: (id,x,y,z) =>boolean;cornerCount: (id) =>number;deleteVertices: (id,vertices) =>void;dissolveEdges: (id,edges) =>void;dump: (id) =>string;edgeCount: (id) =>number;edgesWithBothEndpointsInBox: (id,min,max) =>Uint32Array;edgeVertices: (id) =>Uint32Array;extrude: (id,faces,thickness) =>void;extrudeEdges: (id,edges,dx,dy,dz,distance) =>void;faceCount: (id) =>number;faceOffsets: (id) =>Uint32Array;faceVertices: (id) =>Uint32Array;free: (id) =>boolean;fromBrep: (document) =>number;fromTriangleMesh: (positions,indices,uvs) =>number;intersect: (id,positions,indices) =>number;isSolid: (id) =>boolean;lattice: (id,options_json) =>void;load: (json) =>number;positions: (id) =>Float64Array;reverse: (id) =>number;splitByPlane: (id,plane) =>string;subdivide: (id,options_json) =>void;subtract: (id,positions,indices) =>number;surfaceArea: (id) =>number;sweep: (path,profile,caps) =>number;tessellate: (mesh) =>TriangleMesh;tessellateJson: (id) =>string;thicken: (id,thickness,options_json) =>void;toBrep: (handle) =>unknown[];transform: (id,matrix) =>number;transformVertices: (id,vertices,matrix) =>void;union: (id,positions,indices) =>number;uvApply: (matrix,x,y,z) =>Float64Array;uvFromOrigin: (origin_x,origin_y,origin_z,u_axis_x,u_axis_y,u_axis_z,v_axis_x,v_axis_y,v_axis_z) =>Float64Array;uvPlanar: (u_axis_x,u_axis_y,u_axis_z,v_axis_x,v_axis_y,v_axis_z,u_offset,v_offset) =>Float64Array;vertexCount: (id) =>number;verticesInBox: (id,min,max) =>Uint32Array;volume: (id) =>number; }
The generated wasm namespace plus the members that need a TS reshape. Re-exported from src/index.ts, where it shadows the generated MeshData.
Planar UV (Blender-like): faces carry a 16-float uvMatrix only — no multi-kind projector. Generated members: uvPlanar(uAxis, vAxis, uOffset, vOffset) → matrix uvFromOrigin(origin, uAxis, vAxis) → matrix with origin at UV (0,0) uvApply(matrix, x, y, z) → [u, v] Layout: [ux,uy,uz,uOffset, vx,vy,vz,vOffset, 0,0,0,0, 0,0,0,1].
bevel
bevel: (
id,edges,radius,segments,radius2?) =>void=wasm.mesh_bevel
mesh.bevel(edges, radius, segments, radius2?). edges are indices into mesh.edges.
Parameters
id
number
edges
Uint32Array
radius
number
segments
number
radius2?
number | null
Returns
void
bevelVertices
bevelVertices: (
id,vertices,radius,segments) =>void=wasm.mesh_bevel_vertices
mesh.bevelVertices(vertices, radius, segments). vertices are indices into mesh.vertices.
Parameters
id
number
vertices
Uint32Array
radius
number
segments
number
Returns
void
boundingBox
boundingBox: (
id) =>Float64Array=wasm.mesh_bounding_box
Mesh.boundingBox — [minX, minY, minZ, maxX, maxY, maxZ].
Parameters
id
number
Returns
Float64Array
box
box: (
width,depth,height) =>number=wasm.mesh_box
Mesh.box — axis-aligned box centered on the origin.
Parameters
width
number
depth
number
height
number
Returns
number
chamfer
chamfer: (
id,edges,distance1,distance2) =>void=wasm.mesh_chamfer
mesh.chamfer(edges, distance1, distance2). edges are indices into mesh.edges.
Parameters
id
number
edges
Uint32Array
distance1
number
distance2
number
Returns
void
clone
clone: (
id) =>number=wasm.mesh_clone
Mesh.clone — a topology rebuild, not a field copy.
Parameters
id
number
Returns
number
cone
cone: (
radius_bottom,radius_top,height,sides) =>number=wasm.mesh_cone
Mesh.cone — cone / frustum / cylinder by radii. sides is a f64 because the TS validates it with Number.isInteger and throws otherwise.
Parameters
radius_bottom
number
radius_top
number
height
number
sides
number
Returns
number
containsPoint
containsPoint: (
id,x,y,z) =>boolean=wasm.mesh_contains
Mesh.containsPoint.
Parameters
id
number
x
number
y
number
z
number
Returns
boolean
cornerCount
cornerCount: (
id) =>number=wasm.mesh_corner_count
mesh.corners.length.
Parameters
id
number
Returns
number
deleteVertices
deleteVertices: (
id,vertices) =>void=wasm.mesh_delete_vertices
deleteVertices(mesh, vertices). vertices are indices into mesh.vertices.
Parameters
id
number
vertices
Uint32Array
Returns
void
dissolveEdges
dissolveEdges: (
id,edges) =>void=wasm.mesh_dissolve_edges
dissolveEdges(mesh, edges). edges are indices into mesh.edges.
Parameters
id
number
edges
Uint32Array
Returns
void
dump
dump: (
id) =>string=wasm.mesh_dump
Mesh.toJSON — the MeshEntity payload of a live handle.
Parameters
id
number
Returns
string
edgeCount
edgeCount: (
id) =>number=wasm.mesh_edge_count
mesh.edges.length.
Parameters
id
number
Returns
number
edgesWithBothEndpointsInBox
edgesWithBothEndpointsInBox: (
id,min,max) =>Uint32Array=wasm.mesh_edges_with_both_endpoints_in_box
edgesWithBothEndpointsInBox(mesh, min, max) — the selected edges as indices into mesh.edges.
Parameters
id
number
min
Float64Array
max
Float64Array
Returns
Uint32Array
edgeVertices
edgeVertices: (
id) =>Uint32Array=wasm.mesh_edge_vertices
Every edge's two endpoint vertex INDICES (positions in mesh.vertices), concatenated in mesh.edges order: edge e is [2 * e, 2 * e + 1].
The pair is MeshEdge.vertex1, MeshEdge.vertex2 and those are UNORDERED — an edge records its endpoints, not a direction (the direction lives on the corners walking it). A caller mapping an (endpoint, endpoint) predicate onto edge indices for [mesh_bevel] or [mesh_dissolve_edges] must therefore accept either order.
Parameters
id
number
Returns
Uint32Array
extrude
extrude: (
id,faces,thickness) =>void=wasm.mesh_extrude
mesh.extrude(faces, thickness). faces are indices into mesh.faces.
Parameters
id
number
faces
Uint32Array
thickness
number
Returns
void
extrudeEdges
extrudeEdges: (
id,edges,dx,dy,dz,distance) =>void=wasm.mesh_extrude_edges
mesh.extrudeEdges(edges, direction, distance). edges are indices into mesh.edges.
Parameters
id
number
edges
Uint32Array
dx
number
dy
number
dz
number
distance
number
Returns
void
faceCount
faceCount: (
id) =>number=wasm.mesh_face_count
mesh.faces.length.
Parameters
id
number
Returns
number
faceOffsets
faceOffsets: (
id) =>Uint32Array=wasm.mesh_face_offsets
Start of each face inside [mesh_face_vertices], length faceCount + 1; face f spans [offsets[f], offsets[f + 1]).
Parameters
id
number
Returns
Uint32Array
faceVertices
faceVertices: (
id) =>Uint32Array=wasm.mesh_face_vertices
Every face's vertex INDICES (positions in mesh.vertices), concatenated in mesh.faces order and in each face's winding order. Slice face f with [mesh_face_offsets].
Parameters
id
number
Returns
Uint32Array
free
free: (
id) =>boolean=wasm.mesh_free
Drop a Mesh handle. False if the id was not live.
Parameters
id
number
Returns
boolean
fromBrep
fromBrep: (
document) =>number
B-Rep kernel document (one document or an array of them) → arena handle. Accepts a JSON string or a parsed value; objects are stringified. The typed door SHADOWS the generated mesh_from_brep (raw JSON string in).
Parameters
document
string | object
Returns
number
fromTriangleMesh
fromTriangleMesh: (
positions,indices,uvs) =>number=wasm.mesh_from_triangle_mesh
Mesh.fromTriangleMesh — rebuild half-edge topology from a triangle mesh. uvs is carried because the import FITS a per-face planar projection from the triangle's three (position, UV) samples; pass an empty array when the soup has none.
Parameters
positions
Float64Array
indices
Uint32Array
uvs
Float64Array
Returns
number
intersect
intersect: (
id,positions,indices) =>number=wasm.mesh_intersect
Mesh.intersect — the operand is a triangle mesh.
Parameters
id
number
positions
Float64Array
indices
Uint32Array
Returns
number
isSolid
isSolid: (
id) =>boolean=wasm.mesh_is_solid
Mesh.isSolid.
Parameters
id
number
Returns
boolean
lattice
lattice: (
id,options_json) =>void=wasm.mesh_lattice
mesh.lattice(options) — the wireframe modifier. options_json mirrors LatticeOptions; "" or "{}" means all defaults (and so an offset of 0, which lattice rejects, as the TS does).
Parameters
id
number
options_json
string
Returns
void
load
load: (
json) =>number=wasm.mesh_load
Mesh.fromJSON — parse a MeshEntity payload and return its handle.
Parameters
json
string
Returns
number
positions
positions: (
id) =>Float64Array=wasm.mesh_positions
Vertex positions of mesh.vertices, in order-array order: vertex index i is [3 * i, 3 * i + 2].
Parameters
id
number
Returns
Float64Array
reverse
reverse: (
id) =>number=wasm.mesh_reverse
Mesh.reverse — returns a NEW handle.
Parameters
id
number
Returns
number
splitByPlane
splitByPlane: (
id,plane) =>string=wasm.mesh_split_by_plane
Mesh.splitByPlane. above / below are registered Mesh handles the caller frees, or null; the boundary rings are the cut Path2d's plane-local 2D rings and boundaryTransformation its 16-number toWorld.
Parameters
id
number
plane
Float64Array
Returns
string
subdivide
subdivide: (
id,options_json) =>void=wasm.mesh_subdivide
mesh.subdivide(options) — Catmull-Clark. options_json mirrors SubdivideOptions; "" or "{}" means all defaults.
Parameters
id
number
options_json
string
Returns
void
subtract
subtract: (
id,positions,indices) =>number=wasm.mesh_subtract
Mesh.subtract — the operand is a triangle mesh.
Parameters
id
number
positions
Float64Array
indices
Uint32Array
Returns
number
surfaceArea
surfaceArea: (
id) =>number=wasm.mesh_surface_area
Mesh.surfaceArea.
Parameters
id
number
Returns
number
sweep
sweep: (
path,profile,caps) =>number=wasm.mesh_sweep
Mesh.sweep — sweep a 2D profile along a 2D path. Both are flat [x, y, ...] pairs.
Parameters
path
Float64Array
profile
Float64Array
caps
boolean
Returns
number
tessellate
tessellate: (
mesh) =>TriangleMesh
Tessellate an n-gon MeshData document into the canonical TriangleMesh — one-shot: the arena handle is loaded and freed inside the call.
The crate's wire format (MeshJson, what MeshData.load / .dump speak) keeps flat positions + faces with a parallel faceAttributes; MeshData stores vertices: MeshVertex[] and faces: MeshFace[]. This is the door, so packing vertices[i].position and the face reshape live here.
Parameters
mesh
Returns
tessellateJson
tessellateJson: (
id) =>string=wasm.mesh_tessellate_json
Mesh.tessellate as the FULL TriangleMeshJSON — groups / edges / faces / vertices included. The numeric channels agree with [mesh_tessellate] value for value; this is the same result, spelled in the wire format.
Parameters
id
number
Returns
string
thicken
thicken: (
id,thickness,options_json) =>void=wasm.mesh_thicken
mesh.thicken(thickness, options). options_json mirrors ThickenOptions; "" or "{}" means all defaults.
Parameters
id
number
thickness
number
options_json
string
Returns
void
toBrep
toBrep: (
handle) =>unknown[]
Arena handle → kernel documents (one per half-edge face). The typed door SHADOWS the generated mesh_to_brep (JSON string out).
Parameters
handle
number
Returns
unknown[]
transform
transform: (
id,matrix) =>number=wasm.mesh_transform
Mesh.transform — returns a NEW handle, as the TS returns a new Mesh.
Parameters
id
number
matrix
Float64Array
Returns
number
transformVertices
transformVertices: (
id,vertices,matrix) =>void=wasm.mesh_transform_vertices
transformVertices(mesh, vertices, matrix). vertices are indices into mesh.vertices.
Parameters
id
number
vertices
Uint32Array
matrix
Float64Array
Returns
void
union
union: (
id,positions,indices) =>number=wasm.mesh_union
Mesh.union — the operand is a triangle mesh, as in the TS (which tessellates whatever Shell it is handed). Only positions and indices are read: the cell-graph boolean emits input coordinates and segment interpolations, never a UV or a normal.
Parameters
id
number
positions
Float64Array
indices
Uint32Array
Returns
number
uvApply
uvApply: (
matrix,x,y,z) =>Float64Array=wasm.mesh_uv_apply
Mesh.uvApply(matrix, point) — apply a planar UV matrix to a 3D point.
matrix is [mesh_uv_planar]'s 16-element layout (uAxis rows 0–2, uOffset at 3, vAxis rows 4–6, vOffset at 7). Pure matrix×point for the planar affine encode — no multi-kind projector.
Parameters
matrix
Float64Array
x
number
y
number
z
number
Returns
Float64Array
uvFromOrigin
uvFromOrigin: (
origin_x,origin_y,origin_z,u_axis_x,u_axis_y,u_axis_z,v_axis_x,v_axis_y,v_axis_z) =>Float64Array=wasm.mesh_uv_from_origin
Mesh.uvFromOrigin(origin, uAxis, vAxis) — planar UV matrix whose origin maps to UV (0, 0). Offsets are the negated dots of each axis with the origin.
Parameters
origin_x
number
origin_y
number
origin_z
number
u_axis_x
number
u_axis_y
number
u_axis_z
number
v_axis_x
number
v_axis_y
number
v_axis_z
number
Returns
Float64Array
uvPlanar
uvPlanar: (
u_axis_x,u_axis_y,u_axis_z,v_axis_x,v_axis_y,v_axis_z,u_offset,v_offset) =>Float64Array=wasm.mesh_uv_planar
Mesh.uvPlanar(uAxis, vAxis, uOffset, vOffset) — public planar UV matrix. Layout: [ux, uy, uz, uOffset, vx, vy, vz, vOffset, 0,0,0,0, 0,0,0,1]. Apply as u = uAxis·p + uOffset, v = vAxis·p + vOffset (see [mesh_uv_apply]).
Parameters
u_axis_x
number
u_axis_y
number
u_axis_z
number
v_axis_x
number
v_axis_y
number
v_axis_z
number
u_offset
number
v_offset
number
Returns
Float64Array
vertexCount
vertexCount: (
id) =>number=wasm.mesh_vertex_count
mesh.vertices.length.
Parameters
id
number
Returns
number
verticesInBox
verticesInBox: (
id,min,max) =>Uint32Array=wasm.mesh_vertices_in_box
verticesInBox(mesh, min, max) — the selected vertices as indices into mesh.vertices.
Parameters
id
number
min
Float64Array
max
Float64Array
Returns
Uint32Array
volume
volume: (
id) =>number=wasm.mesh_volume
Mesh.volume.
Parameters
id
number
Returns
number
meshFromJson()
meshFromJson(
document):TriangleMesh
Decode a TriangleMesh wire document into the canonical shape.
Parameters
document
string