浏览代码

Merging latest PRs

David catuhe 10 年之前
父节点
当前提交
d06c5d59c0

文件差异内容过多而无法显示
+ 1078 - 988
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 11 - 10
dist/preview release/babylon.js


文件差异内容过多而无法显示
+ 379 - 0
dist/preview release/babylon.max.js


文件差异内容过多而无法显示
+ 10 - 9
dist/preview release/babylon.noworker.js


+ 21 - 0
src/Particles/babylon.solidParticle.js

@@ -0,0 +1,21 @@
+var BABYLON;
+(function (BABYLON) {
+    var SolidParticle = (function () {
+        function SolidParticle(particleIndex, positionIndex, shape, shapeUV, shapeId) {
+            this.shapeId = shapeId;
+            this.color = new BABYLON.Color4(1, 1, 1, 1);
+            this.position = BABYLON.Vector3.Zero();
+            this.rotation = BABYLON.Vector3.Zero();
+            this.scale = new BABYLON.Vector3(1, 1, 1);
+            this.uvs = new BABYLON.Vector4(0, 0, 1, 1);
+            this.velocity = BABYLON.Vector3.Zero();
+            this.alive = true;
+            this.idx = particleIndex;
+            this._pos = positionIndex;
+            this._shape = shape;
+            this._shapeUV = shapeUV;
+        }
+        return SolidParticle;
+    })();
+    BABYLON.SolidParticle = SolidParticle;
+})(BABYLON || (BABYLON = {}));

+ 8 - 9
src/Particles/babylon.solidParticle.ts

@@ -2,20 +2,19 @@ module BABYLON {
 
     export class SolidParticle {
         public idx: number; 
-        public shapeId: number;
-        public color: Color4 = new Color4(1, 1, 1, 1);
-        public position: Vector3 = Vector3.Zero();
-        public rotation: Vector3 = Vector3.Zero();
+        public color = new Color4(1, 1, 1, 1);
+        public position = Vector3.Zero();
+        public rotation = Vector3.Zero();
         public quaternion: Vector4;
-        public scale: Vector3 = new Vector3(1 ,1, 1);
-        public uvs: Vector4 = new Vector4(0,0, 1,1);
-        public velocity: Vector3 = Vector3.Zero();
-        public alive: boolean = true;
+        public scale = new Vector3(1 ,1, 1);
+        public uvs = new Vector4(0,0, 1,1);
+        public velocity = Vector3.Zero();
+        public alive = true;
         public _pos: number;
         public _shape: Vector3[]; 
         public _shapeUV : number[];   
 
-        constructor(particleIndex: number, positionIndex: number, shape: Vector3[], shapeUV: number[], shapeID: number) {
+        constructor(particleIndex: number, positionIndex: number, shape: Vector3[], shapeUV: number[], public shapeId: number) {
             this.idx = particleIndex;
             this._pos = positionIndex;
             this._shape = shape;

+ 356 - 0
src/Particles/babylon.solidParticleSystem.js

@@ -0,0 +1,356 @@
+var BABYLON;
+(function (BABYLON) {
+    var SolidParticleSystem = (function () {
+        function SolidParticleSystem(name, scene) {
+            // public members  
+            this.particles = new Array();
+            this.nbParticles = 0;
+            this.billboard = false;
+            this.counter = 0;
+            this._positions = new Array();
+            this._indices = new Array();
+            this._normals = new Array();
+            this._colors = new Array();
+            this._uvs = new Array();
+            this._index = 0; // indices index
+            this._shapeCounter = 0;
+            this._useParticleColor = true;
+            this._useParticleTexture = true;
+            this._useParticleRotation = true;
+            this._useParticleVertex = false;
+            this._cam_axisZ = BABYLON.Vector3.Zero();
+            this._cam_axisY = BABYLON.Vector3.Zero();
+            this._cam_axisX = BABYLON.Vector3.Zero();
+            this._axisX = BABYLON.Axis.X;
+            this._axisY = BABYLON.Axis.Y;
+            this._axisZ = BABYLON.Axis.Z;
+            this._fakeCamPos = BABYLON.Vector3.Zero();
+            this._rotMatrix = new BABYLON.Matrix();
+            this._invertedMatrix = new BABYLON.Matrix();
+            this._rotated = BABYLON.Vector3.Zero();
+            this._quaternion = new BABYLON.Quaternion();
+            this._vertex = BABYLON.Vector3.Zero();
+            this._yaw = 0.0;
+            this._pitch = 0.0;
+            this._roll = 0.0;
+            this._halfroll = 0.0;
+            this._halfpitch = 0.0;
+            this._halfyaw = 0.0;
+            this._sinRoll = 0.0;
+            this._cosRoll = 0.0;
+            this._sinPitch = 0.0;
+            this._cosPitch = 0.0;
+            this._sinYaw = 0.0;
+            this._cosYaw = 0.0;
+            this.name = name;
+            this._scene = scene;
+            this._camera = scene.activeCamera;
+        }
+        // build the SPS mesh : returns the mesh
+        SolidParticleSystem.prototype.buildMesh = function () {
+            if (this.nbParticles === 0) {
+                return null;
+            }
+            BABYLON.VertexData.ComputeNormals(this._positions, this._indices, this._normals);
+            var vertexData = new BABYLON.VertexData();
+            vertexData.positions = this._positions;
+            vertexData.indices = this._indices;
+            vertexData.normals = this._normals;
+            if (this._uvs) {
+                vertexData.uvs = this._uvs;
+            }
+            if (this._colors) {
+                vertexData.colors = this._colors;
+            }
+            var mesh = new BABYLON.Mesh(name, this._scene);
+            vertexData.applyToMesh(mesh, true);
+            this.mesh = mesh;
+            return mesh;
+        };
+        // _meshBuilder : inserts the shape model in the global SPS mesh
+        SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors) {
+            var i;
+            var u = 0;
+            var c = 0;
+            for (i = 0; i < shape.length; i++) {
+                positions.push(shape[i].x, shape[i].y, shape[i].z);
+                if (meshUV) {
+                    uvs.push(meshUV[u], meshUV[u + 1]);
+                    u += 2;
+                }
+                if (meshCol) {
+                    colors.push(meshCol[c], meshCol[c + 1], meshCol[c + 2], meshCol[c + 3]);
+                    c += 4;
+                }
+                else {
+                    colors.push(1, 1, 1, 1);
+                }
+            }
+            for (i = 0; i < meshInd.length; i++) {
+                indices.push(p + meshInd[i]);
+            }
+        };
+        // returns a shape array from positions array
+        SolidParticleSystem.prototype._posToShape = function (positions) {
+            var shape = [];
+            for (var i = 0; i < positions.length; i += 3) {
+                shape.push(new BABYLON.Vector3(positions[i], positions[i + 1], positions[i + 2]));
+            }
+            return shape;
+        };
+        // returns a shapeUV array from a Vector4 uvs
+        SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
+            var shapeUV = [];
+            if (uvs) {
+                shapeUV.push(uvs.x, uvs.y, uvs.z, uvs.w);
+            }
+            return shapeUV;
+        };
+        // adds a new particle object in the particles array
+        SolidParticleSystem.prototype._addParticle = function (p, idxpos, shape, shapeUV, shapeId) {
+            this.particles.push(new BABYLON.SolidParticle(p, idxpos, shape, shapeUV, shapeId));
+        };
+        // add solid particles from a shape model in the particles array
+        SolidParticleSystem.prototype.addShape = function (mesh, nb) {
+            var meshPos = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
+            var meshInd = mesh.getIndices();
+            var meshUV = mesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
+            var meshCol = mesh.getVerticesData(BABYLON.VertexBuffer.ColorKind);
+            var shape = this._posToShape(meshPos);
+            var shapeUV = this._uvsToShapeUV(meshUV);
+            // particles
+            for (var i = 0; i < nb; i++) {
+                this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors);
+                this._addParticle(this.nbParticles + i, this._positions.length, shape, shapeUV, this._shapeCounter);
+                this._index += shape.length;
+            }
+            this.nbParticles += nb;
+            this._shapeCounter++;
+            return this._shapeCounter;
+        };
+        // resets a particle back to its just built status
+        SolidParticleSystem.prototype.resetParticle = function (particle) {
+            for (var pt = 0; pt < particle._shape.length; pt++) {
+                this._positions[particle._pos + pt * 3] = particle._shape[pt].x;
+                this._positions[particle._pos + pt * 3 + 1] = particle._shape[pt].y;
+                this._positions[particle._pos + pt * 3 + 2] = particle._shape[pt].z;
+            }
+        };
+        // sets all the particles
+        SolidParticleSystem.prototype.setParticles = function () {
+            // custom beforeUpdate
+            this.beforeUpdateParticles();
+            this._cam_axisX.x = 1;
+            this._cam_axisX.y = 0;
+            this._cam_axisX.z = 0;
+            this._cam_axisY.x = 0;
+            this._cam_axisY.y = 1;
+            this._cam_axisY.z = 0;
+            this._cam_axisZ.x = 0;
+            this._cam_axisZ.y = 0;
+            this._cam_axisZ.z = 1;
+            // if the particles will always face the camera
+            if (this.billboard) {
+                // compute a fake camera position : un-rotate the camera position by the current mesh rotation
+                this._yaw = this.mesh.rotation.y;
+                this._pitch = this.mesh.rotation.x;
+                this._roll = this.mesh.rotation.z;
+                this._quaternionRotationYPR();
+                this._quaternionToRotationMatrix();
+                this._rotMatrix.invertToRef(this._invertedMatrix);
+                BABYLON.Vector3.TransformCoordinatesToRef(this._camera.globalPosition, this._invertedMatrix, this._fakeCamPos);
+                // set two orthogonal vectors (_cam_axisX and and _cam_axisY) to the cam-mesh axis (_cam_axisZ)
+                (this._fakeCamPos).subtractToRef(this.mesh.position, this._cam_axisZ);
+                BABYLON.Vector3.CrossToRef(this._cam_axisZ, this._axisX, this._cam_axisY);
+                BABYLON.Vector3.CrossToRef(this._cam_axisZ, this._cam_axisY, this._cam_axisX);
+                this._cam_axisY.normalize();
+                this._cam_axisX.normalize();
+                this._cam_axisZ.normalize();
+            }
+            BABYLON.Matrix.IdentityToRef(this._rotMatrix);
+            var idx = 0;
+            var index = 0;
+            var colidx = 0;
+            var colorIndex = 0;
+            var uvidx = 0;
+            var uvIndex = 0;
+            // particle loop
+            for (var p = 0; p < this.nbParticles; p++) {
+                this._particle = this.particles[p];
+                // call to custom user function to update the particle properties
+                this.updateParticle(this._particle);
+                // particle rotation matrix
+                if (this.billboard) {
+                    this._particle.rotation.x = 0.0;
+                    this._particle.rotation.y = 0.0;
+                }
+                if (this._useParticleRotation) {
+                    if (this._particle.quaternion) {
+                        this._quaternion.x = this._particle.quaternion.x;
+                        this._quaternion.y = this._particle.quaternion.y;
+                        this._quaternion.z = this._particle.quaternion.z;
+                        this._quaternion.w = this._particle.quaternion.w;
+                    }
+                    else {
+                        this._yaw = this._particle.rotation.y;
+                        this._pitch = this._particle.rotation.x;
+                        this._roll = this._particle.rotation.z;
+                        this._quaternionRotationYPR();
+                    }
+                    this._quaternionToRotationMatrix();
+                }
+                for (var pt = 0; pt < this._particle._shape.length; pt++) {
+                    idx = index + pt * 3;
+                    colidx = colorIndex + pt * 4;
+                    uvidx = uvIndex + pt * 2;
+                    this._vertex.x = this._particle._shape[pt].x;
+                    this._vertex.y = this._particle._shape[pt].y;
+                    this._vertex.z = this._particle._shape[pt].z;
+                    if (this._useParticleVertex) {
+                        this.updateParticleVertex(this._particle, this._vertex, pt);
+                    }
+                    BABYLON.Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
+                    this._positions[idx] = this._particle.position.x + this._cam_axisX.x * this._rotated.x * this._particle.scale.x + this._cam_axisY.x * this._rotated.y * this._particle.scale.y + this._cam_axisZ.x * this._rotated.z * this._particle.scale.z;
+                    this._positions[idx + 1] = this._particle.position.y + this._cam_axisX.y * this._rotated.x * this._particle.scale.x + this._cam_axisY.y * this._rotated.y * this._particle.scale.y + this._cam_axisZ.y * this._rotated.z * this._particle.scale.z;
+                    this._positions[idx + 2] = this._particle.position.z + this._cam_axisX.z * this._rotated.x * this._particle.scale.x + this._cam_axisY.z * this._rotated.y * this._particle.scale.y + this._cam_axisZ.z * this._rotated.z * this._particle.scale.z;
+                    if (this._useParticleColor) {
+                        this._colors[colidx] = this._particle.color.r;
+                        this._colors[colidx + 1] = this._particle.color.g;
+                        this._colors[colidx + 2] = this._particle.color.b;
+                        this._colors[colidx + 3] = this._particle.color.a;
+                    }
+                    if (this._useParticleTexture) {
+                        this._uvs[uvidx] = this._particle._shapeUV[pt * 2] * (this._particle.uvs.z - this._particle.uvs.x) + this._particle.uvs.x;
+                        this._uvs[uvidx + 1] = this._particle._shapeUV[pt * 2 + 1] * (this._particle.uvs.w - this._particle.uvs.y) + this._particle.uvs.y;
+                    }
+                }
+                index = idx + 3;
+                colorIndex = colidx + 4;
+                uvIndex = uvidx + 2;
+            }
+            if (this._useParticleColor) {
+                this.mesh.updateVerticesData(BABYLON.VertexBuffer.ColorKind, this._colors, false, false);
+            }
+            if (this._useParticleTexture) {
+                this.mesh.updateVerticesData(BABYLON.VertexBuffer.UVKind, this._uvs, false, false);
+            }
+            this.mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, this._positions, false, false);
+            if (!this.mesh.areNormalsFrozen) {
+                //   var indices = this.mesh.getIndices();
+                BABYLON.VertexData.ComputeNormals(this._positions, this._indices, this._normals);
+                this.mesh.updateVerticesData(BABYLON.VertexBuffer.NormalKind, this._normals, false, false);
+            }
+            this.afterUpdateParticles();
+        };
+        SolidParticleSystem.prototype._quaternionRotationYPR = function () {
+            this._halfroll = this._roll * 0.5;
+            this._halfpitch = this._pitch * 0.5;
+            this._halfyaw = this._yaw * 0.5;
+            this._sinRoll = Math.sin(this._halfroll);
+            this._cosRoll = Math.cos(this._halfroll);
+            this._sinPitch = Math.sin(this._halfpitch);
+            this._cosPitch = Math.cos(this._halfpitch);
+            this._sinYaw = Math.sin(this._halfyaw);
+            this._cosYaw = Math.cos(this._halfyaw);
+            this._quaternion.x = (this._cosYaw * this._sinPitch * this._cosRoll) + (this._sinYaw * this._cosPitch * this._sinRoll);
+            this._quaternion.y = (this._sinYaw * this._cosPitch * this._cosRoll) - (this._cosYaw * this._sinPitch * this._sinRoll);
+            this._quaternion.z = (this._cosYaw * this._cosPitch * this._sinRoll) - (this._sinYaw * this._sinPitch * this._cosRoll);
+            this._quaternion.w = (this._cosYaw * this._cosPitch * this._cosRoll) + (this._sinYaw * this._sinPitch * this._sinRoll);
+        };
+        SolidParticleSystem.prototype._quaternionToRotationMatrix = function () {
+            this._rotMatrix.m[0] = 1.0 - (2.0 * (this._quaternion.y * this._quaternion.y + this._quaternion.z * this._quaternion.z));
+            this._rotMatrix.m[1] = 2.0 * (this._quaternion.x * this._quaternion.y + this._quaternion.z * this._quaternion.w);
+            this._rotMatrix.m[2] = 2.0 * (this._quaternion.z * this._quaternion.x - this._quaternion.y * this._quaternion.w);
+            this._rotMatrix.m[3] = 0;
+            this._rotMatrix.m[4] = 2.0 * (this._quaternion.x * this._quaternion.y - this._quaternion.z * this._quaternion.w);
+            this._rotMatrix.m[5] = 1.0 - (2.0 * (this._quaternion.z * this._quaternion.z + this._quaternion.x * this._quaternion.x));
+            this._rotMatrix.m[6] = 2.0 * (this._quaternion.y * this._quaternion.z + this._quaternion.x * this._quaternion.w);
+            this._rotMatrix.m[7] = 0;
+            this._rotMatrix.m[8] = 2.0 * (this._quaternion.z * this._quaternion.x + this._quaternion.y * this._quaternion.w);
+            this._rotMatrix.m[9] = 2.0 * (this._quaternion.y * this._quaternion.z - this._quaternion.x * this._quaternion.w);
+            this._rotMatrix.m[10] = 1.0 - (2.0 * (this._quaternion.y * this._quaternion.y + this._quaternion.x * this._quaternion.x));
+            this._rotMatrix.m[11] = 0;
+            this._rotMatrix.m[12] = 0;
+            this._rotMatrix.m[13] = 0;
+            this._rotMatrix.m[14] = 0;
+            this._rotMatrix.m[15] = 1.0;
+        };
+        // dispose the SPS
+        SolidParticleSystem.prototype.dispose = function () {
+            this.mesh.dispose();
+        };
+        Object.defineProperty(SolidParticleSystem.prototype, "useParticleRotation", {
+            // getters
+            get: function () {
+                return this._useParticleRotation;
+            },
+            // Optimizer setters
+            set: function (val) {
+                this._useParticleRotation = val;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(SolidParticleSystem.prototype, "useParticleColor", {
+            get: function () {
+                return this._useParticleColor;
+            },
+            set: function (val) {
+                this._useParticleColor = val;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(SolidParticleSystem.prototype, "useParticleTexture", {
+            get: function () {
+                return this._useParticleTexture;
+            },
+            set: function (val) {
+                this._useParticleTexture = val;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(SolidParticleSystem.prototype, "useParticleVertex", {
+            get: function () {
+                return this._useParticleVertex;
+            },
+            set: function (val) {
+                this._useParticleVertex = val;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        // =======================================================================
+        // Particle behavior logic
+        // these following methods may be overwritten by the user to fit his needs
+        // init : sets all particles first values and calls updateParticle to set them in space
+        // can be overwritten by the user
+        SolidParticleSystem.prototype.initParticles = function () {
+        };
+        // recycles a particle : can by overwritten by the user
+        SolidParticleSystem.prototype.recycleParticle = function (particle) {
+            return particle;
+        };
+        // updates a particle : can be overwritten by the user
+        // will be called on each particle by setParticles() :
+        // ex : just set a particle position or velocity and recycle conditions
+        SolidParticleSystem.prototype.updateParticle = function (particle) {
+            return particle;
+        };
+        // updates a vertex of a particle : can be overwritten by the user
+        // will be called on each vertex particle by setParticles() :
+        // ex : just set a vertex particle position
+        SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, i) {
+            return vertex;
+        };
+        // will be called before any other treatment by setParticles()
+        SolidParticleSystem.prototype.beforeUpdateParticles = function () {
+        };
+        // will be called after all setParticles() treatments
+        SolidParticleSystem.prototype.afterUpdateParticles = function () {
+        };
+        return SolidParticleSystem;
+    })();
+    BABYLON.SolidParticleSystem = SolidParticleSystem;
+})(BABYLON || (BABYLON = {}));

+ 66 - 68
src/Particles/babylon.solidParticleSystem.ts

@@ -2,52 +2,52 @@ module BABYLON {
 
     export class SolidParticleSystem implements IDisposable {
         // public members  
-        public particles: SolidParticle[] = [];
-        public nbParticles:number = 0;
-        public billboard: boolean = false;
-        public counter: number = 0;
+        public particles = new Array<SolidParticle>();
+        public nbParticles = 0;
+        public billboard = false;
+        public counter = 0;
         public name: string;
         public mesh: Mesh;
         
         // private members
         private _scene: Scene;
-        private _positions: number[] = [];
-        private _indices: number[] = [];
-        private _normals: number[] = [];
-        private _colors: number[] = [];
-        private _uvs: number[] = [];
-        private _index: number = 0;  // indices index
-        private _shapeCounter: number = 0;
-        private _useParticleColor: boolean = true;
-        private _useParticleTexture: boolean = true;
-        private _useParticleRotation: boolean = true;
-        private _useParticleVertex: boolean = false;
-        private _cam_axisZ: Vector3 = Vector3.Zero();
-        private _cam_axisY: Vector3 = Vector3.Zero();
-        private _cam_axisX: Vector3 = Vector3.Zero();
-        private _axisX: Vector3 = Axis.X;
-        private _axisY: Vector3 = Axis.Y;
-        private _axisZ: Vector3 = Axis.Z;
+        private _positions = new Array<number>();
+        private _indices = new Array<number>();
+        private _normals = new Array<number>();
+        private _colors = new Array<number>();
+        private _uvs = new Array<number>();
+        private _index = 0;  // indices index
+        private _shapeCounter = 0;
+        private _useParticleColor = true;
+        private _useParticleTexture = true;
+        private _useParticleRotation = true;
+        private _useParticleVertex = false;
+        private _cam_axisZ = Vector3.Zero();
+        private _cam_axisY = Vector3.Zero();
+        private _cam_axisX = Vector3.Zero();
+        private _axisX = Axis.X;
+        private _axisY = Axis.Y;
+        private _axisZ = Axis.Z;
         private _camera: Camera;
         private _particle: SolidParticle;
-        private _fakeCamPos: Vector3 = Vector3.Zero();
-        private _rotMatrix: Matrix = new Matrix();
-        private _invertedMatrix: Matrix = new Matrix();
-        private _rotated: Vector3 = Vector3.Zero();
-        private _quaternion: Quaternion = new Quaternion();
-        private _vertex: Vector3 = Vector3.Zero();
-        private _yaw: number = 0.0;
-        private _pitch: number = 0.0;
-        private _roll: number = 0.0;
-        private _halfroll: number = 0.0;
-        private _halfpitch: number = 0.0;
-        private _halfyaw: number = 0.0;
-        private _sinRoll: number = 0.0;
-        private _cosRoll: number = 0.0;
-        private _sinPitch: number = 0.0;
-        private _cosPitch: number = 0.0;
-        private _sinYaw: number = 0.0;
-        private _cosYaw: number = 0.0;
+        private _fakeCamPos = Vector3.Zero();
+        private _rotMatrix = new Matrix();
+        private _invertedMatrix = new Matrix();
+        private _rotated = Vector3.Zero();
+        private _quaternion = new Quaternion();
+        private _vertex = Vector3.Zero();
+        private _yaw = 0.0;
+        private _pitch = 0.0;
+        private _roll = 0.0;
+        private _halfroll = 0.0;
+        private _halfpitch = 0.0;
+        private _halfyaw = 0.0;
+        private _sinRoll = 0.0;
+        private _cosRoll = 0.0;
+        private _sinPitch = 0.0;
+        private _cosPitch = 0.0;
+        private _sinYaw = 0.0;
+        private _cosYaw = 0.0;
 
         constructor(name: string, scene: Scene) {
             this.name = name;
@@ -57,8 +57,8 @@ module BABYLON {
 
         // build the SPS mesh : returns the mesh
         public buildMesh(): Mesh {
-            if (this.nbParticles == 0) {
-                //this.addTriangles(1, 1);
+            if (this.nbParticles === 0) {
+                return null;
             }
             VertexData.ComputeNormals(this._positions, this._indices, this._normals);
             var vertexData = new VertexData();
@@ -78,7 +78,7 @@ module BABYLON {
         }
 
         // _meshBuilder : inserts the shape model in the global SPS mesh
-        private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors): void  { 
+        private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors): void {
             var i;
             var u = 0;
             var c = 0;
@@ -92,7 +92,7 @@ module BABYLON {
                     colors.push(meshCol[c], meshCol[c + 1], meshCol[c + 2], meshCol[c + 3]);
                     c += 4;
                 } else {
-                    colors.push(1,1,1,1);
+                    colors.push(1, 1, 1, 1);
                 }
             }
             for (i = 0; i < meshInd.length; i++) {
@@ -104,7 +104,7 @@ module BABYLON {
         private _posToShape(positions): Vector3[] {
             var shape = [];
             for (var i = 0; i < positions.length; i += 3) {
-                shape.push(new BABYLON.Vector3(positions[i], positions[i + 1], positions[i + 2]));
+                shape.push(new Vector3(positions[i], positions[i + 1], positions[i + 2]));
             }
             return shape;
         }
@@ -113,7 +113,7 @@ module BABYLON {
         private _uvsToShapeUV(uvs): number[] {
             var shapeUV = [];
             if (uvs) {
-                    shapeUV.push(uvs.x, uvs.y, uvs.z, uvs.w);
+                shapeUV.push(uvs.x, uvs.y, uvs.z, uvs.w);
             }
             return shapeUV;
         }
@@ -140,14 +140,14 @@ module BABYLON {
                 this._index += shape.length;
             }
             this.nbParticles += nb;
-            this._shapeCounter ++;
+            this._shapeCounter++;
             return this._shapeCounter;
         }
 
         // resets a particle back to its just built status
         public resetParticle(particle: SolidParticle): void {
             for (var pt = 0; pt < particle._shape.length; pt++) {
-                this._positions[particle._pos + pt * 3] = particle._shape[pt].x;      
+                this._positions[particle._pos + pt * 3] = particle._shape[pt].x;
                 this._positions[particle._pos + pt * 3 + 1] = particle._shape[pt].y;
                 this._positions[particle._pos + pt * 3 + 2] = particle._shape[pt].z;
             }
@@ -171,13 +171,13 @@ module BABYLON {
             this._cam_axisZ.z = 1;
 
             // if the particles will always face the camera
-            if (this.billboard)  {    
+            if (this.billboard) {    
                 // compute a fake camera position : un-rotate the camera position by the current mesh rotation
                 this._yaw = this.mesh.rotation.y;
                 this._pitch = this.mesh.rotation.x;
                 this._roll = this.mesh.rotation.z;
                 this._quaternionRotationYPR();
-                this._quaternionToRotationMatrix();    
+                this._quaternionToRotationMatrix();
                 this._rotMatrix.invertToRef(this._invertedMatrix);
                 Vector3.TransformCoordinatesToRef(this._camera.globalPosition, this._invertedMatrix, this._fakeCamPos);
 
@@ -189,7 +189,6 @@ module BABYLON {
                 this._cam_axisX.normalize();
                 this._cam_axisZ.normalize();
             }
-          
 
             Matrix.IdentityToRef(this._rotMatrix);
             var idx = 0;
@@ -200,7 +199,7 @@ module BABYLON {
             var uvIndex = 0;
 
             // particle loop
-            for (var p = 0; p < this.nbParticles; p++) { 
+            for (var p = 0; p < this.nbParticles; p++) {
                 this._particle = this.particles[p];
 
                 // call to custom user function to update the particle properties
@@ -223,7 +222,7 @@ module BABYLON {
                         this._roll = this._particle.rotation.z;
                         this._quaternionRotationYPR();
                     }
-                this._quaternionToRotationMatrix();
+                    this._quaternionToRotationMatrix();
                 }
 
                 for (var pt = 0; pt < this._particle._shape.length; pt++) {
@@ -241,9 +240,9 @@ module BABYLON {
 
                     Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
 
-                    this._positions[idx]     = this._particle.position.x + this._cam_axisX.x * this._rotated.x * this._particle.scale.x + this._cam_axisY.x * this._rotated.y * this._particle.scale.y + this._cam_axisZ.x * this._rotated.z * this._particle.scale.z;      
-                    this._positions[idx + 1] = this._particle.position.y + this._cam_axisX.y * this._rotated.x * this._particle.scale.x + this._cam_axisY.y * this._rotated.y * this._particle.scale.y + this._cam_axisZ.y * this._rotated.z * this._particle.scale.z; 
-                    this._positions[idx + 2] = this._particle.position.z + this._cam_axisX.z * this._rotated.x * this._particle.scale.x + this._cam_axisY.z * this._rotated.y * this._particle.scale.y + this._cam_axisZ.z * this._rotated.z * this._particle.scale.z; 
+                    this._positions[idx] = this._particle.position.x + this._cam_axisX.x * this._rotated.x * this._particle.scale.x + this._cam_axisY.x * this._rotated.y * this._particle.scale.y + this._cam_axisZ.x * this._rotated.z * this._particle.scale.z;
+                    this._positions[idx + 1] = this._particle.position.y + this._cam_axisX.y * this._rotated.x * this._particle.scale.x + this._cam_axisY.y * this._rotated.y * this._particle.scale.y + this._cam_axisZ.y * this._rotated.z * this._particle.scale.z;
+                    this._positions[idx + 2] = this._particle.position.z + this._cam_axisX.z * this._rotated.x * this._particle.scale.x + this._cam_axisY.z * this._rotated.y * this._particle.scale.y + this._cam_axisZ.z * this._rotated.z * this._particle.scale.z;
 
                     if (this._useParticleColor) {
                         this._colors[colidx] = this._particle.color.r;
@@ -270,13 +269,13 @@ module BABYLON {
             }
             this.mesh.updateVerticesData(VertexBuffer.PositionKind, this._positions, false, false);
             if (!this.mesh.areNormalsFrozen) {
-                var indices = this.mesh.getIndices();
+             //   var indices = this.mesh.getIndices();
                 VertexData.ComputeNormals(this._positions, this._indices, this._normals);
                 this.mesh.updateVerticesData(VertexBuffer.NormalKind, this._normals, false, false);
             }
             this.afterUpdateParticles();
         }
-        // internal implementation of BJS Quaternion.RotationYawPitchRollToRef() with memory reuse
+        
         private _quaternionRotationYPR(): void {
             this._halfroll = this._roll * 0.5;
             this._halfpitch = this._pitch * 0.5;
@@ -292,8 +291,7 @@ module BABYLON {
             this._quaternion.z = (this._cosYaw * this._cosPitch * this._sinRoll) - (this._sinYaw * this._sinPitch * this._cosRoll);
             this._quaternion.w = (this._cosYaw * this._cosPitch * this._cosRoll) + (this._sinYaw * this._sinPitch * this._sinRoll);
         }
-
-        // internal implemenation of BJS toRotationMatric() with memory reuse
+        
         private _quaternionToRotationMatrix(): void {
             this._rotMatrix.m[0] = 1.0 - (2.0 * (this._quaternion.y * this._quaternion.y + this._quaternion.z * this._quaternion.z));
             this._rotMatrix.m[1] = 2.0 * (this._quaternion.x * this._quaternion.y + this._quaternion.z * this._quaternion.w);
@@ -310,7 +308,7 @@ module BABYLON {
             this._rotMatrix.m[12] = 0;
             this._rotMatrix.m[13] = 0;
             this._rotMatrix.m[14] = 0;
-            this._rotMatrix.m[15] = 1.0
+            this._rotMatrix.m[15] = 1.0;
         }
 
         // dispose the SPS
@@ -329,26 +327,26 @@ module BABYLON {
 
         public set useParticleTexture(val: boolean) {
             this._useParticleTexture = val;
-        } 
+        }
 
         public set useParticleVertex(val: boolean) {
             this._useParticleVertex = val;
         } 
 
         // getters
-         public get useParticleRotation() {
+        public get useParticleRotation(): boolean {
             return this._useParticleRotation;
         }
 
-        public get useParticleColor() {
+        public get useParticleColor(): boolean {
             return this._useParticleColor;
         }
 
-        public get useParticleTexture() {
+        public get useParticleTexture(): boolean {
             return this._useParticleTexture;
-        } 
+        }
 
-        public get useParticleVertex() {
+        public get useParticleVertex(): boolean {
             return this._useParticleVertex;
         } 
        
@@ -360,7 +358,7 @@ module BABYLON {
 
         // init : sets all particles first values and calls updateParticle to set them in space
         // can be overwritten by the user
-        public initParticles(): void {    
+        public initParticles(): void {
         }
 
         // recycles a particle : can by overwritten by the user
@@ -371,7 +369,7 @@ module BABYLON {
         // updates a particle : can be overwritten by the user
         // will be called on each particle by setParticles() :
         // ex : just set a particle position or velocity and recycle conditions
-        public updateParticle (particle: SolidParticle): SolidParticle {
+        public updateParticle(particle: SolidParticle): SolidParticle {
             return particle;
         }