Class PackedMesh<ModelType>

A packed mesh that has all the materials, primitives and the mapping back to model elements.

This can be considered the reified version of CanonicalGeometry.

Type Parameters

Constructors

  • Construct a packed mesh.

    Type Parameters

    Parameters

    • model: ModelType

      The model this mesh came from.

    • materials: readonly CanonicalMaterial[]

      The materials array for the packed mesh (referenced by index by primitives)

    • primitives: readonly [GeometryObject, undefined | number][]

      The primitives for this mesh (the mesh fragments by material), with the material index being the second item of the tuple.

    • triangleElementMaps: readonly TriangleElementMap[]

      Triangle element maps (one per primitive, in the same order, to map elements to primitives)

    • elementPrimitiveIndex: ReadonlyMap<number, number[]>

      Element primitive index, maps element local ids to the correct primitive.

    Returns PackedMesh<ModelType>

Properties

elementPrimitiveIndex: ReadonlyMap<number, number[]>

Element primitive index, maps element local ids to the correct primitive.

materials: readonly CanonicalMaterial[]

The materials array for the packed mesh (referenced by index by primitives)

model: ModelType

The model this mesh came from.

primitives: readonly [GeometryObject, undefined | number][]

The primitives for this mesh (the mesh fragments by material), with the material index being the second item of the tuple.

triangleElementMaps: readonly TriangleElementMap[]

Triangle element maps (one per primitive, in the same order, to map elements to primitives)

Methods

  • Get triangles from a cursor.

    Parameters

    Returns IterableIterator<[number, number, ReadonlyUint32Array]>

    Returns a tuple containing the local ID of the element, the primitive index, and the triangles.

    Note - there may be multiple batches of triangles from the same element, because the triangles maybe in different primitives.