Explorar el Código

Added ModelShape class : refactor

jbousquie hace 9 años
padre
commit
9f6da29073
Se han modificado 1 ficheros con 19 adiciones y 5 borrados
  1. 19 5
      src/Particles/babylon.solidParticle.ts

+ 19 - 5
src/Particles/babylon.solidParticle.ts

@@ -11,21 +11,35 @@ module BABYLON {
         public velocity = Vector3.Zero();       // velocity
         public alive = true;                    // alive
         public _pos: number;                    // index of this particle in the global "positions" array
-        public _shape: Vector3[];               // model shape array reference
-        public _shapeUV: number[];              // model shape UVs array reference
+        public _model: ModelShape;              // model shape reference
         public shapeId: number;                 // model shape id
         public previous: SolidParticle;         // pointer to the previous particle in the global particles array
         public next: SolidParticle;             // pointer to the next particle in the global particles array
         public idxInShape: number;              // index of the particle in its shape id
 
-        constructor(particleIndex: number, positionIndex: number, shape: Vector3[], shapeUV: number[], shapeId: number, idxInShape: number) {
+        constructor(particleIndex: number, positionIndex: number, model: ModelShape, shapeId: number, idxInShape: number) {
             this.idx = particleIndex;
             this._pos = positionIndex;
-            this._shape = shape;
-            this._shapeUV = shapeUV;
+            this._model = model;
             this.shapeId = shapeId;
             this.idxInShape = idxInShape;
         }
     }
+
+    export class ModelShape {
+        public shapeID: number;
+        public _shape: Vector3[];
+        public _shapeUV: number[];
+        public _positionFunction: (particle: SolidParticle, i: number, s: number) => void;
+        public _vertexFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void;
+
+        constructor(id: number, shape: Vector3[], shapeUV: number[], posFunction: (particle: SolidParticle, i: number, s: number) => void, vtxFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void) {
+            this.shapeID = id;
+            this._shape = shape;
+            this._shapeUV = shapeUV;
+            this._positionFunction = posFunction;
+            this._vertexFunction = vtxFunction;
+        }
+    }
 }