Class MeshGroup

A helper class which acts as a single mesh, but contains a list of submeshes, where each submesh is assigned a different material.

Hierarchy

Constructors

  • Create a new MeshGroup from a list of submeshes, a manifold, and a submesh map, which maps triangles from the manifold to triangles from a submesh.

    WARNING: The submeshes array and the manifold mesh will have their ownership tranferred to this object. If you modify them later, they will be modified here as well, possibly corrupting the mesh. To avoid issues with this, do a deep clone of the inputs

    Parameters

    • submeshes: Submesh[] = []

      The list of submeshes to assign to this group.

    • premadeMergeMap: null | MergeMap = null

      A merge map that defines how to create a manifold from the submeshes.

    Returns MeshGroup

Properties

autoDispose: boolean = false

If this flag is set, then dispose will be called after a CSG operation is done. It's recommended to call mark instead of setting this manually, since the method is chainable.

premadeMergeMap: null | MergeMap = null

A merge map that defines how to create a manifold from the submeshes.

submeshes: Submesh[] = []

The list of submeshes to assign to this group.

Accessors

  • get mergeMap(): MergeMap
  • Get the merge map of this MeshGroup. If the MeshGroup has no merge map yet, then a merge map will be automatically generated and cached. Note that this process can throw.

    Returns MergeMap

  • get submeshCount(): number
  • Get the number of submeshes inside this MeshGroup.

    Returns number

Methods

  • Destroy the Wonderland Engine meshes stored in this object. Note that if the submeshes are reused elsewhere, then this will destroy those too.

    Returns void

  • Encode into a format that is passable to the Manifold worker, along with a numeric mapping for materials.

    Parameters

    • materials: Material[]
    • transferables: Transferable[]

    Returns EncodedMeshGroup

  • Get the submeshes at a specific submesh index.

    Returns

    A pair containing a WL.Mesh instance and a WL.Material instance.

    Parameters

    • submeshIdx: number

      The index of the wanted submesh.

    Returns Submesh

  • Get the submeshes inside this MeshGroup.

    Returns

    A list of submeshes, where each submesh is a pair containing a WL.Mesh instance and a WL.Material instance.

    Returns Submesh[]

  • Transform all submeshes and the manifold by a given matrix and normal matrix. Chainable method.

    Parameters

    • matrix: mat4
    • Optional normalMatrix: mat3

    Returns MeshGroup

  • Translate all submeshes and the manifold by a given translation vector. Chainable method.

    Parameters

    • translation: vec3

    Returns MeshGroup

  • Create a new MeshGroup from an EncodedMeshGroup.

    Parameters

    • engine: WonderlandEngine
    • encodedMeshGroup: EncodedMeshGroup
    • materials: Material[]

    Returns MeshGroup

  • Create a new MeshGroup from a WL.Mesh.

    WARNING: The submeshes array and the manifold mesh will have their ownership tranferred to this object. If you modify them later, they will be modified here as well, possibly corrupting the mesh. To avoid issues with this, do a deep clone of the inputs

    Parameters

    • mesh: Mesh

      A WL.Mesh instance.

    • material: null | Material = null

      A WL.Material instance. Null by default.

    Returns MeshGroup

Generated using TypeDoc