API

Class SubMesh

Defines a subdivision inside a mesh

Implements

Index
  • Creates a new submesh

    Parameters

    • materialIndex: number

      defines the material index to use

    • verticesStart: number

      defines vertex index start

    • verticesCount: number

      defines vertices count

    • indexStart: number

      defines index start

    • indexCount: number

      defines indices count

    • mesh: AbstractMesh

      defines the parent mesh

    • OptionalrenderingMesh: Mesh

      defines an optional rendering mesh

    • createBoundingBox: boolean = true

      defines if bounding box should be created for this submesh

    • addToMesh: boolean = true

      defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)

    Returns SubMesh

indexCount: number

indices count

indexStart: number

index start

materialIndex: number

the material index to use

verticesCount: number

vertices count

verticesStart: number

vertex index start

  • Release associated resources

    Parameters

    • immediate: boolean = false

      If true, the effect will be disposed immediately (false by default)

    Returns void

  • Returns the submesh material

    Parameters

    • getDefaultMaterial: boolean = true

      Defines whether or not to get the default material if nothing has been defined.

    • OptionalpassId: number

      Optional render pass id to get the material with. If undefined, the engine's current render pass id is used.

    Returns Nullable<Material>

    null or the current material

  • Resets the draw wrappers cache

    Parameters

    • OptionalpassId: number

      If provided, releases only the draw wrapper corresponding to this render pass id

    • immediate: boolean = false

      If true, the draw wrapper will dispose the effect immediately (false by default)

    Returns void

  • Sets associated effect (effect used to render this submesh)

    Parameters

    • effect: Nullable<Effect>

      defines the effect to associate with

    • defines: Nullable<string | MaterialDefines> = null

      defines the set of defines used to compile this effect

    • OptionalmaterialContext: IMaterialContext

      material context associated to the effect

    • resetContext: boolean = true

      true to reset the draw context

    Returns void

  • Makes the draw of this sub mesh in a render pass read its arguments from a buffer filled on the GPU (by a compute shader that culls instances, for example) instead of the arguments of the CPU. WebGPU only.

    The buffer stays the application's: it is never written into nor released here. It holds the arguments of drawIndexedIndirect for an indexed draw (indexCount, instanceCount and firstIndex as u32, baseVertex as i32, firstInstance as u32) or of drawIndirect otherwise (vertexCount, instanceCount, firstVertex and firstInstance, as u32). A firstInstance other than 0 needs the device to be created with the indirect-first-instance feature (engine.enabledExtensions), not only an adapter that supports it.

    Each draw of the sub mesh in the pass takes the binding, whatever draw context it goes through: the sub mesh's own, the one a material shares between its meshes, or a ShadowDepthWrapper's. Passes without a binding draw with the CPU arguments, as before: the arguments of a camera's pass never reach the shadow maps, which need bindings of their own. A new buffer or offset records the draw's bundle again; new contents written into the same buffer do not. A snapshot (snapshotRendering) must be recorded again after a binding changes. The binding of a pass goes with its render pass id (releaseRenderPassId).

    Parameters

    • buffer: Nullable<DataBuffer>

      the buffer of the arguments (created with the indirect usage), or null to clear the binding of the pass

    • byteOffset: number

      the offset of the arguments in the buffer, in bytes (a multiple of 4)

    • renderPassId: number

      the render pass of the binding: camera.renderPassId for a camera, the renderPassIds of a shadow map for a shadow generator. It is required: a camera rendering to the main framebuffer uses its own render pass id, not Constants.RENDERPASS_MAIN

    Returns void

  • Add a new submesh to a mesh

    Parameters

    • materialIndex: number

      defines the material index to use

    • verticesStart: number

      defines vertex index start

    • verticesCount: number

      defines vertices count

    • indexStart: number

      defines index start

    • indexCount: number

      defines indices count

    • mesh: AbstractMesh

      defines the parent mesh

    • OptionalrenderingMesh: Mesh

      defines an optional rendering mesh

    • createBoundingBox: boolean = true

      defines if bounding box should be created for this submesh

    Returns SubMesh

    the new submesh

  • Creates a new submesh from indices data

    Parameters

    • materialIndex: number

      the index of the main mesh material

    • startIndex: number

      the index where to start the copy in the mesh indices array

    • indexCount: number

      the number of indices to copy then from the startIndex

    • mesh: AbstractMesh

      the main mesh to create the submesh from

    • OptionalrenderingMesh: Mesh

      the optional rendering mesh

    • createBoundingBox: boolean = true

      defines if bounding box should be created for this submesh

    Returns SubMesh

    a new submesh