瀏覽代碼

Move static to PBR Material

Sebastien Vandenberghe 8 年之前
父節點
當前提交
c53bbdedcd
共有 2 個文件被更改,包括 41 次插入37 次删除
  1. 9 37
      src/Materials/PBR/babylon.pbrBaseSimpleMaterial.ts
  2. 32 0
      src/Materials/PBR/babylon.pbrMaterial.ts

+ 9 - 37
src/Materials/PBR/babylon.pbrBaseSimpleMaterial.ts

@@ -1,32 +1,4 @@
-module BABYLON {
-    /**
-     * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
-     */
-    export const PBRMATERIAL_OPAQUE = 0;
-
-    /**
-     * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
-     */
-    export const PBRMATERIAL_ALPHATEST = 1;
-
-    /**
-     * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
-     */
-    export const PBRMATERIAL_ALPHABLEND = 2;
-
-    /**
-     * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
-     * They are also discarded below the alpha cutoff threshold to improve performances.
-     */
-    export const PBRMATERIAL_ALPHATESTANDBLEND = 3;
-
-    /**
-     * Limits the values allowed in the transparency ones to the known ones.
-     */
-    export type PBRMaterialTransparencyMode = 0 | 1 | 2 | 3;
-}
-
-module BABYLON.Internals {
+module BABYLON.Internals {
     /**
      * The Physically based simple base material of BJS.
      * 
@@ -112,20 +84,20 @@ module BABYLON.Internals {
         @expandToProperty(null, "_alphaCutOff")
         public alphaCutOff: number;
 
-        protected _transparencyMode: PBRMaterialTransparencyMode = PBRMATERIAL_OPAQUE;
+        protected _transparencyMode: number = PBRMaterial.PBRMATERIAL_OPAQUE;
         /**
          * Gets the current transparency mode.
          */
         @serialize()
-        public get transparencyMode(): PBRMaterialTransparencyMode {
+        public get transparencyMode(): number {
             return this._transparencyMode;
         }
         /**
          * Sets the transparency mode of the material.
          */
-        public set transparencyMode(value: PBRMaterialTransparencyMode) {
+        public set transparencyMode(value: number) {
             this._transparencyMode = value;
-            if (value === PBRMATERIAL_ALPHATESTANDBLEND) {
+            if (value === PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND) {
                 this._forceAlphaTest = true;
             }
             else {
@@ -152,7 +124,7 @@ module BABYLON.Internals {
          * Specifies wether or not the alpha value of the albedo texture should be used.
          */
         protected _shouldUseAlphaFromAlbedoTexture(): boolean {
-            return this._albedoTexture && this._albedoTexture.hasAlpha && this._transparencyMode !== PBRMATERIAL_OPAQUE;
+            return this._albedoTexture && this._albedoTexture.hasAlpha && this._transparencyMode !== PBRMaterial.PBRMATERIAL_OPAQUE;
         }
 
         /**
@@ -165,8 +137,8 @@ module BABYLON.Internals {
 
             return (this.alpha < 1.0) || 
                     (this._shouldUseAlphaFromAlbedoTexture() &&
-                        (this._transparencyMode === PBRMATERIAL_ALPHABLEND ||
-                            this._transparencyMode === PBRMATERIAL_ALPHATESTANDBLEND));
+                        (this._transparencyMode === PBRMaterial.PBRMATERIAL_ALPHABLEND ||
+                            this._transparencyMode === PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND));
         }
 
         /**
@@ -178,7 +150,7 @@ module BABYLON.Internals {
             }
 
             return this._shouldUseAlphaFromAlbedoTexture() &&
-                 this._transparencyMode === PBRMATERIAL_ALPHATEST;
+                 this._transparencyMode === PBRMaterial.PBRMATERIAL_ALPHATEST;
         }
 
         /**

+ 32 - 0
src/Materials/PBR/babylon.pbrMaterial.ts

@@ -7,6 +7,38 @@
      * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
      */
     export class PBRMaterial extends PBRBaseMaterial {
+        private static _PBRMATERIAL_OPAQUE = 0;
+        /**
+         * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
+         */
+        public static get PBRMATERIAL_OPAQUE(): number {
+            return this._PBRMATERIAL_OPAQUE;
+        }
+
+        private static _PBRMATERIAL_ALPHATEST = 1;
+        /**
+         * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
+         */
+        public static get PBRMATERIAL_ALPHATEST(): number {
+            return this._PBRMATERIAL_ALPHATEST;
+        }
+
+        private static _PBRMATERIAL_ALPHABLEND = 2;
+        /**
+         * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
+         */
+        public static get PBRMATERIAL_ALPHABLEND(): number {
+            return this._PBRMATERIAL_ALPHABLEND;
+        }
+
+        private static _PBRMATERIAL_ALPHATESTANDBLEND = 3;
+        /**
+         * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
+         * They are also discarded below the alpha cutoff threshold to improve performances.
+         */
+        public static get PBRMATERIAL_ALPHATESTANDBLEND(): number {
+            return this._PBRMATERIAL_ALPHATESTANDBLEND;
+        }
 
         /**
          * Intensity of the direct lights e.g. the four lights available in your scene.