Defines a polygonal shape consisting of triangles.
Triangles are defined by an array of unique vertices and triplets of indices into this array. This describes connectivity while reducing the amount of data required to represent the triangle set.
The triangle set can optionally contain normals, colors, and UV coordinates defined per vertex. These attributes can also use indexing in the same manner as vertices.
new IndexedTriangleSet():
IndexedTriangleSet
IndexedTriangleSet
new IndexedTriangleSet(
vertices,vertexIndices,normals?,normalIndices?,colors?,colorIndices?,uvCoordinates?,uvCoordinateIndices?,bvh?):IndexedTriangleSet
Number of vertex attributes (normals / colors / UV coordinates) should be the same as vertices. Otherwise, the appropriate attributes indices array should be specified. If specified, attribute indices array should have the same length as vertex indices array.
If the provided data is inconsistent, an empty triangle set is created. This includes vertex indices outside the provided vertex array and cases where the same vertex index is associated with different normal, color, or UV coordinate indices within the input data.
Float32Array
Array of vertices in {x,y,z} format [x,y,z,x,y,z,...].
Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
Vertex indices array.
Float32Array<ArrayBufferLike>
Array of vertex normals in {x,y,z} format [x,y,z,x,y,z,...].
Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
Normal indices array.
Float32Array<ArrayBufferLike>
Array of colors in RGB ([r,g,b,r,g,b,...]) or RGBA ([r,g,b,a,r,g,b,a,...]) format.
Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
Color indices array.
Float32Array<ArrayBufferLike>
Array of vertex UV coordinates in {u,v} format [u,v,u,v,...].
Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
UV coordinate indices array.
Uint8Array<ArrayBufferLike>
Bounding volume hierarchy.
IndexedTriangleSet
MeshShape.constructor
new IndexedTriangleSet(
vertices,vertexIndices,normals?,normalIndices?,colors?,colorIndices?,uvCoordinates?,uvCoordinateIndices?):IndexedTriangleSet
Number of vertex attributes (normals / colors / UV coordinates) should be the same as vertices. Otherwise, the appropriate attributes indices array should be specified. If specified, attribute indices array should have the same length as vertex indices array.
If the provided data is inconsistent, an empty triangle set is created. This includes vertex indices outside the provided vertex array and cases where the same vertex index is associated with different normal, color, or UV coordinate indices within the input data.
BaseXYZ[]
Array of vertices in [{x,y,z},{x,y,z},...] format.
number[]
Vertex indices array.
BaseXYZ[]
Array of vertex normals in [{x,y,z},{x,y,z},...] format.
number[]
Normal indices array.
Array of colors in RGB and / or RGBA [{r,g,b},{r,g,b,a},...] format.
number[]
Color indices array.
BaseXY[]
Array of vertex UV coordinates in [{x,y},{x,y},...] format.
number[]
UV coordinate indices array.
IndexedTriangleSet
MeshShape.constructor
get bvh():
Uint8Array<ArrayBufferLike> |null
Bounding volume hierarchy.
Uint8Array<ArrayBufferLike> | null
get colors():
Float32Array
Returns array with colors in RGBA ([r,g,b,a,r,g,b,a,...]) format for each vertex (i.e. taking into account colors indices), if specified. Otherwise, returns empty array.
Float32Array
get id():
bigint
Returns the unique identifier of the object.
bigint
get name():
string|null
Name of the mesh shape.
The default value is null.
string | null
set name(
name):void
Sets the name of the mesh shape.
string | null
Mesh shape name.
void
get normals():
Float32Array
Returns array with normals in {x,y,z} format [x,y,z,x,y,z,...] for each vertex (i.e. taking into account normal indices), if specified. Otherwise, returns empty array.
Float32Array
get numberOfColors():
number
Number of unique colors.
number
get numberOfNormals():
number
Number of unique normals.
number
get numberOfTriangles():
number
Number of triangles.
number
get numberOfUVCoordinates():
number
Number of unique UV coordinates.
number
get numberOfVertices():
number
Number of unique vertices.
number
get uvCoordinates():
Float32Array
Returns array with UV coordinates in {u,v} format [u,v,u,v,...] for each vertex (i.e. taking into account UV coordinate indices), if specified. Otherwise, returns empty array.
Float32Array
get vertexIndices():
Uint16Array<ArrayBufferLike> |Uint32Array<ArrayBufferLike>
Vertex indices.
Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
get vertices():
Float32Array
Unique vertices in {x,y,z} format [x,y,z,x,y,z,...].
Float32Array
addTriangles(
triangleSet):boolean
Adds triangles from another indexed triangle set.
Returns true if triangles were added successfully. This triangle set and triangleSet must define the same kinds of attributes. Otherwise, triangles are not added.
IndexedTriangleSet
Indexed triangle set to add.
boolean
addTriangles(
vertices,vertexIndices,normals?,normalIndices?,colors?,colorIndices?,uvCoordinates?,uvCoordinateIndices?):boolean
Adds triangles to this triangle set.
Returns true if triangles were added successfully. This triangle set must already define the same kinds of attributes as the triangles being added. Otherwise, triangles are not added.
Float32Array
Array of vertices in {x,y,z} format [x,y,z,x,y,z,...].
Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
Vertex indices array.
Float32Array<ArrayBufferLike>
Array of vertex normals in {x,y,z} format [x,y,z,x,y,z,...].
Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
Normal indices array.
Float32Array<ArrayBufferLike>
Array of colors in RGB ([r,g,b,r,g,b,...]) or RGBA ([r,g,b,a,r,g,b,a,...]) format.
Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
Color indices array.
Float32Array<ArrayBufferLike>
Array of vertex UV coordinates in {u,v} format [u,v,u,v,...].
Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
UV coordinate indices array.
boolean
addTriangles(
vertices,vertexIndices,normals?,normalIndices?,colors?,colorIndices?,uvCoordinates?,uvCoordinateIndices?):boolean
Adds triangles to this triangle set.
Returns true if triangles were added successfully. This triangle set must already define the same kinds of attributes as the triangles being added. Otherwise, triangles are not added.
BaseXYZ[]
Array of vertices in [{x,y,z},{x,y,z},...] format.
number[]
Vertex indices array.
BaseXYZ[]
Array of vertex normals in [{x,y,z},{x,y,z},...] format.
number[]
Normal indices array.
Array of colors in RGB and / or RGBA [{r,g,b},{r,g,b,a},...] format.
number[]
Color indices array.
BaseXY[]
Array of vertex UV coordinates in [{x,y},{x,y},...] format.
number[]
UV coordinate indices array.
boolean
color(
index):Color
Returns a color.
index must be in the range [0, numberOfColors() - 1]. Otherwise the result is undefined.
number
Color index.
hasColors():
boolean
Returns whether the triangle set has explicitly defined colors.
boolean
hasNormals():
boolean
Returns whether the triangle set has explicitly defined normals.
boolean
hasUVCoordinates():
boolean
Returns whether the triangle set has explicitly defined UV coordinates.
boolean
internalAddTriangles(
vertices,vertexIndices,normals?,normalIndices?,colors?,colorIndices?,uvCoordinates?,uvCoordinateIndices?):boolean
Internal helper adding triangles from normalized input representations.
Float32Array<ArrayBufferLike> | BaseXYZ[]
number[] | Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
Float32Array<ArrayBufferLike> | BaseXYZ[]
number[] | Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
Float32Array<ArrayBufferLike> | (BaseRGBA | BaseRGB)[]
number[] | Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
Float32Array<ArrayBufferLike> | BaseXY[]
number[] | Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
boolean
normal(
index):Vector
Returns a normal.
index must be in the range [0, numberOfNormals() - 1]. Otherwise the result is undefined.
number
Normal index.
triangleNormal(
triangleIndex):Vector
Returns the normal of a triangle.
The normal is calculated on the fly from the triangle vertices. In case of a degenerate triangle, or if triangleIndex is outside the range [0, numberOfTriangles() - 1], the zero vector is returned.
number
Triangle index.
triangleVertex(
triangleIndex,vertexSlot):Point
Returns a vertex of a triangle.
triangleIndex must be in the range [0, numberOfTriangles() - 1]. vertexSlot must be in the range [0, 2]. Otherwise the result is undefined.
number
Triangle index.
number
Vertex slot in the triangle.
triangleVertexColor(
triangleIndex,vertexSlot):Color
Returns a color at vertex in a triangle.
triangleIndex must be in the range [0, numberOfTriangles() - 1]. vertexSlot must be in the range [0, 2]. Otherwise the result is undefined.
number
Triangle index.
number
Vertex slot in the triangle.
triangleVertexColorIndex(
triangleIndex,vertexSlot):number
Returns a color index for vertex in a triangle.
triangleIndex must be in the range [0, numberOfTriangles() - 1]. vertexSlot must be in the range [0, 2]. If the color index was not found, -1 is returned.
number
Triangle index.
number
Vertex slot in the triangle.
number
triangleVertexIndex(
triangleIndex,vertexSlot):number
Returns a vertex index in a triangle.
triangleIndex must be in the range [0, numberOfTriangles() - 1]. vertexSlot must be in the range [0, 2]. If the vertex index was not found -1 will be returned.
number
Triangle index.
number
Vertex slot in the triangle.
number
triangleVertexNormal(
triangleIndex,vertexSlot):Vector
Returns a normal at vertex in a triangle.
triangleIndex must be in the range [0, numberOfTriangles() - 1]. vertexSlot must be in the range [0, 2]. Otherwise the result is undefined.
number
Triangle index.
number
Vertex slot in the triangle.
triangleVertexNormalIndex(
triangleIndex,vertexSlot):number
Returns a normal index for vertex in a triangle.
triangleIndex must be in the range [0, numberOfTriangles() - 1]. vertexSlot must be in the range [0, 2]. If the normal index was not found, -1 is returned.
number
Triangle index.
number
Vertex slot in the triangle.
number
triangleVertexUVCoordinate(
triangleIndex,vertexSlot):XY
Returns a UV coordinate at a vertex in a triangle.
triangleIndex must be in the range [0, numberOfTriangles() - 1]. vertexSlot must be in the range [0, 2]. Otherwise the result is undefined.
number
Triangle index.
number
Vertex slot in the triangle.
triangleVertexUVCoordinateIndex(
triangleIndex,vertexSlot):number
Returns a UV coordinate index for a vertex in a triangle.
triangleIndex must be in the range [0, numberOfTriangles() - 1]. vertexSlot must be in the range [0, 2]. If the UV coordinate index was not found, -1 is returned.
number
Triangle index.
number
Vertex slot in the triangle.
number
uvCoordinate(
index):XY
Returns a UV coordinate.
index must be in the range [0, numberOfUVCoordinates() - 1]. Otherwise the result is undefined.
number
UV coordinate index.
vertex(
index):Point
Returns a vertex.
index must be in the range [0, numberOfVertices() - 1]. Otherwise the result is undefined.
number
Vertex index.