Deltakosh 12 年之前
父节点
当前提交
b04bfe22cf
共有 41 个文件被更改,包括 2371 次插入149 次删除
  1. 5 3
      Babylon/Cameras/babylon.touchCamera.js
  2. 10 2
      Babylon/Materials/babylon.effect.js
  3. 31 47
      Babylon/Materials/babylon.standardMaterial.js
  4. 6 0
      Babylon/Materials/textures/babylon.cubeTexture.js
  5. 68 14
      Babylon/Materials/textures/babylon.texture.js
  6. 8 0
      Babylon/Mesh/babylon.mesh.js
  7. 34 28
      Babylon/Particles/babylon.particleSystem.js
  8. 47 4
      Babylon/Shaders/default.fragment.fx
  9. 11 3
      Babylon/Shaders/default.vertex.fx
  10. 6 8
      Babylon/Shaders/iedefault.fragment.fx
  11. 1 1
      Babylon/Shaders/iedefault.vertex.fx
  12. 42 0
      Babylon/Shaders/sprites.fragment.fx
  13. 9 0
      Babylon/Shaders/sprites.vertex.fx
  14. 27 10
      Babylon/Sprites/babylon.spriteManager.js
  15. 9 0
      Babylon/Tools/babylon.sceneLoader.js
  16. 8 1
      Babylon/babylon.engine.js
  17. 29 17
      Babylon/babylon.scene.js
  18. 40 0
      Typescript/Animations/babylon.animation.d.ts
  19. 71 0
      Typescript/Cameras/babylon.camera.d.ts
  20. 34 0
      Typescript/Collisions/babylon.collider.d.ts
  21. 49 0
      Typescript/Culling/babylon.bounding.d.ts
  22. 15 0
      Typescript/Layer/babylon.layer.d.ts
  23. 30 0
      Typescript/Lights/babylon.light.d.ts
  24. 30 0
      Typescript/Materials/babylon.effect.d.ts
  25. 52 0
      Typescript/Materials/babylon.material.d.ts
  26. 84 0
      Typescript/Materials/textures/babylon.texture.d.ts
  27. 93 0
      Typescript/Mesh/babylon.mesh.d.ts
  28. 68 0
      Typescript/Particles/babylon.particle.d.ts
  29. 32 0
      Typescript/Sprites/Babylon.Sprite.d.ts
  30. 234 0
      Typescript/Tools/babylon.math.d.ts
  31. 5 0
      Typescript/Tools/babylon.sceneLoader.d.ts
  32. 14 0
      Typescript/Tools/babylon.tools.d.ts
  33. 4 0
      Typescript/Tools/babylon.tools.dds.d.ts
  34. 18 0
      Typescript/babylon.d.ts
  35. 108 0
      Typescript/babylon.engine.d.ts
  36. 976 0
      Typescript/babylon.min.d.ts
  37. 47 0
      Typescript/babylon.scene.d.ts
  38. 0 11
      babylon.1.0.3.js
  39. 11 0
      babylon.1.0.4.js
  40. 1 0
      readme.md
  41. 4 0
      what's new.txt

+ 5 - 3
Babylon/Cameras/babylon.touchCamera.js

@@ -12,6 +12,8 @@
         this.cameraRotation = new BABYLON.Vector2(0, 0);
         this.rotation = new BABYLON.Vector3(0, 0, 0);
         this.ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
+        this.angularSensibility = 200000.0;
+        this.moveSensibility = 500.0;
 
         if (!scene.activeCamera) {
             scene.activeCamera = this;
@@ -111,13 +113,13 @@
         if (!this._offsetX) {
             return;
         }
-        this.cameraRotation.y += this._offsetX / 100000.0;
+        this.cameraRotation.y += this._offsetX / this.angularSensibility;
 
         if (this._pointerPressed.length > 1) {
-            this.cameraRotation.x += -this._offsetY / 100000.0;
+            this.cameraRotation.x += -this._offsetY / this.angularSensibility;
         } else {
             var speed = this._computeLocalCameraSpeed();
-            var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / 500.0);
+            var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
 
             var cameraTransform = BABYLON.Matrix.RotationYawPitchRoll(this.rotation.y, this.rotation.x, 0);
             this.cameraDirection = this.cameraDirection.add(BABYLON.Vector3.TransformCoordinates(direction, cameraTransform));

+ 10 - 2
Babylon/Materials/babylon.effect.js

@@ -123,12 +123,20 @@
         this._engine.setVector3(this.getUniform(uniformName), vector3);
     };
     
-    BABYLON.Effect.prototype.setVector4 = function (uniformName, x, y, z, w) {
+    BABYLON.Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
+        if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == x && this._valueCache[uniformName][1] == y && this._valueCache[uniformName][2] == z)
+            return;
+
+        this._valueCache[uniformName] = [x, y, z];
+        this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
+    };
+    
+    BABYLON.Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
         if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == x && this._valueCache[uniformName][1] == y && this._valueCache[uniformName][2] == z && this._valueCache[uniformName][3] == w)
             return;
 
         this._valueCache[uniformName] = [x, y, z, w];
-        this._engine.setVector4(this.getUniform(uniformName), x, y, z, w);
+        this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
     };
     
     BABYLON.Effect.prototype.setColor3 = function (uniformName, color3) {

+ 31 - 47
Babylon/Materials/babylon.standardMaterial.js

@@ -107,6 +107,11 @@
             defines.push("#define ALPHATEST");
         }
         
+        // Fog
+        if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            defines.push("#define FOG");
+        }
+        
         var lightIndex = 0;
         for (var index = 0; index < this._scene.lights.length; index++) {
             var light = this._scene.lights[index];
@@ -158,13 +163,14 @@
 
             this._effect = this._scene.getEngine().createEffect(shaderName,
                 attribs,
-                ["world", "view", "worldViewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
-                 "vLightData0", "vLightDiffuse0", "vLightSpecular0", "vLightDirection0", "vLightGround0",
-                 "vLightData1", "vLightDiffuse1", "vLightSpecular1", "vLightDirection1", "vLightGround1",
-                 "vLightData2", "vLightDiffuse2", "vLightSpecular2", "vLightDirection2", "vLightGround2",
-                 "vLightData3", "vLightDiffuse3", "vLightSpecular3", "vLightDirection3", "vLightGround3",
+            ["world", "view", "worldViewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
+                "vLightData0", "vLightDiffuse0", "vLightSpecular0", "vLightDirection0", "vLightGround0",
+                "vLightData1", "vLightDiffuse1", "vLightSpecular1", "vLightDirection1", "vLightGround1",
+                "vLightData2", "vLightDiffuse2", "vLightSpecular2", "vLightDirection2", "vLightGround2",
+                "vLightData3", "vLightDiffuse3", "vLightSpecular3", "vLightDirection3", "vLightGround3",
+                "vFogInfos", "vFogColor",
                  "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos",
-                 "vMisc", "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix"],
+                 "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix"],
                 ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler"],
                 join);
         }
@@ -192,7 +198,6 @@
     };
 
     BABYLON.StandardMaterial.prototype.bind = function (world, mesh) {
-        var vMisc = [0, 0, 0, 0];
         var baseColor = this.diffuseColor;
 
         // Values
@@ -226,38 +231,8 @@
                 this._effect.setTexture("reflection2DSampler", this.reflectionTexture);
             }
 
-            // Matrix
-            var matrix = BABYLON.Matrix.Identity();
-
-            switch (this.reflectionTexture.coordinatesMode) {
-                case BABYLON.Texture.SPHERICAL_MODE:
-                    matrix.m[0] = -0.5 * this.reflectionTexture.uScale;
-                    matrix.m[5] = -0.5 * this.reflectionTexture.vScale;
-                    matrix.m[12] = 0.5 + this.reflectionTexture.uOffset;
-                    matrix.m[13] = 0.5 + this.reflectionTexture.vOffset;
-                    break;
-                case BABYLON.Texture.PLANAR_MODE:
-                    matrix.m[0] = this.reflectionTexture.uScale;
-                    matrix.m[5] = this.reflectionTexture.vScale;
-                    matrix.m[12] = this.reflectionTexture.uOffset;
-                    matrix.m[13] = this.reflectionTexture.vOffset;
-                    break;
-                case BABYLON.Texture.PROJECTION_MODE:
-                    matrix.m[0] = 0.5;
-                    matrix.m[5] = -0.5;
-                    matrix.m[10] = 0.0;
-                    matrix.m[12] = 0.5;
-                    matrix.m[13] = 0.5;
-                    matrix.m[14] = 1.0;
-                    matrix.m[15] = 1.0;
-
-                    matrix = this._scene.getProjectionMatrix().multiply(matrix);
-                    break;
-            }
-            this._effect.setMatrix("reflectionMatrix", matrix);
-            vMisc[0] = (this.reflectionTexture.isCube ? 1 : 0);
-            this._effect.setMatrix("view", this._scene.getViewMatrix());
-            this._effect.setVector2("vReflectionInfos", this.reflectionTexture.coordinatesMode, this.reflectionTexture.level);
+            this._effect.setMatrix("reflectionMatrix", this.reflectionTexture._computeReflectionTextureMatrix());
+            this._effect.setFloat3("vReflectionInfos", this.reflectionTexture.coordinatesMode, this.reflectionTexture.level, this.reflectionTexture.isCube ? 1 : 0);
         }
 
         if (this.emissiveTexture) {
@@ -299,19 +274,19 @@
                         
             if (light instanceof BABYLON.PointLight) {
                 // Point Light
-                this._effect.setVector4("vLightData" + lightIndex, light.position.x, light.position.y, light.position.z, 0);
+                this._effect.setFloat4("vLightData" + lightIndex, light.position.x, light.position.y, light.position.z, 0);
             } else if (light instanceof BABYLON.DirectionalLight) {
                 // Directional Light
-                this._effect.setVector4("vLightData" + lightIndex, light.direction.x, light.direction.y, light.direction.z, 1);
+                this._effect.setFloat4("vLightData" + lightIndex, light.direction.x, light.direction.y, light.direction.z, 1);
             } else if (light instanceof BABYLON.SpotLight) {
                 // Spot Light
-                this._effect.setVector4("vLightData" + lightIndex, light.position.x, light.position.y, light.position.z, light.exponent);
+                this._effect.setFloat4("vLightData" + lightIndex, light.position.x, light.position.y, light.position.z, light.exponent);
                 var normalizeDirection = BABYLON.Vector3.Normalize(light.direction);
-                this._effect.setVector4("vLightDirection" + lightIndex, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, Math.cos(light.angle * 0.5));
+                this._effect.setFloat4("vLightDirection" + lightIndex, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, Math.cos(light.angle * 0.5));
             } else if (light instanceof BABYLON.HemisphericLight) {
                 // Hemispheric Light
                 var normalizeDirection = BABYLON.Vector3.Normalize(light.direction);
-                this._effect.setVector4("vLightData" + lightIndex, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0);
+                this._effect.setFloat4("vLightData" + lightIndex, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0);
                 this._effect.setColor3("vLightGround" + lightIndex, light.groundColor.scale(light.intensity));
             }
             this._effect.setColor3("vLightDiffuse" + lightIndex, light.diffuse.scale(light.intensity));
@@ -323,10 +298,19 @@
                 break;
         }
 
-        this._effect.setVector4("vMisc", vMisc[0], vMisc[1], vMisc[2], vMisc[3]);
-
         if (BABYLON.clipPlane) {
-            this._effect.setVector4("vClipPlane", BABYLON.clipPlane.normal.x, BABYLON.clipPlane.normal.y, BABYLON.clipPlane.normal.z, BABYLON.clipPlane.d);
+            this._effect.setFloat4("vClipPlane", BABYLON.clipPlane.normal.x, BABYLON.clipPlane.normal.y, BABYLON.clipPlane.normal.z, BABYLON.clipPlane.d);
+        }
+        
+        // View
+        if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE || this.reflectionTexture) {
+            this._effect.setMatrix("view", this._scene.getViewMatrix());
+        }
+
+        // Fog
+        if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            this._effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
+            this._effect.setColor3("vFogColor", this._scene.fogColor);
         }
     };
 

+ 6 - 0
Babylon/Materials/textures/babylon.cubeTexture.js

@@ -16,7 +16,13 @@
         }
         
         this.isCube = true;
+
+        this._textureMatrix = BABYLON.Matrix.Identity();
     };
 
     BABYLON.CubeTexture.prototype = Object.create(BABYLON.BaseTexture.prototype);
+
+    BABYLON.CubeTexture.prototype._computeReflectionTextureMatrix = function () {
+        return this._textureMatrix;
+    }
 })();

+ 68 - 14
Babylon/Materials/textures/babylon.texture.js

@@ -8,11 +8,11 @@
         this.name = url;
 
         this._texture = this._getFromCache(url, noMipmap);
-        
+
         if (!this._texture) {
             this._texture = scene.getEngine().createTexture(url, noMipmap, invertY, scene);
         }
-        
+
         // Animations
         this.animations = [];
     };
@@ -25,7 +25,7 @@
     BABYLON.Texture.PLANAR_MODE = 2;
     BABYLON.Texture.CUBIC_MODE = 3;
     BABYLON.Texture.PROJECTION_MODE = 4;
-    
+
     // Members
     BABYLON.Texture.prototype.uOffset = 0;
     BABYLON.Texture.prototype.vOffset = 0;
@@ -37,10 +37,10 @@
     BABYLON.Texture.prototype.wrapU = true;
     BABYLON.Texture.prototype.wrapV = true;
     BABYLON.Texture.prototype.coordinatesIndex = 0;
-    BABYLON.Texture.prototype.coordinatesMode = BABYLON.Texture.EXPLICIT_MODE;    
+    BABYLON.Texture.prototype.coordinatesMode = BABYLON.Texture.EXPLICIT_MODE;
 
     // Methods    
-    BABYLON.Texture.prototype._prepareRowForTextureGeneration = function(t) {
+    BABYLON.Texture.prototype._prepareRowForTextureGeneration = function (t) {
         var matRot = BABYLON.Matrix.RotationYawPitchRoll(this.vAng, this.uAng, this.wAng);
 
         t.x -= this.uOffset + 0.5;
@@ -49,15 +49,8 @@
 
         t = BABYLON.Vector3.TransformCoordinates(t, matRot);
 
-        if (this.uScale != 1.0)
-        {
-            t.x *= this.uScale;
-        }
-
-        if (this.vScale != 1.0)
-        {
-            t.y *= this.vScale;
-        }
+        t.x *= this.uScale;
+        t.y *= this.vScale;
 
         t.x += 0.5;
         t.y += 0.5;
@@ -67,6 +60,25 @@
     };
 
     BABYLON.Texture.prototype._computeTextureMatrix = function () {
+        if (
+            this.uOffset === this._cachedUOffset &&
+            this.vOffset === this._cachedVOffset &&
+            this.uScale === this._cachedUScale &&
+            this.vScale === this._cachedVScale &&
+            this.uAng === this._cachedUAng &&
+            this.vAng === this._cachedVAng &&
+            this.wAng === this._cachedWAng) {
+                return this._cachedTextureMatrix;
+        }
+
+        this._cachedUOffset = this.uOffset;
+        this._cachedVOffset = this.vOffset;
+        this._cachedUScale = this.uScale;
+        this._cachedVScale = this.vScale;
+        this._cachedUAng = this.uAng;
+        this._cachedVAng = this.vAng;
+        this._cachedWAng = this.wAng;
+
         var t0 = new BABYLON.Vector3(0, 0, 0);
         var t1 = new BABYLON.Vector3(1.0, 0, 0);
         var t2 = new BABYLON.Vector3(0, 1.0, 0);
@@ -84,6 +96,48 @@
         matTemp.m[4] = t2.x; matTemp.m[5] = t2.y; matTemp.m[6] = t2.z;
         matTemp.m[8] = t0.x; matTemp.m[9] = t0.y; matTemp.m[10] = t0.z;
 
+        this._cachedTextureMatrix = matTemp;
         return matTemp;
     };
+
+    BABYLON.Texture.prototype._computeReflectionTextureMatrix = function () {
+        if (
+            this.uOffset === this._cachedUOffset &&
+            this.vOffset === this._cachedVOffset &&
+            this.uScale === this._cachedUScale &&
+            this.vScale === this._cachedVScale &&
+            this.coordinatesMode === this._cachedCoordinatesMode) {
+                return this._cachedTextureMatrix;
+        }
+
+        var matrix = BABYLON.Matrix.Identity();
+
+        switch (this.coordinatesMode) {
+            case BABYLON.Texture.SPHERICAL_MODE:
+                matrix.m[0] = -0.5 * this.uScale;
+                matrix.m[5] = -0.5 * this.vScale;
+                matrix.m[12] = 0.5 + this.uOffset;
+                matrix.m[13] = 0.5 + this.vOffset;
+                break;
+            case BABYLON.Texture.PLANAR_MODE:
+                matrix.m[0] = this.uScale;
+                matrix.m[5] = this.vScale;
+                matrix.m[12] = this.uOffset;
+                matrix.m[13] = this.vOffset;
+                break;
+            case BABYLON.Texture.PROJECTION_MODE:
+                matrix.m[0] = 0.5;
+                matrix.m[5] = -0.5;
+                matrix.m[10] = 0.0;
+                matrix.m[12] = 0.5;
+                matrix.m[13] = 0.5;
+                matrix.m[14] = 1.0;
+                matrix.m[15] = 1.0;
+
+                matrix = this._scene.getProjectionMatrix().multiply(matrix);
+                break;
+        }
+        this._cachedTextureMatrix = matrix;
+        return matrix;
+    };
 })();

+ 8 - 0
Babylon/Mesh/babylon.mesh.js

@@ -75,6 +75,14 @@
     BABYLON.Mesh.prototype.getVertices = function () {
         return this._vertices;
     };
+    
+    BABYLON.Mesh.prototype.getTotalIndices = function () {
+        return this._indices.length;
+    };
+
+    BABYLON.Mesh.prototype.getIndices = function () {
+        return this._indices;
+    };
 
     BABYLON.Mesh.prototype.getVertexStrideSize = function () {
         return this._vertexStrideSize;

+ 34 - 28
Babylon/Particles/babylon.particleSystem.js

@@ -68,17 +68,6 @@
         }
 
         this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
-
-        // Effects
-        this._baseEffect = this._scene.getEngine().createEffect("particles",
-                    ["position", "color", "options"],
-                    ["view", "projection", "textureMask"],
-                    ["diffuseSampler"], "");
-
-        this._clippedEffect = this._scene.getEngine().createEffect("particles",
-                    ["position", "color", "options"],
-                    ["invView", "view", "projection", "vClipPlane", "textureMask"],
-                    ["diffuseSampler"], "#define CLIPPLANE");
     };
 
     // Members
@@ -197,12 +186,34 @@
         }
     };
 
+    BABYLON.ParticleSystem.prototype._getEffect = function () {
+        var defines = [];
+        
+        if (BABYLON.clipPlane) {
+            defines.push("#define CLIPPLANE");
+        }
+        
+        // Effect
+        var join = defines.join("\n");
+        if (this._cachedDefines != join) {
+            this._cachedDefines = join;
+            this._effect = this._scene.getEngine().createEffect("particles",
+                ["position", "color", "options"],
+                ["invView", "view", "projection", "vClipPlane", "textureMask"],
+                ["diffuseSampler"], join);
+        }
+
+        return this._effect;
+    };
+
     BABYLON.ParticleSystem.prototype.animate = function () {
         if (!this._started)
             return;
 
+        var effect = this._getEffect();
+
         // Check
-        if (!this.emitter || !this._baseEffect.isReady() || !this._clippedEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady())
+        if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady())
             return;
 
         this._scaledUpdateSpeed = this.updateSpeed * this._scene.getAnimationRatio();
@@ -263,37 +274,32 @@
     };
 
     BABYLON.ParticleSystem.prototype.render = function () {
-        // Effect
-        if (BABYLON.clipPlane) {
-            this._effect = this._clippedEffect;
-        } else {
-            this._effect = this._baseEffect;
-        }
+        var effect = this._getEffect();
 
         // Check
-        if (!this.emitter || !this._effect.isReady() || !this.particleTexture || !this.particleTexture.isReady() || !this.particles.length)
+        if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady() || !this.particles.length)
             return 0;
 
         var engine = this._scene.getEngine();
 
         // Render
-        engine.enableEffect(this._effect);
+        engine.enableEffect(effect);
 
         var viewMatrix = this._scene.getViewMatrix();
-        this._effect.setTexture("diffuseSampler", this.particleTexture);
-        this._effect.setMatrix("view", viewMatrix);
-        this._effect.setMatrix("projection", this._scene.getProjectionMatrix());
-        this._effect.setVector4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
+        effect.setTexture("diffuseSampler", this.particleTexture);
+        effect.setMatrix("view", viewMatrix);
+        effect.setMatrix("projection", this._scene.getProjectionMatrix());
+        effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
 
         if (BABYLON.clipPlane) {
             var invView = viewMatrix.clone();
             invView.invert();
-            this._effect.setMatrix("invView", invView);
-            this._effect.setVector4("vClipPlane", BABYLON.clipPlane.normal.x, BABYLON.clipPlane.normal.y, BABYLON.clipPlane.normal.z, BABYLON.clipPlane.d);
-        }
+            effect.setMatrix("invView", invView);
+            effect.setFloat4("vClipPlane", BABYLON.clipPlane.normal.x, BABYLON.clipPlane.normal.y, BABYLON.clipPlane.normal.z, BABYLON.clipPlane.d);
+        }        
 
         // VBOs
-        engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, this._effect);
+        engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect);
 
         // Draw order
         if (this.blendMode === BABYLON.ParticleSystem.BLENDMODE_ONEONE) {

+ 47 - 4
Babylon/Shaders/default.fragment.fx

@@ -10,7 +10,6 @@ uniform vec3 vAmbientColor;
 uniform vec4 vDiffuseColor;
 uniform vec4 vSpecularColor;
 uniform vec3 vEmissiveColor;
-uniform vec4 vMisc;
 
 // Lights
 #ifdef LIGHT0
@@ -84,7 +83,7 @@ uniform vec2 vOpacityInfos;
 varying vec3 vReflectionUVW;
 uniform samplerCube reflectionCubeSampler;
 uniform sampler2D reflection2DSampler;
-uniform vec2 vReflectionInfos;
+uniform vec3 vReflectionInfos;
 #endif
 
 #ifdef EMISSIVE
@@ -114,6 +113,43 @@ varying vec3 vNormalW;
 varying float fClipDistance;
 #endif
 
+// Fog
+#ifdef FOG
+
+#define FOGMODE_NONE    0.
+#define FOGMODE_EXP     1.
+#define FOGMODE_EXP2    2.
+#define FOGMODE_LINEAR  3.
+#define E 2.71828
+
+uniform vec4 vFogInfos;
+uniform vec3 vFogColor;
+varying float fFogDistance;
+
+float CalcFogFactor()
+{
+	float fogCoeff = 1.0;
+	float fogStart = vFogInfos.y;
+	float fogEnd = vFogInfos.z;
+	float fogDensity = vFogInfos.w;
+
+	if (FOGMODE_LINEAR == vFogInfos.x)
+	{
+		fogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);
+	}
+	else if (FOGMODE_EXP == vFogInfos.x)
+	{
+		fogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);
+	}
+	else if (FOGMODE_EXP2 == vFogInfos.x)
+	{
+		fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);
+	}
+
+	return min(1., max(0., fogCoeff));
+}
+#endif
+
 #ifdef BUMP
 // Bump
 // Thanks to http://www.thetenthplanet.de/archives/1180
@@ -332,7 +368,7 @@ void main(void) {
 	vec3 reflectionColor = vec3(0., 0., 0.);
 
 #ifdef REFLECTION
-	if (vMisc.x != 0.0)
+	if (vReflectionInfos.z != 0.0)
 	{
 		reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW).rgb * vReflectionInfos.y;
 	}
@@ -375,5 +411,12 @@ void main(void) {
 	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;
 	vec3 finalSpecular = specularBase * specularColor;
 
-	gl_FragColor = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);
+	vec4 color = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);
+
+#ifdef FOG
+	float fog = CalcFogFactor();
+	color.rgb = fog * color.rgb + (1.0 - fog) * vFogColor;
+#endif
+
+	gl_FragColor = color;
 }

+ 11 - 3
Babylon/Shaders/default.vertex.fx

@@ -16,6 +16,7 @@ attribute vec2 uv2;
 
 // Uniforms
 uniform mat4 world;
+uniform mat4 view;
 uniform mat4 worldViewProjection;
 
 #ifdef DIFFUSE
@@ -38,10 +39,8 @@ uniform vec2 vOpacityInfos;
 
 #ifdef REFLECTION
 uniform vec3 vEyePosition;
-uniform mat4 view;
 varying vec3 vReflectionUVW;
-
-uniform vec2 vReflectionInfos;
+uniform vec3 vReflectionInfos;
 uniform mat4 reflectionMatrix;
 #endif
 
@@ -72,6 +71,10 @@ uniform vec4 vClipPlane;
 varying float fClipDistance;
 #endif
 
+#ifdef FOG
+varying float fFogDistance;
+#endif
+
 #ifdef REFLECTION
 vec3 computeReflectionCoords(float mode, vec4 worldPos, vec3 worldNormal)
 {	
@@ -193,4 +196,9 @@ void main(void) {
 #ifdef CLIPPLANE
 		fClipDistance = dot(worldPos, vClipPlane);
 #endif
+
+	// Fog
+#ifdef FOG
+		fFogDistance = (view * worldPos).z;
+#endif
 }

+ 6 - 8
Babylon/Shaders/iedefault.fragment.fx

@@ -10,12 +10,10 @@ uniform vec3 vAmbientColor;
 uniform vec4 vDiffuseColor;
 uniform vec4 vSpecularColor;
 uniform vec3 vEmissiveColor;
-uniform vec4 vMisc;
-uniform vec4 vLightsType;
 
 // Lights
 #ifdef LIGHT0
-uniform vec3 vLightData0;
+uniform vec4 vLightData0;
 uniform vec3 vLightDiffuse0;
 uniform vec3 vLightSpecular0;
 #endif
@@ -43,7 +41,7 @@ uniform vec2 vOpacityInfos;
 varying vec3 vReflectionUVW;
 uniform samplerCube reflectionCubeSampler;
 uniform sampler2D reflection2DSampler;
-uniform vec2 vReflectionInfos;
+uniform vec3 vReflectionInfos;
 #endif
 
 #ifdef EMISSIVE
@@ -103,13 +101,13 @@ void main(void) {
 
 #ifdef LIGHT0
 	vec3 lightVectorW;
-	if (vLightsType.x == 0.)
+	if (vLightData0.w == 0.)
 	{
-		lightVectorW = normalize(vLightData0 - vPositionW);
+		lightVectorW = normalize(vLightData0.xyz - vPositionW);
 	}
 	else 
 	{
-		lightVectorW = normalize(-vLightData0);
+		lightVectorW = normalize(-vLightData0.xyz);
 	}
 
 	// diffuse
@@ -128,7 +126,7 @@ void main(void) {
 	vec3 reflectionColor = vec3(0., 0., 0.);
 
 #ifdef REFLECTION
-	if (vMisc.x != 0.0)
+	if (vReflectionInfos.z != 0.0)
 	{
 		reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW).rgb * vReflectionInfos.y;
 	}

+ 1 - 1
Babylon/Shaders/iedefault.vertex.fx

@@ -41,7 +41,7 @@ uniform vec3 vEyePosition;
 uniform mat4 view;
 varying vec3 vReflectionUVW;
 
-uniform vec2 vReflectionInfos;
+uniform vec3 vReflectionInfos;
 uniform mat4 reflectionMatrix;
 #endif
 

+ 42 - 0
Babylon/Shaders/sprites.fragment.fx

@@ -8,6 +8,43 @@ uniform bool alphaTest;
 varying vec2 vUV;
 uniform sampler2D diffuseSampler;
 
+// Fog
+#ifdef FOG
+
+#define FOGMODE_NONE    0.
+#define FOGMODE_EXP     1.
+#define FOGMODE_EXP2    2.
+#define FOGMODE_LINEAR  3.
+#define E 2.71828
+
+uniform vec4 vFogInfos;
+uniform vec3 vFogColor;
+varying float fFogDistance;
+
+float CalcFogFactor()
+{
+	float fogCoeff = 1.0;
+	float fogStart = vFogInfos.y;
+	float fogEnd = vFogInfos.z;
+	float fogDensity = vFogInfos.w;
+
+	if (FOGMODE_LINEAR == vFogInfos.x)
+	{
+		fogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);
+	}
+	else if (FOGMODE_EXP == vFogInfos.x)
+	{
+		fogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);
+	}
+	else if (FOGMODE_EXP2 == vFogInfos.x)
+	{
+		fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);
+	}
+
+	return min(1., max(0., fogCoeff));
+}
+#endif
+
 
 void main(void) {
 	vec4 baseColor = texture2D(diffuseSampler, vUV);
@@ -18,5 +55,10 @@ void main(void) {
 			discard;
 	}
 
+#ifdef FOG
+	float fog = CalcFogFactor();
+	baseColor.rgb = fog * baseColor.rgb + (1.0 - fog) * vFogColor;
+#endif
+
 	gl_FragColor = baseColor;
 }

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

@@ -11,6 +11,10 @@ uniform mat4 projection;
 // Output
 varying vec2 vUV;
 
+#ifdef FOG
+varying float fFogDistance;
+#endif
+
 void main(void) {	
 	vec3 viewPos = (view * vec4(position, 1.0)).xyz; 
 	vec3 cornerPos;
@@ -36,4 +40,9 @@ void main(void) {
 	vec2 uvOffset = vec2(abs(offset.x - cellInfo.x), 1.0 - abs(offset.y - cellInfo.y));
 
 	vUV = (uvOffset + cellInfo.zw) * uvScale;
+
+	// Fog
+#ifdef FOG
+	fFogDistance = viewPos.z;
+#endif
 }

+ 27 - 10
Babylon/Sprites/babylon.spriteManager.js

@@ -61,10 +61,15 @@
         this.sprites = [];
         
         // Effects
-        this._effect = this._scene.getEngine().createEffect("sprites",
+        this._effectBase = this._scene.getEngine().createEffect("sprites",
                     ["position", "options", "cellInfo"],
                     ["view", "projection", "textureInfos", "alphaTest"],
                     ["diffuseSampler"], "");
+        
+        this._effectFog = this._scene.getEngine().createEffect("sprites",
+                    ["position", "options", "cellInfo"],
+                    ["view", "projection", "textureInfos", "alphaTest", "vFogInfos", "vFogColor"],
+                    ["diffuseSampler"], "#define FOG");
     };
     
     // Members
@@ -73,7 +78,7 @@
     // Methods
     BABYLON.SpriteManager.prototype.render = function() {
         // Check
-        if (!this._effect.isReady() || !this._spriteTexture || !this._spriteTexture.isReady())
+        if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture || !this._spriteTexture.isReady())
             return 0;
 
         var engine = this._scene.getEngine();
@@ -97,24 +102,36 @@
         engine.updateDynamicVertexBuffer(this._vertexBuffer, vertices);
        
         // Render
-        engine.enableEffect(this._effect);
+        var effect = this._effectBase;
+
+        if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            effect = this._effectFog;
+        }
+        
+        engine.enableEffect(effect);
 
         var viewMatrix = this._scene.getViewMatrix();
-        this._effect.setTexture("diffuseSampler", this._spriteTexture);
-        this._effect.setMatrix("view", viewMatrix);
-        this._effect.setMatrix("projection", this._scene.getProjectionMatrix());
+        effect.setTexture("diffuseSampler", this._spriteTexture);
+        effect.setMatrix("view", viewMatrix);
+        effect.setMatrix("projection", this._scene.getProjectionMatrix());
 
-        this._effect.setVector2("textureInfos", this.cellSize / baseSize.width, this.cellSize / baseSize.height);
+        effect.setVector2("textureInfos", this.cellSize / baseSize.width, this.cellSize / baseSize.height);
+        
+        // Fog
+        if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
+            effect.setColor3("vFogColor", this._scene.fogColor);
+        }
 
         // VBOs
-        engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, this._effect);
+        engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect);
 
         // Draw order
-        this._effect.setBool("alphaTest", true);
+        effect.setBool("alphaTest", true);
         engine.setColorWrite(false);
         engine.draw(true, 0, max * 6);
         engine.setColorWrite(true);
-        this._effect.setBool("alphaTest", false);
+        effect.setBool("alphaTest", false);
         
         engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
         engine.draw(true, 0, max * 6);

+ 9 - 0
Babylon/Tools/babylon.sceneLoader.js

@@ -390,6 +390,15 @@
                 scene.ambientColor = BABYLON.Color3.FromArray(parsedData.ambientColor);
                 scene.gravity = BABYLON.Vector3.FromArray(parsedData.gravity);
 
+                // Fog
+                if (parsedData.fogMode && parsedData.fogMode !== 0) {
+                    scene.fogMode = parsedData.fogMode;
+                    scene.fogColor = BABYLON.Color3.FromArray(parsedData.fogColor);
+                    scene.fogStart = parsedData.fogStart;
+                    scene.fogEnd = parsedData.fogEnd;
+                    scene.fogDensity = parsedData.fogDensity;
+                }
+
                 // Lights
                 for (var index = 0; index < parsedData.lights.length; index++) {
                     var parsedLight = parsedData.lights[index];

+ 8 - 1
Babylon/babylon.engine.js

@@ -379,6 +379,13 @@
 
         this._gl.uniform3f(uniform, vector3.x, vector3.y, vector3.z);
     };
+    
+    BABYLON.Engine.prototype.setFloat3 = function (uniform, x, y, z) {
+        if (!uniform)
+            return;
+
+        this._gl.uniform3f(uniform, x, y, z);
+    };
 
     BABYLON.Engine.prototype.setBool = function (uniform, bool) {
         if (!uniform)
@@ -387,7 +394,7 @@
         this._gl.uniform1i(uniform, bool);
     };
 
-    BABYLON.Engine.prototype.setVector4 = function (uniform, x, y, z, w) {
+    BABYLON.Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
         if (!uniform)
             return;
 

+ 29 - 17
Babylon/babylon.scene.js

@@ -21,6 +21,13 @@
 
         this._onReadyCallbacks = [];
         this._pendingData = [];
+        
+        // Fog
+        this.fogMode = BABYLON.Scene.FOGMODE_NONE;
+        this.fogColor = new BABYLON.Color3(0.2, 0.2, 0.3);
+        this.fogDensity = 0.1;
+        this.fogStart = 0;
+        this.fogEnd = 1000.0;
 
         // Lights
         this.lights = [];
@@ -343,9 +350,10 @@
     BABYLON.Scene.prototype._localRender = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, activeMeshes) {
         var engine = this._engine;
         // Opaque
-        for (var subIndex = 0; subIndex < opaqueSubMeshes.length; subIndex++) {
-            var submesh = opaqueSubMeshes[subIndex];
-
+        var subIndex;
+        var submesh;
+        for (subIndex = 0; subIndex < opaqueSubMeshes.length; subIndex++) {
+            submesh = opaqueSubMeshes[subIndex];
             this._activeVertices += submesh.verticesCount;
 
             submesh.render();
@@ -353,9 +361,8 @@
 
         // Alpha test
         engine.setAlphaTesting(true);
-        for (var subIndex = 0; subIndex < alphaTestSubMeshes.length; subIndex++) {
-            var submesh = alphaTestSubMeshes[subIndex];
-
+        for (subIndex = 0; subIndex < alphaTestSubMeshes.length; subIndex++) {
+            submesh = alphaTestSubMeshes[subIndex];
             this._activeVertices += submesh.verticesCount;
 
             submesh.render();
@@ -375,9 +382,8 @@
 
         // Transparent
         engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
-        for (var subIndex = 0; subIndex < transparentSubMeshes.length; subIndex++) {
-            var submesh = transparentSubMeshes[subIndex];
-
+        for (subIndex = 0; subIndex < transparentSubMeshes.length; subIndex++) {
+            submesh = transparentSubMeshes[subIndex];
             this._activeVertices += submesh.verticesCount;
 
             submesh.render();
@@ -441,9 +447,10 @@
 
         // Backgrounds
         engine.setDepthBuffer(false);
-        for (var layerIndex = 0; layerIndex < this.layers.length; layerIndex++) {
-            var layer = this.layers[layerIndex];
-
+        var layerIndex;
+        var layer;
+        for (layerIndex = 0; layerIndex < this.layers.length; layerIndex++) {
+            layer = this.layers[layerIndex];
             if (layer.isBackground) {
                 layer.render();
             }
@@ -455,9 +462,8 @@
 
         // Foregrounds
         engine.setDepthBuffer(false);
-        for (var layerIndex = 0; layerIndex < this.layers.length; layerIndex++) {
-            var layer = this.layers[layerIndex];
-
+        for (layerIndex = 0; layerIndex < this.layers.length; layerIndex++) {
+            layer = this.layers[layerIndex];
             if (!layer.isBackground) {
                 layer.render();
             }
@@ -490,7 +496,8 @@
 
         // Detach cameras
         var canvas = this._engine.getRenderingCanvas();
-        for (var index = 0; index < this.cameras.length; index++) {
+        var index;
+        for (index = 0; index < this.cameras.length; index++) {
             this.cameras[index].detachControl(canvas);
         }
 
@@ -525,7 +532,7 @@
         }
 
         // Remove from engine
-        var index = this._engine.scenes.indexOf(this);
+        index = this._engine.scenes.indexOf(this);
         this._engine.scenes.splice(index, 1);
 
         this._engine.wipeCaches();
@@ -633,4 +640,9 @@
         return { hit: distance != Number.MAX_VALUE, distance: distance, pickedMesh: pickedMesh, pickedPoint: pickedPoint };
     };
 
+    // Statics
+    BABYLON.Scene.FOGMODE_NONE = 0;
+    BABYLON.Scene.FOGMODE_EXP = 1;
+    BABYLON.Scene.FOGMODE_EXP2 = 2;
+    BABYLON.Scene.FOGMODE_LINEAR = 3;
 })();

+ 40 - 0
Typescript/Animations/babylon.animation.d.ts

@@ -0,0 +1,40 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    class _Animatable {
+        target: Object;  
+        fromFrame: number;
+        toFrame: number;
+        loopAnimation: bool;
+        animationStartDate: Date;
+        speedRatio: number;
+
+        constructor(target: Object, from: number, to: number, loop: bool, speedRatio?: number);
+
+        _animate(): bool;
+    }
+
+    class Animation {
+        name: string;
+        targetPropertyPath: string[];
+        framePerSecond: number;
+        dataType: string;
+        loopMode: number;
+        _keys: number[];
+
+        constructor(name: string, targetProperty: string, framePerSecond: number, dataType: string, loopMode: number);
+
+        clone(): Animation;
+        setKeys(values: number[]);
+        _interpolate(currentFrame: number, repeatCount: number, loopMode: number, offsetValue: number, highLimitValue: number);
+        animate(target: Object, delay: number, from: number, to: number, loop: bool, speedRatio: number): bool;
+        
+        static ANIMATIONTYPE_FLOAT: number;
+        static ANIMATIONTYPE_VECTOR3: number;
+        static ANIMATIONTYPE_QUATERNION: number;
+
+        static ANIMATIONLOOPMODE_RELATIVE: number;
+        static ANIMATIONLOOPMODE_CYCLE: number;
+        static ANIMATIONLOOPMODE_CONSTANT: number;
+    }
+}

+ 71 - 0
Typescript/Cameras/babylon.camera.d.ts

@@ -0,0 +1,71 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    class Camera {
+        name: string;
+        id: string;
+        position: Vector3;
+        _scene: Scene;
+
+        constructor(name: string, position: Vector3, scene: Scene);
+
+        fov: number;
+        minZ: number;
+        maxZ: number;
+        intertia: number;
+
+        attachControl(canvas: HTMLCanvasElement): void;
+        detachControl(canvas: HTMLCanvasElement): void;
+        _update();
+        getViewMatrix(): Matrix;
+        getProjectionMatrix(): Matrix;
+    }
+
+    class FreeCamera extends Camera {
+        cameraDirection: Vector3;
+        cameraRotation: Vector2;
+        rotation: Vector3;
+        ellipsoid: Vector3;
+        _keys: number[];
+        keysUp: number[];
+        keysDown: number[];
+        keysLeft: number[];
+        keysRight: number[];
+        _collider: Collider;
+        _needsMoveForGravity: bool;
+        animations: Animation[];
+
+        constructor(name: string, position: Vector3, scene: Scene);
+
+        speed: number;
+        checkCollisions: bool;
+        applyGravity: bool;
+
+        _computeLocalCameraSpeed(): number;
+        setTarget(target: Vector3): void;
+        _collideWithWorld(velocity: Vector3): void;
+        _checkInputs();
+    }
+
+    class TouchCamera extends FreeCamera {
+        _offsetX: number;
+        _offsetY: number;
+        _pointerCount: number;
+        _pointerPressed: number[];
+
+        constructor(name: string, position: Vector3, scene: Scene);
+    }
+
+    class ArcRotateCamera extends Camera {
+        alpha: number;
+        beta: number;
+        radius: number;
+        target: Vector3;
+
+        constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
+
+        inertialAlphaOffset: number;
+        interialBetaOffset: number;
+        setPosition(position: Vector3): void;
+    }
+}

+ 34 - 0
Typescript/Collisions/babylon.collider.d.ts

@@ -0,0 +1,34 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    interface CollisionResponse {
+        position: Vector3;
+        velocity: Vector3;
+    }
+
+    class Collider {
+        radius: Vector3;
+        retry: number;
+
+        constructor();
+
+        _initialize(source: Vector3, dir: Vector3, e: number): void;
+        _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): bool;
+        _testTriangle(subMesh: SubMesh, p1: Vector3, p2: Vector3, p3: Vector3): void;
+        _collide(subMesh: SubMesh, pts: VertexBuffer, indices: IndexBuffer, indexStart: number, indexEnd: number, decal: number);
+        _getResponse(pos: Vector3, vel: Vector3): CollisionResponse;
+    }
+
+    class CollisionPlane {
+        normal: Vector3;
+        origin: Vector3;
+        equation: number[];
+
+        constructor(origin: Vector3, normal: Vector3);
+
+        isFrontFactingTo(direction: Vector3, epsilon: number): bool;
+        signedDistanceTo(point: Vector3): number;
+
+        static CreateFromPoints(p1: Vector3, p2: Vector3, p3: Vector3): CollisionPlane;
+    }
+}

+ 49 - 0
Typescript/Culling/babylon.bounding.d.ts

@@ -0,0 +1,49 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    class BoundingBox {
+        minimum: Vector3;
+        maximum: Vector3;
+        vectors: Vector3[];
+        center: Vector3;
+        extends: Vector3;
+        directions: Vector3[];
+
+        constructor(vertices: VertexBuffer, stride: number, start: number, count: number);
+
+        _update(world: Matrix): void;
+        isInFrustrum(frustrumPlanes: Plane[]): bool;
+        intersectsPoint(point: Vector3): bool;
+        
+        static intersects(box0: BoundingBox, box1: BoundingBox): bool;
+    }
+
+    class BoundingSphere {
+        minimum: Vector3;
+        maximum: Vector3;
+        center: Vector3;
+        radius: number;
+
+        constructor(vertices: VertexBuffer, stride: number, start: number, count: number);
+
+        _update(world: Matrix, scale: number): void;
+        isInFrustrum(frustrumPlanes: Plane[]): bool;
+        intersectsPoint(point: Vector3): bool;
+
+        static intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): bool;
+    }
+
+    class BoundingInfo {
+        boundingBox: BoundingBox;
+        boundingSphere: BoundingSphere;
+
+        constructor(vertices: VertexBuffer, stride: number, start: number, count: number);
+
+        _update(world: Matrix, scale: number): void;
+        isInFrustrum(frustrumPlanes: Plane[]): bool;
+        _checkCollision(collider: Collider): bool;
+        intersectsPoint(point: Vector3): bool;
+        intersects(boundingInfo: BoundingInfo, precise: bool): bool;
+
+    }
+}

+ 15 - 0
Typescript/Layer/babylon.layer.d.ts

@@ -0,0 +1,15 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    class Layer {
+        name: string;
+        texture: Texture;
+        isBackground: bool;
+
+        constructor(name: string, imgUrl: string, scene: Scene, isBackground: bool);
+
+        onDispose: () => void;
+        render(): void;
+        dispose(): void;
+    }
+}

+ 30 - 0
Typescript/Lights/babylon.light.d.ts

@@ -0,0 +1,30 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    class Light {
+        name: string;
+        id: string;
+        diffuse: Color3;
+        specular: Color3;
+        private _scene: Scene;
+
+        constructor(name: string, scene: Scene);
+
+        intensity: number;
+        isEnabled: bool;
+    }
+
+    class PointLight extends Light {
+        position: Vector3;
+        animations: Animation[]; 
+
+        constructor(name: string, position: Vector3, scene: Scene);
+    }
+
+    class DirectionalLight extends Light {
+        direction: Vector3;
+        animations: Animation[]; 
+
+        constructor(name: string, direction: Vector3, scene: Scene);
+    }
+}

+ 30 - 0
Typescript/Materials/babylon.effect.d.ts

@@ -0,0 +1,30 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    class Effect {
+        name: string;
+        defines: string;
+
+        constructor(baseName: string, attributesNames: string[], uniformsNames: string[], samplers: WebGLUniformLocation[], engine: Engine, defines: string);
+
+        isReady(): bool;
+        getProgram(): WebGLProgram;
+        getAttribute(index: number): string;
+        getAttributesCount(): number;
+        getUniformIndex(uniformName: string): number;
+        getUniform(uniformName: string): string;
+        getSamplers(): WebGLUniformLocation[];
+
+        _prepareEffect(vertexSourceCode: string, fragmentSourceCode: string, attributeNames: string[], defines: string): void;
+        setTexture(channel: string, texture: Texture): void;
+        setMatrix(uniformName: string, matrix: Matrix): void;
+        setBool(uniformName: string, val: bool): void;
+        setVector2(uniformName: string, x: number, y: number): void;
+        setVector3(uniformName: string, val: Vector3): void;
+        setVector4(uniformName: string, x: number, y: number, z: number, w: number): void;
+        setColor3(uniformName: string, color: Color3): void;
+        setColor4(uniformName: string, color: Color4): void;
+
+        static ShadersStore: Object;
+    }
+}

+ 52 - 0
Typescript/Materials/babylon.material.d.ts

@@ -0,0 +1,52 @@
+//// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    class Material {
+        name: string;
+        id: string;
+        private _scene: Scene;
+
+        constructor(name: string, scene: Scene);
+
+        alpha: number;
+        wireframe: bool;
+        backFaceCulling: bool;
+        _effect: Effect;
+
+        onDispose: () => void;
+
+        isReady(): bool;
+        getEffect(): Effect;
+        needAlphaBlending(): bool;
+        needAlphaTesting(): bool;
+
+        _preBind(): void;
+        bind(world: Matrix, mesh: Mesh): void;
+        unbind(): void;
+
+        dispose(): void;
+    }
+
+    class MultiMaterial extends Material {
+        constructor(name: string, scene: Scene);
+
+        getSubMaterial(index: number): Material;
+    }
+
+    class StandardMaterial extends Material {
+        diffuseTexture: Texture;
+        ambientTexture: Texture;
+        opacityTexture: Texture;
+        reflectionTexture: Texture;
+        emissiveTexture: Texture;
+        specularTexture: Texture;
+        ambientColor: Color3;
+        diffuseColor: Color3;
+        specularColor: Color3;
+        specularPower: number;
+        emissiveColor: Color3;
+
+        getRenderTargetTextures(): Texture[];
+        getAnimatables(): Texture[];
+    }
+}

+ 84 - 0
Typescript/Materials/textures/babylon.texture.d.ts

@@ -0,0 +1,84 @@
+/// <reference path="../../babylon.d.ts" />
+
+declare module BABYLON {
+    class BaseTexture {
+        _scene: Scene;
+
+        constructor(url: string, scene: Scene);
+
+        hasAlpha: bool;
+        level: number;
+        onDispose: () => void;
+        getInternalTexture(): BaseTexture;
+        isReady(): bool;
+        getSize(): Size2D;
+        getBaseSize(): Size2D;
+        _getFromCache(url: string, noMipmap: bool): BaseTexture;
+        dispose(): void;
+    }
+
+    class Texture extends BaseTexture {
+        name: string;
+
+        constructor(url: string, scene: Scene, noMipmap: bool, invertY: bool);
+
+        static EXPLICIT_MODE: number;
+        static SPHERICAL_MODE: number;
+        static PLANAR_MODE: number;
+        static CUBIC_MODE: number;
+        static PROJECTION_MODE: number;
+
+        uOffset: number;
+        vOffset: number;
+        uScale: number;
+        vScale: number;
+        uAng: number;
+        vAng: number;
+        wAng: number;
+        wrapU: bool;
+        wrapV: bool;
+        coordinatesIndex: number;
+        coordinatesMode: number;
+
+        _prepareRowForTextureGeneration(t: Vector3): Vector3;
+        _computeTextureMatrix(): Matrix;
+    }
+
+    class CubeTexture extends BaseTexture {
+        constructor(rootUrl: string, scene: Scene);
+    }
+
+    class DynamicTexture extends Texture {
+        wrapU: bool;
+        wrapV: bool;
+        _canvas: HTMLCanvasElement;
+        _context: CanvasRenderingContext2D;
+
+        constructor(name: string, size: Size2D, scene: Scene, generateMipMaps: bool);
+
+        getContext(): CanvasRenderingContext2D;
+        update(): void;
+    }
+
+    class RenderTargetTexture extends Texture {
+        constructor(name: string, size: Size2D, scene: Scene, generateMipMaps: bool);
+
+        renderList: any[];
+        isRenderTarget: bool;
+        coordinatesMode: number;
+
+        _onBeforeRender: () => void;
+        _onAfterRender: () => void;
+
+        render(): void;
+    }
+
+    class MirrorTexture extends RenderTargetTexture {
+        constructor(name: string, size: Size2D, scene: Scene, generateMipMaps: bool);
+
+        mirrorPlane: Plane;
+
+        _onBeforeRender: () => void;
+        _onAfterRender: () => void;
+    }
+}

+ 93 - 0
Typescript/Mesh/babylon.mesh.d.ts

@@ -0,0 +1,93 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    interface MeshRayHitTest { hit: bool; distance: number };
+
+    class Mesh {
+        name: string;
+        id: string;
+        private _scene: Scene;
+        private _vertexDeclaration: number[];
+        private _vertexStrideSize: number;
+        private _totalVertices: number;
+        private _worldMatrix: Matrix;
+        position: Vector3;
+        rotation: Vector3;
+        scaling: Vector3;
+        subMeshes: SubMesh[];
+        animations: Animation[];
+
+        constructor(name: string, vertexDeclaration: number[], scene: Scene);
+
+        static BILLBOARDMODE_NONE: number;
+        static BILLBOARDMODE_X: number;
+        static BILLBOARDMODE_Y: number;
+        static BILLBOARDMODE_Z: number;
+        static BILLBOARDMODE_ALL: number;
+
+        material: Material;
+        parent: Mesh;
+        _isEnabled: bool;
+        isVisible: bool;
+        visibility: number;
+        billboardMode: number;
+        checkCollisions: bool;
+
+        onDispose: () => void;
+
+        getScene(): Scene;
+        getWorldMatrix: Matrix;
+        getTotalVertices: number;
+        getVertices: VertexBuffer;
+        getVertexStride(): number;
+        getFloatVertexStrideSize(): number;
+        _needToSynchronizeChildren(): bool;
+        isSynchronized(): bool;
+        isEnabled(): bool;
+        setEnabled(value: bool): void;
+        isAnimated(): bool;
+        computeWorldMatrix(): Matrix;
+        _createGlobalSubMesh(): SubMesh;
+        setVertices(vertices: VertexBuffer, uvCount: number): void;
+        setIndices(indices: number[]): void;
+        render(subMesh: SubMesh): void;
+        isDescendantOf(ancestor: Mesh): bool;
+        getDescendants(): Mesh[];
+        getEmittedParticleSystems(): ParticleSystem[];
+        getHierarchyEmittedParticleSystems(): ParticleSystem[];
+        getChildren(): Mesh[];
+        isInFrustrum(frustumPlanes: Plane[]): bool;
+        setMaterialByID(id: string);
+        getAnimatables(): Material;
+
+        intersectsMesh(mesh: Mesh, precise: bool): bool;
+        intersectsPoint(point: Vector3): bool;
+        intersects(ray: Ray): MeshRayHitTest;
+        clone(name: string, newParent: Mesh): Mesh;
+
+        dispose(): void;
+
+        static createBox(name: string, size: number, scene: Scene): Mesh;
+        static createSphere(name: string, segments: number, diameter: number, scene: Scene): Mesh;
+        static createPlane(name: string, size: number, scene: Scene): Mesh;
+    }
+
+    class SubMesh {
+        materialIndex: number;
+        verticesStart: number;
+        verticesCount: number;
+        indexStart: number;
+        indexCount: number;
+
+        constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: Mesh);
+
+        getMaterial(): Material;
+        updateBoundingInfo(world: Matrix, scale: Vector3): void;
+        isInFrustrum(frustumPlanes: Plane[]): bool;
+        render(): void;
+        getLinesIndexBuffer(indices: number[], engine: Engine): IndexBuffer;
+        canIntersects(ray: Ray): bool;
+        intersects(ray: Ray, positions: Vector3[], indices: number[]): MeshRayHitTest;
+        clone(newMesh: Mesh): SubMesh;
+    }
+}

+ 68 - 0
Typescript/Particles/babylon.particle.d.ts

@@ -0,0 +1,68 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    class Particle {
+        position: Vector3;
+        direction: Vector3;
+        lifetime: number;
+        age: number;
+        size: number;
+        angle: number;
+        angularSpeed: number;
+        color: Color4;
+        colorStep: Color4;
+
+        constructor();
+
+    }
+
+    class ParticleSystem {
+        name: string;
+        id: string;
+        gravity: Vector3;
+        direction1: Vector3;
+        direction2: Vector3;
+        minEmitBox: Vector3;
+        maxEmitBox: Vector3;
+        color1: Color4;
+        color2: Color4;
+        colorDead: Color4;
+        deadAlpha: number;
+        textureMask: Color4;
+        particles: Particle[];
+
+        emitter: any; // needs update
+        emitRate: number;
+        manualEmitCount: number;
+        updateSpeed: number;
+        targetStopDuration: number;
+        disposeOnStop: bool;
+        minEmitPower: number;
+        maxEmitPower: number;
+        minLifeTime: number;
+        maxLifeTime: number;
+        minSize: number;
+        maxSize: number;
+        minAngularSpeed: number;
+        maxAngularSpeed: number;
+
+        particleTexture: Texture;
+
+        onDispose: () => void;
+
+        blendMode: number;
+
+        constructor(name: string, capacity: number, scene: Scene);
+
+        isAlive(): bool;
+        start(): void;
+        stop(): void;
+        animate(): void;
+        render(): number;
+        dispose(): void;
+        clone(name: string, newEmitter: any): ParticleSystem; // needs update (newEmitter)
+
+        static BLENDMODE_ONEONE: number;
+        static BLENDMODE_STANDARD: number;
+    }
+}

+ 32 - 0
Typescript/Sprites/Babylon.Sprite.d.ts

@@ -0,0 +1,32 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    class Sprite {
+        name: string;
+        position: Vector3;
+        size: number;
+        angle: number;
+        cellIndex: number;
+        invertU: number;
+        invertV: number;
+
+        constructor(name: string, manager: SpriteManager);
+
+        playAnimation(from: number, to: number, loop: bool, delay: number);
+        stopAnimation(): void;
+
+    }
+
+    class SpriteManager {
+        name: string;
+        cellSize: number;
+
+        constructor(name: string, imgUrl: string, capacity: number, cellSize: number, scene: Scene, epsilon: number);
+
+        onDispose: () => void;
+
+        render(): void;
+        dispose(): void;
+
+    }
+}

+ 234 - 0
Typescript/Tools/babylon.math.d.ts

@@ -0,0 +1,234 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON {
+    interface RayTriangleIntersection {
+        hit: bool;
+        distance: number;
+        bu: number;
+        bv: number;
+    }
+
+    interface IColor3 {
+        r: number;
+        g: number;
+        b: number;
+    }
+
+    interface Size2D 
+    {
+        width: number;
+        height: number;
+    }
+
+    interface Sphere {
+        center: Vector3;
+        radius: number;
+    }
+
+    class Ray {
+        origin: Vector3;
+        direction: Vector3;
+
+        constructor(origin: Vector3, direction: Vector3);
+
+        intersectsSphere(sphere: Sphere): bool;
+        intersectsTriangle(vertex0: Vector3,
+            vertex1: Vector3,
+            vertex2: Vector3): RayTriangleIntersection;
+
+        static CreateNew(x: number,
+            y: number,
+            viewportWidth: number,
+            viewportHeight: number,
+            world: Matrix,
+            view: Matrix,
+            projection: Matrix): Ray;
+
+    }
+
+    class Color3 implements IColor3 {
+        r: number;
+        g: number;
+        b: number;
+
+        constructor(intialR: number, initialG: number, initialB: number);
+
+        equals(otherColor: Color3): bool;
+        equals(otherColor: Color4): bool;
+        toString(): string;
+        clone(): Color3;
+
+        multiply(otherColor: Color3): Color3;
+        scale(scale: number): Color3;
+        
+        static FromArray(number[]): Color3;
+    }
+
+    class Color4 implements IColor3 {
+        r: number;
+        g: number;
+        b: number;
+        a: number;
+
+        constructor(initialR: number, initialG: number, initialB: number, initialA: number);
+
+        add(right: Color4): Color4;
+        subtract(right: Color4): Color4;
+        scale(factor: number): Color4;
+
+        toString(): string;
+        clone(): Color4;
+
+        static Lerp(left: number, right: number, amount: number): Color4;
+        static FromArray(number[]): Color4;
+
+    }
+
+    class Vector2 {
+        x: number;
+        y: number;
+
+        constructor(x: number, y: number);
+
+        toString(): string;
+
+        add(other: Vector2): Vector2;
+        subtract(other: Vector2): Vector2;
+        negate(): Vector2;
+        scale(factor: number): Vector2;
+        equals(other: Vector2): bool;
+        length(): number;
+        lengthSquared(): number;
+        normalize();
+        clone(): Vector2;
+
+        static Zero(): Vector2;
+        static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
+        static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
+        static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
+        static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
+        static Dot(left: Vector2, right: Vector2): number;
+        static Normalize(vector: Vector2): Vector2;
+        static Minimize(left: Vector2, right: Vector2): Vector2;
+        static Maximize(left: Vector2, right: Vector2): Vector2;
+        static Transform(vector: Vector2, transformation: number[]): Vector2;
+        static Distance(value1: Vector2, value2: Vector2): number;
+        static DistanceSquared(value1: Vector2, value2: Vector2): number;
+    }
+
+    class Vector3 {
+        x: number;
+        y: number;
+        z: number;
+
+        constructor(x: number, y: number, z: number);
+
+        toString(): string;
+
+        add(other: Vector3): Vector3;
+        subtract(other: Vector3): Vector3;
+        negate(): Vector3;
+        scale(factor: number): Vector3;
+        equals(other: Vector3): bool;
+        multiply(other: Vector3): Vector3;
+        divide(other: Vector3): Vector3;
+        length(): number;
+        lengthSquared(): number;
+        normalize();
+        clone(): Vector3;
+
+        static FromArray(array: number[], offset?: number = 0);
+        static Zero(): Vector3;
+        static Up(): Vector3;
+        static TransformCoordinates(vector: Vector3, transformation: Matrix);
+        static TransformNormal(vector: Vector3, transformation: Matrix);
+
+        static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
+        static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
+        static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
+        static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
+        static Dot(left: Vector3, right: Vector3): number;
+        static Normalize(vector: Vector3): Vector3;
+        static Unproject(source: Vector3,
+            viewportWidth: number,
+            viewportHeight: number,
+            world: Matrix,
+            view: Matrix,
+            projection: Matrix): Vector3;
+
+        static Minimize(left: Vector3, right: Vector3): Vector3;
+        static Maximize(left: Vector3, right: Vector3): Vector3;
+        static Distance(value1: Vector3, value2: Vector3): number;
+        static DistanceSquared(value1: Vector3, value2: Vector3): number;
+    }
+
+    class Quaternion {
+        x: number;
+        y: number;
+        z: number;
+        w: number;
+
+        constructor(x: number, y: number, z: number, w: number);
+
+        clone(): Quaternion;
+        add(other: Quaternion): Quaternion;
+        scale(factor: number): Quaternion;
+        toEulerAngles(): Vector3;
+
+        static FromArray(array: number[], offset?: number = 0): Quaternion;
+        static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
+    }
+
+    class Matrix {
+        m: number[];
+
+        constructor();
+
+        isIdentity(): bool;
+        determinant(): number;
+        toArray(): number[];
+        invert(): void;
+        multiply(other: Matrix): Matrix;
+        equals(other: Matrix): Matrix;
+        clone(): Matrix;
+
+        static FromValues(m11: number, m12: number, m13: number, m14: number,
+            m21: number, m22: number, m23: number, m24: number,
+            m31: number, m32: number, m33: number, m34: number,
+            m41: number, m42: number, m43: number, m44: number): Matrix;
+        static Identity(): Matrix;
+        static Zero(): Matrix;
+        static RotationX(angle: number): Matrix;
+        static RotationY(angle: number): Matrix;
+        static RotationZ(angle: number): Matrix;
+        static RotationAxis(axis: Vector3, angle: number): Matrix;
+        static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
+        static Scaling(scaleX: number, scaleY: number, scaleZ: number): Matrix;
+        static Translation(x: number, y: number, z: number): Matrix;
+        static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
+        static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
+        static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
+        static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
+        static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
+        static AffineTransformation(scaling: number, rotationCenter: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
+        static GetFinalMatrix(viewport: Size2D, world: Matrix, view: Matrix, projection: Matrix): Matrix;
+        static Transpose(matrix: Matrix): Matrix;
+        static Reflection(plane: Plane): Matrix;
+    }
+
+    class Plane {
+        normal: Vector3;
+        d: number;
+
+        normalize(): void;
+        transform(transformation: Matrix): Plane;
+        dotCoordinate(point: Vector3): number;
+
+        static FromArray(array: number[]): Plane;
+        static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
+    }
+
+    class Frustum {
+        static GetPlanes(transform: Matrix): Plane[];
+    }
+}

+ 5 - 0
Typescript/Tools/babylon.sceneLoader.d.ts

@@ -0,0 +1,5 @@
+/// <reference path="../babylon.d.ts" />
+declare module BABYLON.SceneLoader {
+    function ImportMesh(meshName: string, rootUrl: string, sceneFilename: string, scene: Scene, then: Function);
+    function Load(rootUrl: string, sceneFilename: string, engine: Engine, then: Function, progressCallback: Function);
+}

+ 14 - 0
Typescript/Tools/babylon.tools.d.ts

@@ -0,0 +1,14 @@
+/// <reference path="../babylon.d.ts" />
+
+declare module BABYLON.Tools {
+    function QueueNewFrame(func: Function): void;
+    function RequestFullscreen(element: HTMLElement): void;
+    function ExitFullscreen(): void;
+    var BaseUrl: string;
+    function LoadFile(url: string, callback: Function, progressCallback: Function): void;
+    function WithinEpsilon(a: number, b: number);
+    function DeepCopy(source: Object, destination: Object, doNotCopyList: string[], mustCopyList: string[]);
+    function GetFps(): number;
+    function GetDeltaTime(): number;
+    function _MeasureFps(): void;
+}

+ 4 - 0
Typescript/Tools/babylon.tools.dds.d.ts

@@ -0,0 +1,4 @@
+/// <reference path="../babylon.d.ts" />
+declare module BABYLON.Tools {
+    function LoadDDSTexture(gl: WebGLRenderingContext, ext: any, data: ArrayBuffer): number;
+}

+ 18 - 0
Typescript/babylon.d.ts

@@ -0,0 +1,18 @@
+/// <reference path="babylon.engine.d.ts" />
+/// <reference path="babylon.scene.d.ts" />
+/// <reference path="tools/babylon.math.d.ts" />
+/// <reference path="tools/babylon.sceneLoader.d.ts" />
+/// <reference path="tools/babylon.tools.d.ts" />
+/// <reference path="tools/babylon.tools.dds.d.ts" />
+/// <reference path="sprites/babylon.sprite.d.ts" />
+/// <reference path="particles/babylon.particle.d.ts" />
+/// <reference path="mesh/babylon.mesh.d.ts" />
+/// <reference path="materials/babylon.effect.d.ts" />
+/// <reference path="materials/babylon.material.d.ts" />
+/// <reference path="materials/textures/babylon.texture.d.ts" />
+/// <reference path="mesh/babylon.mesh.d.ts" />
+/// <reference path="lights/babylon.light.d.ts" />
+/// <reference path="layer/babylon.layer.d.ts" />
+/// <reference path="collisions/babylon.collider.d.ts" />
+/// <reference path="cameras/babylon.camera.d.ts" />
+/// <reference path="animations/babylon.animation.d.ts" />

+ 108 - 0
Typescript/babylon.engine.d.ts

@@ -0,0 +1,108 @@
+/// <reference path="babylon.d.ts" />
+
+interface WebGLProgram {
+
+}
+
+interface WebGLShader {
+
+}
+
+interface WebGLUniformLocation {
+
+}
+
+interface WebGLRenderingContext {
+
+}
+
+interface VertexBuffer {
+    [index: number]: number;
+}
+
+interface IndexBuffer {
+    [index: number]: number;
+}
+
+declare module BABYLON {
+    interface Capabilities {
+        maxTexturesImageUnits: number;
+        maxTextureSize: number;
+        maxCubemapTextureSize: number;
+        maxRenderTextureSize: number;
+    }
+
+    class Engine {
+        constructor(canvas: HTMLCanvasElement, antialias: boolean);
+
+        getAspectRatio(): number; 
+        getRenderWidth(): number;
+        getRenderHeight(): number;
+        getRenderingCanvas(): HTMLCanvasElement;
+        setHardwareScalingLevel(level: number): void;
+        getLoadedTexturesCache(): Texture[]; 
+        getCaps(): Capabilities;
+
+        switchFullscreen(element: HTMLElement);
+        clear(color: IColor3, backBuffer: bool, depthStencil: bool);
+
+        beginFrame(): void;
+        endFrame(): void;
+        resize(): void;
+        bindFramebuffer(texture: Texture);
+        unBindFramebuffer(texture: Texture);
+        flushFramebuffer(): void;
+        restoreDefaultFramebuffer(): void;
+
+        createVertexBuffer(vertices: number[]): VertexBuffer;
+        createVertexBuffer(vertices: ArrayBuffer): VertexBuffer;
+        createVertexBuffer(vertices: ArrayBufferView): VertexBuffer;
+        createDynamicVertexBuffer(capacity: number): VertexBuffer;
+        updateDynamicVertexBuffer(vertexBuffer: VertexBuffer, vertices: number[]): void; 
+        updateDynamicVertexBuffer(vertexBuffer: VertexBuffer, vertices: ArrayBuffer): void; 
+        updateDynamicVertexBuffer(vertexBuffer: VertexBuffer, vertices: ArrayBufferView): void; 
+        createIndexBuffer(indices, is32Bits): IndexBuffer;
+        bindBuffers(vb: VertexBuffer, ib: IndexBuffer, vdecl: number[], strideSize: number, effect: Effect);
+        _releaseBuffer(vb: VertexBuffer);
+        draw(useTriangles: bool, indexStart: number, indexCount: number);
+        createEffect(baseName: string, attributesNames: string, uniformsNames: string[],
+            samplers: WebGLUniformLocation[],
+            defines: string): Effect; 
+        createShaderProgram(vertexCode: string, fragmentCode: string, defines: string): WebGLProgram;
+        getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
+        getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[]; 
+        enableEffect(effect: Effect): void;
+        setMatrix(uniform: string, matrix: Matrix): void; 
+        setVector2(uniform: string, x: number, y: number): void;  
+        setVector3(uniform: string, v: Vector3): void; 
+        setBool(uniform: string, val: bool): void;
+        setVector4(uniform: string, x: number, y: number, z: number, w: number): void;
+        setColor3(uniform: string, color: Color3): void; 
+        setColor4(uniform: string, color: Color3, alpha: number): void; 
+        setState(cullingMode: number): void;
+        setDepthBuffer(enable: bool): void;
+        setDepthWrite(enable: bool): void;
+        setColorWrite(enable: bool): void;
+        setAlphaMode(mode: number): void;
+        setAlphaTesting(enable: bool): void;
+        getAlphaTesting(): bool;
+        wipeCaches(): void;
+        createTexture(url: string, noMipmap: bool, invertY: bool): Texture;
+        createDynamicTexture(size: number, noMipmap: bool): Texture;
+        updateDynamicTexture(texture: Texture, canvas: HTMLCanvasElement): void;
+        createRenderTargetTexture(size: number, generateMipMaps: bool): Texture;
+        createCubeTexture(rootUrl: string): Texture;
+        _releaseTexture(tex: Texture): void;
+        bindSamplers(effect: Effect): void;
+        setTexture(channel: number, texture: Texture): void; 
+        dispose(): void;
+
+        static ShadersRepository: string;
+        static ALPHA_DISABLE: number;
+        static ALPHA_ADD: number;
+        static ALPHA_COMBINE: number;
+        static epsilon: number;
+        static collisionEpsilon: number;
+        static isSupported(): bool;
+    }
+}

+ 976 - 0
Typescript/babylon.min.d.ts

@@ -0,0 +1,976 @@
+// babylon.engine.d.ts
+interface WebGLProgram {
+
+}
+
+interface WebGLShader {
+
+}
+
+interface WebGLUniformLocation {
+
+}
+
+interface WebGLRenderingContext {
+
+}
+
+interface VertexBuffer {
+    [index: number]: number;
+}
+
+interface IndexBuffer {
+    [index: number]: number;
+}
+
+declare module BABYLON {
+    interface Capabilities {
+        maxTexturesImageUnits: number;
+        maxTextureSize: number;
+        maxCubemapTextureSize: number;
+        maxRenderTextureSize: number;
+    }
+
+    class Engine {
+        constructor(canvas: HTMLCanvasElement, antialias: boolean);
+
+        getAspectRatio(): number;
+        getRenderWidth(): number;
+        getRenderHeight(): number;
+        getRenderingCanvas(): HTMLCanvasElement;
+        setHardwareScalingLevel(level: number): void;
+        getLoadedTexturesCache(): Texture[];
+        getCaps(): Capabilities;
+
+        switchFullscreen(element: HTMLElement);
+        clear(color: IColor3, backBuffer: bool, depthStencil: bool);
+
+        beginFrame(): void;
+        endFrame(): void;
+        resize(): void;
+        bindFramebuffer(texture: Texture);
+        unBindFramebuffer(texture: Texture);
+        flushFramebuffer(): void;
+        restoreDefaultFramebuffer(): void;
+
+        createVertexBuffer(vertices: number[]): VertexBuffer;
+        createVertexBuffer(vertices: ArrayBuffer): VertexBuffer;
+        createVertexBuffer(vertices: ArrayBufferView): VertexBuffer;
+        createDynamicVertexBuffer(capacity: number): VertexBuffer;
+        updateDynamicVertexBuffer(vertexBuffer: VertexBuffer, vertices: number[]): void;
+        updateDynamicVertexBuffer(vertexBuffer: VertexBuffer, vertices: ArrayBuffer): void;
+        updateDynamicVertexBuffer(vertexBuffer: VertexBuffer, vertices: ArrayBufferView): void;
+        createIndexBuffer(indices, is32Bits): IndexBuffer;
+        bindBuffers(vb: VertexBuffer, ib: IndexBuffer, vdecl: number[], strideSize: number, effect: Effect);
+        _releaseBuffer(vb: VertexBuffer);
+        draw(useTriangles: bool, indexStart: number, indexCount: number);
+        createEffect(baseName: string, attributesNames: string, uniformsNames: string[],
+            samplers: WebGLUniformLocation[],
+            defines: string): Effect;
+        createShaderProgram(vertexCode: string, fragmentCode: string, defines: string): WebGLProgram;
+        getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
+        getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
+        enableEffect(effect: Effect): void;
+        setMatrix(uniform: string, matrix: Matrix): void;
+        setVector2(uniform: string, x: number, y: number): void;
+        setVector3(uniform: string, v: Vector3): void;
+        setBool(uniform: string, val: bool): void;
+        setVector4(uniform: string, x: number, y: number, z: number, w: number): void;
+        setColor3(uniform: string, color: Color3): void;
+        setColor4(uniform: string, color: Color3, alpha: number): void;
+        setState(cullingMode: number): void;
+        setDepthBuffer(enable: bool): void;
+        setDepthWrite(enable: bool): void;
+        setColorWrite(enable: bool): void;
+        setAlphaMode(mode: number): void;
+        setAlphaTesting(enable: bool): void;
+        getAlphaTesting(): bool;
+        wipeCaches(): void;
+        createTexture(url: string, noMipmap: bool, invertY: bool): Texture;
+        createDynamicTexture(size: number, noMipmap: bool): Texture;
+        updateDynamicTexture(texture: Texture, canvas: HTMLCanvasElement): void;
+        createRenderTargetTexture(size: number, generateMipMaps: bool): Texture;
+        createCubeTexture(rootUrl: string): Texture;
+        _releaseTexture(tex: Texture): void;
+        bindSamplers(effect: Effect): void;
+        setTexture(channel: number, texture: Texture): void;
+        dispose(): void;
+
+        static ShadersRepository: string;
+        static ALPHA_DISABLE: number;
+        static ALPHA_ADD: number;
+        static ALPHA_COMBINE: number;
+        static epsilon: number;
+        static collisionEpsilon: number;
+        static isSupported(): bool;
+    }
+
+    // babylon.scene.d.ts
+    interface ScenePickResult {
+        hit: bool;
+        distance: number;
+        pickedMesh: Mesh;
+        pickedPoint: Vector3;
+    }
+    class Scene {
+        constructor(engine: Engine);
+
+        getEngine(): Engine;
+        getTotalVertices(): number;
+        getActiveVertices(): number;
+        getActiveParticles(): number;
+        getLastFrameDuration(): number;
+        getEvaluateActiveMeshesDuration(): number;
+        getRenderTargetsDuration(): number;
+        getRenderDuration(): number;
+        getParticlesDuration(): number;
+        getSpritesDuration(): number;
+        getAnimationRatio(): number;
+
+        isReady(): bool;
+        executeWhenReady(func: Function): void;
+        // TODO: Animations
+        getViewMatrix(): Matrix;
+        getProjectionMatrix(): Matrix;
+        getTransformMatrix(): Matrix;
+        setTransformMatrix(view: Matrix, projection: Matrix);
+        activeCameraByID(id: number): void;
+        getMaterialByID(id: number): Material;
+        getMeshByID(id: number): Mesh;
+        getLastMeshByID(id: number): Mesh;
+        getMeshByName(name: string): Mesh;
+        isActiveMesh(mesh: Mesh): bool;
+        _evaluateActiveMeshes(): void;
+        _localRender(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, activeMeshes);
+        render();
+        dispose();
+        _getNewPosition(position: Vector3, velocity: Vector3, collider: Sphere, maximumRetries: number): Vector3;
+        _collideWithWorld(position: Vector3, velocity: Vector3, collider: Sphere, maximumRetries: number): Vector3;
+        createPickingRay(x: number, y: number, world: Matrix): Ray;
+        pick(x: number, y: number): ScenePickResult;
+    }
+
+    // babylon.math.d.ts
+    interface RayTriangleIntersection {
+        hit: bool;
+        distance: number;
+        bu: number;
+        bv: number;
+    }
+
+    interface IColor3 {
+        r: number;
+        g: number;
+        b: number;
+    }
+
+    interface Size2D {
+        width: number;
+        height: number;
+    }
+
+    interface Sphere {
+        center: Vector3;
+        radius: number;
+    }
+
+    class Ray {
+        origin: Vector3;
+        direction: Vector3;
+
+        constructor(origin: Vector3, direction: Vector3);
+
+        intersectsSphere(sphere: Sphere): bool;
+        intersectsTriangle(vertex0: Vector3,
+            vertex1: Vector3,
+            vertex2: Vector3): RayTriangleIntersection;
+
+        static CreateNew(x: number,
+            y: number,
+            viewportWidth: number,
+            viewportHeight: number,
+            world: Matrix,
+            view: Matrix,
+            projection: Matrix): Ray;
+
+    }
+
+    class Color3 implements IColor3 {
+        r: number;
+        g: number;
+        b: number;
+
+        constructor(intialR: number, initialG: number, initialB: number);
+
+        equals(otherColor: Color3): bool;
+        equals(otherColor: Color4): bool;
+        toString(): string;
+        clone(): Color3;
+
+        multiply(otherColor: Color3): Color3;
+        scale(scale: number): Color3;
+
+        static FromArray(values: number[]): Color3;
+    }
+
+    class Color4 implements IColor3 {
+        r: number;
+        g: number;
+        b: number;
+        a: number;
+
+        constructor(initialR: number, initialG: number, initialB: number, initialA: number);
+
+        add(right: Color4): Color4;
+        subtract(right: Color4): Color4;
+        scale(factor: number): Color4;
+
+        toString(): string;
+        clone(): Color4;
+
+        static Lerp(left: number, right: number, amount: number): Color4;
+        static FromArray(values: number[]): Color4;
+
+    }
+
+    class Vector2 {
+        x: number;
+        y: number;
+
+        constructor(x: number, y: number);
+
+        toString(): string;
+
+        add(other: Vector2): Vector2;
+        subtract(other: Vector2): Vector2;
+        negate(): Vector2;
+        scale(factor: number): Vector2;
+        equals(other: Vector2): bool;
+        length(): number;
+        lengthSquared(): number;
+        normalize();
+        clone(): Vector2;
+
+        static Zero(): Vector2;
+        static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
+        static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
+        static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
+        static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
+        static Dot(left: Vector2, right: Vector2): number;
+        static Normalize(vector: Vector2): Vector2;
+        static Minimize(left: Vector2, right: Vector2): Vector2;
+        static Maximize(left: Vector2, right: Vector2): Vector2;
+        static Transform(vector: Vector2, transformation: number[]): Vector2;
+        static Distance(value1: Vector2, value2: Vector2): number;
+        static DistanceSquared(value1: Vector2, value2: Vector2): number;
+    }
+
+    class Vector3 {
+        x: number;
+        y: number;
+        z: number;
+
+        constructor(x: number, y: number, z: number);
+
+        toString(): string;
+
+        add(other: Vector3): Vector3;
+        subtract(other: Vector3): Vector3;
+        negate(): Vector3;
+        scale(factor: number): Vector3;
+        equals(other: Vector3): bool;
+        multiply(other: Vector3): Vector3;
+        divide(other: Vector3): Vector3;
+        length(): number;
+        lengthSquared(): number;
+        normalize();
+        clone(): Vector3;
+
+        static FromArray(array: number[], offset?: number);
+        static Zero(): Vector3;
+        static Up(): Vector3;
+        static TransformCoordinates(vector: Vector3, transformation: Matrix);
+        static TransformNormal(vector: Vector3, transformation: Matrix);
+
+        static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
+        static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
+        static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
+        static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
+        static Dot(left: Vector3, right: Vector3): number;
+        static Normalize(vector: Vector3): Vector3;
+        static Unproject(source: Vector3,
+            viewportWidth: number,
+            viewportHeight: number,
+            world: Matrix,
+            view: Matrix,
+            projection: Matrix): Vector3;
+
+        static Minimize(left: Vector3, right: Vector3): Vector3;
+        static Maximize(left: Vector3, right: Vector3): Vector3;
+        static Distance(value1: Vector3, value2: Vector3): number;
+        static DistanceSquared(value1: Vector3, value2: Vector3): number;
+    }
+
+    class Quaternion {
+        x: number;
+        y: number;
+        z: number;
+        w: number;
+
+        constructor(x: number, y: number, z: number, w: number);
+
+        clone(): Quaternion;
+        add(other: Quaternion): Quaternion;
+        scale(factor: number): Quaternion;
+        toEulerAngles(): Vector3;
+
+        static FromArray(array: number[], offset?: number): Quaternion;
+        static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
+    }
+
+    class Matrix {
+        m: number[];
+
+        constructor();
+
+        isIdentity(): bool;
+        determinant(): number;
+        toArray(): number[];
+        invert(): void;
+        multiply(other: Matrix): Matrix;
+        equals(other: Matrix): Matrix;
+        clone(): Matrix;
+
+        static FromValues(m11: number, m12: number, m13: number, m14: number,
+            m21: number, m22: number, m23: number, m24: number,
+            m31: number, m32: number, m33: number, m34: number,
+            m41: number, m42: number, m43: number, m44: number): Matrix;
+        static Identity(): Matrix;
+        static Zero(): Matrix;
+        static RotationX(angle: number): Matrix;
+        static RotationY(angle: number): Matrix;
+        static RotationZ(angle: number): Matrix;
+        static RotationAxis(axis: Vector3, angle: number): Matrix;
+        static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
+        static Scaling(scaleX: number, scaleY: number, scaleZ: number): Matrix;
+        static Translation(x: number, y: number, z: number): Matrix;
+        static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
+        static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
+        static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
+        static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
+        static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
+        static AffineTransformation(scaling: number, rotationCenter: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
+        static GetFinalMatrix(viewport: Size2D, world: Matrix, view: Matrix, projection: Matrix): Matrix;
+        static Transpose(matrix: Matrix): Matrix;
+        static Reflection(plane: Plane): Matrix;
+    }
+
+    class Plane {
+        normal: Vector3;
+        d: number;
+
+        normalize(): void;
+        transform(transformation: Matrix): Plane;
+        dotCoordinate(point: Vector3): number;
+
+        static FromArray(array: number[]): Plane;
+        static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
+    }
+
+    class Frustum {
+        static GetPlanes(transform: Matrix): Plane[];
+    }
+
+    // babylon.tools.d.ts
+    function QueueNewFrame(func: Function): void;
+    function RequestFullscreen(element: HTMLElement): void;
+    function ExitFullscreen(): void;
+    var BaseUrl: string;
+    function LoadFile(url: string, callback: Function, progressCallback: Function): void;
+    function WithinEpsilon(a: number, b: number);
+    function DeepCopy(source: Object, destination: Object, doNotCopyList: string[], mustCopyList: string[]);
+    function GetFps(): number;
+    function GetDeltaTime(): number;
+    function _MeasureFps(): void;
+
+    //babylon.tools.dds.d.ts
+    function LoadDDSTexture(gl: WebGLRenderingContext, ext: any, data: ArrayBuffer): number; 
+
+    //babylon.sceneLoader.d.ts
+    function ImportMesh(meshName: string, rootUrl: string, sceneFilename: string, scene: Scene, then: Function);
+    function Load(rootUrl: string, sceneFilename: string, engine: Engine, then: Function, progressCallback: Function);
+
+    // babylon.animation.d.ts
+    class _Animatable {
+        target: Object;
+        fromFrame: number;
+        toFrame: number;
+        loopAnimation: bool;
+        animationStartDate: Date;
+        speedRatio: number;
+
+        constructor(target: Object, from: number, to: number, loop: bool, speedRatio?: number);
+
+        _animate(): bool;
+    }
+
+    class Animation {
+        name: string;
+        targetPropertyPath: string[];
+        framePerSecond: number;
+        dataType: string;
+        loopMode: number;
+        _keys: number[];
+
+        constructor(name: string, targetProperty: string, framePerSecond: number, dataType: string, loopMode: number);
+
+        clone(): Animation;
+        setKeys(values: number[]);
+        _interpolate(currentFrame: number, repeatCount: number, loopMode: number, offsetValue: number, highLimitValue: number);
+        animate(target: Object, delay: number, from: number, to: number, loop: bool, speedRatio: number): bool;
+
+        static ANIMATIONTYPE_FLOAT: number;
+        static ANIMATIONTYPE_VECTOR3: number;
+        static ANIMATIONTYPE_QUATERNION: number;
+
+        static ANIMATIONLOOPMODE_RELATIVE: number;
+        static ANIMATIONLOOPMODE_CYCLE: number;
+        static ANIMATIONLOOPMODE_CONSTANT: number;
+    }
+
+    // babylon.camera.d.ts
+    class Camera {
+        name: string;
+        id: string;
+        position: Vector3;
+        _scene: Scene;
+
+        constructor(name: string, position: Vector3, scene: Scene);
+
+        fov: number;
+        minZ: number;
+        maxZ: number;
+        intertia: number;
+
+        attachControl(canvas: HTMLCanvasElement): void;
+        detachControl(canvas: HTMLCanvasElement): void;
+        _update();
+        getViewMatrix(): Matrix;
+        getProjectionMatrix(): Matrix;
+    }
+
+    class FreeCamera extends Camera {
+        cameraDirection: Vector3;
+        cameraRotation: Vector2;
+        rotation: Vector3;
+        ellipsoid: Vector3;
+        _keys: number[];
+        keysUp: number[];
+        keysDown: number[];
+        keysLeft: number[];
+        keysRight: number[];
+        _collider: Collider;
+        _needsMoveForGravity: bool;
+        animations: Animation[];
+
+        constructor(name: string, position: Vector3, scene: Scene);
+
+        speed: number;
+        checkCollisions: bool;
+        applyGravity: bool;
+
+        _computeLocalCameraSpeed(): number;
+        setTarget(target: Vector3): void;
+        _collideWithWorld(velocity: Vector3): void;
+        _checkInputs();
+    }
+
+    class TouchCamera extends FreeCamera {
+        _offsetX: number;
+        _offsetY: number;
+        _pointerCount: number;
+        _pointerPressed: number[];
+
+        constructor(name: string, position: Vector3, scene: Scene);
+    }
+
+    class ArcRotateCamera extends Camera {
+        alpha: number;
+        beta: number;
+        radius: number;
+        target: Vector3;
+
+        constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
+
+        inertialAlphaOffset: number;
+        interialBetaOffset: number;
+        setPosition(position: Vector3): void;
+    }
+
+    // babylon.collider.d.ts
+    interface CollisionResponse {
+        position: Vector3;
+        velocity: Vector3;
+    }
+
+    class Collider {
+        radius: Vector3;
+        retry: number;
+
+        constructor();
+
+        _initialize(source: Vector3, dir: Vector3, e: number): void;
+        _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): bool;
+        _testTriangle(subMesh: SubMesh, p1: Vector3, p2: Vector3, p3: Vector3): void;
+        _collide(subMesh: SubMesh, pts: VertexBuffer, indices: IndexBuffer, indexStart: number, indexEnd: number, decal: number);
+        _getResponse(pos: Vector3, vel: Vector3): CollisionResponse;
+    }
+
+    class CollisionPlane {
+        normal: Vector3;
+        origin: Vector3;
+        equation: number[];
+
+        constructor(origin: Vector3, normal: Vector3);
+
+        isFrontFactingTo(direction: Vector3, epsilon: number): bool;
+        signedDistanceTo(point: Vector3): number;
+
+        static CreateFromPoints(p1: Vector3, p2: Vector3, p3: Vector3): CollisionPlane;
+    }
+
+    // babylon.bounding.d.ts
+    class BoundingBox {
+        minimum: Vector3;
+        maximum: Vector3;
+        vectors: Vector3[];
+        center: Vector3;
+        extends: Vector3;
+        directions: Vector3[];
+
+        constructor(vertices: VertexBuffer, stride: number, start: number, count: number);
+
+        _update(world: Matrix): void;
+        isInFrustrum(frustrumPlanes: Plane[]): bool;
+        intersectsPoint(point: Vector3): bool;
+
+        static intersects(box0: BoundingBox, box1: BoundingBox): bool;
+    }
+
+    class BoundingSphere {
+        minimum: Vector3;
+        maximum: Vector3;
+        center: Vector3;
+        radius: number;
+
+        constructor(vertices: VertexBuffer, stride: number, start: number, count: number);
+
+        _update(world: Matrix, scale: number): void;
+        isInFrustrum(frustrumPlanes: Plane[]): bool;
+        intersectsPoint(point: Vector3): bool;
+
+        static intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): bool;
+    }
+
+    class BoundingInfo {
+        boundingBox: BoundingBox;
+        boundingSphere: BoundingSphere;
+
+        constructor(vertices: VertexBuffer, stride: number, start: number, count: number);
+
+        _update(world: Matrix, scale: number): void;
+        isInFrustrum(frustrumPlanes: Plane[]): bool;
+        _checkCollision(collider: Collider): bool;
+        intersectsPoint(point: Vector3): bool;
+        intersects(boundingInfo: BoundingInfo, precise: bool): bool;
+
+    }
+
+    // babylon.layer.d.ts
+    class Layer {
+        name: string;
+        texture: Texture;
+        isBackground: bool;
+
+        constructor(name: string, imgUrl: string, scene: Scene, isBackground: bool);
+
+        onDispose: () => void;
+        render(): void;
+        dispose(): void;
+    }
+
+    // babylon.light.d.ts
+    class Light {
+        name: string;
+        id: string;
+        diffuse: Color3;
+        specular: Color3;
+        private _scene: Scene;
+
+        constructor(name: string, scene: Scene);
+
+        intensity: number;
+        isEnabled: bool;
+    }
+
+    class PointLight extends Light {
+        position: Vector3;
+        animations: Animation[];
+
+        constructor(name: string, position: Vector3, scene: Scene);
+    }
+
+    class DirectionalLight extends Light {
+        direction: Vector3;
+        animations: Animation[];
+
+        constructor(name: string, direction: Vector3, scene: Scene);
+    }
+
+    // babylon.effect.d.ts
+    class Effect {
+        name: string;
+        defines: string;
+
+        constructor(baseName: string, attributesNames: string[], uniformsNames: string[], samplers: WebGLUniformLocation[], engine: Engine, defines: string);
+
+        isReady(): bool;
+        getProgram(): WebGLProgram;
+        getAttribute(index: number): string;
+        getAttributesCount(): number;
+        getUniformIndex(uniformName: string): number;
+        getUniform(uniformName: string): string;
+        getSamplers(): WebGLUniformLocation[];
+
+        _prepareEffect(vertexSourceCode: string, fragmentSourceCode: string, attributeNames: string[], defines: string): void;
+        setTexture(channel: string, texture: Texture): void;
+        setMatrix(uniformName: string, matrix: Matrix): void;
+        setBool(uniformName: string, val: bool): void;
+        setVector2(uniformName: string, x: number, y: number): void;
+        setVector3(uniformName: string, val: Vector3): void;
+        setVector4(uniformName: string, x: number, y: number, z: number, w: number): void;
+        setColor3(uniformName: string, color: Color3): void;
+        setColor4(uniformName: string, color: Color4): void;
+
+        static ShadersStore: Object;
+    }
+
+    // babylon.material.d.ts
+    class Material {
+        name: string;
+        id: string;
+        private _scene: Scene;
+
+        constructor(name: string, scene: Scene);
+
+        alpha: number;
+        wireframe: bool;
+        backFaceCulling: bool;
+        _effect: Effect;
+
+        onDispose: () => void;
+
+        isReady(): bool;
+        getEffect(): Effect;
+        needAlphaBlending(): bool;
+        needAlphaTesting(): bool;
+
+        _preBind(): void;
+        bind(world: Matrix, mesh: Mesh): void;
+        unbind(): void;
+
+        dispose(): void;
+    }
+
+    class MultiMaterial extends Material {
+        constructor(name: string, scene: Scene);
+
+        getSubMaterial(index: number): Material;
+    }
+
+    class StandardMaterial extends Material {
+        diffuseTexture: Texture;
+        ambientTexture: Texture;
+        opacityTexture: Texture;
+        reflectionTexture: Texture;
+        emissiveTexture: Texture;
+        specularTexture: Texture;
+        ambientColor: Color3;
+        diffuseColor: Color3;
+        specularColor: Color3;
+        specularPower: number;
+        emissiveColor: Color3;
+
+        getRenderTargetTextures(): Texture[];
+        getAnimatables(): Texture[];
+    }
+
+    // babylon.texture.d.ts
+    class BaseTexture {
+        _scene: Scene;
+
+        constructor(url: string, scene: Scene);
+
+        hasAlpha: bool;
+        level: number;
+        onDispose: () => void;
+        getInternalTexture(): BaseTexture;
+        isReady(): bool;
+        getSize(): Size2D;
+        getBaseSize(): Size2D;
+        _getFromCache(url: string, noMipmap: bool): BaseTexture;
+        dispose(): void;
+    }
+
+    class Texture extends BaseTexture {
+        name: string;
+
+        constructor(url: string, scene: Scene, noMipmap: bool, invertY: bool);
+
+        static EXPLICIT_MODE: number;
+        static SPHERICAL_MODE: number;
+        static PLANAR_MODE: number;
+        static CUBIC_MODE: number;
+        static PROJECTION_MODE: number;
+
+        uOffset: number;
+        vOffset: number;
+        uScale: number;
+        vScale: number;
+        uAng: number;
+        vAng: number;
+        wAng: number;
+        wrapU: bool;
+        wrapV: bool;
+        coordinatesIndex: number;
+        coordinatesMode: number;
+
+        _prepareRowForTextureGeneration(t: Vector3): Vector3;
+        _computeTextureMatrix(): Matrix;
+    }
+
+    class CubeTexture extends BaseTexture {
+        constructor(rootUrl: string, scene: Scene);
+    }
+
+    class DynamicTexture extends Texture {
+        wrapU: bool;
+        wrapV: bool;
+        _canvas: HTMLCanvasElement;
+        _context: CanvasRenderingContext2D;
+
+        constructor(name: string, size: Size2D, scene: Scene, generateMipMaps: bool);
+
+        getContext(): CanvasRenderingContext2D;
+        update(): void;
+    }
+
+    class RenderTargetTexture extends Texture {
+        constructor(name: string, size: Size2D, scene: Scene, generateMipMaps: bool);
+
+        renderList: any[];
+        isRenderTarget: bool;
+        coordinatesMode: number;
+
+        _onBeforeRender: () => void;
+        _onAfterRender: () => void;
+
+        render(): void;
+    }
+
+    class MirrorTexture extends RenderTargetTexture {
+        constructor(name: string, size: Size2D, scene: Scene, generateMipMaps: bool);
+
+        mirrorPlane: Plane;
+
+        _onBeforeRender: () => void;
+        _onAfterRender: () => void;
+    }
+
+    // babylon.mesh.d.ts
+    interface MeshRayHitTest { hit: bool; distance: number }
+
+    class Mesh {
+        name: string;
+        id: string;
+        private _scene: Scene;
+        private _vertexDeclaration: number[];
+        private _vertexStrideSize: number;
+        private _totalVertices: number;
+        private _worldMatrix: Matrix;
+        position: Vector3;
+        rotation: Vector3;
+        scaling: Vector3;
+        subMeshes: SubMesh[];
+        animations: Animation[];
+
+        constructor(name: string, vertexDeclaration: number[], scene: Scene);
+
+        static BILLBOARDMODE_NONE: number;
+        static BILLBOARDMODE_X: number;
+        static BILLBOARDMODE_Y: number;
+        static BILLBOARDMODE_Z: number;
+        static BILLBOARDMODE_ALL: number;
+
+        material: Material;
+        parent: Mesh;
+        _isEnabled: bool;
+        isVisible: bool;
+        visibility: number;
+        billboardMode: number;
+        checkCollisions: bool;
+
+        onDispose: () => void;
+
+        getScene(): Scene;
+        getWorldMatrix: Matrix;
+        getTotalVertices: number;
+        getVertices: VertexBuffer;
+        getVertexStride(): number;
+        getFloatVertexStrideSize(): number;
+        _needToSynchronizeChildren(): bool;
+        isSynchronized(): bool;
+        isEnabled(): bool;
+        setEnabled(value: bool): void;
+        isAnimated(): bool;
+        computeWorldMatrix(): Matrix;
+        _createGlobalSubMesh(): SubMesh;
+        setVertices(vertices: VertexBuffer, uvCount: number): void;
+        setIndices(indices: number[]): void;
+        render(subMesh: SubMesh): void;
+        isDescendantOf(ancestor: Mesh): bool;
+        getDescendants(): Mesh[];
+        getEmittedParticleSystems(): ParticleSystem[];
+        getHierarchyEmittedParticleSystems(): ParticleSystem[];
+        getChildren(): Mesh[];
+        isInFrustrum(frustumPlanes: Plane[]): bool;
+        setMaterialByID(id: string);
+        getAnimatables(): Material;
+
+        intersectsMesh(mesh: Mesh, precise: bool): bool;
+        intersectsPoint(point: Vector3): bool;
+        intersects(ray: Ray): MeshRayHitTest;
+        clone(name: string, newParent: Mesh): Mesh;
+
+        dispose(): void;
+
+        static createBox(name: string, size: number, scene: Scene): Mesh;
+        static createSphere(name: string, segments: number, diameter: number, scene: Scene): Mesh;
+        static createPlane(name: string, size: number, scene: Scene): Mesh;
+    }
+
+    class SubMesh {
+        materialIndex: number;
+        verticesStart: number;
+        verticesCount: number;
+        indexStart: number;
+        indexCount: number;
+
+        constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: Mesh);
+
+        getMaterial(): Material;
+        updateBoundingInfo(world: Matrix, scale: Vector3): void;
+        isInFrustrum(frustumPlanes: Plane[]): bool;
+        render(): void;
+        getLinesIndexBuffer(indices: number[], engine: Engine): IndexBuffer;
+        canIntersects(ray: Ray): bool;
+        intersects(ray: Ray, positions: Vector3[], indices: number[]): MeshRayHitTest;
+        clone(newMesh: Mesh): SubMesh;
+    }
+
+    // babylon.particle.d.ts
+    class Particle {
+        position: Vector3;
+        direction: Vector3;
+        lifetime: number;
+        age: number;
+        size: number;
+        angle: number;
+        angularSpeed: number;
+        color: Color4;
+        colorStep: Color4;
+
+        constructor();
+
+    }
+
+    class ParticleSystem {
+        name: string;
+        id: string;
+        gravity: Vector3;
+        direction1: Vector3;
+        direction2: Vector3;
+        minEmitBox: Vector3;
+        maxEmitBox: Vector3;
+        color1: Color4;
+        color2: Color4;
+        colorDead: Color4;
+        deadAlpha: number;
+        textureMask: Color4;
+        particles: Particle[];
+
+        emitter: any; // needs update
+        emitRate: number;
+        manualEmitCount: number;
+        updateSpeed: number;
+        targetStopDuration: number;
+        disposeOnStop: bool;
+        minEmitPower: number;
+        maxEmitPower: number;
+        minLifeTime: number;
+        maxLifeTime: number;
+        minSize: number;
+        maxSize: number;
+        minAngularSpeed: number;
+        maxAngularSpeed: number;
+
+        particleTexture: Texture;
+
+        onDispose: () => void;
+
+        blendMode: number;
+
+        constructor(name: string, capacity: number, scene: Scene);
+
+        isAlive(): bool;
+        start(): void;
+        stop(): void;
+        animate(): void;
+        render(): number;
+        dispose(): void;
+        clone(name: string, newEmitter: any): ParticleSystem; // needs update (newEmitter)
+
+        static BLENDMODE_ONEONE: number;
+        static BLENDMODE_STANDARD: number;
+    }
+
+    // babylon.sprite.d.ts
+    class Sprite {
+        name: string;
+        position: Vector3;
+        size: number;
+        angle: number;
+        cellIndex: number;
+        invertU: number;
+        invertV: number;
+
+        constructor(name: string, manager: SpriteManager);
+
+        playAnimation(from: number, to: number, loop: bool, delay: number);
+        stopAnimation(): void;
+
+    }
+
+    class SpriteManager {
+        name: string;
+        cellSize: number;
+
+        constructor(name: string, imgUrl: string, capacity: number, cellSize: number, scene: Scene, epsilon: number);
+
+        onDispose: () => void;
+
+        render(): void;
+        dispose(): void;
+
+    }
+}

+ 47 - 0
Typescript/babylon.scene.d.ts

@@ -0,0 +1,47 @@
+/// <reference path="babylon.d.ts" />
+
+declare module BABYLON {
+    interface ScenePickResult {
+        hit: bool;
+        distance: number;
+        pickedMesh: Mesh;
+        pickedPoint: Vector3;
+    }
+    class Scene {
+        constructor(engine: Engine);
+
+        getEngine(): Engine;
+        getTotalVertices(): number;
+        getActiveVertices(): number;
+        getActiveParticles(): number;
+        getLastFrameDuration(): number;
+        getEvaluateActiveMeshesDuration(): number;
+        getRenderTargetsDuration(): number;
+        getRenderDuration(): number;
+        getParticlesDuration(): number;
+        getSpritesDuration(): number;
+        getAnimationRatio(): number;
+
+        isReady(): bool;
+        executeWhenReady(func: Function): void;
+        // TODO: Animations
+        getViewMatrix(): Matrix;
+        getProjectionMatrix(): Matrix;
+        getTransformMatrix(): Matrix;
+        setTransformMatrix(view: Matrix, projection: Matrix);
+        activeCameraByID(id: number): void;
+        getMaterialByID(id: number): Material;
+        getMeshByID(id: number): Mesh;
+        getLastMeshByID(id: number): Mesh;
+        getMeshByName(name: string): Mesh;
+        isActiveMesh(mesh: Mesh): bool;
+        _evaluateActiveMeshes(): void;
+        _localRender(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, activeMeshes);
+        render();
+        dispose();
+        _getNewPosition(position: Vector3, velocity: Vector3, collider: Sphere, maximumRetries: number): Vector3;
+        _collideWithWorld(position: Vector3, velocity: Vector3, collider: Sphere, maximumRetries: number): Vector3;
+        createPickingRay(x: number, y: number, world: Matrix): Ray;
+        pick(x: number, y: number): ScenePickResult;
+    }
+}

文件差异内容过多而无法显示
+ 0 - 11
babylon.1.0.3.js


文件差异内容过多而无法显示
+ 11 - 0
babylon.1.0.4.js


+ 1 - 0
readme.md

@@ -42,6 +42,7 @@ Babylon.js is a webgl / javascript 3D engine. It supports the following features
 - Mesh cloning
 - Animations engine
 - Sprites and 2D layers
+- Fog
 
 ### License
 

+ 4 - 0
what's new.txt

@@ -1,3 +1,7 @@
+1.0.4:
+ - Various optimizations
+ - Fog
+ - TypeScript support
 1.0.3:
  - Video textures
  - Normal map (bump)