Mesh
Subclass of Data that represents a surface mesh.
Extends
Properties
| Property | Type | Description |
|---|---|---|
matrixToWorld | mat4 | The matrix of this data mapping to world coordinages. Setting the matrix sets the bounding box dirty. |
matrixFromWorld | mat4 | The matrix of this data mapping from world coordinages. Setting the matrix sets the bounding box dirty. |
Accessors
Inherited from Data
| Accessor | Description |
|---|---|
| name | The name of the dataset |
Methods
| Method | Description |
|---|---|
| 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
| Method | Description |
|---|---|
| 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
| Method | Description |
|---|---|
| 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()
numberOfVertices(): number;Number of vertices currently stored. May still include recently deleted vertices if no garbage collection has been performed.
Returns
number
numberOfFaces()
numberOfFaces(): number;Number of faces currently stored. May still include recently deleted faces if no garbage collection has been performed.
Returns
number
computeVertexNormals()
computeVertexNormals(weighting: MeshVertexNormalWeighting): void;Compute vertex normals as weighted average of normals of faces around a vertex. Replaces previous normals.
Parameters
| Parameter | Type | Description |
|---|---|---|
weighting | MeshVertexNormalWeighting | How the face normals are weighted to compute vertex normals. |
Returns
void
computeFaceNormals()
computeFaceNormals(): void;Compute face normals. Replaces previous normals.
Returns
void
displayOptions()
displayOptions(): MeshDisplayOptions;Returns the MeshDisplayOptions for configuring Mesh rendering.
Returns
onChanged()
onChanged(callback: () => void): () => void;Fires when the mesh data has changed
Parameters
| Parameter | Type |
|---|---|
callback | () => void |
Returns
unsubscribe function
() => void
vertexVertexNeighbors()
vertexVertexNeighbors(vertexIndex: number): number[];Returns an array of neighboring vertices of the given vertex
Parameters
| Parameter | Type |
|---|---|
vertexIndex | number |
Returns
number[]
vertexFaceNeighbors()
vertexFaceNeighbors(vertexIndex: number): number[];Returns an array of neighboring faces of the given vertex
Parameters
| Parameter | Type |
|---|---|
vertexIndex | number |
Returns
number[]
addVertex()
addVertex(position: vec3): number;Adds a new vertex at the given position. Returns index of newly added vertex.
Parameters
| Parameter | Type |
|---|---|
position | vec3 |
Returns
number
setVertex()
setVertex(index: number, position: vec3): void;Set vertex position
Parameters
| Parameter | Type |
|---|---|
index | number |
position | vec3 |
Returns
void
addTriangle()
addTriangle(
p1: vec3,
p2: vec3,
p3: vec3): number;Adds a new triangle with vertices at the specified positions.
Parameters
Returns
number
index of newly added face. -1 if the face could not be added.
See
- addFace
- addVertex
addFace()
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
| Parameter | Type |
|---|---|
vertexIndices | vec3i |
Returns
number
index of newly added face. -1 if the face could not be added.
faceVertices()
faceVertices(faceIndex: number): vec3i;Returns a array of all vertices associated with the given face
Parameters
| Parameter | Type |
|---|---|
faceIndex | number |
Returns
vertex()
vertex(index: number): vec3 | undefined;Get vertex position
Parameters
| Parameter | Type |
|---|---|
index | number |
Returns
vec3 | undefined
undefined if index is not valid