فهرست منبع

Merge pull request #7037 from Popov72/Add-accessors-for-ShaderMaterial_shaderPath

Add get/set accessors for ShaderMaterial._shaderPath
David Catuhe 5 سال پیش
والد
کامیت
a05d417b75
2فایلهای تغییر یافته به همراه22 افزوده شده و 12 حذف شده
  1. 1 1
      dist/preview release/what's new.md
  2. 21 11
      src/Materials/shaderMaterial.ts

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

@@ -108,7 +108,7 @@
 
 - Added `ShaderMaterial.setColor4Array` ([JonathanTron](https://github.com/JonathanTron/))
 - Added `ShaderMaterial.setArray4` ([JonathanTron](https://github.com/JonathanTron/))
-- Updated signature of `ShaderMaterial.setMatrices` to `Mat4[] | Float32Array` ([Popov72](https://github.com/Popov72))
+- Added get/set accessors for `ShaderMaterial._shaderPath` ([Popov72](https://github.com/Popov72))
 - Added `scene.environmentIntensity` to control the IBL strength overall in a scene ([Sebavan](https://github.com/sebavan/))
 - Added support of image processing for `WaterMaterial` ([julien-moreau](https://github.com/julien-moreau))
 - Added `pbrBRDFConfiguration.useSpecularGlossinessInputEnergyConservation` to allow Specular-Workflow energy conservation to be turned off ([ColorDigital-PS](https://github.com/ColorDigital-PS)).

+ 21 - 11
src/Materials/shaderMaterial.ts

@@ -118,6 +118,22 @@ export class ShaderMaterial extends Material {
     }
 
     /**
+     * Gets the shader path used to define the shader code
+     * It can be modified to trigger a new compilation
+     */
+    public get shaderPath(): any {
+        return this._shaderPath;
+    }
+
+    /**
+     * Sets the shader path used to define the shader code
+     * It can be modified to trigger a new compilation
+     */
+    public set shaderPath(shaderPath: any) {
+        this._shaderPath = shaderPath;
+    }
+
+    /**
      * Gets the options used to compile the shader.
      * They can be modified to trigger a new compilation
      */
@@ -342,21 +358,15 @@ export class ShaderMaterial extends Material {
      * @param value Define the value to give to the uniform
      * @return the material itself allowing "fluent" like uniform updates
      */
-    public setMatrices(name: string, value: Matrix[] | Float32Array): ShaderMaterial {
+    public setMatrices(name: string, value: Matrix[]): ShaderMaterial {
         this._checkUniform(name);
 
-        let float32Array;
+        let float32Array = new Float32Array(value.length * 16);
 
-        if (Array.isArray(value)) {
-            float32Array = new Float32Array(value.length * 16);
+        for (var index = 0; index < value.length; index++) {
+            let matrix = value[index];
 
-            for (var index = 0; index < value.length; index++) {
-                let matrix = value[index];
-
-                matrix.copyToArray(float32Array, index * 16);
-            }
-        } else {
-            float32Array = value;
+            matrix.copyToArray(float32Array, index * 16);
         }
 
         this._matrixArrays[name] = float32Array;