babylon.solidParticle.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 isVisible = true; // visibility
  13. public _pos: number; // index of this particle in the global "positions" array
  14. public _model: ModelShape; // model shape reference
  15. public shapeId: number; // model shape id
  16. public idxInShape: number; // index of the particle in its shape id
  17. constructor(particleIndex: number, positionIndex: number, model: ModelShape, shapeId: number, idxInShape: number) {
  18. this.idx = particleIndex;
  19. this._pos = positionIndex;
  20. this._model = model;
  21. this.shapeId = shapeId;
  22. this.idxInShape = idxInShape;
  23. }
  24. //legacy support, changed scale to scaling
  25. public get scale(): Vector3 {
  26. return this.scaling;
  27. }
  28. public set scale(scale: Vector3) {
  29. this.scaling = scale;
  30. }
  31. //legacy support, changed quaternion to rotationQuaternion
  32. public get quaternion(): Quaternion {
  33. return this.rotationQuaternion;
  34. }
  35. public set quaternion(q: Quaternion) {
  36. this.rotationQuaternion = q;
  37. }
  38. }
  39. export class ModelShape {
  40. public shapeID: number;
  41. public _shape: Vector3[];
  42. public _shapeUV: number[];
  43. public _positionFunction: (particle: SolidParticle, i: number, s: number) => void;
  44. public _vertexFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void;
  45. constructor(id: number, shape: Vector3[], shapeUV: number[], posFunction: (particle: SolidParticle, i: number, s: number) => void, vtxFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void) {
  46. this.shapeID = id;
  47. this._shape = shape;
  48. this._shapeUV = shapeUV;
  49. this._positionFunction = posFunction;
  50. this._vertexFunction = vtxFunction;
  51. }
  52. }
  53. }