babylon.solidParticle.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. module BABYLON {
  2. export class SolidParticle {
  3. public idx: number; // particle global index
  4. public color = new Color4(1, 1, 1, 1); // color
  5. public position = Vector3.Zero(); // position
  6. public rotation = Vector3.Zero(); // rotation
  7. public rotationQuaternion: Quaternion; // quaternion, will overwrite rotation
  8. public scaling = new Vector3(1, 1, 1); // scaling
  9. public uvs = new Vector4(0, 0, 1, 1); // uvs
  10. public velocity = Vector3.Zero(); // velocity
  11. public alive = true; // alive
  12. public _pos: number; // index of this particle in the global "positions" array
  13. public _model: ModelShape; // model shape reference
  14. public shapeId: number; // model shape id
  15. public idxInShape: number; // index of the particle in its shape id
  16. constructor(particleIndex: number, positionIndex: number, model: ModelShape, shapeId: number, idxInShape: number) {
  17. this.idx = particleIndex;
  18. this._pos = positionIndex;
  19. this._model = model;
  20. this.shapeId = shapeId;
  21. this.idxInShape = idxInShape;
  22. }
  23. //legacy support, changed scale to scaling
  24. public get scale(): Vector3 {
  25. return this.scaling;
  26. }
  27. public set scale(scale: Vector3) {
  28. this.scaling = scale;
  29. }
  30. //legacy support, changed quaternion to rotationQuaternion
  31. public get quaternion(): Quaternion {
  32. return this.rotationQuaternion;
  33. }
  34. public set quaternion(q: Quaternion) {
  35. this.rotationQuaternion = q;
  36. }
  37. }
  38. export class ModelShape {
  39. public shapeID: number;
  40. public _shape: Vector3[];
  41. public _shapeUV: number[];
  42. public _positionFunction: (particle: SolidParticle, i: number, s: number) => void;
  43. public _vertexFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void;
  44. constructor(id: number, shape: Vector3[], shapeUV: number[], posFunction: (particle: SolidParticle, i: number, s: number) => void, vtxFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void) {
  45. this.shapeID = id;
  46. this._shape = shape;
  47. this._shapeUV = shapeUV;
  48. this._positionFunction = posFunction;
  49. this._vertexFunction = vtxFunction;
  50. }
  51. }
  52. }