MeshIndexedTriangles

class cee.geo.MeshIndexedTriangles()

This class implements a Mesh for indexed triangles.

Rather than defining each triangle directly as an array of vertices, an array containing x, y and z values for each unique vertex in the part is defined. Then triangles are defined by arrays of indices that refer to elements of this vertex array. This allows triangles to share vertices, thus reducing the number of vertices, and enabling the computation of smooth shade normals.

Note that while the vertices array contains 3 elements per point (x, y and z), the elements in the indices array are interpreted as vertex indices. For example, if vertices contains 3 vertices A, B and C:

vertices = [Ax, Ay, Az, Bx, By, Bz, Cx, Cy, Cz];

Then vertex A is at index 0, vertex B and 1 and vertex C at 2. So the triangle containing these vertices would be defined with

indices = [0, 1, 2];

Constructors

cee.geo.MeshIndexedTriangles.constructor()
MeshIndexedTriangles(vertices: ArrayLike, indices: ArrayLike, optionalVertexData: OptionalIndexedTriangleVertexData): MeshIndexedTriangles

Creates an indexed triangle mesh with the given vertices and indices.

Parameters

vertices: ArrayLike

indices: ArrayLike

optionalVertexData: OptionalIndexedTriangleVertexData

Returns: MeshIndexedTriangles

Accessors

cee.geo.MeshIndexedTriangles.boundingBox()

The BoundingBox of the mesh.

get boundingBox(): BoundingBox

Returns a copy of the BoundingBox of the mesh

Returns: BoundingBox

cee.geo.MeshIndexedTriangles.indexArray()
get indexArray(): ArrayLike

A readonly array containing the indices of the mesh

Returns: ArrayLike

cee.geo.MeshIndexedTriangles.primitiveCount()

The number of primitives in the mesh.

get primitiveCount(): number

The number of primitives in the mesh.

Returns: number

cee.geo.MeshIndexedTriangles.primitiveType()

The type of primitives that are used in the mesh.

get primitiveType(): MeshPrimitiveType

The type of primitives that are used in the mesh.

Returns: MeshPrimitiveType

cee.geo.MeshIndexedTriangles.textureCoordinates()
get textureCoordinates(): ArrayLike

A readonly array containing the 2d texture coordinates of the mesh

Returns: ArrayLike

cee.geo.MeshIndexedTriangles.vertexArray()
get vertexArray(): ArrayLike

A readonly array containing the vertices of the mesh

Returns: ArrayLike

cee.geo.MeshIndexedTriangles.vertexCount()

The number of vertices in the mesh.

get vertexCount(): number

The number of vertices in the mesh.

Returns: number

Methods

cee.geo.MeshIndexedTriangles.getPrimitiveVertices()
getPrimitiveVertices(primitiveIndex: number): Vec3[]

Returns a copy of the vertex indices of a given primitive.

Parameters

primitiveIndex: number

Returns: Vec3[]

cee.geo.MeshIndexedTriangles.rayIntersect()
rayIntersect(ray: Ray, hitItem: MeshHitItem): boolean

Performs picking on the mesh.

If a primitive was hit, the function returns true and populates the passed hitItem object with information about this primitive. It nothing was hit, returns false.

Parameters

ray: Ray

hitItem: MeshHitItem

Returns: boolean

static cee.geo.MeshIndexedTriangles.constructPreserveSharpEdges()

static

constructPreserveSharpEdges(creaseAngleDegrees: number, vertices: ArrayLike, indices: ArrayLike, optionalVertexData: OptionalIndexedTriangleVertexData): MeshIndexedTriangles

Creates an indexed triangle mesh with the given vertices and indices.

Preserve sharp edges by splitting vertices on edges where the surface normal of the two triangles sharing the edge is more than the given angle (in degrees).

Parameters

creaseAngleDegrees: number

vertices: ArrayLike

indices: ArrayLike

optionalVertexData: OptionalIndexedTriangleVertexData

Returns: MeshIndexedTriangles