@huukhanhnguyen/geometry / namespaces/Mesh
namespaces/Mesh
bevel
constbevel: (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
constbevelVertices: (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
constboundingBox: (id) =>Float64Array=wasm.mesh_bounding_box
Mesh.boundingBox — [minX, minY, minZ, maxX, maxY, maxZ].
Parameters
id
number
Returns
Float64Array
box
constbox: (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
constchamfer: (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
constclone: (id) =>number=wasm.mesh_clone
Mesh.clone — a topology rebuild, not a field copy.
Parameters
id
number
Returns
number
cone
constcone: (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
constcontainsPoint: (id,x,y,z) =>boolean=wasm.mesh_contains
Mesh.containsPoint.
Parameters
id
number
x
number
y
number
z
number
Returns
boolean
cornerCount
constcornerCount: (id) =>number=wasm.mesh_corner_count
mesh.corners.length.
Parameters
id
number
Returns
number
deleteVertices
constdeleteVertices: (id,vertices) =>void=wasm.mesh_delete_vertices
deleteVertices(mesh, vertices). vertices are indices into mesh.vertices.
Parameters
id
number
vertices
Uint32Array
Returns
void
dissolveEdges
constdissolveEdges: (id,edges) =>void=wasm.mesh_dissolve_edges
dissolveEdges(mesh, edges). edges are indices into mesh.edges.
Parameters
id
number
edges
Uint32Array
Returns
void
dump
constdump: (id) =>string=wasm.mesh_dump
Mesh.toJSON — the MeshEntity payload of a live handle.
Parameters
id
number
Returns
string
edgeCount
constedgeCount: (id) =>number=wasm.mesh_edge_count
mesh.edges.length.
Parameters
id
number
Returns
number
edgesWithBothEndpointsInBox
constedgesWithBothEndpointsInBox: (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
constedgeVertices: (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
constextrude: (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
constextrudeEdges: (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
constfaceCount: (id) =>number=wasm.mesh_face_count
mesh.faces.length.
Parameters
id
number
Returns
number
faceOffsets
constfaceOffsets: (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
constfaceVertices: (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
constfree: (id) =>boolean=wasm.mesh_free
Drop a Mesh handle. False if the id was not live.
Parameters
id
number
Returns
boolean
fromBrep
constfromBrep: (json) =>number=wasm.mesh_from_brep
Sample every face of every shell into a private PolygonMeshJson and weld it into a half-edge mesh (1e-6 + T-junction).
Parameters
json
string
Returns
number
fromTriangleMesh
constfromTriangleMesh: (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
constintersect: (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
constisSolid: (id) =>boolean=wasm.mesh_is_solid
Mesh.isSolid.
Parameters
id
number
Returns
boolean
lattice
constlattice: (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
constload: (json) =>number=wasm.mesh_load
Mesh.fromJSON — parse a MeshEntity payload and return its handle.
Parameters
json
string
Returns
number
positions
constpositions: (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
constreverse: (id) =>number=wasm.mesh_reverse
Mesh.reverse — returns a NEW handle.
Parameters
id
number
Returns
number
splitByPlane
constsplitByPlane: (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
constsubdivide: (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
constsubtract: (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
constsurfaceArea: (id) =>number=wasm.mesh_surface_area
Mesh.surfaceArea.
Parameters
id
number
Returns
number
sweep
constsweep: (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
consttessellate: (id) =>Float64Array=wasm.mesh_tessellate
Mesh.tessellate, numeric channels only — a [pack_triangle_mesh] buffer. Use [mesh_tessellate_json] for the material strings and edge kinds no typed array can hold.
Parameters
id
number
Returns
Float64Array
tessellateJson
consttessellateJson: (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
constthicken: (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
consttoBrep: (id) =>string=wasm.mesh_to_brep
Each half-edge face (outer + holes) → one version-2 kernel document.
Parameters
id
number
Returns
string
transform
consttransform: (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
consttransformVertices: (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
constunion: (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
constuvApply: (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
constuvFromOrigin: (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
constuvPlanar: (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
constvertexCount: (id) =>number=wasm.mesh_vertex_count
mesh.vertices.length.
Parameters
id
number
Returns
number
verticesInBox
constverticesInBox: (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
constvolume: (id) =>number=wasm.mesh_volume
Mesh.volume.
Parameters
id
number
Returns
number