Просмотр исходного кода

Adding LensFlareSystem.isEnabled property

David Catuhe 11 лет назад
Родитель
Сommit
2e954475cc

+ 17 - 0
Babylon/LensFlare/babylon.lensFlareSystem.js

@@ -7,6 +7,7 @@
             this.borderLimit = 300;
             this._vertexDeclaration = [2];
             this._vertexStrideSize = 2 * 4;
+            this._isEnabled = true;
             this._scene = scene;
             this._emitter = emitter;
             scene.lensFlareSystems.push(this);
@@ -39,6 +40,18 @@
             // Effects
             this._effect = this._scene.getEngine().createEffect("lensFlare", ["position"], ["color", "viewportMatrix"], ["textureSampler"], "");
         }
+        Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
+            get: function () {
+                return this._isEnabled;
+            },
+            set: function (value) {
+                this._isEnabled = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+
         LensFlareSystem.prototype.getScene = function () {
             return this._scene;
         };
@@ -72,6 +85,10 @@
         };
 
         LensFlareSystem.prototype._isVisible = function () {
+            if (!this._isEnabled) {
+                return false;
+            }
+
             var emitterPosition = this.getEmitterPosition();
             var direction = emitterPosition.subtract(this._scene.activeCamera.position);
             var distance = direction.length();

+ 13 - 0
Babylon/LensFlare/babylon.lensFlareSystem.ts

@@ -13,6 +13,7 @@
         private _effect: Effect;
         private _positionX: number;
         private _positionY: number;
+        private _isEnabled = true;
 
         constructor(public name: string, emitter: any, scene: Scene) {
 
@@ -50,6 +51,14 @@
                 ["textureSampler"], "");
         }
 
+        public get isEnabled(): boolean {
+            return this._isEnabled;
+        }
+
+        public set isEnabled(value: boolean) {
+            this._isEnabled = value;
+        }
+
         public getScene(): Scene {
             return this._scene;
         }
@@ -83,6 +92,10 @@
         }
 
         public _isVisible(): boolean {
+            if (!this._isEnabled) {
+                return false;
+            }
+
             var emitterPosition = this.getEmitterPosition();
             var direction = emitterPosition.subtract(this._scene.activeCamera.position);
             var distance = direction.length();

Разница между файлами не показана из-за своего большого размера
+ 5 - 5
babylon.1.12-beta.js