浏览代码

Fixed HolographicButton

David Catuhe 7 年之前
父节点
当前提交
94c1957e07
共有 2 个文件被更改,包括 23 次插入8 次删除
  1. 11 2
      gui/src/3D/controls/button3D.ts
  2. 12 6
      gui/src/3D/controls/holographicButton.ts

+ 11 - 2
gui/src/3D/controls/button3D.ts

@@ -67,8 +67,17 @@ module BABYLON.GUI {
             }
             
             this._facadeTexture.addControl(value);
-        
-            (<any>this._currentMaterial).emissiveTexture = this._facadeTexture;
+
+            this._applyFacade(this._facadeTexture);
+        }
+
+        /**
+         * Apply the facade texture (created from the content property).
+         * This function can be overloaded by child classes
+         * @param facadeTexture defines the AdvancedDynamicTexture to use
+         */
+        protected _applyFacade(facadeTexture: AdvancedDynamicTexture) {
+            (<any>this._currentMaterial).emissiveTexture = facadeTexture;
         }
 
         protected _getTypeName(): string {

+ 12 - 6
gui/src/3D/controls/holographicButton.ts

@@ -6,6 +6,7 @@ module BABYLON.GUI {
      */
     export class HolographicButton extends Button3D {
         private _frontPlate: Mesh;
+        private _fluentMaterial: FluentMaterial;
 
         /**
          * Creates a new button
@@ -20,14 +21,14 @@ module BABYLON.GUI {
                 if (!this.mesh) {
                     return;
                 }
-                this._frontPlate.setEnabled(true);
+                this._frontPlate.edgesRenderer!.isEnabled = true;
             }
 
             this.pointerOutAnimation = () => {
                 if (!this.mesh) {
                     return;
                 }
-                this._frontPlate.setEnabled(false);
+                this._frontPlate.edgesRenderer!.isEnabled = false;
             }                      
         }
     
@@ -42,21 +43,26 @@ module BABYLON.GUI {
             this._frontPlate= <Mesh>super._createNode(scene);
             this._frontPlate.parent = mesh;
             this._frontPlate.position.z = -0.05;
-            this._frontPlate.setEnabled(false);
             this._frontPlate.isPickable = false;
-            this._frontPlate.visibility = 0.001;
 
             this._frontPlate.edgesWidth = 1.0;
             this._frontPlate.edgesColor = new Color4(1.0, 1.0, 1.0, 1.0);
             this._frontPlate.enableEdgesRendering();
+            this._frontPlate.edgesRenderer!.isEnabled = false;
             
             return mesh;
         }
 
+        protected _applyFacade(facadeTexture: AdvancedDynamicTexture) {
+            (<any>this._currentMaterial).emissiveTexture = facadeTexture;
+            (<any>this._currentMaterial).opacityTexture = facadeTexture;
+        }        
+
         protected _affectMaterial(mesh: Mesh) {
-            this._currentMaterial = new FluentMaterial(this.name + "Material", mesh.getScene());
+            super._affectMaterial(this._frontPlate);
+            this._fluentMaterial = new FluentMaterial(this.name + "Material", mesh.getScene());
 
-            mesh.material = this._currentMaterial;
+            mesh.material = this._fluentMaterial;
         }
     }
 }