babylon.particle.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. module BABYLON {
  2. export class Particle {
  3. public position = Vector3.Zero();
  4. public direction = Vector3.Zero();
  5. public color = new Color4(0, 0, 0, 0);
  6. public colorStep = new Color4(0, 0, 0, 0);
  7. public lifeTime = 1.0;
  8. public age = 0;
  9. public size = 0;
  10. public angle = 0;
  11. public angularSpeed = 0;
  12. constructor(private particleSystem: ParticleSystem, public cellIndex: number = 0, private _loopAnimation = false, private _fromIndex = 0, private _toIndex = 0, private disposeWhenFinishedAnimating = false) {
  13. }
  14. public updateCellIndex(deltaTime: number): void {
  15. // this._time += deltaTime;
  16. // if (this._time > this._delay) {
  17. // this._time = this._time % this._delay;
  18. // this.cellIndex += this._sheetDirection;
  19. // if (this.cellIndex > this._toIndex) {
  20. // if (this._loopAnimation) {
  21. // this.cellIndex = this._fromIndex;
  22. // }
  23. // else {
  24. // this.cellIndex = this._toIndex;
  25. // if (this.disposeWhenFinishedAnimating) {
  26. // this.readyForRecycling();
  27. // }
  28. // }
  29. // }
  30. // }
  31. }
  32. public copyTo(other: Particle) {
  33. other.position.copyFrom(this.position);
  34. other.direction.copyFrom(this.direction);
  35. other.color.copyFrom(this.color);
  36. other.colorStep.copyFrom(this.colorStep);
  37. other.lifeTime = this.lifeTime;
  38. other.age = this.age;
  39. other.size = this.size;
  40. other.angle = this.angle;
  41. other.angularSpeed = this.angularSpeed;
  42. other.particleSystem = this.particleSystem;
  43. other.cellIndex = this.cellIndex;
  44. other._loopAnimation = this._loopAnimation;
  45. other._fromIndex = this._fromIndex;
  46. other._toIndex = this._toIndex;
  47. other.disposeWhenFinishedAnimating = this.disposeWhenFinishedAnimating;
  48. }
  49. public readyForRecycling() {
  50. this.age = this.lifeTime;
  51. }
  52. }
  53. }