multiMaterial.d.ts 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import type { Nullable } from "../types";
  2. import type { Scene } from "../scene";
  3. import type { AbstractMesh } from "../Meshes/abstractMesh";
  4. import type { SubMesh } from "../Meshes/subMesh";
  5. import type { BaseTexture } from "../Materials/Textures/baseTexture";
  6. import { Material } from "../Materials/material";
  7. /**
  8. * A multi-material is used to apply different materials to different parts of the same object without the need of
  9. * separate meshes. This can be use to improve performances.
  10. * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/multiMaterials
  11. */
  12. export declare class MultiMaterial extends Material {
  13. private _subMaterials;
  14. /** @internal */
  15. _waitingSubMaterialsUniqueIds: string[];
  16. /**
  17. * Gets or Sets the list of Materials used within the multi material.
  18. * They need to be ordered according to the submeshes order in the associated mesh
  19. */
  20. get subMaterials(): Nullable<Material>[];
  21. set subMaterials(value: Nullable<Material>[]);
  22. /**
  23. * Function used to align with Node.getChildren()
  24. * @returns the list of Materials used within the multi material
  25. */
  26. getChildren(): Nullable<Material>[];
  27. /**
  28. * Instantiates a new Multi Material
  29. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30. * separate meshes. This can be use to improve performances.
  31. * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/multiMaterials
  32. * @param name Define the name in the scene
  33. * @param scene Define the scene the material belongs to
  34. */
  35. constructor(name: string, scene?: Scene);
  36. private _hookArray;
  37. /**
  38. * Get one of the submaterial by its index in the submaterials array
  39. * @param index The index to look the sub material at
  40. * @returns The Material if the index has been defined
  41. */
  42. getSubMaterial(index: number): Nullable<Material>;
  43. /**
  44. * Get the list of active textures for the whole sub materials list.
  45. * @returns All the textures that will be used during the rendering
  46. */
  47. getActiveTextures(): BaseTexture[];
  48. /**
  49. * Specifies if any sub-materials of this multi-material use a given texture.
  50. * @param texture Defines the texture to check against this multi-material's sub-materials.
  51. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  52. */
  53. hasTexture(texture: BaseTexture): boolean;
  54. /**
  55. * Gets the current class name of the material e.g. "MultiMaterial"
  56. * Mainly use in serialization.
  57. * @returns the class name
  58. */
  59. getClassName(): string;
  60. /**
  61. * Checks if the material is ready to render the requested sub mesh
  62. * @param mesh Define the mesh the submesh belongs to
  63. * @param subMesh Define the sub mesh to look readiness for
  64. * @param useInstances Define whether or not the material is used with instances
  65. * @returns true if ready, otherwise false
  66. */
  67. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  68. /**
  69. * Clones the current material and its related sub materials
  70. * @param name Define the name of the newly cloned material
  71. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  72. * @returns the cloned material
  73. */
  74. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  75. /**
  76. * Serializes the materials into a JSON representation.
  77. * @returns the JSON representation
  78. */
  79. serialize(): any;
  80. /**
  81. * Dispose the material and release its associated resources
  82. * @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)
  83. * @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)
  84. * @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)
  85. */
  86. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87. /**
  88. * Creates a MultiMaterial from parsed MultiMaterial data.
  89. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  90. * @param scene defines the hosting scene
  91. * @returns a new MultiMaterial
  92. */
  93. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94. }