Browse Source

material.pointSize and material.pointsCloud properties

David Catuhe 10 years ago
parent
commit
c2c671f2e0
40 changed files with 30139 additions and 30409 deletions
  1. 1 1
      Babylon/Culling/babylon.boundingBox.js
  2. 1 1
      Babylon/Layer/babylon.layer.js
  3. 1 1
      Babylon/Layer/babylon.layer.ts
  4. 1 1
      Babylon/LensFlare/babylon.lensFlareSystem.js
  5. 1 1
      Babylon/LensFlare/babylon.lensFlareSystem.ts
  6. 4 4
      Babylon/Lights/Shadows/babylon.shadowGenerator.js
  7. 4 4
      Babylon/Lights/Shadows/babylon.shadowGenerator.ts
  8. 1 2
      Babylon/Loading/babylon.sceneLoader.js
  9. 1 1
      Babylon/Loading/babylon.sceneLoader.ts
  10. 65 1
      Babylon/Materials/babylon.material.js
  11. 43 1
      Babylon/Materials/babylon.material.ts
  12. 12 2
      Babylon/Materials/babylon.standardMaterial.js
  13. 12 2
      Babylon/Materials/babylon.standardMaterial.ts
  14. 1 1
      Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.js
  15. 1 1
      Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.ts
  16. 12 0
      Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.js
  17. 13 1
      Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.ts
  18. 2342 2448
      Babylon/Math/babylon.math.js
  19. 11 133
      Babylon/Math/babylon.math.ts
  20. 1 1
      Babylon/Mesh/babylon.InstancedMesh.js
  21. 3 3
      Babylon/Mesh/babylon.linesMesh.js
  22. 3 3
      Babylon/Mesh/babylon.linesMesh.ts
  23. 27 75
      Babylon/Mesh/babylon.mesh.js
  24. 27 78
      Babylon/Mesh/babylon.mesh.ts
  25. 1 1
      Babylon/Particles/babylon.particleSystem.js
  26. 1 1
      Babylon/Particles/babylon.particleSystem.ts
  27. 1 1
      Babylon/PostProcess/babylon.postProcessManager.js
  28. 1 1
      Babylon/PostProcess/babylon.postProcessManager.ts
  29. 2 2
      Babylon/Rendering/babylon.boundingBoxRenderer.js
  30. 2 2
      Babylon/Rendering/babylon.boundingBoxRenderer.ts
  31. 4 4
      Babylon/Rendering/babylon.outlineRenderer.js
  32. 4 4
      Babylon/Rendering/babylon.outlineRenderer.ts
  33. 9 0
      Babylon/Shaders/default.vertex.fx
  34. 2 2
      Babylon/Sprites/babylon.spriteManager.js
  35. 2 2
      Babylon/Sprites/babylon.spriteManager.ts
  36. 19 30
      Babylon/babylon.engine.js
  37. 13 29
      Babylon/babylon.engine.ts
  38. 27447 27466
      babylon.2.0-alpha.debug.js
  39. 14 14
      babylon.2.0-alpha.js
  40. 29 84
      babylon.2.0.d.ts

+ 1 - 1
Babylon/Culling/babylon.boundingBox.js

@@ -171,4 +171,4 @@
     })();
     BABYLON.BoundingBox = BoundingBox;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.BoundingBox.js.map
+//# sourceMappingURL=babylon.boundingBox.js.map

+ 1 - 1
Babylon/Layer/babylon.layer.js

@@ -59,7 +59,7 @@
 
             // Draw order
             engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
-            engine.draw(WebGLRenderingContext.TRIANGLES, 0, 6);
+            engine.draw(true, 0, 6);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
         };
 

+ 1 - 1
Babylon/Layer/babylon.layer.ts

@@ -71,7 +71,7 @@
 
             // Draw order
             engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
-            engine.draw(WebGLRenderingContext.TRIANGLES, 0, 6);
+            engine.draw(true, 0, 6);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
         }
 

+ 1 - 1
Babylon/LensFlare/babylon.lensFlareSystem.js

@@ -189,7 +189,7 @@
                 this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
 
                 // Draw order
-                engine.draw(WebGLRenderingContext.TRIANGLES, 0, 6);
+                engine.draw(true, 0, 6);
             }
 
             engine.setDepthBuffer(true);

+ 1 - 1
Babylon/LensFlare/babylon.lensFlareSystem.ts

@@ -201,7 +201,7 @@
                 this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
 
                 // Draw order
-                engine.draw(WebGLRenderingContext.TRIANGLES, 0, 6);
+                engine.draw(true, 0, 6);
             }
 
             engine.setDepthBuffer(true);

+ 4 - 4
Babylon/Lights/Shadows/babylon.shadowGenerator.js

@@ -42,7 +42,7 @@
 
                 if (_this.isReady(subMesh, hardwareInstancedRendering)) {
                     engine.enableEffect(_this._effect);
-                    mesh._bind(subMesh, _this._effect, WebGLRenderingContext.TRIANGLES);
+                    mesh._bind(subMesh, _this._effect, BABYLON.Material.TriangleFillMode);
                     var material = subMesh.getMaterial();
 
                     _this._effect.setMatrix("viewProjection", _this.getTransformMatrix());
@@ -62,13 +62,13 @@
                     }
 
                     if (hardwareInstancedRendering) {
-                        mesh._renderWithInstances(subMesh, WebGLRenderingContext.TRIANGLES, batch, _this._effect, engine);
+                        mesh._renderWithInstances(subMesh, BABYLON.Material.TriangleFillMode, batch, _this._effect, engine);
                     } else {
                         if (batch.renderSelf[subMesh._id]) {
                             _this._effect.setMatrix("world", mesh.getWorldMatrix());
 
                             // Draw
-                            mesh._draw(subMesh, WebGLRenderingContext.TRIANGLES);
+                            mesh._draw(subMesh, BABYLON.Material.TriangleFillMode);
                         }
 
                         if (batch.visibleInstances[subMesh._id]) {
@@ -78,7 +78,7 @@
                                 _this._effect.setMatrix("world", instance.getWorldMatrix());
 
                                 // Draw
-                                mesh._draw(subMesh, WebGLRenderingContext.TRIANGLES);
+                                mesh._draw(subMesh, BABYLON.Material.TriangleFillMode);
                             }
                         }
                     }

+ 4 - 4
Babylon/Lights/Shadows/babylon.shadowGenerator.ts

@@ -81,7 +81,7 @@
 
                 if (this.isReady(subMesh, hardwareInstancedRendering)) {
                     engine.enableEffect(this._effect);
-                    mesh._bind(subMesh, this._effect, WebGLRenderingContext.TRIANGLES);
+                    mesh._bind(subMesh, this._effect, Material.TriangleFillMode);
                     var material = subMesh.getMaterial();
 
                     this._effect.setMatrix("viewProjection", this.getTransformMatrix());
@@ -101,13 +101,13 @@
                     }
 
                     if (hardwareInstancedRendering) {
-                        mesh._renderWithInstances(subMesh, WebGLRenderingContext.TRIANGLES, batch, this._effect, engine);
+                        mesh._renderWithInstances(subMesh, Material.TriangleFillMode, batch, this._effect, engine);
                     } else {
                         if (batch.renderSelf[subMesh._id]) {
                             this._effect.setMatrix("world", mesh.getWorldMatrix());
 
                             // Draw
-                            mesh._draw(subMesh, WebGLRenderingContext.TRIANGLES);
+                            mesh._draw(subMesh, Material.TriangleFillMode);
                         }
 
                         if (batch.visibleInstances[subMesh._id]) {
@@ -117,7 +117,7 @@
                                 this._effect.setMatrix("world", instance.getWorldMatrix());
 
                                 // Draw
-                                mesh._draw(subMesh, WebGLRenderingContext.TRIANGLES);
+                                mesh._draw(subMesh, Material.TriangleFillMode);
                             }
                         }
                     }

+ 1 - 2
Babylon/Loading/babylon.sceneLoader.js

@@ -51,11 +51,10 @@
         };
 
         SceneLoader.ImportMesh = function (meshesNames, rootUrl, sceneFilename, scene, onsuccess, progressCallBack, onerror) {
-            var _this = this;
             var manifestChecked = function (success) {
                 scene.database = database;
 
-                var plugin = _this._getPluginForFilename(sceneFilename);
+                var plugin = SceneLoader._getPluginForFilename(sceneFilename);
 
                 var importMeshFromData = function (data) {
                     var meshes = [];

+ 1 - 1
Babylon/Loading/babylon.sceneLoader.ts

@@ -56,7 +56,7 @@
             var manifestChecked = success => {
                 scene.database = database;
 
-                var plugin = this._getPluginForFilename(sceneFilename);
+                var plugin = SceneLoader._getPluginForFilename(sceneFilename);
 
                 var importMeshFromData = data => {
                     var meshes = [];

+ 65 - 1
Babylon/Materials/babylon.material.js

@@ -7,9 +7,10 @@
             this.checkReadyOnlyOnce = false;
             this.state = "";
             this.alpha = 1.0;
-            this.drawAs = WebGLRenderingContext.TRIANGLES;
             this.backFaceCulling = true;
             this._wasPreviouslyReady = false;
+            this._fillMode = Material.TriangleFillMode;
+            this.pointSize = 1.0;
             this.id = name;
 
             this._scene = scene;
@@ -18,6 +19,66 @@
                 scene.materials.push(this);
             }
         }
+        Object.defineProperty(Material, "TriangleFillMode", {
+            get: function () {
+                return Material._TriangleFillMode;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Material, "WireFrameFillMode", {
+            get: function () {
+                return Material._WireFrameFillMode;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Material, "PointFillMode", {
+            get: function () {
+                return Material._PointFillMode;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Material.prototype, "wireframe", {
+            get: function () {
+                return this._fillMode === Material.WireFrameFillMode;
+            },
+            set: function (value) {
+                this._fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+
+        Object.defineProperty(Material.prototype, "pointsCloud", {
+            get: function () {
+                return this._fillMode === Material.PointFillMode;
+            },
+            set: function (value) {
+                this._fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+
+        Object.defineProperty(Material.prototype, "fillMode", {
+            get: function () {
+                return this._fillMode;
+            },
+            set: function (value) {
+                this._fillMode = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+
         Material.prototype.isReady = function (mesh, useInstances) {
             return true;
         };
@@ -77,6 +138,9 @@
                 this.onDispose();
             }
         };
+        Material._TriangleFillMode = 0;
+        Material._WireFrameFillMode = 1;
+        Material._PointFillMode = 2;
         return Material;
     })();
     BABYLON.Material = Material;

+ 43 - 1
Babylon/Materials/babylon.material.ts

@@ -1,11 +1,26 @@
 module BABYLON {
     export class Material {
+        private static _TriangleFillMode = 0;
+        private static _WireFrameFillMode = 1;
+        private static _PointFillMode = 2;
+
+        public static get TriangleFillMode(): number {
+            return Material._TriangleFillMode;
+        }
+
+        public static get WireFrameFillMode(): number {
+            return Material._WireFrameFillMode;
+        }
+
+        public static get PointFillMode(): number {
+            return Material._PointFillMode;
+        }
+
         public id: string;
         public checkReadyOnEveryCall = true;
         public checkReadyOnlyOnce = false;
         public state = "";
         public alpha = 1.0;
-        public drawAs = WebGLRenderingContext.TRIANGLES;
         public backFaceCulling = true;
         public onCompiled: (effect: Effect) => void;
         public onError: (effect: Effect, errors: string) => void;
@@ -15,6 +30,33 @@
         public _effect: Effect;
         public _wasPreviouslyReady = false;
         private _scene: Scene;
+        private _fillMode = Material.TriangleFillMode;
+
+        public pointSize = 1.0;
+
+        public get wireframe(): boolean {
+            return this._fillMode === Material.WireFrameFillMode;
+        }
+
+        public set wireframe(value:boolean) {
+            this._fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
+        }
+
+        public get pointsCloud(): boolean {
+            return this._fillMode === Material.PointFillMode;
+        }
+
+        public set pointsCloud(value: boolean) {
+            this._fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
+        }
+
+        public get fillMode(): number {
+            return this._fillMode;
+        }
+
+        public set fillMode(value: number) {
+            this._fillMode = value;
+        }
 
         constructor(public name: string, scene: Scene, doNotAdd?: boolean) {
             this.id = name;

+ 12 - 2
Babylon/Materials/babylon.standardMaterial.js

@@ -170,6 +170,11 @@ var BABYLON;
                 defines.push("#define ALPHAFROMDIFFUSE");
             }
 
+            // Point size
+            if (this.pointsCloud) {
+                defines.push("#define POINTSIZE");
+            }
+
             // Fog
             if (scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
                 defines.push("#define FOG");
@@ -353,7 +358,7 @@ var BABYLON;
                     "vLightData1", "vLightDiffuse1", "vLightSpecular1", "vLightDirection1", "vLightGround1", "lightMatrix1",
                     "vLightData2", "vLightDiffuse2", "vLightSpecular2", "vLightDirection2", "vLightGround2", "lightMatrix2",
                     "vLightData3", "vLightDiffuse3", "vLightSpecular3", "vLightDirection3", "vLightGround3", "lightMatrix3",
-                    "vFogInfos", "vFogColor",
+                    "vFogInfos", "vFogColor", "pointSize",
                     "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos",
                     "mBones",
                     "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix",
@@ -542,6 +547,11 @@ var BABYLON;
                 this._effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
                 this._effect.setColor3("vFogColor", scene.fogColor);
             }
+
+            // Point size
+            if (this.pointsCloud) {
+                this._effect.setFloat("pointSize", this.pointSize);
+            }
         };
 
         StandardMaterial.prototype.getAnimatables = function () {
@@ -616,7 +626,7 @@ var BABYLON;
             // Base material
             newStandardMaterial.checkReadyOnEveryCall = this.checkReadyOnEveryCall;
             newStandardMaterial.alpha = this.alpha;
-            newStandardMaterial.drawAs = this.drawAs;
+            newStandardMaterial.fillMode = this.fillMode;
             newStandardMaterial.backFaceCulling = this.backFaceCulling;
 
             // Standard material

+ 12 - 2
Babylon/Materials/babylon.standardMaterial.ts

@@ -174,6 +174,11 @@
                 defines.push("#define ALPHAFROMDIFFUSE");
             }
 
+            // Point size
+            if (this.pointsCloud) {
+                defines.push("#define POINTSIZE");
+            }
+
             // Fog
             if (scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
                 defines.push("#define FOG");
@@ -363,7 +368,7 @@
                         "vLightData1", "vLightDiffuse1", "vLightSpecular1", "vLightDirection1", "vLightGround1", "lightMatrix1",
                         "vLightData2", "vLightDiffuse2", "vLightSpecular2", "vLightDirection2", "vLightGround2", "lightMatrix2",
                         "vLightData3", "vLightDiffuse3", "vLightSpecular3", "vLightDirection3", "vLightGround3", "lightMatrix3",
-                        "vFogInfos", "vFogColor",
+                        "vFogInfos", "vFogColor", "pointSize",
                         "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos",
                         "mBones",
                         "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix",
@@ -554,6 +559,11 @@
                 this._effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
                 this._effect.setColor3("vFogColor", scene.fogColor);
             }
+
+            // Point size
+            if (this.pointsCloud) {
+                this._effect.setFloat("pointSize", this.pointSize);
+            }
         }
 
         public getAnimatables(): IAnimatable[] {
@@ -628,7 +638,7 @@
             // Base material
             newStandardMaterial.checkReadyOnEveryCall = this.checkReadyOnEveryCall;
             newStandardMaterial.alpha = this.alpha;
-            newStandardMaterial.drawAs = this.drawAs;
+            newStandardMaterial.fillMode = this.fillMode;
             newStandardMaterial.backFaceCulling = this.backFaceCulling;
 
             // Standard material

+ 1 - 1
Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.js

@@ -233,7 +233,7 @@ var BABYLON;
             engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, this._effect);
 
             // Draw order
-            engine.draw(WebGLRenderingContext.TRIANGLES, 0, 6);
+            engine.draw(true, 0, 6);
 
             // Unbind
             engine.unBindFramebuffer(this._texture);

+ 1 - 1
Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.ts

@@ -247,7 +247,7 @@
             engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, this._effect);
 
             // Draw order
-            engine.draw(WebGLRenderingContext.TRIANGLES, 0, 6);
+            engine.draw(true, 0, 6);
 
             // Unbind
             engine.unBindFramebuffer(this._texture);

+ 12 - 0
Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.js

@@ -248,5 +248,17 @@ var BABYLON;
         return FireProceduralTexture;
     })(BABYLON.ProceduralTexture);
     BABYLON.FireProceduralTexture = FireProceduralTexture;
+
+    var CloudProceduralTexture = (function (_super) {
+        __extends(CloudProceduralTexture, _super);
+        function CloudProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
+            _super.call(this, name, size, "cloud", scene, fallbackTexture, generateMipMaps);
+
+            // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
+            this.refreshRate = 0;
+        }
+        return CloudProceduralTexture;
+    })(BABYLON.ProceduralTexture);
+    BABYLON.CloudProceduralTexture = CloudProceduralTexture;
 })(BABYLON || (BABYLON = {}));
 //# sourceMappingURL=babylon.standardProceduralTexture.js.map

+ 13 - 1
Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.ts

@@ -151,7 +151,6 @@
                 [0.0, 0.2, 0.9]
             ];
         }
-       
 
         public get fireColors(): number[][] {
             return this._fireColors;
@@ -199,4 +198,17 @@
         }
 
     }
+
+    export class CloudProceduralTexture extends ProceduralTexture {
+
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
+            super(name, size, "cloud", scene, fallbackTexture, generateMipMaps);
+
+
+            // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
+            this.refreshRate = 0;
+
+        }
+    }
+
 }

File diff suppressed because it is too large
+ 2342 - 2448
Babylon/Math/babylon.math.js


+ 11 - 133
Babylon/Math/babylon.math.ts

@@ -1254,19 +1254,18 @@
                 result.x = Math.atan2(qxz + qwy, qwx - qyz);
                 result.y = Math.acos(1 - 2 * determinant);
                 result.z = Math.atan2(qxz - qwy, qwx + qyz);
+            } else {
+                if (determinant == 0.000) {
+                    result.x = 0.0;
+                    result.y = 0.0;
+                    result.z = Math.atan2(qxy - qwz, 0.5 - sqy - qz * qz); //actually, degeneracy gives us choice with x+z=Math.atan2(qxy-qwz,0.5-sqy-qz*qz)
+                } else //determinant == 1.000
+                {
+                    result.x = Math.atan2(qxy - qwz, 0.5 - sqy - qz * qz); //actually, degeneracy gives us choice with x-z=Math.atan2(qxy-qwz,0.5-sqy-qz*qz)
+                    result.y = Math.PI;
+                    result.z = 0.0;
+                }
             }
-            else
-            if (determinant == 0.000) {
-                result.x = 0.0;
-                result.y = 0.0;
-                result.z = Math.atan2(qxy - qwz, 0.5 - sqy - qz * qz); //actually, degeneracy gives us choice with x+z=Math.atan2(qxy-qwz,0.5-sqy-qz*qz)
-            }
-            else //determinant == 1.000
-            {
-                result.x = Math.atan2(qxy - qwz, 0.5 - sqy - qz * qz); //actually, degeneracy gives us choice with x-z=Math.atan2(qxy-qwz,0.5-sqy-qz*qz)
-                result.y = Math.PI;
-                result.z = 0.0;
-            }
         }
 
         public toRotationMatrix(result: Matrix): void {
@@ -1428,127 +1427,6 @@
         }
     }
 
-    export class EulerAngles {
-        constructor(public x: number = 0, public y: number = 0, public z: number = 0) { }
-
-        public toString(): string {
-            return "{x: " + this.x + " y:" + this.y + " z:" + this.z + "}";
-        }
-
-        public asArray(): number[] {
-            return [this.x, this.y, this.z];
-        }
-
-        public equals(otherEulerAngles: EulerAngles): boolean {
-            return otherEulerAngles && this.x === otherEulerAngles.x && this.y === otherEulerAngles.y && this.z === otherEulerAngles.z;
-        }
-
-        public clone(): EulerAngles {
-            return new EulerAngles(this.x, this.y, this.z);
-        }
-
-        public copyFrom(other: EulerAngles): void {
-            this.x = other.x;
-            this.y = other.y;
-            this.z = other.z;
-        }
-
-        public copyFromFloats(x: number, y: number, z: number): void {
-            this.x = x;
-            this.y = y;
-            this.z = z;
-        }
-
-        public add(other: EulerAngles): EulerAngles {
-            return new EulerAngles(this.x + other.x, this.y + other.y, this.z + other.z);
-        }
-
-        public subtract(other: EulerAngles): EulerAngles {
-            return new EulerAngles(this.x - other.x, this.y - other.y, this.z - other.z);
-        }
-
-        public scale(value: number): EulerAngles {
-            return new EulerAngles(this.x * value, this.y * value, this.z * value);
-        }
-
-        public length(): number {
-            return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z));
-        }
-
-        public normalize(): void {
-            var length = 1.0 / this.length();
-            this.x *= length;
-            this.y *= length;
-            this.z *= length;
-        }
-
-        public toQuaternion(): Vector4 {
-            var result;
-
-            //result is a Quaternion in the z-x-z rotation convention
-            var cosxPlusz = Math.cos((this.x + this.z) * 0.5);
-            var sinxPlusz = Math.sin((this.x + this.z) * 0.5);
-            var coszMinusx = Math.cos((this.z - this.x) * 0.5);
-            var sinzMinusx = Math.sin((this.z - this.x) * 0.5);
-            var cosy = Math.cos(this.y * 0.5);
-            var siny = Math.sin(this.y * 0.5);
-
-            result.x = coszMinusx * siny;
-            result.y = -sinzMinusx * siny; 
-            result.z = sinxPlusz * cosy;
-            result.w = cosxPlusz * cosy;
-
-            return result;
-
-        }
-
-        public toRotationMatrix(result: Matrix): void {
-            //returns matrix with result.m[0]=m11,result.m[1]=m21,result.m[2]=m31,result.m[4]=12, etc
-            //done in the z-x-z rotation convention
-            var cosx = Math.cos(this.x);
-            var sinx = Math.sin(this.x);
-            var cosy = Math.cos(this.y);
-            var siny = Math.sin(this.y);
-            var cosz = Math.cos(this.z);
-            var sinz = Math.sin(this.z);
-
-            result.m[0] = cosx * cosz - cosy * sinx * sinz;
-            result.m[1] = cosy * sinx * cosz + cosx * sinz;
-            result.m[2] = siny * sinx;
-            result.m[4] = -sinx * cosz - cosy * cosx * sinz;
-            result.m[5] = cosy * cosx * cosz - sinx * sinz;
-            result.m[6] = siny * cosx;
-            result.m[8] = siny * sinz;
-            result.m[9] = -siny * cosz;
-            result.m[10] = cosy;
-        }
-
-        public fromRotationMatrix(matrix: Matrix): void {
-            var data = matrix.m;
-            var m11 = data[0], m12 = data[4], m13 = data[8];
-            var m21 = data[1], m22 = data[5], m23 = data[9];
-            var m31 = data[2], m32 = data[6], m33 = data[10];
-
-            if (m33 == -1) {
-                this.x = 0; //any angle works here
-                this.y = Math.PI;
-                this.z = Math.atan2(m21, m11); //generally, atan2(m21,m11)-x
-
-            }
-            else
-            if (m33 == 1) {
-                this.x = 0; //any angle works here
-                this.y = 0;
-                this.z = Math.atan2(m21, m11); //generally, atan2(m21,m11)-x
-            }
-            else {
-                this.x = Math.atan2(m31, m32);
-                this.y = Math.acos(m33); //principal value (between 0 and PI)
-                this.z = Math.atan2(m13, -m23);
-            }
-        }
-    }
-
     export class Matrix {
         private static _tempQuaternion: Quaternion = new Quaternion();
         private static _xAxis: Vector3 = Vector3.Zero();

+ 1 - 1
Babylon/Mesh/babylon.InstancedMesh.js

@@ -167,4 +167,4 @@ var BABYLON;
     })(BABYLON.AbstractMesh);
     BABYLON.InstancedMesh = InstancedMesh;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.InstancedMesh.js.map
+//# sourceMappingURL=babylon.instancedMesh.js.map

+ 3 - 3
Babylon/Mesh/babylon.linesMesh.js

@@ -45,7 +45,7 @@ var BABYLON;
             configurable: true
         });
 
-        LinesMesh.prototype._bind = function (subMesh, effect, drawAs) {
+        LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
             var engine = this.getScene().getEngine();
 
             var indexToBind = this._geometry.getIndexBuffer();
@@ -57,7 +57,7 @@ var BABYLON;
             this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
         };
 
-        LinesMesh.prototype._draw = function (subMesh, drawAs, instancesCount) {
+        LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
             if (!this._geometry || !this._geometry.getVertexBuffers() || !this._geometry.getIndexBuffer()) {
                 return;
             }
@@ -65,7 +65,7 @@ var BABYLON;
             var engine = this.getScene().getEngine();
 
             // Draw order
-            engine.draw(WebGLRenderingContext.LINES, subMesh.indexStart, subMesh.indexCount);
+            engine.draw(false, subMesh.indexStart, subMesh.indexCount);
         };
 
         LinesMesh.prototype.intersects = function (ray, fastCheck) {

+ 3 - 3
Babylon/Mesh/babylon.linesMesh.ts

@@ -32,7 +32,7 @@
             return false;
         }
 
-        public _bind(subMesh: SubMesh, effect: Effect, drawAs: number): void {
+        public _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void {
             var engine = this.getScene().getEngine();
 
             var indexToBind = this._geometry.getIndexBuffer();
@@ -44,7 +44,7 @@
             this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
         }
 
-        public _draw(subMesh: SubMesh, drawAs: number, instancesCount?: number): void {
+        public _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void {
             if (!this._geometry || !this._geometry.getVertexBuffers() || !this._geometry.getIndexBuffer()) {
                 return;
             }
@@ -52,7 +52,7 @@
             var engine = this.getScene().getEngine();
 
             // Draw order
-            engine.draw(WebGLRenderingContext.LINES, subMesh.indexStart, subMesh.indexCount);
+            engine.draw(false, subMesh.indexStart, subMesh.indexCount);
         }
 
         public intersects(ray: Ray, fastCheck?: boolean) {

+ 27 - 75
Babylon/Mesh/babylon.mesh.js

@@ -245,93 +245,46 @@ var BABYLON;
             }
         };
 
-        Mesh.prototype._bind = function (subMesh, effect, drawAs) {
+        Mesh.prototype._bind = function (subMesh, effect, fillMode) {
             var engine = this.getScene().getEngine();
 
-            var indexToBind = undefined;
-            switch (drawAs) {
-                case WebGLRenderingContext.LINES:
-                    indexToBind = subMesh.getLinesIndexBuffer(this.getIndices(), engine);
-                    break;
-
-                case WebGLRenderingContext.POINTS:
-                    indexToBind = null;
-                    break;
+            // Wireframe
+            var indexToBind;
 
-                case WebGLRenderingContext.TRIANGLES:
-                default:
+            switch (fillMode) {
+                case BABYLON.Material.TriangleFillMode:
                     indexToBind = this._geometry.getIndexBuffer();
                     break;
-            }
-
-            // VBOs
-            engine.bindMultiBuffers(this._geometry.getVertexBuffers(), indexToBind, effect);
-        };
-
-        Mesh.prototype._getStartIndexOfMesh = function (subMesh, drawAs) {
-            var start = 0;
-            switch (drawAs) {
-                case WebGLRenderingContext.LINES:
-                    start = 0;
-                    break;
-                case WebGLRenderingContext.POINTS:
-                    start = 0;
-                    break;
-
-                case WebGLRenderingContext.TRIANGLES:
-                default:
-                    start = subMesh.indexStart;
-                    break;
-            }
-
-            return start;
-        };
-
-        Mesh.prototype._getCountOfMesh = function (subMesh, drawAs) {
-            var count = 0;
-            switch (drawAs) {
-                case WebGLRenderingContext.LINES:
-                    count = subMesh.linesIndexCount;
-                    break;
-                case WebGLRenderingContext.POINTS:
-                    count = subMesh.verticesCount;
+                case BABYLON.Material.WireFrameFillMode:
+                    indexToBind = subMesh.getLinesIndexBuffer(this.getIndices(), engine);
                     break;
-
-                case WebGLRenderingContext.TRIANGLES:
                 default:
-                    count = subMesh.indexCount;
+                    indexToBind = null;
                     break;
             }
 
-            return count;
+            // VBOs
+            engine.bindMultiBuffers(this._geometry.getVertexBuffers(), indexToBind, effect);
         };
 
-        Mesh.prototype._draw = function (subMesh, drawAs, instancesCount) {
+        Mesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
             if (!this._geometry || !this._geometry.getVertexBuffers() || !this._geometry.getIndexBuffer()) {
                 return;
             }
 
             var engine = this.getScene().getEngine();
 
-            var start = this._getStartIndexOfMesh(subMesh, drawAs);
-            var count = this._getCountOfMesh(subMesh, drawAs);
-
-            // Draw order
-            engine.draw(drawAs, start, count, instancesCount);
-        };
+            switch (fillMode) {
+                case BABYLON.Material.PointFillMode:
+                    engine.drawPointClouds(subMesh.verticesStart, subMesh.verticesCount, instancesCount);
+                    break;
+                case BABYLON.Material.WireFrameFillMode:
+                    engine.draw(false, 0, subMesh.linesIndexCount, instancesCount);
+                    break;
 
-        Mesh.prototype._fullDraw = function (subMesh, drawAs, instancesCount) {
-            if (!this._geometry || !this._geometry.getVertexBuffers() || !this._geometry.getIndexBuffer()) {
-                return;
+                default:
+                    engine.draw(true, subMesh.indexStart, subMesh.indexCount, instancesCount);
             }
-
-            var engine = this.getScene().getEngine();
-
-            var start = this._getStartIndexOfMesh(subMesh, drawAs);
-            var count = this._getCountOfMesh(subMesh, drawAs);
-
-            // Draw order
-            engine.draw(drawAs, start, count, instancesCount);
         };
 
         Mesh.prototype.registerBeforeRender = function (func) {
@@ -391,7 +344,7 @@ var BABYLON;
             return this._batchCache;
         };
 
-        Mesh.prototype._renderWithInstances = function (subMesh, drawAs, batch, effect, engine) {
+        Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
             var matricesCount = this.instances.length + 1;
             var bufferSize = matricesCount * 16 * 4;
 
@@ -438,7 +391,7 @@ var BABYLON;
 
             engine.updateAndBindInstancesBuffer(this._worldMatricesInstancesBuffer, this._worldMatricesInstancesArray, offsetLocations);
 
-            this._draw(subMesh, drawAs, instancesCount);
+            this._draw(subMesh, fillMode, instancesCount);
 
             engine.unBindInstancesBuffer(this._worldMatricesInstancesBuffer, offsetLocations);
         };
@@ -483,20 +436,19 @@ var BABYLON;
             var effect = effectiveMaterial.getEffect();
 
             // Bind
-            var drawAs = engine.forceWireframe ? WebGLRenderingContext.LINES : effectiveMaterial.drawAs;
-
-            this._bind(subMesh, effect, drawAs);
+            var fillMode = engine.forceWireframe ? BABYLON.Material.WireFrameFillMode : effectiveMaterial.fillMode;
+            this._bind(subMesh, effect, fillMode);
 
             var world = this.getWorldMatrix();
             effectiveMaterial.bind(world, this);
 
             // Instances rendering
             if (hardwareInstancedRendering) {
-                this._renderWithInstances(subMesh, drawAs, batch, effect, engine);
+                this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
             } else {
                 if (batch.renderSelf[subMesh._id]) {
                     // Draw
-                    this._draw(subMesh, drawAs);
+                    this._draw(subMesh, fillMode);
                 }
 
                 if (batch.visibleInstances[subMesh._id]) {
@@ -508,7 +460,7 @@ var BABYLON;
                         effectiveMaterial.bindOnlyWorldMatrix(world);
 
                         // Draw
-                        this._draw(subMesh, drawAs);
+                        this._draw(subMesh, fillMode);
                     }
                 }
             }

+ 27 - 78
Babylon/Mesh/babylon.mesh.ts

@@ -251,23 +251,21 @@
             }
         }
 
-        public _bind(subMesh: SubMesh, effect: Effect, drawAs: number): void {
+        public _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void {
             var engine = this.getScene().getEngine();
 
-            var indexToBind = undefined;
-            switch (drawAs)
-            {
-                case WebGLRenderingContext.LINES:
+            // Wireframe
+            var indexToBind;
+
+            switch (fillMode) {
+                case Material.TriangleFillMode:
+                    indexToBind = this._geometry.getIndexBuffer();
+                    break;
+                case Material.WireFrameFillMode:
                     indexToBind = subMesh.getLinesIndexBuffer(this.getIndices(), engine);
                     break;
-                //PLEASE CHECK THIS!
-                case WebGLRenderingContext.POINTS:
-                    indexToBind = null;
-                    break
-                //Draw triangles as default
-                case WebGLRenderingContext.TRIANGLES:
                 default:
-                    indexToBind = this._geometry.getIndexBuffer();
+                    indexToBind = null;
                     break;
             }
 
@@ -275,73 +273,25 @@
             engine.bindMultiBuffers(this._geometry.getVertexBuffers(), indexToBind, effect);
         }
 
-        private _getStartIndexOfMesh(subMesh: SubMesh, drawAs: number) : number {
-            var start = 0;
-            switch (drawAs) {
-                case WebGLRenderingContext.LINES:
-                    start = 0;
-                    break;
-                case WebGLRenderingContext.POINTS:
-                    start = 0;
-                    break;
-
-                //Render as triangle as default
-                case WebGLRenderingContext.TRIANGLES:
-                default:
-                    start = subMesh.indexStart;
-                    break;
-            }
-
-            return start;
-        }
-
-        private _getCountOfMesh(subMesh: SubMesh, drawAs: number) : number {
-            var count = 0;
-            switch (drawAs) {
-                case WebGLRenderingContext.LINES:
-                    count = subMesh.linesIndexCount;
-                    break;
-                case WebGLRenderingContext.POINTS:
-                    count = subMesh.verticesCount;
-                    break;
-
-                //Render as triangle as default
-                case WebGLRenderingContext.TRIANGLES:
-                default:
-                    count = subMesh.indexCount;
-                    break;
-            }
-
-            return count;
-        }
-
-
-        public _draw(subMesh: SubMesh, drawAs: number, instancesCount?: number): void {
+        public _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void {
             if (!this._geometry || !this._geometry.getVertexBuffers() || !this._geometry.getIndexBuffer()) {
                 return;
             }
 
             var engine = this.getScene().getEngine();
 
-            var start = this._getStartIndexOfMesh(subMesh, drawAs);
-            var count = this._getCountOfMesh(subMesh, drawAs);
-           
             // Draw order
-            engine.draw(drawAs, start, count, instancesCount);
-        }
+            switch (fillMode) {
+                case Material.PointFillMode:
+                    engine.drawPointClouds(subMesh.verticesStart, subMesh.verticesCount, instancesCount);
+                    break;
+                case Material.WireFrameFillMode:
+                    engine.draw(false, 0, subMesh.linesIndexCount, instancesCount);
+                    break;
 
-        public _fullDraw(subMesh: SubMesh, drawAs: number, instancesCount?: number): void {
-            if (!this._geometry || !this._geometry.getVertexBuffers() || !this._geometry.getIndexBuffer()) {
-                return;
+                default:
+                    engine.draw(true, subMesh.indexStart, subMesh.indexCount, instancesCount);
             }
-
-            var engine = this.getScene().getEngine();
-
-            var start = this._getStartIndexOfMesh(subMesh, drawAs);
-            var count = this._getCountOfMesh(subMesh, drawAs);
-
-            // Draw order
-            engine.draw(drawAs, start, count, instancesCount);
         }
 
         public registerBeforeRender(func: () => void): void {
@@ -402,7 +352,7 @@
             return this._batchCache;
         }
 
-        public _renderWithInstances(subMesh: SubMesh, drawAs: number, batch: _InstancesBatch, effect: Effect, engine: Engine): void {
+        public _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): void {
             var matricesCount = this.instances.length + 1;
             var bufferSize = matricesCount * 16 * 4;
 
@@ -449,7 +399,7 @@
 
             engine.updateAndBindInstancesBuffer(this._worldMatricesInstancesBuffer, this._worldMatricesInstancesArray, offsetLocations);
 
-            this._draw(subMesh, drawAs, instancesCount);
+            this._draw(subMesh, fillMode, instancesCount);
 
             engine.unBindInstancesBuffer(this._worldMatricesInstancesBuffer, offsetLocations);
         }
@@ -494,20 +444,19 @@
             var effect = effectiveMaterial.getEffect();
 
             // Bind
-            var drawAs = engine.forceWireframe ? WebGLRenderingContext.LINES : effectiveMaterial.drawAs;
-
-            this._bind(subMesh, effect, drawAs);
+            var fillMode = engine.forceWireframe ? Material.WireFrameFillMode : effectiveMaterial.fillMode;
+            this._bind(subMesh, effect, fillMode);
 
             var world = this.getWorldMatrix();
             effectiveMaterial.bind(world, this);
 
             // Instances rendering
             if (hardwareInstancedRendering) {
-                this._renderWithInstances(subMesh, drawAs, batch, effect, engine);
+                this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
             } else {
                 if (batch.renderSelf[subMesh._id]) {
                     // Draw
-                    this._draw(subMesh, drawAs);
+                    this._draw(subMesh, fillMode);
                 }
 
                 if (batch.visibleInstances[subMesh._id]) {
@@ -519,7 +468,7 @@
                         effectiveMaterial.bindOnlyWorldMatrix(world);
 
                         // Draw
-                        this._draw(subMesh, drawAs);
+                        this._draw(subMesh, fillMode);
                     }
                 }
             }

+ 1 - 1
Babylon/Particles/babylon.particleSystem.js

@@ -341,7 +341,7 @@
                 engine.setDepthWrite(true);
             }
 
-            engine.draw(WebGLRenderingContext.TRIANGLES, 0, this.particles.length * 6);
+            engine.draw(true, 0, this.particles.length * 6);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
 
             return this.particles.length;

+ 1 - 1
Babylon/Particles/babylon.particleSystem.ts

@@ -376,7 +376,7 @@
                 engine.setDepthWrite(true);
             }
 
-            engine.draw(WebGLRenderingContext.TRIANGLES, 0, this.particles.length * 6);
+            engine.draw(true, 0, this.particles.length * 6);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
 
             return this.particles.length;

+ 1 - 1
Babylon/PostProcess/babylon.postProcessManager.js

@@ -76,7 +76,7 @@
                     engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect);
 
                     // Draw order
-                    engine.draw(WebGLRenderingContext.TRIANGLES, 0, 6);
+                    engine.draw(true, 0, 6);
                 }
             }
 

+ 1 - 1
Babylon/PostProcess/babylon.postProcessManager.ts

@@ -80,7 +80,7 @@
                     engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect);
 
                     // Draw order
-                    engine.draw(WebGLRenderingContext.TRIANGLES, 0, 6);
+                    engine.draw(true, 0, 6);
                 }
             }
 

+ 2 - 2
Babylon/Rendering/babylon.boundingBoxRenderer.js

@@ -48,7 +48,7 @@
                     this._colorShader.bind(worldMatrix);
 
                     // Draw order
-                    engine.draw(WebGLRenderingContext.LINES, 0, 24);
+                    engine.draw(false, 0, 24);
                 }
 
                 // Front
@@ -57,7 +57,7 @@
                 this._colorShader.bind(worldMatrix);
 
                 // Draw order
-                engine.draw(WebGLRenderingContext.LINES, 0, 24);
+                engine.draw(false, 0, 24);
             }
             this._colorShader.unbind();
             engine.setDepthFunctionToLessOrEqual();

+ 2 - 2
Babylon/Rendering/babylon.boundingBoxRenderer.ts

@@ -59,7 +59,7 @@
                     this._colorShader.bind(worldMatrix);
 
                     // Draw order
-                    engine.draw(WebGLRenderingContext.LINES, 0, 24);
+                    engine.draw(false, 0, 24);
                 }
 
                 // Front
@@ -68,7 +68,7 @@
                 this._colorShader.bind(worldMatrix);
 
                 // Draw order
-                engine.draw(WebGLRenderingContext.LINES, 0, 24);
+                engine.draw(false, 0, 24);
             }
             this._colorShader.unbind();
             engine.setDepthFunctionToLessOrEqual();

+ 4 - 4
Babylon/Rendering/babylon.outlineRenderer.js

@@ -28,7 +28,7 @@
                 this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices());
             }
 
-            mesh._bind(subMesh, this._effect, WebGLRenderingContext.TRIANGLES);
+            mesh._bind(subMesh, this._effect, BABYLON.Material.TriangleFillMode);
 
             // Alpha test
             if (material && material.needAlphaTesting()) {
@@ -38,13 +38,13 @@
             }
 
             if (hardwareInstancedRendering) {
-                mesh._renderWithInstances(subMesh, WebGLRenderingContext.TRIANGLES, batch, this._effect, engine);
+                mesh._renderWithInstances(subMesh, BABYLON.Material.TriangleFillMode, batch, this._effect, engine);
             } else {
                 if (batch.renderSelf[subMesh._id]) {
                     this._effect.setMatrix("world", mesh.getWorldMatrix());
 
                     // Draw
-                    mesh._draw(subMesh, WebGLRenderingContext.TRIANGLES);
+                    mesh._draw(subMesh, BABYLON.Material.TriangleFillMode);
                 }
 
                 if (batch.visibleInstances[subMesh._id]) {
@@ -54,7 +54,7 @@
                         this._effect.setMatrix("world", instance.getWorldMatrix());
 
                         // Draw
-                        mesh._draw(subMesh, WebGLRenderingContext.TRIANGLES);
+                        mesh._draw(subMesh, BABYLON.Material.TriangleFillMode);
                     }
                 }
             }

+ 4 - 4
Babylon/Rendering/babylon.outlineRenderer.ts

@@ -32,7 +32,7 @@
                 this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices());
             }
 
-            mesh._bind(subMesh, this._effect, WebGLRenderingContext.TRIANGLES);
+            mesh._bind(subMesh, this._effect, Material.TriangleFillMode);
 
             // Alpha test
             if (material && material.needAlphaTesting()) {
@@ -43,13 +43,13 @@
 
 
             if (hardwareInstancedRendering) {
-                mesh._renderWithInstances(subMesh, WebGLRenderingContext.TRIANGLES, batch, this._effect, engine);
+                mesh._renderWithInstances(subMesh, Material.TriangleFillMode, batch, this._effect, engine);
             } else {
                 if (batch.renderSelf[subMesh._id]) {
                     this._effect.setMatrix("world", mesh.getWorldMatrix());
 
                     // Draw
-                    mesh._draw(subMesh, WebGLRenderingContext.TRIANGLES);
+                    mesh._draw(subMesh, Material.TriangleFillMode);
                 }
 
                 if (batch.visibleInstances[subMesh._id]) {
@@ -59,7 +59,7 @@
                         this._effect.setMatrix("world", instance.getWorldMatrix());
 
                         // Draw
-                        mesh._draw(subMesh, WebGLRenderingContext.TRIANGLES);
+                        mesh._draw(subMesh, Material.TriangleFillMode);
                     }
                 }
             }

+ 9 - 0
Babylon/Shaders/default.vertex.fx

@@ -73,6 +73,10 @@ uniform mat4 bumpMatrix;
 uniform mat4 mBones[BonesPerMesh];
 #endif
 
+#ifdef POINTSIZE
+uniform float pointSize;
+#endif
+
 // Output
 varying vec3 vPositionW;
 varying vec3 vNormalW;
@@ -249,4 +253,9 @@ void main(void) {
 #ifdef VERTEXCOLOR
 	vColor = color;
 #endif
+
+	// Point size
+#ifdef POINTSIZE
+	gl_PointSize = pointSize;
+#endif
 }

+ 2 - 2
Babylon/Sprites/babylon.spriteManager.js

@@ -133,12 +133,12 @@
             // Draw order
             effect.setBool("alphaTest", true);
             engine.setColorWrite(false);
-            engine.draw(WebGLRenderingContext.TRIANGLES, 0, max * 6);
+            engine.draw(true, 0, max * 6);
             engine.setColorWrite(true);
             effect.setBool("alphaTest", false);
 
             engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
-            engine.draw(WebGLRenderingContext.TRIANGLES, 0, max * 6);
+            engine.draw(true, 0, max * 6);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
         };
 

+ 2 - 2
Babylon/Sprites/babylon.spriteManager.ts

@@ -150,12 +150,12 @@
             // Draw order
             effect.setBool("alphaTest", true);
             engine.setColorWrite(false);
-            engine.draw(WebGLRenderingContext.TRIANGLES, 0, max * 6);
+            engine.draw(true, 0, max * 6);
             engine.setColorWrite(true);
             effect.setBool("alphaTest", false);
 
             engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
-            engine.draw(WebGLRenderingContext.TRIANGLES, 0, max * 6);
+            engine.draw(true, 0, max * 6);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
         }
 

+ 19 - 30
Babylon/babylon.engine.js

@@ -894,42 +894,31 @@
             this._alphaState.apply(this._gl);
         };
 
-        Engine.prototype.draw = function (drawAs, start, count, instancesCount) {
+        Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
             // Apply states
             this.applyStates();
 
-            switch (drawAs) {
-                case this._gl.LINES:
-                case this._gl.TRIANGLES:
-                     {
-                        if (instancesCount) {
-                            this._caps.instancedArrays.drawElementsInstancedANGLE(drawAs, count, this._gl.UNSIGNED_SHORT, start * 2, instancesCount);
-                        } else {
-                            this._gl.drawElements(drawAs, count, this._gl.UNSIGNED_SHORT, start * 2);
-                        }
-                    }
-                    break;
-                case this._gl.POINTS:
-                     {
-                        this._gl.drawArrays(drawAs, 0, count);
-                    }
-                    break;
+            // Render
+            if (instancesCount) {
+                this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2, instancesCount);
+                return;
             }
+
+            this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2);
+        };
+
+        Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
+            // Apply states
+            this.applyStates();
+
+            if (instancesCount) {
+                this._caps.instancedArrays.drawArraysInstancedANGLE(this._gl.POINTS, verticesStart, verticesCount, instancesCount);
+                return;
+            }
+
+            this._gl.drawArrays(this._gl.POINTS, verticesStart, verticesCount);
         };
 
-        /*
-        public draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void {
-        // Apply states
-        this.applyStates();
-        
-        // Render
-        if (instancesCount) {
-        this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2, instancesCount);
-        return;
-        }
-        
-        this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2);
-        }*/
         // Shaders
         Engine.prototype._releaseEffect = function (effect) {
             if (this._compiledEffects[effect._key]) {

+ 13 - 29
Babylon/babylon.engine.ts

@@ -845,9 +845,8 @@
                     }
                 }
             }
-            
-            if (indexBuffer != null &&
-                this._cachedIndexBuffer !== indexBuffer) {
+
+            if (indexBuffer!= null && this._cachedIndexBuffer !== indexBuffer) {
                 this._cachedIndexBuffer = indexBuffer;
                 this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
             }
@@ -905,45 +904,30 @@
             this._alphaState.apply(this._gl);
         }
 
-
-        public draw(drawAs: number, start: number, count: number, instancesCount?: number): void {
+        public draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void {
             // Apply states
             this.applyStates();
 
-            // Render         
-            switch (drawAs) {
-                case this._gl.LINES:
-                case this._gl.TRIANGLES:
-                    {
-                        if (instancesCount) {
-                            this._caps.instancedArrays.drawElementsInstancedANGLE(drawAs, count, this._gl.UNSIGNED_SHORT, start * 2, instancesCount);
-                        }
-                        else {
-                            this._gl.drawElements(drawAs, count, this._gl.UNSIGNED_SHORT, start * 2);
-                        }
-                    }
-                    break;
-                case this._gl.POINTS:
-                    {
-                        this._gl.drawArrays(drawAs, 0, count);
-                    }
-                    break;
+            // Render
+            if (instancesCount) {
+                this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2, instancesCount);
+                return;
             }
+
+            this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2);
         }
 
-        /*
-        public draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void {
+        public drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void {
             // Apply states
             this.applyStates();
 
-            // Render
             if (instancesCount) {
-                this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2, instancesCount);
+                this._caps.instancedArrays.drawArraysInstancedANGLE(this._gl.POINTS, verticesStart, verticesCount, instancesCount);
                 return;
             }
 
-            this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2);
-        }*/
+            this._gl.drawArrays(this._gl.POINTS, verticesStart, verticesCount);
+        }
 
         // Shaders
         public _releaseEffect(effect: Effect): void {

File diff suppressed because it is too large
+ 27447 - 27466
babylon.2.0-alpha.debug.js


File diff suppressed because it is too large
+ 14 - 14
babylon.2.0-alpha.js


+ 29 - 84
babylon.2.0.d.ts

@@ -143,6 +143,7 @@ declare module BABYLON {
         public unBindInstancesBuffer(instancesBuffer: WebGLBuffer, offsetLocations: number[]): void;
         public applyStates(): void;
         public draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
+        public drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
         public _releaseEffect(effect: Effect): void;
         public createEffect(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
         public createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
@@ -1566,12 +1567,17 @@ declare module BABYLON {
 declare module BABYLON {
     class Material {
         public name: string;
+        private static _TriangleFillMode;
+        private static _WireFrameFillMode;
+        private static _PointFillMode;
+        static TriangleFillMode : number;
+        static WireFrameFillMode : number;
+        static PointFillMode : number;
         public id: string;
         public checkReadyOnEveryCall: boolean;
         public checkReadyOnlyOnce: boolean;
         public state: string;
         public alpha: number;
-        public wireframe: boolean;
         public backFaceCulling: boolean;
         public onCompiled: (effect: Effect) => void;
         public onError: (effect: Effect, errors: string) => void;
@@ -1580,6 +1586,11 @@ declare module BABYLON {
         public _effect: Effect;
         public _wasPreviouslyReady: boolean;
         private _scene;
+        private _fillMode;
+        public pointSize: number;
+        public wireframe : boolean;
+        public pointsCloud : boolean;
+        public fillMode : number;
         constructor(name: string, scene: Scene, doNotAdd?: boolean);
         public isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
         public getEffect(): Effect;
@@ -1764,50 +1775,6 @@ declare module BABYLON {
     }
 }
 declare module BABYLON {
-    class ProceduralTexture extends Texture {
-        private _size;
-        public _generateMipMaps: boolean;
-        private _doNotChangeAspectRatio;
-        private _currentRefreshId;
-        private _refreshRate;
-        private _vertexBuffer;
-        private _indexBuffer;
-        private _effect;
-        private _vertexDeclaration;
-        private _vertexStrideSize;
-        private _uniforms;
-        private _samplers;
-        private _fragment;
-        private _textures;
-        private _floats;
-        private _floatsArrays;
-        private _colors3;
-        private _colors4;
-        private _vectors2;
-        private _vectors3;
-        private _matrices;
-        constructor(name: string, size: any, fragment: any, scene: Scene, generateMipMaps?: boolean);
-        public isReady(): boolean;
-        public resetRefreshCounter(): void;
-        public refreshRate : number;
-        public _shouldRender(): boolean;
-        public getRenderSize(): number;
-        public resize(size: any, generateMipMaps: any): void;
-        private _checkUniform(uniformName);
-        public setTexture(name: string, texture: Texture): ProceduralTexture;
-        public setFloat(name: string, value: number): ProceduralTexture;
-        public setFloats(name: string, value: number[]): ProceduralTexture;
-        public setColor3(name: string, value: Color3): ProceduralTexture;
-        public setColor4(name: string, value: Color4): ProceduralTexture;
-        public setVector2(name: string, value: Vector2): ProceduralTexture;
-        public setVector3(name: string, value: Vector3): ProceduralTexture;
-        public setMatrix(name: string, value: Matrix): ProceduralTexture;
-        public render(useCameraPostProcess?: boolean): void;
-        public clone(): ProceduralTexture;
-        public dispose(): void;
-    }
-}
-declare module BABYLON {
     class RenderTargetTexture extends Texture {
         public renderList: AbstractMesh[];
         public renderParticles: boolean;
@@ -1973,6 +1940,9 @@ declare module BABYLON {
         public shift : number;
         public alpha : number;
     }
+    class CloudProceduralTexture extends ProceduralTexture {
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+    }
 }
 declare module BABYLON {
     class Color3 {
@@ -2139,7 +2109,6 @@ declare module BABYLON {
         static DistanceSquared(value1: Vector3, value2: Vector3): number;
         static Center(value1: Vector3, value2: Vector3): Vector3;
     }
-
     class Vector4 {
         public x: number;
         public y: number;
@@ -2160,13 +2129,13 @@ declare module BABYLON {
         public negate(): Vector4;
         public scaleInPlace(scale: number): Vector4;
         public scale(scale: number): Vector4;
-        public scaleToRef(scale: number, result: Vector4);
+        public scaleToRef(scale: number, result: Vector4): void;
         public equals(otherVector: Vector4): boolean;
         public equalsWithEpsilon(otherVector: Vector4): boolean;
         public equalsToFloats(x: number, y: number, z: number, w: number): boolean;
         public multiplyInPlace(otherVector: Vector4): void;
         public multiply(otherVector: Vector4): Vector4;
-        public multiplyToRef(otherVector: Vector4, result: Vector4): void
+        public multiplyToRef(otherVector: Vector4, result: Vector4): void;
         public multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
         public divide(otherVector: Vector4): Vector4;
         public divideToRef(otherVector: Vector4, result: Vector4): void;
@@ -2191,7 +2160,6 @@ declare module BABYLON {
         static DistanceSquared(value1: Vector4, value2: Vector4): number;
         static Center(value1: Vector4, value2: Vector4): Vector4;
     }
-
     class Quaternion {
         public x: number;
         public y: number;
@@ -2222,28 +2190,6 @@ declare module BABYLON {
         static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
         static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
     }
-
-    class EulerAngles {
-        public x: number;
-        public y: number;
-        public z: number;
-        constructor(x?: number, y?: number, z?: number);
-        public toString(): string;
-        public asArray(): number[];
-        public equals(otherEulerAngles: EulerAngles): boolean;
-        public clone(): EulerAngles;
-        public copyFrom(other: EulerAngles): void;
-        public copyFromFloats(x: number, y: number, z: number): void;
-        public add(other: EulerAngles): EulerAngles;
-        public subtract(other: EulerAngles): EulerAngles;
-        public scale(value: number): EulerAngles;
-        public length(): number;
-        public normalize(): void;
-        public toQuaternion(): Vector4;
-        public toRotationMatrix(result: Matrix): void;
-        public fromRotationMatrix(matrix: Matrix): void;
-    }
-
     class Matrix {
         private static _tempQuaternion;
         private static _xAxis;
@@ -2681,8 +2627,8 @@ declare module BABYLON {
         public material : Material;
         public isPickable : boolean;
         public checkCollisions : boolean;
-        public _bind(subMesh: SubMesh, effect: Effect, wireframe?: boolean): void;
-        public _draw(subMesh: SubMesh, useTriangles: boolean, instancesCount?: number): void;
+        public _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
+        public _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
         public intersects(ray: Ray, fastCheck?: boolean): any;
         public dispose(doNotRecurse?: boolean): void;
     }
@@ -2731,15 +2677,14 @@ declare module BABYLON {
         public updateVerticesDataDirectly(kind: string, data: Float32Array, makeItUnique?: boolean): void;
         public makeGeometryUnique(): void;
         public setIndices(indices: number[]): void;
-        public _bind(subMesh: SubMesh, effect: Effect, wireframe?: boolean): void;
-        public _draw(subMesh: SubMesh, useTriangles: boolean, instancesCount?: number): void;
-        public _fullDraw(subMesh: SubMesh, useTriangles: boolean, instancesCount?: number): void;
+        public _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
+        public _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
         public registerBeforeRender(func: () => void): void;
         public unregisterBeforeRender(func: () => void): void;
         public registerAfterRender(func: () => void): void;
         public unregisterAfterRender(func: () => void): void;
         public _getInstancesRenderList(subMeshId: number): _InstancesBatch;
-        public _renderWithInstances(subMesh: SubMesh, wireFrame: boolean, batch: _InstancesBatch, effect: Effect, engine: Engine): void;
+        public _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): void;
         public render(subMesh: SubMesh): void;
         public getEmittedParticleSystems(): ParticleSystem[];
         public getHierarchyEmittedParticleSystems(): ParticleSystem[];
@@ -3680,32 +3625,32 @@ declare module BABYLON {
         public apply: (scene: Scene) => boolean;
         constructor(priority?: number);
     }
-    class TextureSceneOptimization extends SceneOptimization {
+    class TextureOptimization extends SceneOptimization {
         public priority: number;
         public maximumSize: number;
         constructor(priority?: number, maximumSize?: number);
         public apply: (scene: Scene) => boolean;
     }
-    class HardwareScalingSceneOptimization extends SceneOptimization {
+    class HardwareScalingOptimization extends SceneOptimization {
         public priority: number;
         public maximumScale: number;
         private _currentScale;
         constructor(priority?: number, maximumScale?: number);
         public apply: (scene: Scene) => boolean;
     }
-    class ShadowsSceneOptimization extends SceneOptimization {
+    class ShadowsOptimization extends SceneOptimization {
         public apply: (scene: Scene) => boolean;
     }
-    class PostProcessesSceneOptimization extends SceneOptimization {
+    class PostProcessesOptimization extends SceneOptimization {
         public apply: (scene: Scene) => boolean;
     }
-    class LensFlaresSceneOptimization extends SceneOptimization {
+    class LensFlaresOptimization extends SceneOptimization {
         public apply: (scene: Scene) => boolean;
     }
-    class ParticlesSceneOptimization extends SceneOptimization {
+    class ParticlesOptimization extends SceneOptimization {
         public apply: (scene: Scene) => boolean;
     }
-    class RenderTargetsSceneOptimization extends SceneOptimization {
+    class RenderTargetsOptimization extends SceneOptimization {
         public apply: (scene: Scene) => boolean;
     }
     class SceneOptimizerOptions {