فهرست منبع

disposing particle

DESKTOP-QJU4N0L\mityh 8 سال پیش
والد
کامیت
8e8b515f85

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 8201 - 8199
dist/preview release/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 19 - 19
dist/preview release/babylon.js


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

@@ -40844,14 +40844,8 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
-    var IParticleAnimation = (function () {
-        function IParticleAnimation() {
-        }
-        return IParticleAnimation;
-    }());
-    BABYLON.IParticleAnimation = IParticleAnimation;
     var Particle = (function () {
-        function Particle(cellWidth, cellHeight, cellIndex, invertU, invertV, _loopAnimation, _fromIndex, _toIndex, _delay, _sheetDirection, _time) {
+        function Particle(particleSystem, cellWidth, cellHeight, cellIndex, invertU, invertV, _loopAnimation, _fromIndex, _toIndex, _delay, _sheetDirection, _time, disposeWhenFinishedAnimating) {
             if (cellWidth === void 0) { cellWidth = 0; }
             if (cellHeight === void 0) { cellHeight = 0; }
             if (cellIndex === void 0) { cellIndex = 0; }
@@ -40863,6 +40857,8 @@ var BABYLON;
             if (_delay === void 0) { _delay = 0; }
             if (_sheetDirection === void 0) { _sheetDirection = 1; }
             if (_time === void 0) { _time = 0; }
+            if (disposeWhenFinishedAnimating === void 0) { disposeWhenFinishedAnimating = false; }
+            this.particleSystem = particleSystem;
             this.cellWidth = cellWidth;
             this.cellHeight = cellHeight;
             this.cellIndex = cellIndex;
@@ -40874,6 +40870,7 @@ var BABYLON;
             this._delay = _delay;
             this._sheetDirection = _sheetDirection;
             this._time = _time;
+            this.disposeWhenFinishedAnimating = disposeWhenFinishedAnimating;
             this.position = BABYLON.Vector3.Zero();
             this.direction = BABYLON.Vector3.Zero();
             this.color = new BABYLON.Color4(0, 0, 0, 0);
@@ -40895,7 +40892,9 @@ var BABYLON;
                     }
                     else {
                         this.cellIndex = this._toIndex;
-                        // stop and remove from scene
+                        if (this.disposeWhenFinishedAnimating) {
+                            this.dispose();
+                        }
                     }
                 }
             }
@@ -40910,6 +40909,22 @@ var BABYLON;
             other.size = this.size;
             other.angle = this.angle;
             other.angularSpeed = this.angularSpeed;
+            other.particleSystem = this.particleSystem;
+            other.cellWidth = this.cellWidth;
+            other.cellHeight = this.cellHeight;
+            other.cellIndex = this.cellIndex;
+            other.invertU = this.invertU;
+            other.invertV = this.invertV;
+            other._loopAnimation = this._loopAnimation;
+            other._fromIndex = this._fromIndex;
+            other._toIndex = this._toIndex;
+            other._delay = this._delay;
+            other._sheetDirection = this._sheetDirection;
+            other._time = this._time;
+            other.disposeWhenFinishedAnimating = this.disposeWhenFinishedAnimating;
+        };
+        Particle.prototype.dispose = function () {
+            this.age = this.lifeTime;
         };
         return Particle;
     }());
@@ -40954,6 +40969,7 @@ var BABYLON;
             this.layerMask = 0x0FFFFFFF;
             this.customShader = null;
             this.preventAutoStart = false;
+            this.disposeParticlesWhenFinishedAnimating = false;
             /**
             * An event triggered when the system is disposed.
             * @type {BABYLON.Observable}
@@ -41188,13 +41204,14 @@ var BABYLON;
                 if (this._stockParticles.length !== 0) {
                     particle = this._stockParticles.pop();
                     particle.age = 0;
+                    particle.cellIndex = this._fromIndex;
                 }
                 else {
                     if (this.cellSize) {
-                        particle = new BABYLON.Particle(this.cellWidth, this.cellHeight, this.cellIndex, this.invertU, this.invertV, this._loopAnimation, this._fromIndex, this._toIndex, this._delay, this._sheetDirection, this._time);
+                        particle = new BABYLON.Particle(this, this.cellWidth, this.cellHeight, this.cellIndex, this.invertU, this.invertV, this._loopAnimation, this._fromIndex, this._toIndex, this._delay, this._sheetDirection, this._time, this.disposeParticlesWhenFinishedAnimating);
                     }
                     else {
-                        particle = new BABYLON.Particle();
+                        particle = new BABYLON.Particle(this);
                     }
                 }
                 this.particles.push(particle);

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 8201 - 8199
dist/preview release/babylon.module.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 19 - 19
dist/preview release/babylon.worker.js


+ 21 - 6
src/Particles/babylon.particle.ts

@@ -1,9 +1,5 @@
 module BABYLON {
 
-    export class IParticleAnimation {
-
-    }
-
     export class Particle {
         public position = Vector3.Zero();
         public direction = Vector3.Zero();
@@ -15,7 +11,7 @@
         public angle = 0;
         public angularSpeed = 0;
 
-        constructor(public cellWidth: number = 0, public cellHeight: number = 0, public cellIndex: number = 0, public invertU: number = 0, public invertV: number = 0, private _loopAnimation = false, private _fromIndex = 0, private _toIndex = 0, private _delay = 0, private _sheetDirection = 1, private _time = 0) {
+        constructor(private particleSystem: ParticleSystem, public cellWidth: number = 0, public cellHeight: number = 0, public cellIndex: number = 0, public invertU: number = 0, public invertV: number = 0, private _loopAnimation = false, private _fromIndex = 0, private _toIndex = 0, private _delay = 0, private _sheetDirection = 1, private _time = 0, private disposeWhenFinishedAnimating = false) {
         }
 
         public _animate(deltaTime: number): void {
@@ -29,7 +25,9 @@
                     }
                     else {
                         this.cellIndex = this._toIndex;
-                        // stop and remove from scene
+                        if (this.disposeWhenFinishedAnimating) {
+                            this.dispose();
+                        }
                     }
                 }
             }
@@ -45,6 +43,23 @@
             other.size = this.size;
             other.angle = this.angle;
             other.angularSpeed = this.angularSpeed;
+            other.particleSystem = this.particleSystem;
+            other.cellWidth = this.cellWidth;
+            other.cellHeight = this.cellHeight;
+            other.cellIndex = this.cellIndex;
+            other.invertU = this.invertU;
+            other.invertV = this.invertV;
+            other._loopAnimation = this._loopAnimation;
+            other._fromIndex = this._fromIndex;
+            other._toIndex = this._toIndex;
+            other._delay = this._delay;
+            other._sheetDirection = this._sheetDirection;
+            other._time = this._time;
+            other.disposeWhenFinishedAnimating = this.disposeWhenFinishedAnimating;
+        }
+
+        public dispose() {
+            this.age = this.lifeTime;
         }
     }
 } 

+ 4 - 2
src/Particles/babylon.particleSystem.ts

@@ -65,6 +65,7 @@
         public cellIndex: number;
         public invertU: number;
         public invertV: number;
+        public disposeParticlesWhenFinishedAnimating = false;
         private _epsilon: number;
 
 
@@ -364,12 +365,13 @@
                 if (this._stockParticles.length !== 0) {
                     particle = this._stockParticles.pop();
                     particle.age = 0;
+                    particle.cellIndex = this._fromIndex;
                 } else {
                     if (this.cellSize) {
-                        particle = new Particle(this.cellWidth, this.cellHeight, this.cellIndex, this.invertU, this.invertV, this._loopAnimation, this._fromIndex, this._toIndex, this._delay, this._sheetDirection, this._time);
+                        particle = new Particle(this, this.cellWidth, this.cellHeight, this.cellIndex, this.invertU, this.invertV, this._loopAnimation, this._fromIndex, this._toIndex, this._delay, this._sheetDirection, this._time,this.disposeParticlesWhenFinishedAnimating);
                     }
                     else {
-                        particle = new Particle();
+                        particle = new Particle(this);
                     }
                 }
                 this.particles.push(particle);