|
@@ -60,6 +60,8 @@
|
|
*/
|
|
*/
|
|
public cellIndex: number = 0;
|
|
public cellIndex: number = 0;
|
|
|
|
|
|
|
|
+ public _randomCellOffset?: number;
|
|
|
|
+
|
|
/** @hidden */
|
|
/** @hidden */
|
|
public _initialDirection: Nullable<Vector3>;
|
|
public _initialDirection: Nullable<Vector3>;
|
|
|
|
|
|
@@ -115,7 +117,7 @@
|
|
*/
|
|
*/
|
|
constructor(
|
|
constructor(
|
|
/**
|
|
/**
|
|
- * particleSystem the particle system the particle belongs to.
|
|
|
|
|
|
+ * The particle system the particle belongs to.
|
|
*/
|
|
*/
|
|
public particleSystem: ParticleSystem) {
|
|
public particleSystem: ParticleSystem) {
|
|
if (!this.particleSystem.isAnimationSheetEnabled) {
|
|
if (!this.particleSystem.isAnimationSheetEnabled) {
|
|
@@ -133,12 +135,34 @@
|
|
* Defines how the sprite cell index is updated for the particle
|
|
* Defines how the sprite cell index is updated for the particle
|
|
*/
|
|
*/
|
|
public updateCellIndex(): void {
|
|
public updateCellIndex(): void {
|
|
|
|
+ let offsetAge = this.age;
|
|
|
|
+
|
|
|
|
+ if (this.particleSystem.spriteRandomStartCell) {
|
|
|
|
+ if (this._randomCellOffset === undefined) {
|
|
|
|
+ this._randomCellOffset = Math.random() * this.lifeTime;
|
|
|
|
+ }
|
|
|
|
+ offsetAge += this._randomCellOffset;
|
|
|
|
+ }
|
|
|
|
+
|
|
let dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
|
|
let dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
|
|
- let ratio = Scalar.Clamp(((this.age * this.particleSystem.spriteCellChangeSpeed) % this.lifeTime) / this.lifeTime);
|
|
|
|
|
|
+ let ratio = Scalar.Clamp(((offsetAge * this.particleSystem.spriteCellChangeSpeed) % this.lifeTime) / this.lifeTime);
|
|
|
|
|
|
this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
|
|
this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /** @hidden */
|
|
|
|
+ public _reset() {
|
|
|
|
+ this.age = 0;
|
|
|
|
+ this._currentColorGradient = null;
|
|
|
|
+ this._currentSizeGradient = null;
|
|
|
|
+ this._currentAngularSpeedGradient = null;
|
|
|
|
+ this._currentVelocityGradient = null;
|
|
|
|
+ this._currentLimitVelocityGradient = null;
|
|
|
|
+ this._currentDragGradient = null;
|
|
|
|
+ this.cellIndex = this.particleSystem.startSpriteCellID;
|
|
|
|
+ this._randomCellOffset = undefined;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Copy the properties of particle to another one.
|
|
* Copy the properties of particle to another one.
|
|
* @param other the particle to copy the information to.
|
|
* @param other the particle to copy the information to.
|
|
@@ -159,6 +183,7 @@
|
|
other.colorStep.copyFrom(this.colorStep);
|
|
other.colorStep.copyFrom(this.colorStep);
|
|
other.lifeTime = this.lifeTime;
|
|
other.lifeTime = this.lifeTime;
|
|
other.age = this.age;
|
|
other.age = this.age;
|
|
|
|
+ other._randomCellOffset = undefined;
|
|
other.size = this.size;
|
|
other.size = this.size;
|
|
other.scale.copyFrom(this.scale);
|
|
other.scale.copyFrom(this.scale);
|
|
other.angle = this.angle;
|
|
other.angle = this.angle;
|