Browse Source

Merge pull request #9301 from Vampiro/master

Override hasTexture in MultiMaterial.
Raanan Weber 4 years ago
parent
commit
d15b5d9d53
2 changed files with 20 additions and 0 deletions
  1. 1 0
      dist/preview release/what's new.md
  2. 19 0
      src/Materials/multiMaterial.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -187,6 +187,7 @@
 - Added `muted` setting to `VideoTexture`, fix autoplay in Chrome ([simonihmig](https://github.com/simonihmig))
 - Added `waveCount` to `WaterMaterial` used to adjust waves count according to the ground's size where the material is applied on ([julien-moreau](https://github.com/julien-moreau))
 - Alpha test `transparencyMode` no-longer requires a diffuse/albedo texture if `opacityTexture` is present ([metaobjects](https://github.com/metaobjects))
+- Added `hasTexture` override in `MultiMaterial` ([Vampiro](https://github.com/vampiro))
 
 ### Meshes
 

+ 19 - 0
src/Materials/multiMaterial.ts

@@ -102,6 +102,25 @@ export class MultiMaterial extends Material {
     }
 
     /**
+     * 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.
+     */
+    public hasTexture(texture: BaseTexture): boolean {
+        if (super.hasTexture(texture)) {
+            return true;
+        }
+
+        for (let i = 0; i < this.subMaterials.length; i++) {
+            if (this.subMaterials[i]?.hasTexture(texture)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
      * Gets the current class name of the material e.g. "MultiMaterial"
      * Mainly use in serialization.
      * @returns the class name