ImFusion Web SDK

Mesh

Subclass of Data that represents a surface mesh.

Extends

Properties

PropertyTypeDescription
matrixToWorldmat4The matrix of this data mapping to world coordinages. Setting the matrix sets the bounding box dirty.
matrixFromWorldmat4The matrix of this data mapping from world coordinages. Setting the matrix sets the bounding box dirty.

Accessors

Inherited from Data

AccessorDescription
nameThe name of the dataset

Methods

MethodDescription
numberOfVertices()Number of vertices currently stored.
numberOfFaces()Number of faces currently stored.
computeVertexNormals()Compute vertex normals as weighted average of normals of faces around a vertex.
computeFaceNormals()Compute face normals.
displayOptions()Returns the MeshDisplayOptions for configuring Mesh rendering.
onChanged()Fires when the mesh data has changed
vertexVertexNeighbors()Returns an array of neighboring vertices of the given vertex
vertexFaceNeighbors()Returns an array of neighboring faces of the given vertex
addVertex()Adds a new vertex at the given position.
setVertex()Set vertex position
addTriangle()Adds a new triangle with vertices at the specified positions.
addFace()Adds a new face, consisting of the 3 existing(!) vertices specified by their indices.
faceVertices()Returns a array of all vertices associated with the given face
vertex()Get vertex position

Inherited from Data

MethodDescription
kind()Returns the kind of this data.
modality()Returns the modality of this data.
bounds()Returns the axis-aligned bounding box of this data in world space.

Inherited from ClassHandle

MethodDescription
isAliasOf()Returns true if this handle and other alias the same underlying C++ object.
delete()Releases this JavaScript handle.
deleteLater()Schedules this handle for deferred deletion and returns this handle.
isDeleted()Returns true if this handle has already been deleted.
[dispose]()Releases this handle when the enclosing scope exits, so a handle can be declared with using instead of calling delete() later manually.
clone()Returns a new JavaScript handle aliasing the same underlying C++ object.

numberOfVertices()

ts
numberOfVertices(): number;

Number of vertices currently stored. May still include recently deleted vertices if no garbage collection has been performed.

Returns

number


numberOfFaces()

ts
numberOfFaces(): number;

Number of faces currently stored. May still include recently deleted faces if no garbage collection has been performed.

Returns

number


computeVertexNormals()

ts
computeVertexNormals(weighting: MeshVertexNormalWeighting): void;

Compute vertex normals as weighted average of normals of faces around a vertex. Replaces previous normals.

Parameters

ParameterTypeDescription
weightingMeshVertexNormalWeightingHow the face normals are weighted to compute vertex normals.

Returns

void


computeFaceNormals()

ts
computeFaceNormals(): void;

Compute face normals. Replaces previous normals.

Returns

void


displayOptions()

ts
displayOptions(): MeshDisplayOptions;

Returns the MeshDisplayOptions for configuring Mesh rendering.

Returns

MeshDisplayOptions


onChanged()

ts
onChanged(callback: () => void): () => void;

Fires when the mesh data has changed

Parameters

ParameterType
callback() => void

Returns

unsubscribe function

() => void


vertexVertexNeighbors()

ts
vertexVertexNeighbors(vertexIndex: number): number[];

Returns an array of neighboring vertices of the given vertex

Parameters

ParameterType
vertexIndexnumber

Returns

number[]


vertexFaceNeighbors()

ts
vertexFaceNeighbors(vertexIndex: number): number[];

Returns an array of neighboring faces of the given vertex

Parameters

ParameterType
vertexIndexnumber

Returns

number[]


addVertex()

ts
addVertex(position: vec3): number;

Adds a new vertex at the given position. Returns index of newly added vertex.

Parameters

ParameterType
positionvec3

Returns

number


setVertex()

ts
setVertex(index: number, position: vec3): void;

Set vertex position

Parameters

ParameterType
indexnumber
positionvec3

Returns

void


addTriangle()

ts
addTriangle(
   p1: vec3,
   p2: vec3,
   p3: vec3): number;

Adds a new triangle with vertices at the specified positions.

Parameters

ParameterType
p1vec3
p2vec3
p3vec3

Returns

number

index of newly added face. -1 if the face could not be added.

See

  • addFace
  • addVertex

addFace()

ts
addFace(vertexIndices: vec3i): number;

Adds a new face, consisting of the 3 existing(!) vertices specified by their indices. Duplicate vertices will be created to patch up topology problems as needed.

Parameters

ParameterType
vertexIndicesvec3i

Returns

number

index of newly added face. -1 if the face could not be added.


faceVertices()

ts
faceVertices(faceIndex: number): vec3i;

Returns a array of all vertices associated with the given face

Parameters

ParameterType
faceIndexnumber

Returns

vec3i


vertex()

ts
vertex(index: number): vec3 | undefined;

Get vertex position

Parameters

ParameterType
indexnumber

Returns

vec3 | undefined

undefined if index is not valid

On this page