瀏覽代碼

Added custom color selector for Glow Layer

David Catuhe 7 年之前
父節點
當前提交
87df5c1dc8
共有 29 個文件被更改,包括 37908 次插入37826 次删除
  1. 13697 13689
      Playground/babylon.d.txt
  2. 15830 15822
      dist/preview release/babylon.d.ts
  3. 47 47
      dist/preview release/babylon.js
  4. 20 10
      dist/preview release/babylon.max.js
  5. 48 48
      dist/preview release/babylon.worker.js
  6. 8033 8025
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  7. 50 50
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  8. 20 10
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  9. 20 10
      dist/preview release/customConfigurations/minimalGLTFViewer/es6.js
  10. 20 10
      dist/preview release/es6.js
  11. 3 3
      dist/preview release/gui/babylon.gui.min.js
  12. 4 4
      dist/preview release/inspector/babylon.inspector.bundle.js
  13. 3 3
      dist/preview release/inspector/babylon.inspector.min.js
  14. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  15. 2 2
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  16. 3 3
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  17. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  18. 3 3
      dist/preview release/loaders/babylonjs.loaders.min.js
  19. 1 1
      dist/preview release/materialsLibrary/babylon.customMaterial.min.js
  20. 1 1
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js
  21. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  22. 3 3
      dist/preview release/materialsLibrary/babylonjs.materials.min.js
  23. 1 1
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  24. 1 1
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  25. 1 1
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js
  26. 1 1
      dist/preview release/serializers/babylon.glTF2Serializer.min.js
  27. 1 1
      dist/preview release/serializers/babylonjs.serializers.min.js
  28. 53 53
      dist/preview release/viewer/babylon.viewer.js
  29. 38 20
      src/Layer/babylon.glowLayer.ts

File diff suppressed because it is too large
+ 13697 - 13689
Playground/babylon.d.txt


File diff suppressed because it is too large
+ 15830 - 15822
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 47 - 47
dist/preview release/babylon.js


+ 20 - 10
dist/preview release/babylon.max.js

@@ -51299,7 +51299,7 @@ var BABYLON;
 
 
 
-//# sourceMappingURL=babylon.iParticleEmitterType.js.map
+//# sourceMappingURL=babylon.IParticleEmitterType.js.map
 
 var BABYLON;
 (function (BABYLON) {
@@ -84140,20 +84140,30 @@ var BABYLON;
          */
         GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
             var textureLevel = 1.0;
-            if (material) {
-                this._emissiveTextureAndColor.texture = material.emissiveTexture;
-                if (this._emissiveTextureAndColor.texture) {
-                    textureLevel = this._emissiveTextureAndColor.texture.level;
-                }
+            if (this.customEmissiveTextureSelector) {
+                this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
             }
             else {
-                this._emissiveTextureAndColor.texture = null;
+                if (material) {
+                    this._emissiveTextureAndColor.texture = material.emissiveTexture;
+                    if (this._emissiveTextureAndColor.texture) {
+                        textureLevel = this._emissiveTextureAndColor.texture.level;
+                    }
+                }
+                else {
+                    this._emissiveTextureAndColor.texture = null;
+                }
             }
-            if (material.emissiveColor) {
-                this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, 1.0);
+            if (this.customEmissiveColorSelector) {
+                this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
             }
             else {
-                this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
+                if (material.emissiveColor) {
+                    this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, 1.0);
+                }
+                else {
+                    this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
+                }
             }
         };
         /**

File diff suppressed because it is too large
+ 48 - 48
dist/preview release/babylon.worker.js


File diff suppressed because it is too large
+ 8033 - 8025
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


File diff suppressed because it is too large
+ 50 - 50
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 20 - 10
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -51299,7 +51299,7 @@ var BABYLON;
 
 
 
-//# sourceMappingURL=babylon.iParticleEmitterType.js.map
+//# sourceMappingURL=babylon.IParticleEmitterType.js.map
 
 var BABYLON;
 (function (BABYLON) {
@@ -83884,20 +83884,30 @@ var BABYLON;
          */
         GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
             var textureLevel = 1.0;
-            if (material) {
-                this._emissiveTextureAndColor.texture = material.emissiveTexture;
-                if (this._emissiveTextureAndColor.texture) {
-                    textureLevel = this._emissiveTextureAndColor.texture.level;
-                }
+            if (this.customEmissiveTextureSelector) {
+                this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
             }
             else {
-                this._emissiveTextureAndColor.texture = null;
+                if (material) {
+                    this._emissiveTextureAndColor.texture = material.emissiveTexture;
+                    if (this._emissiveTextureAndColor.texture) {
+                        textureLevel = this._emissiveTextureAndColor.texture.level;
+                    }
+                }
+                else {
+                    this._emissiveTextureAndColor.texture = null;
+                }
             }
-            if (material.emissiveColor) {
-                this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, 1.0);
+            if (this.customEmissiveColorSelector) {
+                this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
             }
             else {
-                this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
+                if (material.emissiveColor) {
+                    this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, 1.0);
+                }
+                else {
+                    this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
+                }
             }
         };
         /**

+ 20 - 10
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js

@@ -51285,7 +51285,7 @@ var BABYLON;
 
 
 
-//# sourceMappingURL=babylon.iParticleEmitterType.js.map
+//# sourceMappingURL=babylon.IParticleEmitterType.js.map
 
 var BABYLON;
 (function (BABYLON) {
@@ -83870,20 +83870,30 @@ var BABYLON;
          */
         GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
             var textureLevel = 1.0;
-            if (material) {
-                this._emissiveTextureAndColor.texture = material.emissiveTexture;
-                if (this._emissiveTextureAndColor.texture) {
-                    textureLevel = this._emissiveTextureAndColor.texture.level;
-                }
+            if (this.customEmissiveTextureSelector) {
+                this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
             }
             else {
-                this._emissiveTextureAndColor.texture = null;
+                if (material) {
+                    this._emissiveTextureAndColor.texture = material.emissiveTexture;
+                    if (this._emissiveTextureAndColor.texture) {
+                        textureLevel = this._emissiveTextureAndColor.texture.level;
+                    }
+                }
+                else {
+                    this._emissiveTextureAndColor.texture = null;
+                }
             }
-            if (material.emissiveColor) {
-                this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, 1.0);
+            if (this.customEmissiveColorSelector) {
+                this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
             }
             else {
-                this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
+                if (material.emissiveColor) {
+                    this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, 1.0);
+                }
+                else {
+                    this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
+                }
             }
         };
         /**

+ 20 - 10
dist/preview release/es6.js

@@ -51285,7 +51285,7 @@ var BABYLON;
 
 
 
-//# sourceMappingURL=babylon.iParticleEmitterType.js.map
+//# sourceMappingURL=babylon.IParticleEmitterType.js.map
 
 var BABYLON;
 (function (BABYLON) {
@@ -84126,20 +84126,30 @@ var BABYLON;
          */
         GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
             var textureLevel = 1.0;
-            if (material) {
-                this._emissiveTextureAndColor.texture = material.emissiveTexture;
-                if (this._emissiveTextureAndColor.texture) {
-                    textureLevel = this._emissiveTextureAndColor.texture.level;
-                }
+            if (this.customEmissiveTextureSelector) {
+                this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
             }
             else {
-                this._emissiveTextureAndColor.texture = null;
+                if (material) {
+                    this._emissiveTextureAndColor.texture = material.emissiveTexture;
+                    if (this._emissiveTextureAndColor.texture) {
+                        textureLevel = this._emissiveTextureAndColor.texture.level;
+                    }
+                }
+                else {
+                    this._emissiveTextureAndColor.texture = null;
+                }
             }
-            if (material.emissiveColor) {
-                this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, 1.0);
+            if (this.customEmissiveColorSelector) {
+                this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
             }
             else {
-                this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
+                if (material.emissiveColor) {
+                    this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, 1.0);
+                }
+                else {
+                    this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
+                }
             }
         };
         /**

File diff suppressed because it is too large
+ 3 - 3
dist/preview release/gui/babylon.gui.min.js


File diff suppressed because it is too large
+ 4 - 4
dist/preview release/inspector/babylon.inspector.bundle.js


File diff suppressed because it is too large
+ 3 - 3
dist/preview release/inspector/babylon.inspector.min.js


File diff suppressed because it is too large
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


File diff suppressed because it is too large
+ 2 - 2
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


File diff suppressed because it is too large
+ 3 - 3
dist/preview release/loaders/babylon.glTFFileLoader.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


File diff suppressed because it is too large
+ 3 - 3
dist/preview release/loaders/babylonjs.loaders.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/materialsLibrary/babylon.customMaterial.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/materialsLibrary/babylon.waterMaterial.min.js


File diff suppressed because it is too large
+ 3 - 3
dist/preview release/materialsLibrary/babylonjs.materials.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/serializers/babylon.glTF2Serializer.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/serializers/babylonjs.serializers.min.js


File diff suppressed because it is too large
+ 53 - 53
dist/preview release/viewer/babylon.viewer.js


+ 38 - 20
src/Layer/babylon.glowLayer.ts

@@ -101,6 +101,15 @@
         private _excludedMeshes: number[] = [];
 
         /**
+         * Callback used to let the user override the color selection on a per mesh basis
+         */
+        public customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
+        /**
+         * Callback used to let the user override the texture selection on a per mesh basis
+         */
+        public customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
+
+        /**
          * Instantiates a new glow Layer and references it to the scene.
          * @param name The name of the layer
          * @param scene The scene to use the layer in
@@ -310,29 +319,38 @@
          */
         protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void {
             var textureLevel = 1.0;
-            if (material) {
-                this._emissiveTextureAndColor.texture = (<any>material).emissiveTexture;
-                if (this._emissiveTextureAndColor.texture) {
-                    textureLevel = this._emissiveTextureAndColor.texture.level;
+
+            if (this.customEmissiveTextureSelector) {
+                this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
+            } else {
+                if (material) {
+                    this._emissiveTextureAndColor.texture = (<any>material).emissiveTexture;
+                    if (this._emissiveTextureAndColor.texture) {
+                        textureLevel = this._emissiveTextureAndColor.texture.level;
+                    }
+                }
+                else {
+                    this._emissiveTextureAndColor.texture = null;
                 }
-            }
-            else {
-                this._emissiveTextureAndColor.texture = null;
             }
 
-            if ((<any>material).emissiveColor) {
-                this._emissiveTextureAndColor.color.set(
-                    (<any>material).emissiveColor.r * textureLevel,
-                    (<any>material).emissiveColor.g * textureLevel,
-                    (<any>material).emissiveColor .b * textureLevel,
-                    1.0);
-            }
-            else {
-                this._emissiveTextureAndColor.color.set(
-                    this.neutralColor.r,
-                    this.neutralColor.g,
-                    this.neutralColor.b,
-                    this.neutralColor.a);
+            if (this.customEmissiveColorSelector) {
+                this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
+            } else {
+                if ((<any>material).emissiveColor) {
+                    this._emissiveTextureAndColor.color.set(
+                        (<any>material).emissiveColor.r * textureLevel,
+                        (<any>material).emissiveColor.g * textureLevel,
+                        (<any>material).emissiveColor .b * textureLevel,
+                        1.0);
+                }
+                else {
+                    this._emissiveTextureAndColor.color.set(
+                        this.neutralColor.r,
+                        this.neutralColor.g,
+                        this.neutralColor.b,
+                        this.neutralColor.a);
+                }
             }
         }