@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
95 lines (94 loc) • 4.65 kB
TypeScript
import type { Nullable } from "../types.js";
import type { Scene } from "../scene.js";
import type { AbstractMesh } from "../Meshes/abstractMesh.js";
import type { SubMesh } from "../Meshes/subMesh.js";
import type { BaseTexture } from "../Materials/Textures/baseTexture.js";
import { Material } from "../Materials/material.js";
/**
* A multi-material is used to apply different materials to different parts of the same object without the need of
* separate meshes. This can be use to improve performances.
* @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/multiMaterials
*/
export declare class MultiMaterial extends Material {
private _subMaterials;
/** @internal */
_waitingSubMaterialsUniqueIds: string[];
/**
* Gets or Sets the list of Materials used within the multi material.
* They need to be ordered according to the submeshes order in the associated mesh
*/
get subMaterials(): Nullable<Material>[];
set subMaterials(value: Nullable<Material>[]);
/**
* Function used to align with Node.getChildren()
* @returns the list of Materials used within the multi material
*/
getChildren(): Nullable<Material>[];
/**
* Instantiates a new Multi Material
* A multi-material is used to apply different materials to different parts of the same object without the need of
* separate meshes. This can be use to improve performances.
* @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/multiMaterials
* @param name Define the name in the scene
* @param scene Define the scene the material belongs to
*/
constructor(name: string, scene?: Scene);
private _hookArray;
/**
* Get one of the submaterial by its index in the submaterials array
* @param index The index to look the sub material at
* @returns The Material if the index has been defined
*/
getSubMaterial(index: number): Nullable<Material>;
/**
* Get the list of active textures for the whole sub materials list.
* @returns All the textures that will be used during the rendering
*/
getActiveTextures(): BaseTexture[];
/**
* Specifies if any sub-materials of this multi-material use a given texture.
* @param texture Defines the texture to check against this multi-material's sub-materials.
* @returns A boolean specifying if any sub-material of this multi-material uses the texture.
*/
hasTexture(texture: BaseTexture): boolean;
/**
* Gets the current class name of the material e.g. "MultiMaterial"
* Mainly use in serialization.
* @returns the class name
*/
getClassName(): string;
/**
* Checks if the material is ready to render the requested sub mesh
* @param mesh Define the mesh the submesh belongs to
* @param subMesh Define the sub mesh to look readiness for
* @param useInstances Define whether or not the material is used with instances
* @returns true if ready, otherwise false
*/
isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
/**
* Clones the current material and its related sub materials
* @param name Define the name of the newly cloned material
* @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
* @returns the cloned material
*/
clone(name: string, cloneChildren?: boolean): MultiMaterial;
/**
* Serializes the materials into a JSON representation.
* @returns the JSON representation
*/
serialize(): any;
/**
* Dispose the material and release its associated resources
* @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
* @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
* @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
*/
dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
/**
* Creates a MultiMaterial from parsed MultiMaterial data.
* @param parsedMultiMaterial defines parsed MultiMaterial data.
* @param scene defines the hosting scene
* @returns a new MultiMaterial
*/
static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
}