David Catuhe 11 jaren geleden
bovenliggende
commit
4b77caf3d7
100 gewijzigde bestanden met toevoegingen van 773 en 1794 verwijderingen
  1. 2 2
      Babylon/Cameras/Controllers/babylon.inputCollisionFilter.js
  2. 2 2
      Babylon/Cameras/babylon.oculusOrientedCamera.js
  3. 59 13
      Babylon/Materials/babylon.effect.js
  4. 202 0
      Babylon/Materials/babylon.shaderMaterial.js
  5. 14 331
      Babylon/Mesh/babylon.mesh.js
  6. 477 0
      Babylon/Mesh/babylon.mesh.vertexData.js
  7. 1 1
      Babylon/Shaders/shadowMap.fragment.fx
  8. 14 0
      Babylon/Tools/babylon.tools.js
  9. 2 2
      Babylon/babylon.engine.js
  10. BIN
      Samples/Assets/BandeauEmbleme.png
  11. BIN
      Samples/Assets/Bandeauhaut.png
  12. BIN
      Samples/Assets/BtnAbout.png
  13. BIN
      Samples/Assets/BtnDownload.png
  14. BIN
      Samples/Assets/CamDeviceOff.png
  15. BIN
      Samples/Assets/CamTouchOff.png
  16. BIN
      Samples/Assets/Download.png
  17. BIN
      Samples/Assets/Flare.png
  18. BIN
      Samples/Assets/Layer0_0.png
  19. BIN
      Samples/Assets/Layer1_0.png
  20. BIN
      Samples/Assets/Layer2_0.png
  21. BIN
      Samples/Assets/Logo.png
  22. BIN
      Samples/Assets/MonsterARun.png
  23. BIN
      Samples/Assets/Player.png
  24. BIN
      Samples/Assets/Sand.jpg
  25. BIN
      Samples/Assets/Snow.jpg
  26. BIN
      Samples/Assets/SpotDown.png
  27. BIN
      Samples/Assets/SpotLast.png
  28. BIN
      Samples/Assets/Tree.png
  29. BIN
      Samples/Assets/amiga.jpg
  30. BIN
      Samples/Assets/camera.png
  31. BIN
      Samples/Assets/gradient.png
  32. BIN
      Samples/Assets/grass.jpg
  33. BIN
      Samples/Assets/heightMap.png
  34. BIN
      Samples/Assets/kosh.jpg
  35. BIN
      Samples/Assets/lens4.png
  36. BIN
      Samples/Assets/lens5.png
  37. BIN
      Samples/Assets/logo50.png
  38. BIN
      Samples/Assets/mosaic.jpg
  39. BIN
      Samples/Assets/rock.jpg
  40. BIN
      Samples/Assets/wood.jpg
  41. BIN
      Samples/Scenes/Blender/Metal1.png
  42. BIN
      Samples/Scenes/Blender/MountainGrass_jpg72767116-efb0-4b79-a016-8ac4ef7561a1Larger.jpg
  43. 0 9
      Samples/Scenes/Blender/blender.babylon
  44. BIN
      Samples/Scenes/Blender/blender.blend
  45. BIN
      Samples/Scenes/Blender/chocolat.jpg
  46. BIN
      Samples/Scenes/Blender/concrete5.png
  47. BIN
      Samples/Scenes/Blender/paper.png
  48. BIN
      Samples/Scenes/Blender/paper02.png
  49. BIN
      Samples/Scenes/Blender/paper_bump.png
  50. BIN
      Samples/Scenes/Blender/wildtextures-old-wood-original-file-1280x853.jpg
  51. BIN
      Samples/Scenes/Customs/Ground.jpg
  52. 0 61
      Samples/Scenes/Customs/bones.js
  53. 0 20
      Samples/Scenes/Customs/bump_test.js
  54. 0 99
      Samples/Scenes/Customs/cellShading.js
  55. 0 129
      Samples/Scenes/Customs/charting.js
  56. 0 64
      Samples/Scenes/Customs/csg.js
  57. 0 42
      Samples/Scenes/Customs/fog_test.js
  58. BIN
      Samples/Scenes/Customs/grass.dds
  59. BIN
      Samples/Scenes/Customs/heightMap.png
  60. 0 49
      Samples/Scenes/Customs/heightMap_test.js
  61. 0 39
      Samples/Scenes/Customs/lensFlares.js
  62. 0 78
      Samples/Scenes/Customs/lights_test.js
  63. 0 40
      Samples/Scenes/Customs/multimat.js
  64. BIN
      Samples/Scenes/Customs/normalMap.jpg
  65. 0 33
      Samples/Scenes/Customs/octree.js
  66. 0 141
      Samples/Scenes/Customs/physics.js
  67. 0 77
      Samples/Scenes/Customs/postprocessBloom.js
  68. 0 62
      Samples/Scenes/Customs/postprocessConvolution.js
  69. 0 56
      Samples/Scenes/Customs/postprocessRefraction.js
  70. 0 25
      Samples/Scenes/Customs/postprocesses/compose.fragment.fx
  71. 0 29
      Samples/Scenes/Customs/postprocesses/downsample.fragment.fx
  72. BIN
      Samples/Scenes/Customs/refMap.jpg
  73. 0 50
      Samples/Scenes/Customs/shaders/cellShading.fragment.fx
  74. 0 27
      Samples/Scenes/Customs/shaders/cellShading.vertex.fx
  75. 0 85
      Samples/Scenes/Customs/shadows.js
  76. BIN
      Samples/Scenes/Customs/skybox/night_nx.jpg
  77. BIN
      Samples/Scenes/Customs/skybox/night_ny.jpg
  78. BIN
      Samples/Scenes/Customs/skybox/night_nz.jpg
  79. BIN
      Samples/Scenes/Customs/skybox/night_px.jpg
  80. BIN
      Samples/Scenes/Customs/skybox/night_py.jpg
  81. BIN
      Samples/Scenes/Customs/skybox/night_pz.jpg
  82. BIN
      Samples/Scenes/Customs/skybox/skybox_nx.jpg
  83. BIN
      Samples/Scenes/Customs/skybox/skybox_ny.jpg
  84. BIN
      Samples/Scenes/Customs/skybox/skybox_nz.jpg
  85. BIN
      Samples/Scenes/Customs/skybox/skybox_px.jpg
  86. BIN
      Samples/Scenes/Customs/skybox/skybox_py.jpg
  87. BIN
      Samples/Scenes/Customs/skybox/skybox_pz.jpg
  88. BIN
      Samples/Scenes/Customs/skybox/snow_nx.jpg
  89. BIN
      Samples/Scenes/Customs/skybox/snow_ny.jpg
  90. BIN
      Samples/Scenes/Customs/skybox/snow_nz.jpg
  91. BIN
      Samples/Scenes/Customs/skybox/snow_px.jpg
  92. BIN
      Samples/Scenes/Customs/skybox/snow_py.jpg
  93. BIN
      Samples/Scenes/Customs/skybox/snow_pz.jpg
  94. 0 227
      Samples/Scenes/Customs/test.js
  95. BIN
      Samples/Scenes/Dude/0.jpg
  96. BIN
      Samples/Scenes/Dude/1.jpg
  97. BIN
      Samples/Scenes/Dude/2.jpg
  98. BIN
      Samples/Scenes/Dude/3.jpg
  99. 0 1
      Samples/Scenes/Dude/Dude.babylon
  100. 0 0
      Samples/Scenes/Espilit/Blanc.jpg

+ 2 - 2
Babylon/Cameras/Controllers/babylon.inputCollisionFilter.js

@@ -8,7 +8,7 @@ var BABYLON = BABYLON || {};
 		this._transformedDirection = new BABYLON.Vector3();
 		this._tempNewPosition = new BABYLON.Vector3();
 		this._tempNewPosition2 = new BABYLON.Vector3();
-		this._ellipsoid = ellipsoid || new BABYLON.Vector3(.5,.5,.5);
+		this._ellipsoid = ellipsoid || new BABYLON.Vector3(.2,.855,.2);
 		this._collider = new BABYLON.Collider();
 		this._collidedPosition = new BABYLON.Vector3(0, 0, 0);
 		this._cameraHeight = 1.7;
@@ -31,7 +31,7 @@ var BABYLON = BABYLON || {};
 
 
 		this._collidedPosition.subtractToRef(this._positionBottom, this._tempNewPosition2);
-		if (this._tempNewPosition2.length() > BABYLON.Engine.collisionsEpsilon * 5) {
+		if (this._tempNewPosition2.length() > BABYLON.Engine.collisionsEpsilon * 2) {
 
 		    BABYLON.Vector3.TransformNormalToRef(this._tempNewPosition2, this.getInvertOrientationMatrix(), this._tempNewPosition);
 		    this.target.moveRelative(this._tempNewPosition);

+ 2 - 2
Babylon/Cameras/babylon.oculusOrientedCamera.js

@@ -35,7 +35,7 @@ var BABYLON = BABYLON || {};
         this.resetViewMatrix();
     };
     
-    BABYLON.OculusOrientedCamera.BuildOculusStereoCamera = function (scene, name, minZ, maxZ, position, neutralOrientation, useFXAA, disableGravity, disableCollisions, ovrSettings) {
+    BABYLON.OculusOrientedCamera.BuildOculusStereoCamera = function (scene, name, minZ, maxZ, position, neutralOrientation, useFXAA, disableGravity, disableCollisions, collisionEllipsoid, ovrSettings) {
         var canvas = scene.getEngine().getRenderingCanvas();
         position = position || BABYLON.Vector3.Zero(0, 0, 0);
         neutralOrientation = neutralOrientation || { yaw: 0.0, pitch: 0.0, roll: 0.0 };
@@ -64,7 +64,7 @@ var BABYLON = BABYLON || {};
         var controller = new BABYLON.OculusController(scene, multiTarget);
         var moveTarget = multiTarget;
         if (!disableCollisions) {
-            var collisionFilter = new BABYLON.InputCollisionFilter(scene, multiTarget);
+            var collisionFilter = new BABYLON.InputCollisionFilter(scene, multiTarget, collisionEllipsoid);
             moveTarget = collisionFilter;
         }
         if (!disableGravity) {

+ 59 - 13
Babylon/Materials/babylon.effect.js

@@ -14,12 +14,20 @@ var BABYLON = BABYLON || {};
         this._compilationError = "";
         this._attributesNames = attributesNames;
 
-        var vertex = baseName.vertex || baseName;
-        var fragment = baseName.fragment || baseName;
+        var vertexSource;
+        var fragmentSource;
+
+        if (baseName.vertexElement) {
+            vertexSource = document.getElementById(baseName.vertexElement);
+            fragmentSource = document.getElementById(baseName.fragmentElement);
+        } else {
+            vertexSource = baseName.vertexElement || baseName.vertex || baseName;
+            fragmentSource = baseName.fragmentElement || baseName.fragment || baseName;
+        }
 
         var that = this;
-        this._loadVertexShader(vertex, function (vertexCode) {
-            that._loadFragmentShader(fragment, function (fragmentCode) {
+        this._loadVertexShader(vertexSource, function (vertexCode) {
+            that._loadFragmentShader(fragmentSource, function (fragmentCode) {
                 that._prepareEffect(vertexCode, fragmentCode, attributesNames, defines, optionalDefines);
             });
         });   
@@ -67,6 +75,13 @@ var BABYLON = BABYLON || {};
 
     // Methods
     BABYLON.Effect.prototype._loadVertexShader = function (vertex, callback) {
+        // DOM element ?
+        if (vertex instanceof HTMLElement) {
+            var vertexCode = BABYLON.Tools.GetDOMTextContent(vertex);
+            callback(vertexCode);
+            return;
+        }
+
         // Is in local store ?
         if (BABYLON.Effect.ShadersStore[vertex + "VertexShader"]) {
             callback(BABYLON.Effect.ShadersStore[vertex + "VertexShader"]);
@@ -86,6 +101,13 @@ var BABYLON = BABYLON || {};
     };
 
     BABYLON.Effect.prototype._loadFragmentShader = function (fragment, callback) {
+        // DOM element ?
+        if (fragment instanceof HTMLElement) {
+            var fragmentCode = BABYLON.Tools.GetDOMTextContent(fragment);
+            callback(fragmentCode);
+            return;
+        }
+
         // Is in local store ?
         if (BABYLON.Effect.ShadersStore[fragment + "PixelShader"]) {
             callback(BABYLON.Effect.ShadersStore[fragment + "PixelShader"]);
@@ -196,10 +218,14 @@ var BABYLON = BABYLON || {};
     
     BABYLON.Effect.prototype.setArray = function (uniformName, array) {
         this._engine.setArray(this.getUniform(uniformName), array);
+
+        return this;
     };
 
     BABYLON.Effect.prototype.setMatrices = function (uniformName, matrices) {
         this._engine.setMatrices(this.getUniform(uniformName), matrices);
+
+        return this;
     };
 
     BABYLON.Effect.prototype.setMatrix = function (uniformName, matrix) {
@@ -208,81 +234,101 @@ var BABYLON = BABYLON || {};
 
         //this._cacheMatrix(uniformName, matrix);
         this._engine.setMatrix(this.getUniform(uniformName), matrix);
+
+        return this;
     };
 
     BABYLON.Effect.prototype.setFloat = function (uniformName, value) {
         if (this._valueCache[uniformName] && this._valueCache[uniformName] === value)
-            return;
+            return this;
 
         this._valueCache[uniformName] = value;
 
         this._engine.setFloat(this.getUniform(uniformName), value);
+
+        return this;
     };
 
     BABYLON.Effect.prototype.setBool = function (uniformName, bool) {
         if (this._valueCache[uniformName] && this._valueCache[uniformName] === bool)
-            return;
+            return this;
 
         this._valueCache[uniformName] = bool;
 
         this._engine.setBool(this.getUniform(uniformName), bool);
+
+        return this;
     };
     
     BABYLON.Effect.prototype.setVector2 = function (uniformName, vector2) {
         if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == vector2.x && this._valueCache[uniformName][1] == vector2.y)
-            return;
+            return this;
 
         this._cacheFloat2(uniformName, vector2.x, vector2.y);
         this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
+
+        return this;
     };
 
     BABYLON.Effect.prototype.setFloat2 = function (uniformName, x, y) {
         if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == x && this._valueCache[uniformName][1] == y)
-            return;
+            return this;
 
         this._cacheFloat2(uniformName, x, y);
         this._engine.setFloat2(this.getUniform(uniformName), x, y);
+
+        return this;
     };
     
     BABYLON.Effect.prototype.setVector3 = function (uniformName, vector3) {
         if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == vector3.x && this._valueCache[uniformName][1] == vector3.y && this._valueCache[uniformName][2] == vector3.z)
-            return;
+            return this;
 
         this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z);
 
         this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
+
+        return this;
     };
 
     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;
+            return this;
 
         this._cacheFloat3(uniformName, x, y, z);
         this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
+
+        return this;
     };
 
     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;
+            return this;
 
         this._cacheFloat4(uniformName, x, y, z, w);
         this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
+
+        return this;
     };
 
     BABYLON.Effect.prototype.setColor3 = function (uniformName, color3) {
         if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == color3.r && this._valueCache[uniformName][1] == color3.g && this._valueCache[uniformName][2] == color3.b)
-            return;
+            return this;
 
         this._cacheFloat3(uniformName, color3.r, color3.g, color3.b);
         this._engine.setColor3(this.getUniform(uniformName), color3);
+
+        return this;
     };
 
     BABYLON.Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
         if (this._valueCache[uniformName] && this._valueCache[uniformName][0] == color3.r && this._valueCache[uniformName][1] == color3.g && this._valueCache[uniformName][2] == color3.b && this._valueCache[uniformName][3] == alpha)
-            return;
+            return this;
 
         this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha);
         this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
+
+        return this;
     };
 
     // Statics

+ 202 - 0
Babylon/Materials/babylon.shaderMaterial.js

@@ -0,0 +1,202 @@
+"use strict";
+
+var BABYLON = BABYLON || {};
+
+(function () {
+    BABYLON.ShaderMaterial = function (name, scene, shaderPath, options) {
+        this.name = name;
+        this.id = name;
+        this._shaderPath = shaderPath;
+
+        options.needAlphaBlending = options.needAlphaBlending || false;
+        options.needAlphaTesting = options.needAlphaTesting || false;
+        options.attributes = options.attributes || ["position", "normal", "uv"];
+        options.uniforms = options.uniforms || ["worldViewProjection"];
+        options.samplers = options.samplers || [];
+        
+        this._options = options;
+        this._scene = scene;
+        scene.materials.push(this);
+
+        this._textures = [];
+        this._floats = [];
+        this._floatsArrays = [];
+        this._colors3 = [];
+        this._colors4 = [];
+        this._vectors2 = [];
+        this._vectors3 = [];
+        this._vectors4 = [];
+        this._matrices = [];
+    };
+
+    BABYLON.ShaderMaterial.prototype = Object.create(BABYLON.Material.prototype);
+
+    // Properties   
+    BABYLON.ShaderMaterial.prototype.needAlphaBlending = function () {
+        return this._options.needAlphaBlending;
+    };
+
+    BABYLON.ShaderMaterial.prototype.needAlphaTesting = function () {
+        return this._options.needAlphaTesting;
+    };
+
+    // Methods   
+    BABYLON.ShaderMaterial.prototype._checkUniform = function (uniformName) {
+        if (this._options.uniforms.indexOf(uniformName) === -1) {
+            this._options.uniforms.push(uniformName);
+        }
+    };
+
+    BABYLON.ShaderMaterial.prototype.setTexture = function (name, texture) {
+        this._checkUniform(name);
+        this._textures[name] = texture;
+
+        return this;
+    };
+
+    BABYLON.ShaderMaterial.prototype.setFloat = function (name, value) {
+        this._checkUniform(name);
+        this._floats[name] = value;
+
+        return this;
+    };
+
+    BABYLON.ShaderMaterial.prototype.setFloats = function (name, value) {
+        this._checkUniform(name);
+        this._floatsArrays[name] = value;
+
+        return this;
+    };
+
+    BABYLON.ShaderMaterial.prototype.setColor3 = function (name, value) {
+        this._checkUniform(name);
+        this._colors3[name] = value;
+
+        return this;
+    };
+
+    BABYLON.ShaderMaterial.prototype.setColor4 = function (name, value) {
+        this._checkUniform(name);
+        this._colors4[name] = value;
+
+        return this;
+    };
+
+    BABYLON.ShaderMaterial.prototype.setVector2 = function (name, value) {
+        this._checkUniform(name);
+        this._vectors2[name] = value;
+
+        return this;
+    };
+
+    BABYLON.ShaderMaterial.prototype.setVector3 = function (name, value) {
+        this._checkUniform(name);
+        this._vectors3[name] = value;
+
+        return this;
+    };
+
+    BABYLON.ShaderMaterial.prototype.setVector4 = function (name, value) {
+        this._checkUniform(name);
+        this._vectors4[name] = value;
+
+        return this;
+    };
+
+    BABYLON.ShaderMaterial.prototype.setMatrix = function (name, value) {
+        this._checkUniform(name);
+        this._matrices[name] = value;
+
+        return this;
+    };
+
+    BABYLON.ShaderMaterial.prototype.isReady = function (mesh) {
+        var engine = this._scene.getEngine();
+
+        this._effect = engine.createEffect(this._shaderPath,
+            this._options.attributes,
+            this._options.uniforms,
+            this._options.samplers,
+            "");
+
+        if (!this._effect.isReady()) {
+            return false;
+        }
+
+        return true;
+    };
+
+    BABYLON.ShaderMaterial.prototype.bind = function (world, mesh) {
+        // Std values
+        if (this._options.uniforms.indexOf("world") !== -1) {
+            this._effect.setMatrix("world", world);
+        }
+
+        if (this._options.uniforms.indexOf("view") !== -1) {
+            this._effect.setMatrix("view", this._scene.getViewMatrix());
+        }
+
+        if (this._options.uniforms.indexOf("projection") !== -1) {
+            this._effect.setMatrix("projection", this._scene.getProjectionMatrix());
+        }
+
+        if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
+            this._effect.setMatrix("worldViewProjection", world.multiply(this._scene.getTransformMatrix()));
+        }        
+
+        // Texture
+        for (var name in this._textures) {
+            this._effect.setTexture(name, this._textures[name]);
+        }
+
+        // Float    
+        for (name in this._floats) {            
+            this._effect.setFloat(name, this._floats[name]);
+        }
+
+        // Float s   
+        for (name in this._floatsArrays) {
+            this._effect.setArray(name, this._floatsArrays[name]);
+        }
+
+        // Color3        
+        for (name in this._colors3) {
+            this._effect.setColor3(name, this._colors3[name]);
+        }
+
+        // Color4      
+        for (name in this._colors4) {
+            this._effect.setColor4(name, this._colors4[name]);
+        }
+
+        // Vector2        
+        for (name in this._vectors2) {
+            this._effect.setVector2(name, this._vectors2[name]);
+        }
+
+        // Vector3        
+        for (name in this._vectors3) {
+            this._effect.setVector3(name, this._vectors3[name]);
+        }
+
+        // Vector4      
+        for (name in this._vectors4) {
+            this._effect.setVector4(name, this._vectors4[name]);
+        }
+
+        // Matrix      
+        for (name in this._matrices) {
+            this._effect.setMatrix(name, this._matrices[name]);
+        }
+    };
+
+    BABYLON.ShaderMaterial.prototype.dispose = function () {
+        for (var name in this._textures) {
+            this._textures[name].dispose();
+        }
+
+        this._textures = [];
+        
+        this.baseDispose();
+    };
+})();

+ 14 - 331
Babylon/Mesh/babylon.mesh.js

@@ -1100,231 +1100,28 @@ var BABYLON = BABYLON || {};
     // Statics
     BABYLON.Mesh.CreateBox = function (name, size, scene, updatable) {
         var box = new BABYLON.Mesh(name, scene);
+        var vertexData = BABYLON.VertexData.CreateBox(size);
 
-        var normalsSource = [
-            new BABYLON.Vector3(0, 0, 1),
-            new BABYLON.Vector3(0, 0, -1),
-            new BABYLON.Vector3(1, 0, 0),
-            new BABYLON.Vector3(-1, 0, 0),
-            new BABYLON.Vector3(0, 1, 0),
-            new BABYLON.Vector3(0, -1, 0)
-        ];
-
-        var indices = [];
-        var positions = [];
-        var normals = [];
-        var uvs = [];
-
-        // Create each face in turn.
-        for (var index = 0; index < normalsSource.length; index++) {
-            var normal = normalsSource[index];
-
-            // Get two vectors perpendicular to the face normal and to each other.
-            var side1 = new BABYLON.Vector3(normal.y, normal.z, normal.x);
-            var side2 = BABYLON.Vector3.Cross(normal, side1);
-
-            // Six indices (two triangles) per face.
-            var verticesLength = positions.length / 3;
-            indices.push(verticesLength);
-            indices.push(verticesLength + 1);
-            indices.push(verticesLength + 2);
-
-            indices.push(verticesLength);
-            indices.push(verticesLength + 2);
-            indices.push(verticesLength + 3);
-
-            // Four vertices per face.
-            var vertex = normal.subtract(side1).subtract(side2).scale(size / 2);
-            positions.push(vertex.x, vertex.y, vertex.z);
-            normals.push(normal.x, normal.y, normal.z);
-            uvs.push(1.0, 1.0);
-
-            vertex = normal.subtract(side1).add(side2).scale(size / 2);
-            positions.push(vertex.x, vertex.y, vertex.z);
-            normals.push(normal.x, normal.y, normal.z);
-            uvs.push(0.0, 1.0);
-
-            vertex = normal.add(side1).add(side2).scale(size / 2);
-            positions.push(vertex.x, vertex.y, vertex.z);
-            normals.push(normal.x, normal.y, normal.z);
-            uvs.push(0.0, 0.0);
-
-            vertex = normal.add(side1).subtract(side2).scale(size / 2);
-            positions.push(vertex.x, vertex.y, vertex.z);
-            normals.push(normal.x, normal.y, normal.z);
-            uvs.push(1.0, 0.0);
-        }
-
-        box.setVerticesData(positions, BABYLON.VertexBuffer.PositionKind, updatable);
-        box.setVerticesData(normals, BABYLON.VertexBuffer.NormalKind, updatable);
-        box.setVerticesData(uvs, BABYLON.VertexBuffer.UVKind, updatable);
-        box.setIndices(indices);
+        vertexData.applyToMesh(box, updatable);
 
         return box;
     };
 
     BABYLON.Mesh.CreateSphere = function (name, segments, diameter, scene, updatable) {
         var sphere = new BABYLON.Mesh(name, scene);
+        var vertexData = BABYLON.VertexData.CreateSphere(segments, diameter);
 
-        var radius = diameter / 2;
-
-        var totalZRotationSteps = 2 + segments;
-        var totalYRotationSteps = 2 * totalZRotationSteps;
-
-        var indices = [];
-        var positions = [];
-        var normals = [];
-        var uvs = [];
-
-        for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
-            var normalizedZ = zRotationStep / totalZRotationSteps;
-            var angleZ = (normalizedZ * Math.PI);
-
-            for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
-                var normalizedY = yRotationStep / totalYRotationSteps;
-
-                var angleY = normalizedY * Math.PI * 2;
-
-                var rotationZ = BABYLON.Matrix.RotationZ(-angleZ);
-                var rotationY = BABYLON.Matrix.RotationY(angleY);
-                var afterRotZ = BABYLON.Vector3.TransformCoordinates(BABYLON.Vector3.Up(), rotationZ);
-                var complete = BABYLON.Vector3.TransformCoordinates(afterRotZ, rotationY);
-
-                var vertex = complete.scale(radius);
-                var normal = BABYLON.Vector3.Normalize(vertex);
-
-                positions.push(vertex.x, vertex.y, vertex.z);
-                normals.push(normal.x, normal.y, normal.z);
-                uvs.push(normalizedZ, normalizedY);
-            }
-
-            if (zRotationStep > 0) {
-                var verticesCount = positions.length / 3;
-                for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1) ; (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
-                    indices.push((firstIndex));
-                    indices.push((firstIndex + 1));
-                    indices.push(firstIndex + totalYRotationSteps + 1);
-
-                    indices.push((firstIndex + totalYRotationSteps + 1));
-                    indices.push((firstIndex + 1));
-                    indices.push((firstIndex + totalYRotationSteps + 2));
-                }
-            }
-        }
-
-        sphere.setVerticesData(positions, BABYLON.VertexBuffer.PositionKind, updatable);
-        sphere.setVerticesData(normals, BABYLON.VertexBuffer.NormalKind, updatable);
-        sphere.setVerticesData(uvs, BABYLON.VertexBuffer.UVKind, updatable);
-        sphere.setIndices(indices);
+        vertexData.applyToMesh(sphere, updatable);
 
         return sphere;
     };
 
     // Cylinder and cone (Code inspired by SharpDX.org)
     BABYLON.Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, scene, updatable) {
-        var radiusTop = diameterTop / 2;
-        var radiusBottom = diameterBottom / 2;
-        var indices = [];
-        var positions = [];
-        var normals = [];
-        var uvs = [];
-        var cylinder = new BABYLON.Mesh(name, scene);
-
-        var getCircleVector = function (i) {
-            var angle = (i * 2.0 * Math.PI / tessellation);
-            var dx = Math.sin(angle);
-            var dz = Math.cos(angle);
-
-            return new BABYLON.Vector3(dx, 0, dz);
-        };
-
-        var createCylinderCap = function (isTop) {
-            var radius = isTop ? radiusTop : radiusBottom;
-
-            if (radius == 0) {
-                return;
-            }
-
-            // Create cap indices.
-            for (var i = 0; i < tessellation - 2; i++) {
-                var i1 = (i + 1) % tessellation;
-                var i2 = (i + 2) % tessellation;
-
-                if (!isTop) {
-                    var tmp = i1;
-                    var i1 = i2;
-                    i2 = tmp;
-                }
-
-                var vbase = positions.length / 3;
-                indices.push(vbase);
-                indices.push(vbase + i1);
-                indices.push(vbase + i2);
-            }
-
-
-            // Which end of the cylinder is this?
-            var normal = new BABYLON.Vector3(0, -1, 0);
-            var textureScale = new BABYLON.Vector2(-0.5, -0.5);
-
-            if (!isTop) {
-                normal = normal.scale(-1);
-                textureScale.x = -textureScale.x;
-            }
-
-            // Create cap vertices.
-            for (var i = 0; i < tessellation; i++) {
-                var circleVector = getCircleVector(i);
-                var position = circleVector.scale(radius).add(normal.scale(height));
-                var textureCoordinate = new BABYLON.Vector2(circleVector.x * textureScale.x + 0.5, circleVector.z * textureScale.y + 0.5);
-
-                positions.push(position.x, position.y, position.z);
-                normals.push(normal.x, normal.y, normal.z);
-                uvs.push(textureCoordinate.x, textureCoordinate.y);
-            }
-        };
-
-        height /= 2;
-
-        var topOffset = new BABYLON.Vector3(0, 1, 0).scale(height);
-
-        var stride = tessellation + 1;
-
-        // Create a ring of triangles around the outside of the cylinder.
-        for (var i = 0; i <= tessellation; i++) {
-            var normal = getCircleVector(i);
-            var sideOffsetBottom = normal.scale(radiusBottom);
-            var sideOffsetTop = normal.scale(radiusTop);
-            var textureCoordinate = new BABYLON.Vector2(i / tessellation, 0);
-
-            var position = sideOffsetBottom.add(topOffset);
-            positions.push(position.x, position.y, position.z);
-            normals.push(normal.x, normal.y, normal.z);
-            uvs.push(textureCoordinate.x, textureCoordinate.y);
-
-            position = sideOffsetTop.subtract(topOffset);
-            textureCoordinate.y += 1;
-            positions.push(position.x, position.y, position.z);
-            normals.push(normal.x, normal.y, normal.z);
-            uvs.push(textureCoordinate.x, textureCoordinate.y);
-
-            indices.push(i * 2);
-            indices.push((i * 2 + 2) % (stride * 2));
-            indices.push(i * 2 + 1);
-
-            indices.push(i * 2 + 1);
-            indices.push((i * 2 + 2) % (stride * 2));
-            indices.push((i * 2 + 3) % (stride * 2));
-        }
-
-        // Create flat triangle fan caps to seal the top and bottom.
-        createCylinderCap(true);
-        createCylinderCap(false);
+        var cylinder = new BABYLON.Mesh(name, scene);        
+        var vertexData = BABYLON.VertexData.CreateCylinder(height, diameterTop, diameterBottom, tessellation);
 
-        cylinder.setVerticesData(positions, BABYLON.VertexBuffer.PositionKind, updatable);
-        cylinder.setVerticesData(normals, BABYLON.VertexBuffer.NormalKind, updatable);
-        cylinder.setVerticesData(uvs, BABYLON.VertexBuffer.UVKind, updatable);
-        cylinder.setIndices(indices);
+        vertexData.applyToMesh(cylinder, updatable);
 
         return cylinder;
     };
@@ -1332,142 +1129,28 @@ var BABYLON = BABYLON || {};
     // Torus  (Code from SharpDX.org)
     BABYLON.Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable) {
         var torus = new BABYLON.Mesh(name, scene);
+        var vertexData = BABYLON.VertexData.CreateTorus(diameter, thickness, tessellation);
 
-        var indices = [];
-        var positions = [];
-        var normals = [];
-        var uvs = [];
-
-        var stride = tessellation + 1;
-
-        for (var i = 0; i <= tessellation; i++) {
-            var u = i / tessellation;
-
-            var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
-
-            var transform = BABYLON.Matrix.Translation(diameter / 2.0, 0, 0).multiply(BABYLON.Matrix.RotationY(outerAngle));
-
-            for (var j = 0; j <= tessellation; j++) {
-                var v = 1 - j / tessellation;
-
-                var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
-                var dx = Math.cos(innerAngle);
-                var dy = Math.sin(innerAngle);
-
-                // Create a vertex.
-                var normal = new BABYLON.Vector3(dx, dy, 0);
-                var position = normal.scale(thickness / 2);
-                var textureCoordinate = new BABYLON.Vector2(u, v);
-
-                position = BABYLON.Vector3.TransformCoordinates(position, transform);
-                normal = BABYLON.Vector3.TransformNormal(normal, transform);
-
-                positions.push(position.x, position.y, position.z);
-                normals.push(normal.x, normal.y, normal.z);
-                uvs.push(textureCoordinate.x, textureCoordinate.y);
-
-                // And create indices for two triangles.
-                var nextI = (i + 1) % stride;
-                var nextJ = (j + 1) % stride;
-
-                indices.push(i * stride + j);
-                indices.push(i * stride + nextJ);
-                indices.push(nextI * stride + j);
-
-                indices.push(i * stride + nextJ);
-                indices.push(nextI * stride + nextJ);
-                indices.push(nextI * stride + j);
-            }
-        }
-
-        torus.setVerticesData(positions, BABYLON.VertexBuffer.PositionKind, updatable);
-        torus.setVerticesData(normals, BABYLON.VertexBuffer.NormalKind, updatable);
-        torus.setVerticesData(uvs, BABYLON.VertexBuffer.UVKind, updatable);
-        torus.setIndices(indices);
+        vertexData.applyToMesh(torus, updatable);
 
         return torus;
     };
 
-    // Plane
+    // Plane & ground
     BABYLON.Mesh.CreatePlane = function (name, size, scene, updatable) {
         var plane = new BABYLON.Mesh(name, scene);
+        var vertexData = BABYLON.VertexData.CreatePlane(size);
 
-        var indices = [];
-        var positions = [];
-        var normals = [];
-        var uvs = [];
-
-        // Vertices
-        var halfSize = size / 2.0;
-        positions.push(-halfSize, -halfSize, 0);
-        normals.push(0, 0, -1.0);
-        uvs.push(0.0, 0.0);
-
-        positions.push(halfSize, -halfSize, 0);
-        normals.push(0, 0, -1.0);
-        uvs.push(1.0, 0.0);
-
-        positions.push(halfSize, halfSize, 0);
-        normals.push(0, 0, -1.0);
-        uvs.push(1.0, 1.0);
-
-        positions.push(-halfSize, halfSize, 0);
-        normals.push(0, 0, -1.0);
-        uvs.push(0.0, 1.0);
-
-        // Indices
-        indices.push(0);
-        indices.push(1);
-        indices.push(2);
-
-        indices.push(0);
-        indices.push(2);
-        indices.push(3);
-
-        plane.setVerticesData(positions, BABYLON.VertexBuffer.PositionKind, updatable);
-        plane.setVerticesData(normals, BABYLON.VertexBuffer.NormalKind, updatable);
-        plane.setVerticesData(uvs, BABYLON.VertexBuffer.UVKind, updatable);
-        plane.setIndices(indices);
+        vertexData.applyToMesh(plane, updatable);
 
         return plane;
     };
 
     BABYLON.Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
         var ground = new BABYLON.Mesh(name, scene);
+        var vertexData = BABYLON.VertexData.CreateGround(width, height, subdivisions);
 
-        var indices = [];
-        var positions = [];
-        var normals = [];
-        var uvs = [];
-        var row, col;
-
-        for (row = 0; row <= subdivisions; row++) {
-            for (col = 0; col <= subdivisions; col++) {
-                var position = new BABYLON.Vector3((col * width) / subdivisions - (width / 2.0), 0, ((subdivisions - row) * height) / subdivisions - (height / 2.0));
-                var normal = new BABYLON.Vector3(0, 1.0, 0);
-
-                positions.push(position.x, position.y, position.z);
-                normals.push(normal.x, normal.y, normal.z);
-                uvs.push(col / subdivisions, 1.0 - row / subdivisions);
-            }
-        }
-
-        for (row = 0; row < subdivisions; row++) {
-            for (col = 0; col < subdivisions; col++) {
-                indices.push(col + 1 + (row + 1) * (subdivisions + 1));
-                indices.push(col + 1 + row * (subdivisions + 1));
-                indices.push(col + row * (subdivisions + 1));
-
-                indices.push(col + (row + 1) * (subdivisions + 1));
-                indices.push(col + 1 + (row + 1) * (subdivisions + 1));
-                indices.push(col + row * (subdivisions + 1));
-            }
-        }
-
-        ground.setVerticesData(positions, BABYLON.VertexBuffer.PositionKind, updatable);
-        ground.setVerticesData(normals, BABYLON.VertexBuffer.NormalKind, updatable);
-        ground.setVerticesData(uvs, BABYLON.VertexBuffer.UVKind, updatable);
-        ground.setIndices(indices);
+        vertexData.applyToMesh(ground, updatable);
 
         return ground;
     };

+ 477 - 0
Babylon/Mesh/babylon.mesh.vertexData.js

@@ -0,0 +1,477 @@
+"use strict";
+
+var BABYLON = BABYLON || {};
+
+(function () {
+    BABYLON.VertexData = function () {
+    };
+
+    // Methods
+    BABYLON.VertexData.prototype.applyToMesh = function(mesh, updatable) {
+        if (this.positions) {
+            mesh.setVerticesData(this.positions, BABYLON.VertexBuffer.PositionKind, updatable);
+        }
+
+        if (this.normals) {
+            mesh.setVerticesData(this.normals, BABYLON.VertexBuffer.NormalKind, updatable);
+        }
+
+        if (this.uvs) {
+            mesh.setVerticesData(this.uvs, BABYLON.VertexBuffer.UVKind, updatable);
+        }
+
+        if (this.indices) {
+            mesh.setIndices(this.indices);
+        }
+    };
+
+    BABYLON.VertexData.prototype.transform = function (matrix) {
+        var transformed = BABYLON.Vector3.Zero();
+
+        if (this.positions) {
+            var position = BABYLON.Vector3.Zero();
+
+            for (var index = 0; index < this.positions.length; index += 3) {
+                BABYLON.Vector3.FromArrayToRef(this.positions, index, position);
+
+                BABYLON.Vector3.TransformCoordinatesToRef(position, matrix, transformed);
+                this.positions[index] = transformed.x;
+                this.positions[index + 1] = transformed.y;
+                this.positions[index + 2] = transformed.z;
+            }
+        }
+
+        if (this.normals) {
+            var normal = BABYLON.Vector3.Zero();
+
+            for (index = 0; index < this.normals.length; index += 3) {
+                BABYLON.Vector3.FromArrayToRef(this.normals, index, normal);
+
+                BABYLON.Vector3.TransformNormalToRef(normal, matrix, transformed);
+                this.normals[index] = transformed.x;
+                this.normals[index + 1] = transformed.y;
+                this.normals[index + 2] = transformed.z;
+            }
+        }
+    };
+
+    BABYLON.VertexData.prototype.merge = function (other) {
+        if (other.indices) {
+            if (!this.indices) {
+                this.indices = [];
+            }
+
+            var offset = this.positions ? this.positions.length / 3 : 0;
+            for (var index = 0; index < other.indices.length; index++) {
+                this.indices.push(other.indices[index] + offset);
+            }
+        }
+
+        if (other.positions) {
+            if (!this.positions) {
+                this.positions = [];
+            }
+
+            for (index = 0; index < other.positions.length; index++) {
+                this.positions.push(other.positions[index]);
+            }
+        }
+
+        if (other.normals) {
+            if (!this.normals) {
+                this.normals = [];
+            }
+            for (index = 0; index < other.normals.length; index++) {
+                this.normals.push(other.normals[index]);
+            }
+        }
+
+        if (other.uvs) {
+            if (!this.uvs) {
+                this.uvs = [];
+            }
+            for (index = 0; index < other.uvs.length; index++) {
+                this.uvs.push(other.uvs[index]);
+            }
+        }
+    };
+
+    // Statics
+    BABYLON.VertexData.CreateBox = function(size) {
+        var normalsSource = [
+            new BABYLON.Vector3(0, 0, 1),
+            new BABYLON.Vector3(0, 0, -1),
+            new BABYLON.Vector3(1, 0, 0),
+            new BABYLON.Vector3(-1, 0, 0),
+            new BABYLON.Vector3(0, 1, 0),
+            new BABYLON.Vector3(0, -1, 0)
+        ];
+
+        var indices = [];
+        var positions = [];
+        var normals = [];
+        var uvs = [];
+
+        // Create each face in turn.
+        for (var index = 0; index < normalsSource.length; index++) {
+            var normal = normalsSource[index];
+
+            // Get two vectors perpendicular to the face normal and to each other.
+            var side1 = new BABYLON.Vector3(normal.y, normal.z, normal.x);
+            var side2 = BABYLON.Vector3.Cross(normal, side1);
+
+            // Six indices (two triangles) per face.
+            var verticesLength = positions.length / 3;
+            indices.push(verticesLength);
+            indices.push(verticesLength + 1);
+            indices.push(verticesLength + 2);
+
+            indices.push(verticesLength);
+            indices.push(verticesLength + 2);
+            indices.push(verticesLength + 3);
+
+            // Four vertices per face.
+            var vertex = normal.subtract(side1).subtract(side2).scale(size / 2);
+            positions.push(vertex.x, vertex.y, vertex.z);
+            normals.push(normal.x, normal.y, normal.z);
+            uvs.push(1.0, 1.0);
+
+            vertex = normal.subtract(side1).add(side2).scale(size / 2);
+            positions.push(vertex.x, vertex.y, vertex.z);
+            normals.push(normal.x, normal.y, normal.z);
+            uvs.push(0.0, 1.0);
+
+            vertex = normal.add(side1).add(side2).scale(size / 2);
+            positions.push(vertex.x, vertex.y, vertex.z);
+            normals.push(normal.x, normal.y, normal.z);
+            uvs.push(0.0, 0.0);
+
+            vertex = normal.add(side1).subtract(side2).scale(size / 2);
+            positions.push(vertex.x, vertex.y, vertex.z);
+            normals.push(normal.x, normal.y, normal.z);
+            uvs.push(1.0, 0.0);
+        }
+
+        // Result
+        var vertexData = new BABYLON.VertexData();
+
+        vertexData.indices = indices;
+        vertexData.positions = positions;
+        vertexData.normals = normals;
+        vertexData.uvs = uvs;
+
+        return vertexData;
+    };
+
+    BABYLON.VertexData.CreateSphere = function (segments, diameter) {
+        var radius = diameter / 2;
+
+        var totalZRotationSteps = 2 + segments;
+        var totalYRotationSteps = 2 * totalZRotationSteps;
+
+        var indices = [];
+        var positions = [];
+        var normals = [];
+        var uvs = [];
+
+        for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
+            var normalizedZ = zRotationStep / totalZRotationSteps;
+            var angleZ = (normalizedZ * Math.PI);
+
+            for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
+                var normalizedY = yRotationStep / totalYRotationSteps;
+
+                var angleY = normalizedY * Math.PI * 2;
+
+                var rotationZ = BABYLON.Matrix.RotationZ(-angleZ);
+                var rotationY = BABYLON.Matrix.RotationY(angleY);
+                var afterRotZ = BABYLON.Vector3.TransformCoordinates(BABYLON.Vector3.Up(), rotationZ);
+                var complete = BABYLON.Vector3.TransformCoordinates(afterRotZ, rotationY);
+
+                var vertex = complete.scale(radius);
+                var normal = BABYLON.Vector3.Normalize(vertex);
+
+                positions.push(vertex.x, vertex.y, vertex.z);
+                normals.push(normal.x, normal.y, normal.z);
+                uvs.push(normalizedZ, normalizedY);
+            }
+
+            if (zRotationStep > 0) {
+                var verticesCount = positions.length / 3;
+                for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1) ; (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
+                    indices.push((firstIndex));
+                    indices.push((firstIndex + 1));
+                    indices.push(firstIndex + totalYRotationSteps + 1);
+
+                    indices.push((firstIndex + totalYRotationSteps + 1));
+                    indices.push((firstIndex + 1));
+                    indices.push((firstIndex + totalYRotationSteps + 2));
+                }
+            }
+        }
+
+        // Result
+        var vertexData = new BABYLON.VertexData();
+
+        vertexData.indices = indices;
+        vertexData.positions = positions;
+        vertexData.normals = normals;
+        vertexData.uvs = uvs;
+
+        return vertexData;
+    };
+
+    BABYLON.VertexData.CreateCylinder = function (height, diameterTop, diameterBottom, tessellation) {
+        var radiusTop = diameterTop / 2;
+        var radiusBottom = diameterBottom / 2;
+        var indices = [];
+        var positions = [];
+        var normals = [];
+        var uvs = [];
+
+        var getCircleVector = function (i) {
+            var angle = (i * 2.0 * Math.PI / tessellation);
+            var dx = Math.sin(angle);
+            var dz = Math.cos(angle);
+
+            return new BABYLON.Vector3(dx, 0, dz);
+        };
+
+        var createCylinderCap = function (isTop) {
+            var radius = isTop ? radiusTop : radiusBottom;
+
+            if (radius == 0) {
+                return;
+            }
+
+            // Create cap indices.
+            for (var i = 0; i < tessellation - 2; i++) {
+                var i1 = (i + 1) % tessellation;
+                var i2 = (i + 2) % tessellation;
+
+                if (!isTop) {
+                    var tmp = i1;
+                    var i1 = i2;
+                    i2 = tmp;
+                }
+
+                var vbase = positions.length / 3;
+                indices.push(vbase);
+                indices.push(vbase + i1);
+                indices.push(vbase + i2);
+            }
+
+
+            // Which end of the cylinder is this?
+            var normal = new BABYLON.Vector3(0, -1, 0);
+            var textureScale = new BABYLON.Vector2(-0.5, -0.5);
+
+            if (!isTop) {
+                normal = normal.scale(-1);
+                textureScale.x = -textureScale.x;
+            }
+
+            // Create cap vertices.
+            for (var i = 0; i < tessellation; i++) {
+                var circleVector = getCircleVector(i);
+                var position = circleVector.scale(radius).add(normal.scale(height));
+                var textureCoordinate = new BABYLON.Vector2(circleVector.x * textureScale.x + 0.5, circleVector.z * textureScale.y + 0.5);
+
+                positions.push(position.x, position.y, position.z);
+                normals.push(normal.x, normal.y, normal.z);
+                uvs.push(textureCoordinate.x, textureCoordinate.y);
+            }
+        };
+
+        height /= 2;
+
+        var topOffset = new BABYLON.Vector3(0, 1, 0).scale(height);
+
+        var stride = tessellation + 1;
+
+        // Create a ring of triangles around the outside of the cylinder.
+        for (var i = 0; i <= tessellation; i++) {
+            var normal = getCircleVector(i);
+            var sideOffsetBottom = normal.scale(radiusBottom);
+            var sideOffsetTop = normal.scale(radiusTop);
+            var textureCoordinate = new BABYLON.Vector2(i / tessellation, 0);
+
+            var position = sideOffsetBottom.add(topOffset);
+            positions.push(position.x, position.y, position.z);
+            normals.push(normal.x, normal.y, normal.z);
+            uvs.push(textureCoordinate.x, textureCoordinate.y);
+
+            position = sideOffsetTop.subtract(topOffset);
+            textureCoordinate.y += 1;
+            positions.push(position.x, position.y, position.z);
+            normals.push(normal.x, normal.y, normal.z);
+            uvs.push(textureCoordinate.x, textureCoordinate.y);
+
+            indices.push(i * 2);
+            indices.push((i * 2 + 2) % (stride * 2));
+            indices.push(i * 2 + 1);
+
+            indices.push(i * 2 + 1);
+            indices.push((i * 2 + 2) % (stride * 2));
+            indices.push((i * 2 + 3) % (stride * 2));
+        }
+
+        // Create flat triangle fan caps to seal the top and bottom.
+        createCylinderCap(true);
+        createCylinderCap(false);
+
+        // Result
+        var vertexData = new BABYLON.VertexData();
+
+        vertexData.indices = indices;
+        vertexData.positions = positions;
+        vertexData.normals = normals;
+        vertexData.uvs = uvs;
+
+        return vertexData;
+    };
+
+    BABYLON.VertexData.CreateTorus = function (diameter, thickness, tessellation) {
+        var indices = [];
+        var positions = [];
+        var normals = [];
+        var uvs = [];
+
+        var stride = tessellation + 1;
+
+        for (var i = 0; i <= tessellation; i++) {
+            var u = i / tessellation;
+
+            var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
+
+            var transform = BABYLON.Matrix.Translation(diameter / 2.0, 0, 0).multiply(BABYLON.Matrix.RotationY(outerAngle));
+
+            for (var j = 0; j <= tessellation; j++) {
+                var v = 1 - j / tessellation;
+
+                var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
+                var dx = Math.cos(innerAngle);
+                var dy = Math.sin(innerAngle);
+
+                // Create a vertex.
+                var normal = new BABYLON.Vector3(dx, dy, 0);
+                var position = normal.scale(thickness / 2);
+                var textureCoordinate = new BABYLON.Vector2(u, v);
+
+                position = BABYLON.Vector3.TransformCoordinates(position, transform);
+                normal = BABYLON.Vector3.TransformNormal(normal, transform);
+
+                positions.push(position.x, position.y, position.z);
+                normals.push(normal.x, normal.y, normal.z);
+                uvs.push(textureCoordinate.x, textureCoordinate.y);
+
+                // And create indices for two triangles.
+                var nextI = (i + 1) % stride;
+                var nextJ = (j + 1) % stride;
+
+                indices.push(i * stride + j);
+                indices.push(i * stride + nextJ);
+                indices.push(nextI * stride + j);
+
+                indices.push(i * stride + nextJ);
+                indices.push(nextI * stride + nextJ);
+                indices.push(nextI * stride + j);
+            }
+        }
+
+        // Result
+        var vertexData = new BABYLON.VertexData();
+
+        vertexData.indices = indices;
+        vertexData.positions = positions;
+        vertexData.normals = normals;
+        vertexData.uvs = uvs;
+
+        return vertexData;
+    };
+
+    BABYLON.VertexData.CreateGround = function (width, height, subdivisions) {
+        var indices = [];
+        var positions = [];
+        var normals = [];
+        var uvs = [];
+        var row, col;
+
+        for (row = 0; row <= subdivisions; row++) {
+            for (col = 0; col <= subdivisions; col++) {
+                var position = new BABYLON.Vector3((col * width) / subdivisions - (width / 2.0), 0, ((subdivisions - row) * height) / subdivisions - (height / 2.0));
+                var normal = new BABYLON.Vector3(0, 1.0, 0);
+
+                positions.push(position.x, position.y, position.z);
+                normals.push(normal.x, normal.y, normal.z);
+                uvs.push(col / subdivisions, 1.0 - row / subdivisions);
+            }
+        }
+
+        for (row = 0; row < subdivisions; row++) {
+            for (col = 0; col < subdivisions; col++) {
+                indices.push(col + 1 + (row + 1) * (subdivisions + 1));
+                indices.push(col + 1 + row * (subdivisions + 1));
+                indices.push(col + row * (subdivisions + 1));
+
+                indices.push(col + (row + 1) * (subdivisions + 1));
+                indices.push(col + 1 + (row + 1) * (subdivisions + 1));
+                indices.push(col + row * (subdivisions + 1));
+            }
+        }
+
+        // Result
+        var vertexData = new BABYLON.VertexData();
+
+        vertexData.indices = indices;
+        vertexData.positions = positions;
+        vertexData.normals = normals;
+        vertexData.uvs = uvs;
+
+        return vertexData;
+    };
+
+    BABYLON.VertexData.CreatePlane = function (size) {
+        var indices = [];
+        var positions = [];
+        var normals = [];
+        var uvs = [];
+
+        // Vertices
+        var halfSize = size / 2.0;
+        positions.push(-halfSize, -halfSize, 0);
+        normals.push(0, 0, -1.0);
+        uvs.push(0.0, 0.0);
+
+        positions.push(halfSize, -halfSize, 0);
+        normals.push(0, 0, -1.0);
+        uvs.push(1.0, 0.0);
+
+        positions.push(halfSize, halfSize, 0);
+        normals.push(0, 0, -1.0);
+        uvs.push(1.0, 1.0);
+
+        positions.push(-halfSize, halfSize, 0);
+        normals.push(0, 0, -1.0);
+        uvs.push(0.0, 1.0);
+
+        // Indices
+        indices.push(0);
+        indices.push(1);
+        indices.push(2);
+
+        indices.push(0);
+        indices.push(2);
+        indices.push(3);
+
+        // Result
+        var vertexData = new BABYLON.VertexData();
+
+        vertexData.indices = indices;
+        vertexData.positions = positions;
+        vertexData.normals = normals;
+        vertexData.uvs = uvs;
+
+        return vertexData;
+    };
+})();

+ 1 - 1
Babylon/Shaders/shadowMap.fragment.fx

@@ -7,7 +7,7 @@ vec4 pack(float depth)
 	const vec4 bitOffset = vec4(255. * 255. * 255., 255. * 255., 255., 1.);
 	const vec4 bitMask = vec4(0., 1. / 255., 1. / 255., 1. / 255.);
 	
-	vec4 comp = fract(depth * bitOffset);
+	vec4 comp = mod(depth * bitOffset * vec4(254.), vec4(255.)) / vec4(254.);
 	comp -= comp.xxyz * bitMask;
 	
 	return comp;

+ 14 - 0
Babylon/Tools/babylon.tools.js

@@ -13,6 +13,20 @@ var BABYLON = BABYLON || {};
         return path.substring(index + 1);
     };
 
+    BABYLON.Tools.GetDOMTextContent = function(element) {
+        var result = "";
+        var child = element.firstChild;
+
+        while (child) {
+            if (child.nodeType == 3) {
+                result += child.textContent;
+            }
+            child = child.nextSibling;
+        }
+
+        return result;
+    };
+
     BABYLON.Tools.ToDegrees = function(angle) {
         return angle * 180 / Math.PI;
     };

+ 2 - 2
Babylon/babylon.engine.js

@@ -369,8 +369,8 @@ var BABYLON = BABYLON || {};
 
     // Shaders
     BABYLON.Engine.prototype.createEffect = function (baseName, attributesNames, uniformsNames, samplers, defines, optionalDefines) {
-        var vertex = baseName.vertex || baseName;
-        var fragment = baseName.fragment || baseName;
+        var vertex = baseName.vertexElement || baseName.vertex || baseName;
+        var fragment = baseName.fragmentElement || baseName.fragment || baseName;
         
         var name = vertex + "+" + fragment + "@" + defines;
         if (this._compiledEffects[name]) {

BIN
Samples/Assets/BandeauEmbleme.png


BIN
Samples/Assets/Bandeauhaut.png


BIN
Samples/Assets/BtnAbout.png


BIN
Samples/Assets/BtnDownload.png


BIN
Samples/Assets/CamDeviceOff.png


BIN
Samples/Assets/CamTouchOff.png


BIN
Samples/Assets/Download.png


BIN
Samples/Assets/Flare.png


BIN
Samples/Assets/Layer0_0.png


BIN
Samples/Assets/Layer1_0.png


BIN
Samples/Assets/Layer2_0.png


BIN
Samples/Assets/Logo.png


BIN
Samples/Assets/MonsterARun.png


BIN
Samples/Assets/Player.png


BIN
Samples/Assets/Sand.jpg


BIN
Samples/Assets/Snow.jpg


BIN
Samples/Assets/SpotDown.png


BIN
Samples/Assets/SpotLast.png


BIN
Samples/Assets/Tree.png


BIN
Samples/Assets/amiga.jpg


BIN
Samples/Assets/camera.png


BIN
Samples/Assets/gradient.png


BIN
Samples/Assets/grass.jpg


BIN
Samples/Assets/heightMap.png


BIN
Samples/Assets/kosh.jpg


BIN
Samples/Assets/lens4.png


BIN
Samples/Assets/lens5.png


BIN
Samples/Assets/logo50.png


BIN
Samples/Assets/mosaic.jpg


BIN
Samples/Assets/rock.jpg


BIN
Samples/Assets/wood.jpg


BIN
Samples/Scenes/Blender/Metal1.png


BIN
Samples/Scenes/Blender/MountainGrass_jpg72767116-efb0-4b79-a016-8ac4ef7561a1Larger.jpg


File diff suppressed because it is too large
+ 0 - 9
Samples/Scenes/Blender/blender.babylon


BIN
Samples/Scenes/Blender/blender.blend


BIN
Samples/Scenes/Blender/chocolat.jpg


BIN
Samples/Scenes/Blender/concrete5.png


BIN
Samples/Scenes/Blender/paper.png


BIN
Samples/Scenes/Blender/paper02.png


BIN
Samples/Scenes/Blender/paper_bump.png


BIN
Samples/Scenes/Blender/wildtextures-old-wood-original-file-1280x853.jpg


BIN
Samples/Scenes/Customs/Ground.jpg


+ 0 - 61
Samples/Scenes/Customs/bones.js

@@ -1,61 +0,0 @@
-var CreateBonesTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var light = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, -0.5, -1.0), scene);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, new BABYLON.Vector3(0, 30, 0), scene);
-    camera.setPosition(new BABYLON.Vector3(20, 70, 120));
-    light.position = new BABYLON.Vector3(20, 150, 70);
-    camera.minZ = 10.0;
-
-    scene.ambientColor = new BABYLON.Color3(0.3, 0.3, 0.3);
-
-    // Ground
-    var ground = BABYLON.Mesh.CreateGround("ground", 1000, 1000, 1, scene, false);
-    var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
-    groundMaterial.diffuseColor = new BABYLON.Color3(0.2, 0.2, 0.2);
-    groundMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    ground.material = groundMaterial;
-    ground.receiveShadows = true;
-
-    // Shadows
-    var shadowGenerator = new BABYLON.ShadowGenerator(1024, light);
-
-    // Meshes
-    BABYLON.SceneLoader.ImportMesh("Rabbit", "Scenes/Rabbit/", "Rabbit.babylon", scene, function (newMeshes, particleSystems, skeletons) {
-        var rabbit = newMeshes[1];
-        
-        rabbit.scaling = new BABYLON.Vector3(0.4, 0.4, 0.4);
-        shadowGenerator.getShadowMap().renderList.push(rabbit);
-
-        var rabbit2 = rabbit.clone("rabbit2");
-        var rabbit3 = rabbit.clone("rabbit2");
-
-        shadowGenerator.getShadowMap().renderList.push(rabbit2);
-        shadowGenerator.getShadowMap().renderList.push(rabbit3);
-
-        rabbit2.position = new BABYLON.Vector3(-50, 0, -20);
-        rabbit2.skeleton = rabbit.skeleton.clone("clonedSkeleton");
-
-        rabbit3.position = new BABYLON.Vector3(50, 0, -20);
-        rabbit3.skeleton = rabbit.skeleton.clone("clonedSkeleton2");
-
-        scene.beginAnimation(skeletons[0], 0, 100, true, 0.8);
-        scene.beginAnimation(rabbit2.skeleton, 73, 100, true, 0.8);
-        scene.beginAnimation(rabbit3.skeleton, 0, 72, true, 0.8);
-        
-        // Dude
-        BABYLON.SceneLoader.ImportMesh("him", "Scenes/Dude/", "Dude.babylon", scene, function (newMeshes2, particleSystems2, skeletons2) {
-            var dude = newMeshes2[0];
-            
-            for (var index = 0; index < newMeshes2.length; index++) {
-                shadowGenerator.getShadowMap().renderList.push(newMeshes2[index]);
-            }
-
-            dude.rotation.y = Math.PI;
-            dude.position = new BABYLON.Vector3(0, 0, -80);
-                
-            scene.beginAnimation(skeletons2[0], 0, 100, true, 1.0);
-        });
-    });
-
-    return scene;
-};

+ 0 - 20
Samples/Scenes/Customs/bump_test.js

@@ -1,20 +0,0 @@
-var CreateBumpScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
-    var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 100, 2), scene);
-    var sphere = BABYLON.Mesh.CreateSphere("Sphere", 16, 3, scene);
-    var material = new BABYLON.StandardMaterial("kosh", scene);
-    material.bumpTexture = new BABYLON.Texture("Scenes/Customs/normalMap.jpg", scene);
-    material.diffuseColor = new BABYLON.Color3(1, 0, 0);
-    
-    sphere.material = material;
-    
-    camera.setPosition(new BABYLON.Vector3(-5, 5, 0));
-
-    // Animations
-    scene.registerBeforeRender(function() {
-        sphere.rotation.y += 0.02;
-    });
-
-    return scene;
-};

+ 0 - 99
Samples/Scenes/Customs/cellShading.js

@@ -1,99 +0,0 @@
-var CreateCellShadingScene = function (engine) {
-    
-    var CellShadingMaterial = function (name, scene, light) {
-        this.name = name;
-        this.id = name;
-        this.light = light;
-
-        this._scene = scene;
-        scene.materials.push(this);
-
-        this.texture = null;
-
-        this.toonThresholds = [0.95, 0.5, 0.2, 0.03];
-        this.toonBrightnessLevels = [1.0, 0.8, 0.6, 0.35, 0.01];
-    };
-
-    CellShadingMaterial.prototype = Object.create(BABYLON.Material.prototype);
-
-    // Properties   
-    CellShadingMaterial.prototype.needAlphaBlending = function () {
-        return false;
-    };
-
-    CellShadingMaterial.prototype.needAlphaTesting = function () {
-        return false;
-    };
-
-    // Methods   
-    CellShadingMaterial.prototype.isReady = function (mesh) {
-        var engine = this._scene.getEngine();
-
-        if (this.texture && !this.texture.isReady) {
-            return false;
-        }
-
-        this._effect = engine.createEffect("./Scenes/Customs/shaders/cellShading",
-            ["position", "normal", "uv"],
-            ["worldViewProjection", "world", "view", "vLightPosition", "vLightColor", "ToonBrightnessLevels", "ToonThresholds"],
-            ["textureSampler"],
-            "");
-
-        if (!this._effect.isReady()) {
-            return false;
-        }
-
-        return true;
-    };
-
-    CellShadingMaterial.prototype.bind = function (world, mesh) {
-        this._effect.setMatrix("world", world);
-        this._effect.setMatrix("worldViewProjection", world.multiply(this._scene.getTransformMatrix()));
-        this._effect.setVector3("vLightPosition", this.light.position);
-        this._effect.setColor3("vLightColor", this.light.diffuse);
-
-        this._effect.setArray("ToonThresholds", this.toonThresholds);
-        this._effect.setArray("ToonBrightnessLevels", this.toonBrightnessLevels);
-
-        // Textures        
-        this._effect.setTexture("textureSampler", this.texture);
-    };
-
-    CellShadingMaterial.prototype.dispose = function () {
-        if (this.texture) {
-            this.texture.dispose();
-        }
-        this.baseDispose();
-    };
-
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, Math.PI / 4, 40, BABYLON.Vector3.Zero(), scene);
-    var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 100, 2), scene);
-    var sphere = BABYLON.Mesh.CreateSphere("Sphere0", 32, 3, scene);
-    var cylinder = BABYLON.Mesh.CreateCylinder("Sphere1", 5, 3, 2, 32, scene);
-    var torus = BABYLON.Mesh.CreateTorus("Sphere2", 3, 1, 32, scene);
-
-    var cellShadingMaterial = new CellShadingMaterial("mat0", scene, light);
-    cellShadingMaterial.texture = new BABYLON.Texture("Scenes/Customs/Ground.jpg", scene);
-    
-    sphere.material = cellShadingMaterial;
-    sphere.position = new BABYLON.Vector3(-10, 0, 0);
-    cylinder.material = cellShadingMaterial;
-    torus.material = cellShadingMaterial;
-    torus.position = new BABYLON.Vector3(10, 0, 0);
-    
-    // Animations
-    var alpha = 0;
-    scene.registerBeforeRender(function () {
-        sphere.rotation.y = alpha;
-        sphere.rotation.x = alpha;
-        cylinder.rotation.y = alpha;
-        cylinder.rotation.x = alpha;
-        torus.rotation.y = alpha;
-        torus.rotation.x = alpha;
-
-        alpha += 0.05;
-    });
-    
-    return scene;
-};

+ 0 - 129
Samples/Scenes/Customs/charting.js

@@ -1,129 +0,0 @@
-var CreateChartingTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var light = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, -0.5, 1.0), scene);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
-    camera.setPosition(new BABYLON.Vector3(20, 70, -100));
-    light.position = new BABYLON.Vector3(0, 25, -50);
-    
-    // Data
-    var scale = 0.6;
-    var operatingSystem_Series = [
-        { label: "Macintosh", value: 12, color: new BABYLON.Color3(0, 1, 0) },
-        { label: "Windows", value: 77, color: new BABYLON.Color3(1, 0, 0) },
-        { label: "Linux", value: 4, color: new BABYLON.Color3(1, 0, 1) },
-        { label: "iOS", value: 3, color: new BABYLON.Color3(1, 1, 0) },
-        { label: "Android", value: 2, color: new BABYLON.Color3(0, 0, 1) },
-        { label: "Win Phone", value: 1, color: new BABYLON.Color3(1, 1, 1) }
-    ];
-    
-    var browsers_Series = [
-        { label: "IE", value: 32, color: new BABYLON.Color3(0, 0, 1) },
-        { label: "Chrome", value: 28, color: new BABYLON.Color3(1, 0, 0) },
-        { label: "Firefox", value: 16, color: new BABYLON.Color3(1, 0, 1) },
-        { label: "Opera", value: 14, color: new BABYLON.Color3(1, 1, 0) },
-        { label: "Safari", value: 10, color: new BABYLON.Color3(0, 1, 1) }        
-    ];
-    
-    var playgroundSize = 100;
-    // Background
-    var background = BABYLON.Mesh.CreatePlane("background", playgroundSize, scene, false);
-    background.material = new BABYLON.StandardMaterial("background", scene);
-    background.scaling.y = 0.5;
-    background.position.z = playgroundSize / 2 - 0.5;
-    background.position.y = playgroundSize / 4;
-    background.receiveShadows = true;
-    var backgroundTexture = new BABYLON.DynamicTexture("dynamic texture", 512, scene, true);
-    background.material.diffuseTexture = backgroundTexture;
-    background.material.specularColor = new BABYLON.Color3(0, 0, 0);
-    background.material.backFaceCulling = false;
-
-    backgroundTexture.drawText("Eternalcoding", null, 80, "bold 70px Segoe UI", "white", "#555555");
-    backgroundTexture.drawText("- browsers statistics -", null, 250, "35px Segoe UI", "white", null);
-    //background.material.reflectionTexture = new BABYLON.MirrorTexture("mirror", 1024, scene, true);
-    //background.material.reflectionTexture.mirrorPlane = new BABYLON.Plane(0, 0, 1.0, -playgroundSize / 2 + 0.5);
-    //background.material.reflectionTexture.level = 0.5;
-
-    // Ground    
-    var ground = BABYLON.Mesh.CreateGround("ground", playgroundSize, playgroundSize, 1, scene, false);
-    var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
-    groundMaterial.diffuseColor = new BABYLON.Color3(0.5, 0.5, 0.5);
-    groundMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    ground.material = groundMaterial;
-    ground.receiveShadows = true;
-    ground.position.y = -0.1;
-    //background.material.reflectionTexture.renderList.push(ground);
-    
-    var shadowGenerator = new BABYLON.ShadowGenerator(1024, light);
-    
-    var createSeries = function (series) {
-        var margin = 2;
-        var offset = playgroundSize / (series.length) - margin;
-        var x = -playgroundSize / 2 + offset / 2;
-
-        for (var index = 0; index < series.length; index++) {
-            var data = series[index];
-
-            var bar = BABYLON.Mesh.CreateBox(data.label, 1.0, scene, false);
-            bar.scaling = new BABYLON.Vector3(offset / 2.0, 0, offset / 2.0);
-            bar.position.x = x;
-            bar.position.y = 0;
-            
-            // Animate a bit
-            var animation = new BABYLON.Animation("anim", "scaling", 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3);
-            animation.setKeys([
-                { frame: 0, value: new BABYLON.Vector3(offset / 2.0, 0, offset / 2.0) },
-                { frame: 100, value: new BABYLON.Vector3(offset / 2.0, data.value * scale, offset / 2.0) }]);
-            bar.animations.push(animation);
-            
-            animation = new BABYLON.Animation("anim2", "position.y", 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT);
-            animation.setKeys([
-                { frame: 0, value: 0 },
-                { frame: 100, value: (data.value * scale) / 2 }]);
-            bar.animations.push(animation);            
-            scene.beginAnimation(bar, 0, 100, false, 2.0);
-
-            // Material
-            bar.material = new BABYLON.StandardMaterial(data.label + "mat", scene);
-            bar.material.diffuseColor = data.color;
-            bar.material.emissiveColor = data.color.scale(0.3);
-            bar.material.specularColor = new BABYLON.Color3(0, 0, 0);
-
-            // Shadows
-            shadowGenerator.getShadowMap().renderList.push(bar);
-            
-            // Mirror
-          //  background.material.reflectionTexture.renderList.push(bar);
-            
-            // Legend
-            var barLegend = BABYLON.Mesh.CreateGround(data.label + "Legend", playgroundSize / 2, offset * 2, 1, scene, false);
-            barLegend.position.x = x;
-            barLegend.position.z = -playgroundSize / 4;
-            barLegend.rotation.y = Math.PI / 2;
-            
-            barLegend.material = new BABYLON.StandardMaterial(data.label + "LegendMat", scene);
-            var barLegendTexture = new BABYLON.DynamicTexture("dynamic texture", 512, scene, true);
-            barLegendTexture.hasAlpha = true;
-            barLegend.material.diffuseTexture = barLegendTexture;
-            barLegend.material.emissiveColor = new BABYLON.Color3(0.4, 0.4, 0.4);
-            
-            var size = barLegendTexture.getSize();
-            barLegendTexture.drawText(data.label + " (" + data.value + "%)", 80, size.height / 2 + 30, "bold 50px Segoe UI", "white", "transparent");
-         //   background.material.reflectionTexture.renderList.push(barLegend);
-            
-            // Going next
-            x += offset + margin;
-        }
-    };
-
-    createSeries(browsers_Series);
-
-    // Limit camera
-    camera.lowerAlphaLimit = Math.PI;
-    camera.upperAlphaLimit = 2 * Math.PI;
-    camera.lowerBetaLimit = 0.1;
-    camera.upperBetaLimit = (Math.PI / 2) * 0.99;
-    camera.lowerRadiusLimit = 5;
-    camera.upperRadiusLimit = 150;
-
-    return scene;
-};

+ 0 - 64
Samples/Scenes/Customs/csg.js

@@ -1,64 +0,0 @@
-var CreateCSGTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var light = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, -0.5, -1.0), scene);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, new BABYLON.Vector3(0, 0, 0), scene);
-    camera.setPosition(new BABYLON.Vector3(10, 10, 10));
-    light.position = new BABYLON.Vector3(20, 150, 70);
-    camera.minZ = 10.0;
-
-    scene.ambientColor = new BABYLON.Color3(0.3, 0.3, 0.3);
-
-    var sourceMat = new BABYLON.StandardMaterial("sourceMat", scene);
-    sourceMat.wireframe = true;
-    sourceMat.backFaceCulling = false;
-
-    var a = BABYLON.Mesh.CreateSphere("sphere", 16, 4, scene);
-    var b = BABYLON.Mesh.CreateBox("box", 4, scene);
-    var c = BABYLON.Mesh.CreateBox("box", 4, scene);
-
-    a.material = sourceMat;
-    b.material = sourceMat;
-    c.material = sourceMat;
-
-    a.position.y += 5;
-    b.position.y += 2.5;
-    c.position.y += 3.5;
-    c.rotation.y += Math.PI / 8.0;
-
-    var aCSG = BABYLON.CSG.FromMesh(a);
-    var bCSG = BABYLON.CSG.FromMesh(b);
-    var cCSG = BABYLON.CSG.FromMesh(c);
-
-    // Set up a MultiMaterial
-    var mat0 = new BABYLON.StandardMaterial("mat0", scene);
-    var mat1 = new BABYLON.StandardMaterial("mat1", scene);
-
-    mat0.diffuseColor.copyFromFloats(0.8, 0.2, 0.2);
-    mat0.backFaceCulling = false;
-
-    mat1.diffuseColor.copyFromFloats(0.2, 0.8, 0.2);
-    mat1.backFaceCulling = false;
-
-    var subCSG = bCSG.subtract(aCSG);
-    var newMesh = subCSG.toMesh("csg", mat0, scene);
-    newMesh.position = new BABYLON.Vector3(-10, 0, 0);
-
-    subCSG = aCSG.subtract(bCSG);
-    newMesh = subCSG.toMesh("csg2", mat0, scene);
-    newMesh.position = new BABYLON.Vector3(10, 0, 0);
-
-    subCSG = aCSG.intersect(bCSG);
-    newMesh = subCSG.toMesh("csg3", mat0, scene);
-    newMesh.position = new BABYLON.Vector3(0, 0, 10);
-
-    // Submeshes are built in order : mat0 will be for the first cube, and mat1 for the second
-    var multiMat = new BABYLON.MultiMaterial("multiMat", scene);
-    multiMat.subMaterials.push(mat0, mat1);
-
-    // Last parameter to true means you want to build 1 subMesh for each mesh involved
-    subCSG = bCSG.subtract(cCSG);
-    newMesh = subCSG.toMesh("csg4", multiMat, scene, true);
-    newMesh.position = new BABYLON.Vector3(0, 0, -10);
-
-    return scene;
-};

+ 0 - 42
Samples/Scenes/Customs/fog_test.js

@@ -1,42 +0,0 @@
-var CreateFogScene = function(engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(0, 0, -20), scene);
-    var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 100, 2), scene);
-    var sphere0 = BABYLON.Mesh.CreateSphere("Sphere0", 16, 3, scene);
-    var sphere1 = BABYLON.Mesh.CreateSphere("Sphere1", 16, 3, scene);
-    var sphere2 = BABYLON.Mesh.CreateSphere("Sphere2", 16, 3, scene);
-
-    var material0 = new BABYLON.StandardMaterial("mat0", scene);
-    material0.diffuseColor = new BABYLON.Color3(1, 0, 0);
-    sphere0.material = material0;
-    sphere0.position = new BABYLON.Vector3(-10, 0, 0);
-
-    var material1 = new BABYLON.StandardMaterial("mat1", scene);
-    material1.diffuseColor = new BABYLON.Color3(1, 1, 0);
-    sphere1.material = material1;
-
-    var material2 = new BABYLON.StandardMaterial("mat2", scene);
-    material2.diffuseColor = new BABYLON.Color3(1, 0, 1);
-    sphere2.material = material2;
-    sphere2.position = new BABYLON.Vector3(10, 0, 0);
-
-    sphere1.convertToFlatShadedMesh();
-    
-    camera.setTarget(new BABYLON.Vector3(0, 0, 0));
-    
-    // Fog
-    scene.fogMode = BABYLON.Scene.FOGMODE_EXP;
-    scene.fogDensity = 0.1;
-
-    // Animations
-    var alpha = 0;
-    scene.registerBeforeRender(function () {
-        sphere0.position.z = 4 * Math.cos(alpha);
-        sphere1.position.z = 4 * Math.sin(alpha);
-        sphere2.position.z = 4 * Math.cos(alpha);
-
-        alpha += 0.1;
-    });
-
-    return scene;
-};

BIN
Samples/Scenes/Customs/grass.dds


BIN
Samples/Scenes/Customs/heightMap.png


+ 0 - 49
Samples/Scenes/Customs/heightMap_test.js

@@ -1,49 +0,0 @@
-var CreateHeightMapTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
-    var sun = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(60, 100, 10), scene);
-
-    camera.setPosition(new BABYLON.Vector3(-20, 20, 0));
-    
-    // Skybox
-    var skybox = BABYLON.Mesh.CreateBox("skyBox", 100.0, scene);
-    var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
-    skyboxMaterial.backFaceCulling = false;
-    skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("Scenes/Customs/skybox/skybox", scene);
-    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
-    skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    skybox.material = skyboxMaterial;
-    
-    // Ground
-    var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "Scenes/Customs/heightMap.png", 100, 100, 100, 0, 10, scene, false);
-    var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
-    if (engine.getCaps().s3tc) {
-        groundMaterial.diffuseTexture = new BABYLON.Texture("Scenes/Customs/grass.dds", scene);
-    } else {
-        groundMaterial.diffuseTexture = new BABYLON.Texture("Scenes/Customs/ground.jpg", scene);
-    }
-    groundMaterial.diffuseTexture.uScale = 6;
-    groundMaterial.diffuseTexture.vScale = 6;
-    groundMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    ground.position.y = -2.05;
-    ground.material = groundMaterial;
-
-    var beforeRenderFunction = function() {
-        // Camera
-        if (camera.beta < 0.1)
-            camera.beta = 0.1;
-        else if (camera.beta > (Math.PI / 2) * 0.9)
-            camera.beta = (Math.PI / 2) * 0.9;
-
-        if (camera.radius > 50)
-            camera.radius = 50;
-
-        if (camera.radius < 5)
-            camera.radius = 5;
-    };
-
-    scene.registerBeforeRender(beforeRenderFunction);
-
-    return scene;
-};

+ 0 - 39
Samples/Scenes/Customs/lensFlares.js

@@ -1,39 +0,0 @@
-var CreateLensFlaresTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
-    var light0 = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(21.84, 50, -28.26), scene);
-
-    camera.alpha = 2.8;
-    camera.beta = 2.25;
-    
-    // Creating light sphere
-    var lightSphere0 = BABYLON.Mesh.CreateSphere("Sphere0", 16, 0.5, scene);
-    
-    lightSphere0.material = new BABYLON.StandardMaterial("white", scene);
-    lightSphere0.material.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    lightSphere0.material.specularColor = new BABYLON.Color3(0, 0, 0);
-    lightSphere0.material.emissiveColor = new BABYLON.Color3(1, 1, 1);
-
-    lightSphere0.position = light0.position;
-    
-    var lensFlareSystem = new BABYLON.LensFlareSystem("lensFlareSystem", light0, scene);
-    var flare00 = new BABYLON.LensFlare(0.2, 0, new BABYLON.Color3(1, 1, 1), "Assets/lens5.png", lensFlareSystem);
-    var flare01 = new BABYLON.LensFlare(0.5, 0.2, new BABYLON.Color3(0.5, 0.5, 1), "Assets/lens4.png", lensFlareSystem);
-    var flare02 = new BABYLON.LensFlare(0.2, 1.0, new BABYLON.Color3(1, 1, 1), "Assets/lens4.png", lensFlareSystem);
-    var flare03 = new BABYLON.LensFlare(0.4, 0.4, new BABYLON.Color3(1, 0.5, 1), "Assets/Flare.png", lensFlareSystem);
-    var flare04 = new BABYLON.LensFlare(0.1, 0.6, new BABYLON.Color3(1, 1, 1), "Assets/lens5.png", lensFlareSystem);
-    var flare05 = new BABYLON.LensFlare(0.3, 0.8, new BABYLON.Color3(1, 1, 1), "Assets/lens4.png", lensFlareSystem);
-
-
-    // Skybox
-    var skybox = BABYLON.Mesh.CreateBox("skyBox", 100.0, scene);
-    var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
-    skyboxMaterial.backFaceCulling = false;
-    skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("Scenes/Customs/skybox/skybox", scene);
-    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
-    skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    skybox.material = skyboxMaterial;
-
-    return scene;
-};

+ 0 - 78
Samples/Scenes/Customs/lights_test.js

@@ -1,78 +0,0 @@
-var CreateLightsTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
-    var light0 = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(0, 10, 0), scene);
-    var light1 = new BABYLON.PointLight("Omni1", new BABYLON.Vector3(0, -10, 0), scene);
-    var light2 = new BABYLON.PointLight("Omni2", new BABYLON.Vector3(10, 0, 0), scene);
-    var light3 = new BABYLON.DirectionalLight("Dir0", new BABYLON.Vector3(1, -1, 0), scene);
-    var material = new BABYLON.StandardMaterial("kosh", scene);
-    var sphere = BABYLON.Mesh.CreateSphere("Sphere", 16, 3, scene);
-
-    camera.setPosition(new BABYLON.Vector3(-10, 10, 0));
-
-    light3.parent = camera;
-    
-    // Creating light sphere
-    var lightSphere0 = BABYLON.Mesh.CreateSphere("Sphere0", 16, 0.5, scene);
-    var lightSphere1 = BABYLON.Mesh.CreateSphere("Sphere1", 16, 0.5, scene);
-    var lightSphere2 = BABYLON.Mesh.CreateSphere("Sphere2", 16, 0.5, scene);
-    
-    lightSphere0.material = new BABYLON.StandardMaterial("red", scene);
-    lightSphere0.material.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    lightSphere0.material.specularColor = new BABYLON.Color3(0, 0, 0);
-    lightSphere0.material.emissiveColor = new BABYLON.Color3(1, 0, 0);
-
-    lightSphere1.material = new BABYLON.StandardMaterial("green", scene);
-    lightSphere1.material.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    lightSphere1.material.specularColor = new BABYLON.Color3(0, 0, 0);
-    lightSphere1.material.emissiveColor = new BABYLON.Color3(0, 1, 0);
-
-    lightSphere2.material = new BABYLON.StandardMaterial("blue", scene);
-    lightSphere2.material.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    lightSphere2.material.specularColor = new BABYLON.Color3(0, 0, 0);
-    lightSphere2.material.emissiveColor = new BABYLON.Color3(0, 0, 1);
-
-    // Sphere material
-    material.diffuseColor = new BABYLON.Color3(1, 1, 1);
-    sphere.material = material;
-
-    // Lights colors
-    light0.diffuse = new BABYLON.Color3(1, 0, 0);
-    light0.specular = new BABYLON.Color3(1, 0, 0);
-    
-    light1.diffuse = new BABYLON.Color3(0, 1, 0);
-    light1.specular = new BABYLON.Color3(0, 1, 0);
-    
-    light2.diffuse = new BABYLON.Color3(0, 0, 1);
-    light2.specular = new BABYLON.Color3(0, 0, 1);
-    
-    light3.diffuse = new BABYLON.Color3(1, 1, 1);
-    light3.specular = new BABYLON.Color3(1, 1, 1);
-    
-    // Skybox
-    var skybox = BABYLON.Mesh.CreateBox("skyBox", 100.0, scene);
-    var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
-    skyboxMaterial.backFaceCulling = false;
-    skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("Scenes/Customs/skybox/skybox", scene);
-    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
-    skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    skybox.material = skyboxMaterial;
-    skybox.infiniteDistance = true;
-
-    // Animations
-    var alpha = 0;
-    scene.registerBeforeRender(function () {
-        light0.position = new BABYLON.Vector3(10 * Math.sin(alpha), 0, 10 * Math.cos(alpha));
-        light1.position = new BABYLON.Vector3(10 * Math.sin(alpha), 0, -10 * Math.cos(alpha));
-        light2.position = new BABYLON.Vector3(10 * Math.cos(alpha), 0, 10 * Math.sin(alpha));
-
-        lightSphere0.position = light0.position;
-        lightSphere1.position = light1.position;
-        lightSphere2.position = light2.position;
-
-        alpha += 0.01;
-    });
-
-    return scene;
-};

+ 0 - 40
Samples/Scenes/Customs/multimat.js

@@ -1,40 +0,0 @@
-var CreateMultiMaterialScene = function(engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
-    var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 100, 2), scene);
-    
-
-    var material0 = new BABYLON.StandardMaterial("mat0", scene);
-    material0.diffuseColor = new BABYLON.Color3(1, 0, 0);
-    material0.bumpTexture = new BABYLON.Texture("Scenes/Customs/normalMap.jpg", scene);
-    
-    var material1 = new BABYLON.StandardMaterial("mat1", scene);
-    material1.diffuseColor = new BABYLON.Color3(0, 0, 1);
-    
-    var material2 = new BABYLON.StandardMaterial("mat2", scene);
-    material2.emissiveColor = new BABYLON.Color3(0.4, 0, 0.4);
-
-    var multimat = new BABYLON.MultiMaterial("multi", scene);
-    multimat.subMaterials.push(material0);
-    multimat.subMaterials.push(material1);
-    multimat.subMaterials.push(material2);
-
-    var sphere = BABYLON.Mesh.CreateSphere("Sphere0", 16, 3, scene);
-    sphere.material = multimat;
-
-    sphere.subMeshes = [];
-    var verticesCount = sphere.getTotalVertices();
-    
-    sphere.subMeshes.push(new BABYLON.SubMesh(0, 0, verticesCount, 0, 900, sphere));
-    sphere.subMeshes.push(new BABYLON.SubMesh(1, 0, verticesCount, 900, 900, sphere));
-    sphere.subMeshes.push(new BABYLON.SubMesh(2, 0, verticesCount, 1800, 2088, sphere));
-
-    camera.setPosition(new BABYLON.Vector3(-3, 3, 0));
-    
-    // Animations
-    scene.registerBeforeRender(function () {
-        sphere.rotation.y += 0.01;
-    });
-
-    return scene;
-};

BIN
Samples/Scenes/Customs/normalMap.jpg


+ 0 - 33
Samples/Scenes/Customs/octree.js

@@ -1,33 +0,0 @@
-var CreateOctreeTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
-    var light0 = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(0, 10, 0), scene);
-    var material = new BABYLON.StandardMaterial("kosh", scene);
-    var sphere = BABYLON.Mesh.CreateSphere("sphere0", 16, 1, scene);
-
-    camera.setPosition(new BABYLON.Vector3(-10, 10, 0));
-    
-    // Sphere material
-    material.diffuseColor = new BABYLON.Color3(0.5, 0.5, 0.5);
-    material.specularColor = new BABYLON.Color3(1.0, 1.0, 1.0);
-    material.specularPower = 32;
-    material.checkReadyOnEveryCall = false;
-    sphere.material = material;
-    
-    // Fog
-    scene.fogMode = BABYLON.Scene.FOGMODE_EXP;
-    scene.fogDensity = 0.05;
-    
-    // Clone spheres
-    var playgroundSize = 50;
-    for (var index = 0; index < 8000; index++) {
-        var clone = sphere.clone("sphere" + (index + 1), null, true);
-        var scale = Math.random() * 0.8 + 0.6;
-        clone.scaling = new BABYLON.Vector3(scale, scale, scale);
-        clone.position = new BABYLON.Vector3(Math.random() * 2 * playgroundSize - playgroundSize, Math.random() * 2 * playgroundSize - playgroundSize, Math.random() * 2 * playgroundSize - playgroundSize);
-    }
-    sphere.setEnabled(false);
-    scene.createOrUpdateSelectionOctree();
-    
-    return scene;
-};

+ 0 - 141
Samples/Scenes/Customs/physics.js

@@ -1,141 +0,0 @@
-var CreatePhysicsScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(0, 0, -20), scene);
-    camera.checkCollisions = true;
-    camera.applyGravity = true;
-
-    var light = new BABYLON.DirectionalLight("dir02", new BABYLON.Vector3(0.2, -1, 0), scene);
-    light.position = new BABYLON.Vector3(0, 80, 0);
-
-    // Material
-    var materialAmiga = new BABYLON.StandardMaterial("amiga", scene);
-    materialAmiga.diffuseTexture = new BABYLON.Texture("assets/amiga.jpg", scene);
-    materialAmiga.emissiveColor = new BABYLON.Color3(0.5, 0.5, 0.5);
-    materialAmiga.diffuseTexture.uScale = 5;
-    materialAmiga.diffuseTexture.vScale = 5;
-
-    var materialAmiga2 = new BABYLON.StandardMaterial("amiga", scene);
-    materialAmiga2.diffuseTexture = new BABYLON.Texture("assets/mosaic.jpg", scene);
-    materialAmiga2.emissiveColor = new BABYLON.Color3(0.5, 0.5, 0.5);
-
-    // Shadows
-    var shadowGenerator = new BABYLON.ShadowGenerator(2048, light);
-    shadowGenerator.getShadowMap().renderList.push(box0);
-
-    // Physics
-    scene.enablePhysics();
-
-    // Spheres
-    var y = 0;
-    for (var index = 0; index < 32; index++) {
-        var sphere = BABYLON.Mesh.CreateSphere("Sphere0", 16, 3, scene);
-        sphere.material = materialAmiga;
-
-        sphere.position = new BABYLON.Vector3(Math.random() * 20 - 10, y, Math.random() * 10 - 5);
-
-        shadowGenerator.getShadowMap().renderList.push(sphere);
-
-        sphere.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 1 });
-
-        y += 2;
-    }
-
-    // Link
-    var spheres = [];
-    for (var index = 0; index < 10; index++) {
-        var sphere = BABYLON.Mesh.CreateSphere("Sphere0", 16, 1, scene);
-        spheres.push(sphere);
-        sphere.material = materialAmiga2;
-        sphere.position = new BABYLON.Vector3(Math.random() * 20 - 10, y, Math.random() * 10 - 5);
-
-        shadowGenerator.getShadowMap().renderList.push(sphere);
-
-        sphere.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 1 });
-    }
-
-    for (var index = 0; index < 10; index++) {
-        spheres[index].setPhysicsLinkWith(spheres[index + 1], new BABYLON.Vector3(0, 0.5, 0), new BABYLON.Vector3(0, -0.5, 0));
-    }
-
-    // Box
-    var box0 = BABYLON.Mesh.CreateBox("Box0", 3, scene);
-    box0.position = new BABYLON.Vector3(3, 30, 0);
-    var materialWood = new BABYLON.StandardMaterial("wood", scene);
-    materialWood.diffuseTexture = new BABYLON.Texture("assets/wood.jpg", scene);
-    materialWood.emissiveColor = new BABYLON.Color3(0.5, 0.5, 0.5);
-    box0.material = materialWood;
-
-    shadowGenerator.getShadowMap().renderList.push(box0);
-
-    // Compound
-    var part0 = BABYLON.Mesh.CreateBox("part0", 3, scene);
-    part0.position = new BABYLON.Vector3(3, 30, 0);
-    part0.material = materialWood;
-
-    var part1 = BABYLON.Mesh.CreateBox("part1", 3, scene);
-    part1.parent = part0; // We need a hierarchy for compound objects
-    part1.position = new BABYLON.Vector3(0, 3, 0);
-    part1.material = materialWood;
-
-    shadowGenerator.getShadowMap().renderList.push(part0);
-    shadowGenerator.getShadowMap().renderList.push(part1);
-
-
-    // Playground
-    var ground = BABYLON.Mesh.CreateBox("Ground", 1, scene);
-    ground.scaling = new BABYLON.Vector3(100, 1, 100);
-    ground.position.y = -5.0;
-    ground.checkCollisions = true;
-
-    var border0 = BABYLON.Mesh.CreateBox("border0", 1, scene);
-    border0.scaling = new BABYLON.Vector3(1, 100, 100);
-    border0.position.y = -5.0;
-    border0.position.x = -50.0;
-    border0.checkCollisions = true;
-
-    var border1 = BABYLON.Mesh.CreateBox("border1", 1, scene);
-    border1.scaling = new BABYLON.Vector3(1, 100, 100);
-    border1.position.y = -5.0;
-    border1.position.x = 50.0;
-    border1.checkCollisions = true;
-
-    var border2 = BABYLON.Mesh.CreateBox("border2", 1, scene);
-    border2.scaling = new BABYLON.Vector3(100, 100, 1);
-    border2.position.y = -5.0;
-    border2.position.z = 50.0;
-    border2.checkCollisions = true;
-
-    var border3 = BABYLON.Mesh.CreateBox("border3", 1, scene);
-    border3.scaling = new BABYLON.Vector3(100, 100, 1);
-    border3.position.y = -5.0;
-    border3.position.z = -50.0;
-    border3.checkCollisions = true;
-
-    camera.setTarget(new BABYLON.Vector3(0, 0, 0));
-
-    var groundMat = new BABYLON.StandardMaterial("groundMat", scene);
-    groundMat.diffuseColor = new BABYLON.Color3(0.5, 0.5, 0.5);
-    groundMat.emissiveColor = new BABYLON.Color3(0.2, 0.2, 0.2);
-    ground.material = groundMat;
-    border0.material = groundMat;
-    border1.material = groundMat;
-    border2.material = groundMat;
-    border3.material = groundMat;
-    ground.receiveShadows = true;
-
-    // Physics
-    box0.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 2, friction: 0.4, restitution: 0.3 });
-    ground.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 0, friction: 0.5, restitution: 0.7 });
-    border0.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 0 });
-    border1.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 0 });
-    border2.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 0 });
-    border3.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 0 });
-
-    scene.createCompoundImpostor({
-        mass: 2, friction: 0.4, restitution: 0.3, parts: [
-        { mesh: part0, impostor: BABYLON.PhysicsEngine.BoxImpostor },
-        { mesh: part1, impostor: BABYLON.PhysicsEngine.BoxImpostor }]
-    });
-
-    return scene;
-};

+ 0 - 77
Samples/Scenes/Customs/postprocessBloom.js

@@ -1,77 +0,0 @@
-var CreatePostProcessBloomTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
-    var light = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, -1, -0.2), scene);
-    var light2 = new BABYLON.DirectionalLight("dir02", new BABYLON.Vector3(-1, -2, -1), scene);
-    light.position = new BABYLON.Vector3(0, 30, 0);
-    light2.position = new BABYLON.Vector3(10, 20, 10);
-
-    light.intensity = 0.6;
-    light2.intensity = 0.6;
-
-    camera.setPosition(new BABYLON.Vector3(-40, 40, 0));
-    camera.lowerBetaLimit = (Math.PI / 2) * 0.9;
-    
-    // Skybox
-    var skybox = BABYLON.Mesh.CreateBox("skyBox", 1000.0, scene);
-    var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
-    skyboxMaterial.backFaceCulling = false;
-    skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("Scenes/Customs/skybox/snow", scene);
-    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
-    skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    skybox.material = skyboxMaterial;
-    
-    // Spheres
-    var sphere0 = BABYLON.Mesh.CreateSphere("Sphere0", 16, 10, scene);
-    var sphere1 = BABYLON.Mesh.CreateSphere("Sphere1", 16, 10, scene);
-    var sphere2 = BABYLON.Mesh.CreateSphere("Sphere2", 16, 10, scene);
-    var cube = BABYLON.Mesh.CreateBox("Cube", 10.0, scene);
-
-    sphere0.material = new BABYLON.StandardMaterial("white", scene);
-    sphere0.material.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    sphere0.material.specularColor = new BABYLON.Color3(0, 0, 0);
-    sphere0.material.emissiveColor = new BABYLON.Color3(1.0, 1.0, 1.0);
-    
-    sphere1.material = sphere0.material;
-    sphere2.material = sphere0.material;
-    
-    cube.material = new BABYLON.StandardMaterial("red", scene);
-    cube.material.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    cube.material.specularColor = new BABYLON.Color3(0, 0, 0);
-    cube.material.emissiveColor = new BABYLON.Color3(1.0, 0, 0);
-       
-    // Post-process
-    var blurWidth = 1.0;
-    
-    var postProcess0 = new BABYLON.PassPostProcess("Scene copy", 1.0, camera);
-    var postProcess1 = new BABYLON.PostProcess("Down sample", "./Scenes/Customs/postprocesses/downsample", ["screenSize", "highlightThreshold"], null, 0.25, camera, BABYLON.Texture.BILINEAR_SAMPLINGMODE);
-    postProcess1.onApply = function (effect) {
-        effect.setFloat2("screenSize", postProcess1.width, postProcess1.height);
-        effect.setFloat("highlightThreshold", 0.90);
-    };
-    var postProcess2 = new BABYLON.BlurPostProcess("Horizontal blur", new BABYLON.Vector2(1.0, 0), blurWidth, 0.25, camera);
-    var postProcess3 = new BABYLON.BlurPostProcess("Vertical blur", new BABYLON.Vector2(0, 1.0), blurWidth, 0.25, camera);
-    var postProcess4 = new BABYLON.PostProcess("Final compose", "./Scenes/Customs/postprocesses/compose", ["sceneIntensity", "glowIntensity", "highlightIntensity"], ["sceneSampler"], 1, camera);
-    postProcess4.onApply = function (effect) {
-        effect.setTextureFromPostProcess("sceneSampler", postProcess0);
-        effect.setFloat("sceneIntensity", 0.5);
-        effect.setFloat("glowIntensity", 0.4);
-        effect.setFloat("highlightIntensity", 1.0);
-    };
-    
-    // Animations
-    var alpha = 0;
-    scene.registerBeforeRender(function() {
-        sphere0.position = new BABYLON.Vector3(20 * Math.sin(alpha), 0, 20 * Math.cos(alpha));
-        sphere1.position = new BABYLON.Vector3(20 * Math.sin(alpha), 0, -20 * Math.cos(alpha));
-        sphere2.position = new BABYLON.Vector3(20 * Math.cos(alpha), 0, 20 * Math.sin(alpha));
-
-        cube.rotation.y += 0.01;
-        cube.rotation.z += 0.01;
-
-        alpha += 0.01;
-    });
-    
-    return scene;
-};

+ 0 - 62
Samples/Scenes/Customs/postprocessConvolution.js

@@ -1,62 +0,0 @@
-var CreateConvolutionTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
-    var light = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, -1, -0.2), scene);
-    var light2 = new BABYLON.DirectionalLight("dir02", new BABYLON.Vector3(-1, 2, -1), scene);
-    light.position = new BABYLON.Vector3(0, 30, 0);
-    light2.position = new BABYLON.Vector3(10, 20, 10);
-
-    light.intensity = 0.6;
-    light2.intensity = 0.6;
-
-    camera.setPosition(new BABYLON.Vector3(-40, 40, 0));
-
-    // Skybox
-    var skybox = BABYLON.Mesh.CreateBox("skyBox", 500.0, scene);
-    var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
-    skyboxMaterial.backFaceCulling = false;
-    skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("Scenes/Customs/skybox/skybox", scene);
-    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
-    skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    skybox.material = skyboxMaterial;
-    skybox.infiniteDistance = true;
-        
-    // Spheres
-    var sphere0 = BABYLON.Mesh.CreateSphere("Sphere0", 16, 10, scene);
-    var sphere1 = BABYLON.Mesh.CreateSphere("Sphere1", 16, 10, scene);
-    var sphere2 = BABYLON.Mesh.CreateSphere("Sphere2", 16, 10, scene);
-    var cube = BABYLON.Mesh.CreateBox("Cube", 10.0, scene);
-
-    sphere0.material = new BABYLON.StandardMaterial("white", scene);
-    sphere0.material.diffuseColor = new BABYLON.Color3(0.5, 0.5, 1.0);
-    
-    sphere1.material = sphere0.material;
-    sphere2.material = sphere0.material;
-
-    sphere0.convertToFlatShadedMesh();
-    sphere1.convertToFlatShadedMesh();
-    sphere2.convertToFlatShadedMesh();
-    
-    cube.material = new BABYLON.StandardMaterial("red", scene);
-    cube.material.diffuseColor = new BABYLON.Color3(1.0, 0.5, 0.5);
-    cube.material.specularColor = new BABYLON.Color3(0, 0, 0);
-       
-    // Post-process
-    var postProcess = new BABYLON.ConvolutionPostProcess("convolution", BABYLON.ConvolutionPostProcess.EmbossKernel, 1.0, camera);
-    
-    // Animations
-    var alpha = 0;
-    scene.registerBeforeRender(function() {
-        sphere0.position = new BABYLON.Vector3(20 * Math.sin(alpha), 0, 20 * Math.cos(alpha));
-        sphere1.position = new BABYLON.Vector3(20 * Math.sin(alpha), -20 * Math.cos(alpha), 0);
-        sphere2.position = new BABYLON.Vector3(0, 20 * Math.cos(alpha), 20 * Math.sin(alpha));
-
-        cube.rotation.y += 0.01;
-        cube.rotation.z += 0.01;
-
-        alpha += 0.05;
-    });
-    
-    return scene;
-};

+ 0 - 56
Samples/Scenes/Customs/postprocessRefraction.js

@@ -1,56 +0,0 @@
-var CreatePostProcessRefractionTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 100, BABYLON.Vector3.Zero(), scene);
-    var light = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, -1, -0.2), scene);
-    var light2 = new BABYLON.DirectionalLight("dir02", new BABYLON.Vector3(-1, -2, -1), scene);
-    light.position = new BABYLON.Vector3(0, 30, 0);
-    light2.position = new BABYLON.Vector3(10, 20, 10);
-
-    light.intensity = 0.6;
-    light2.intensity = 0.6;
-
-    camera.setPosition(new BABYLON.Vector3(-60, 60, 0));
-    camera.lowerBetaLimit = (Math.PI / 2) * 0.8;
-    
-    // Skybox
-    var skybox = BABYLON.Mesh.CreateBox("skyBox", 1000.0, scene);
-    var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
-    skyboxMaterial.backFaceCulling = false;
-    skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("Scenes/Customs/skybox/snow", scene);
-    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
-    skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    skybox.material = skyboxMaterial;
-    
-    // Spheres
-    var sphere0 = BABYLON.Mesh.CreateSphere("Sphere0", 16, 10, scene);
-    var sphere1 = BABYLON.Mesh.CreateSphere("Sphere1", 16, 10, scene);
-    var sphere2 = BABYLON.Mesh.CreateSphere("Sphere2", 16, 10, scene);
-
-    sphere0.material = new BABYLON.StandardMaterial("red", scene);
-    sphere0.material.specularColor = new BABYLON.Color3(0, 0, 0);
-    sphere0.material.diffuseColor = new BABYLON.Color3(1.0, 0, 0);
-    
-    sphere1.material = new BABYLON.StandardMaterial("green", scene);
-    sphere1.material.specularColor = new BABYLON.Color3(0, 0, 0);
-    sphere1.material.diffuseColor = new BABYLON.Color3(0, 1.0, 0);
-    
-    sphere2.material = new BABYLON.StandardMaterial("blue", scene);
-    sphere2.material.specularColor = new BABYLON.Color3(0, 0, 0);
-    sphere2.material.diffuseColor = new BABYLON.Color3(0, 0, 1.0);
-       
-    // Post-process
-    var postProcess = new BABYLON.RefractionPostProcess("Refraction", "/scenes/customs/refMap.jpg", new BABYLON.Color3(1.0, 1.0, 1.0), 0.5, 0.5, 1.0, camera);
-    
-    // Animations
-    var alpha = 0;
-    scene.registerBeforeRender(function() {
-        sphere0.position = new BABYLON.Vector3(20 * Math.sin(alpha), 0, 20 * Math.cos(alpha));
-        sphere1.position = new BABYLON.Vector3(20 * Math.sin(alpha), 0, -20 * Math.cos(alpha));
-        sphere2.position = new BABYLON.Vector3(20 * Math.cos(alpha), 0, 20 * Math.sin(alpha));
-
-        alpha += 0.01;
-    });
-    
-    return scene;
-};

+ 0 - 25
Samples/Scenes/Customs/postprocesses/compose.fragment.fx

@@ -1,25 +0,0 @@
-#ifdef GL_ES
-precision mediump float;
-#endif
-
-// Samplers
-varying vec2 vUV;
-uniform sampler2D textureSampler;
-uniform sampler2D sceneSampler;
-
-// Parameters
-uniform vec2 screenSize;
-uniform float sceneIntensity;
-uniform float glowIntensity;
-uniform float highlightIntensity;
-
-void main(void) 
-{
-	vec4 orig = texture2D(sceneSampler, vUV);
-	vec4 blur = texture2D(textureSampler, vUV);
-
-	vec4 final = sceneIntensity * orig + glowIntensity * blur + highlightIntensity * blur.a;
-	final.a = 1.0;
-
-	gl_FragColor = final;
-}

+ 0 - 29
Samples/Scenes/Customs/postprocesses/downsample.fragment.fx

@@ -1,29 +0,0 @@
-#ifdef GL_ES
-precision mediump float;
-#endif
-
-// Samplers
-varying vec2 vUV;
-uniform sampler2D textureSampler;
-
-// Parameters
-uniform vec2 screenSize;
-uniform float highlightThreshold;
-
-float highlights(vec3 color)
-{
-	return smoothstep(highlightThreshold, 1.0, dot(color, vec3(0.3, 0.59, 0.11)));
-}
-
-void main(void) 
-{
-	vec2 texelSize = vec2(1.0 / screenSize.x, 1.0 / screenSize.y);
-	vec4 baseColor = texture2D(textureSampler, vUV + vec2(-1.0, -1.0) * texelSize) * 0.25;
-	baseColor += texture2D(textureSampler, vUV + vec2(1.0, -1.0) * texelSize) * 0.25;
-	baseColor += texture2D(textureSampler, vUV + vec2(1.0, 1.0) * texelSize) * 0.25;
-	baseColor += texture2D(textureSampler, vUV + vec2(-1.0, 1.0) * texelSize) * 0.25;
-	
-	baseColor.a = highlights(baseColor.rgb);
-
-	gl_FragColor = baseColor;
-}

BIN
Samples/Scenes/Customs/refMap.jpg


+ 0 - 50
Samples/Scenes/Customs/shaders/cellShading.fragment.fx

@@ -1,50 +0,0 @@
-#ifdef GL_ES
-precision mediump float;
-#endif
-
-// Lights
-varying vec3 vPositionW;
-varying vec3 vNormalW;
-varying vec2 vUV;
-
-
-// Refs
-uniform float ToonThresholds[4];
-uniform float ToonBrightnessLevels[5];
-uniform vec3 vLightPosition;
-uniform vec3 vLightColor;
-
-uniform sampler2D textureSampler;
-
-void main(void) {
-	// Light
-	vec3 lightVectorW = normalize(vLightPosition - vPositionW);
-
-	// diffuse
-	float ndl = max(0., dot(vNormalW, lightVectorW));
-
-	vec3 color = texture2D(textureSampler, vUV).rgb * vLightColor;
-
-	if (ndl > ToonThresholds[0])
-	{
-		color *= ToonBrightnessLevels[0];
-	} 
-	else if (ndl > ToonThresholds[1])
-	{
-		color *= ToonBrightnessLevels[1];
-	}
-	else if (ndl > ToonThresholds[2])
-	{
-		color *= ToonBrightnessLevels[2];
-	}
-	else if (ndl > ToonThresholds[3])
-	{
-		color *= ToonBrightnessLevels[3];
-	}
-	else
-	{
-		color *= ToonBrightnessLevels[4];
-	}
-	
-	gl_FragColor = vec4(color, 1.);
-}

+ 0 - 27
Samples/Scenes/Customs/shaders/cellShading.vertex.fx

@@ -1,27 +0,0 @@
-#ifdef GL_ES
-precision mediump float;
-#endif
-
-// Attributes
-attribute vec3 position;
-attribute vec3 normal;
-attribute vec2 uv;
-
-// Uniforms
-uniform mat4 world;
-uniform mat4 worldViewProjection;
-
-// Normal
-varying vec3 vPositionW;
-varying vec3 vNormalW;
-varying vec2 vUV;
-
-void main(void) {
-	vec4 outPosition = worldViewProjection * vec4(position, 1.0);
-	gl_Position = outPosition;
-	
-	vPositionW = vec3(world * vec4(position, 1.0));
-	vNormalW = normalize(vec3(world * vec4(normal, 0.0)));
-
-	vUV = uv;
-}

+ 0 - 85
Samples/Scenes/Customs/shadows.js

@@ -1,85 +0,0 @@
-var CreateShadowsTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
-    var light = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, -1, -0.2), scene);
-    var light2 = new BABYLON.DirectionalLight("dir02", new BABYLON.Vector3(-1, -2, -1), scene);
-    light.position = new BABYLON.Vector3(0, 30, 0);
-    light2.position = new BABYLON.Vector3(10, 20, 10);
-
-    light.intensity = 0.6;
-    light2.intensity = 0.6;
-
-    camera.setPosition(new BABYLON.Vector3(-20, 20, 0));
-    
-    // Skybox
-    var skybox = BABYLON.Mesh.CreateBox("skyBox", 1000.0, scene);
-    var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
-    skyboxMaterial.backFaceCulling = false;
-    skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("Scenes/Customs/skybox/night", scene);
-    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
-    skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    skybox.material = skyboxMaterial;
-
-    // Ground
-    var ground = BABYLON.Mesh.CreateGround("ground", 1000, 1000, 1, scene, false);
-    var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
-    groundMaterial.diffuseTexture = new BABYLON.Texture("/Assets/grass.jpg", scene);
-    groundMaterial.diffuseTexture.uScale = 60;
-    groundMaterial.diffuseTexture.vScale = 60;
-    groundMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    groundMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    ground.position.y = -2.05;
-    ground.material = groundMaterial;
-    
-    // Torus
-    var torus = BABYLON.Mesh.CreateTorus("torus", 8, 2, 32, scene, false);
-    torus.position.y = 6.0;
-    var torus2 = BABYLON.Mesh.CreateTorus("torus2", 4, 1, 32, scene, false);
-    torus2.position.y = 6.0;
-
-    var torusMaterial = new BABYLON.StandardMaterial("torus", scene);
-    torusMaterial.diffuseTexture = new BABYLON.Texture("/Scenes/Customs/rocks.dds", scene);
-    torusMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
-    torusMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
-    torus.material = torusMaterial;
-    torus2.material = torusMaterial;
-    
-    // Shadows
-    var shadowGenerator = new BABYLON.ShadowGenerator(512, light);
-    shadowGenerator.getShadowMap().renderList.push(torus);
-    shadowGenerator.getShadowMap().renderList.push(torus2);
-    
-    var shadowGenerator2 = new BABYLON.ShadowGenerator(512, light2);
-    shadowGenerator2.getShadowMap().renderList.push(torus);
-    shadowGenerator2.getShadowMap().renderList.push(torus2);
-    shadowGenerator2.useVarianceShadowMap = false;
-
-    ground.receiveShadows = true;
-    
-    var beforeRenderFunction = function () {
-        // Camera
-        if (camera.beta < 0.1)
-            camera.beta = 0.1;
-        else if (camera.beta > (Math.PI / 2) * 0.99)
-            camera.beta = (Math.PI / 2) * 0.99;
-
-        if (camera.radius > 150)
-            camera.radius = 150;
-
-        if (camera.radius < 5)
-            camera.radius = 5;
-    };
-
-    scene.registerBeforeRender(beforeRenderFunction);
-    
-    // Animations
-    scene.registerBeforeRender(function () {
-        torus.rotation.x += 0.01;
-        torus.rotation.z += 0.02;
-        torus2.rotation.x += 0.02;
-        torus2.rotation.y += 0.01;
-    });
-    
-    return scene;
-};

BIN
Samples/Scenes/Customs/skybox/night_nx.jpg


BIN
Samples/Scenes/Customs/skybox/night_ny.jpg


BIN
Samples/Scenes/Customs/skybox/night_nz.jpg


BIN
Samples/Scenes/Customs/skybox/night_px.jpg


BIN
Samples/Scenes/Customs/skybox/night_py.jpg


BIN
Samples/Scenes/Customs/skybox/night_pz.jpg


BIN
Samples/Scenes/Customs/skybox/skybox_nx.jpg


BIN
Samples/Scenes/Customs/skybox/skybox_ny.jpg


BIN
Samples/Scenes/Customs/skybox/skybox_nz.jpg


BIN
Samples/Scenes/Customs/skybox/skybox_px.jpg


BIN
Samples/Scenes/Customs/skybox/skybox_py.jpg


BIN
Samples/Scenes/Customs/skybox/skybox_pz.jpg


BIN
Samples/Scenes/Customs/skybox/snow_nx.jpg


BIN
Samples/Scenes/Customs/skybox/snow_ny.jpg


BIN
Samples/Scenes/Customs/skybox/snow_nz.jpg


BIN
Samples/Scenes/Customs/skybox/snow_px.jpg


BIN
Samples/Scenes/Customs/skybox/snow_py.jpg


BIN
Samples/Scenes/Customs/skybox/snow_pz.jpg


+ 0 - 227
Samples/Scenes/Customs/test.js

@@ -1,227 +0,0 @@
-var CreateTestScene = function (engine) {
-    var scene = new BABYLON.Scene(engine);
-    //var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 10, BABYLON.Vector3.Zero(), scene);
-    var camera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(0, 0, -10), scene);
-    var camera2 = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(0, 0, -10), scene);
-    var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 100, 50), scene);
-    var material = new BABYLON.StandardMaterial("leaves", scene);
-    var material2 = new BABYLON.StandardMaterial("kosh transparent", scene);
-    var material3 = new BABYLON.StandardMaterial("kosh", scene);
-    var planeMaterial = new BABYLON.StandardMaterial("plane material", scene);
-    var box = BABYLON.Mesh.CreateBox("Box", 1.0, scene);
-    var cylinder = BABYLON.Mesh.CreateCylinder("Cylinder", 2, 0.8, 0, 32, scene);
-    var torus = BABYLON.Mesh.CreateTorus("Torus", 1.0, 0.5, 16, scene);
-    var sphere = BABYLON.Mesh.CreateSphere("Sphere", 16, 3, scene);
-    var plane = BABYLON.Mesh.CreatePlane("plane", 3, scene);
-
-    camera.viewport = new BABYLON.Viewport(0.5, 0, 0.5, 1.0);
-    camera2.viewport = new BABYLON.Viewport(0, 0, 0.5, 1.0);
-
-    scene.activeCameras.push(camera);
-    scene.activeCameras.push(camera2);
-
-    //material.diffuseColor = new BABYLON.Color3(0, 0, 1);
-    material.diffuseTexture = new BABYLON.Texture("Assets/Tree.png", scene);
-    material.diffuseTexture.hasAlpha = true;
-    material.backFaceCulling = false;
-    material2.diffuseTexture = new BABYLON.Texture("Assets/kosh.jpg", scene);
-    material2.alpha = 0.5;
-    material2.backFaceCulling = false;
-    material3.diffuseTexture = new BABYLON.Texture("Assets/kosh.jpg", scene);
-    planeMaterial.backFaceCulling = false;
-    var planeTexture = new BABYLON.DynamicTexture("dynamic texture", 512, scene, true);
-    planeTexture.hasAlpha = true;
-    planeMaterial.diffuseTexture = planeTexture;
-    plane.billboardMode = BABYLON.Mesh.BILLBOARDMODE_ALL;
-
-    box.material = material;
-    cylinder.material = material3;
-    torus.material = material2;
-    sphere.material = material;
-    plane.material = planeMaterial;
-    cylinder.position.z += 13;
-    cylinder.renderingGroupId = 1;
-    torus.position.x -= 3;
-    torus.parent = sphere;
-    sphere.position.z = 3;
-    plane.position = new BABYLON.Vector3(0, 7, 0);
-
-    cylinder.parent = camera2;
-
-    // Particles
-    var particleSystem = new BABYLON.ParticleSystem("particles", 4000, scene);
-    particleSystem.particleTexture = new BABYLON.Texture("Assets/Flare.png", scene);
-    particleSystem.minAngularSpeed = -0.5;
-    particleSystem.maxAngularSpeed = 0.5;
-    particleSystem.minSize = 0.5;
-    particleSystem.maxSize = 1.0;
-    particleSystem.minLifeTime = 0.5;
-    particleSystem.maxLifeTime = 1.0;
-    particleSystem.emitter = torus;
-    particleSystem.emitRate = 300;
-    particleSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_ONEONE;
-    particleSystem.minEmitBox = new BABYLON.Vector3(0, 0.1, 0);
-    particleSystem.maxEmitBox = new BABYLON.Vector3(0, -0.1, 0);
-    particleSystem.gravity = new BABYLON.Vector3(0, -0.5, 0);
-    particleSystem.start();
-
-    // Mirror
-    var mirror = BABYLON.Mesh.CreateBox("Mirror", 1.0, scene);
-    mirror.scaling = new BABYLON.Vector3(100.0, 0.01, 100.0);
-    mirror.material = new BABYLON.StandardMaterial("mirror", scene);
-    mirror.material.diffuseColor = new BABYLON.Color3(0.4, 0.4, 0.4);
-    mirror.material.reflectionTexture = new BABYLON.MirrorTexture("mirror", 512, scene, true);
-    mirror.material.reflectionTexture.mirrorPlane = new BABYLON.Plane(0, -1.0, 0, -5.0);
-    mirror.material.reflectionTexture.renderList = [box, cylinder, torus, sphere];
-    mirror.material.reflectionTexture.level = 0.5;
-    mirror.position = new BABYLON.Vector3(0, -5.0, 0);
-    
-    // Sprites
-    var spriteManager = new BABYLON.SpriteManager("MonsterA", "Assets/Player.png", 500, 64, scene);
-    for (var index = 0; index < 500; index++) {
-        var sprite = new BABYLON.Sprite("toto", spriteManager);
-        sprite.position.y = -4.5;
-        sprite.position.z = Math.random() * 20 - 10;
-        sprite.position.x = Math.random() * 20 - 10;
-        sprite.dir = Math.round(Math.random()) * 2 - 1;
-        sprite.invertU = (sprite.dir < 0);
-
-        sprite.playAnimation(0, 9, true, 100);
-
-        sprite.color = new BABYLON.Color4(1, 0, 0, 1);
-    }
-    
-    // Backgrounds
-    var background0 = new BABYLON.Layer("back0", "Assets/Layer0_0.png", scene);
-    var background1 = new BABYLON.Layer("back1", "Assets/Layer1_0.png", scene);
-    var foreground = new BABYLON.Layer("back0", "Assets/Layer2_0.png", scene, true, new BABYLON.Color4(1, 0, 0, 1));
-    
-    // Import
-    var spaceDek;
-    BABYLON.SceneLoader.ImportMesh("Vaisseau", "Scenes/SpaceDek/", "SpaceDek.babylon", scene, function (newMeshes, particleSystems) {
-        spaceDek = newMeshes[0];
-        for (var index = 0; index < newMeshes.length; index++) {
-            mirror.material.reflectionTexture.renderList.push(newMeshes[index]);
-        }
-
-        spaceDek.position = new BABYLON.Vector3(0, 20, 0);
-        spaceDek.scaling = new BABYLON.Vector3(0.3, 0.3, 0.3);
-    });
-
-    var spaceDek2;
-    var spaceDek3;
-    BABYLON.SceneLoader.ImportMesh("Vaisseau", "Scenes/SpaceDek/", "SpaceDek.babylon", scene, function (newMeshes) {
-        spaceDek2 = newMeshes[0];
-        spaceDek2.name = "Vaisseau 2";
-        for (var index = 0; index < newMeshes.length; index++) {
-            mirror.material.reflectionTexture.renderList.push(newMeshes[index]);
-        }
-
-        spaceDek2.position = new BABYLON.Vector3(40, 20, 0);
-        spaceDek2.scaling = new BABYLON.Vector3(0.3, 0.3, 0.3);
-
-        // Clone
-        spaceDek3 = spaceDek2.clone("Vaisseau 3");
-        spaceDek3.position = new BABYLON.Vector3(-50, 20, 0);
-        spaceDek3.scaling = new BABYLON.Vector3(0.3, 0.3, 0.3);
-        mirror.material.reflectionTexture.renderList.push(spaceDek3);
-        var children = spaceDek3.getDescendants();
-        for (var index = 0; index < children.length; index++) {
-            mirror.material.reflectionTexture.renderList.push(children[index]);
-        }
-
-        spaceDek3.material = spaceDek2.material.clone("Vaisseau 3 mat");
-        
-        spaceDek3.material.emissiveColor = new BABYLON.Color3(1.0, 0, 0);
-
-        spaceDek3.infiniteDistance = true;
-
-        scene.beginAnimation(spaceDek3, 0, 100, true, 1.0);
-
-        // Test serialization
-        var serializationObject = BABYLON.SceneSerializer.Serialize(scene);
-        var string = JSON.stringify(serializationObject);
-    });
-
-    // Animations
-    var alpha = 0;
-    var frameCount = 0;
-    var reloop = 0;
-    var startDate = new Date();
-    var count = 0;
-    scene.registerBeforeRender(function () {
-        box.rotation.y += 0.01;
-       // cylinder.rotation.x += 0.01;
-        sphere.rotation.y += 0.02;
-        //  box3.scaling.y = 1 + Math.cos(alpha);
-        torus.rotation.z += 0.01;
-        alpha += 0.01;
-
-        if (spaceDek) {
-            spaceDek.rotation.y += 0.01;
-        }
-
-        if (spaceDek2) {
-            spaceDek2.rotation.y -= 0.01;
-        }
-
-        if (spaceDek3) {
-            spaceDek3.rotation.y -= 0.01;
-        }
-        
-        if (torus.intersectsMesh(box, true)) {
-            material2.alpha = 1;
-            torus.scaling = new BABYLON.Vector3(2, 2, 2);
-        } else {
-            material2.alpha = 0.5;
-            torus.scaling = new BABYLON.Vector3(1, 1, 1);
-        }
-
-        // Sprites
-        frameCount++;
-        if (frameCount > 3) {
-            frameCount = 0;
-            reloop++;
-            for (var index = 0; index < spriteManager.sprites.length; index++) {
-                var sprite = spriteManager.sprites[index];
-                sprite.position.x -= 0.1 * sprite.dir;
-
-                if (reloop > 20) {
-                    sprite.dir *= -1;
-                    sprite.invertU = !sprite.invertU;
-                }
-            }
-
-            if (reloop > 20) {
-                reloop = 0;
-            }
-        }
-        
-        // Update dynamic texture
-        var diff = (new Date() - startDate);
-        
-        if (diff > 200) {
-            startDate = new Date();
-
-            var textureContext = planeTexture.getContext();
-            var size = planeTexture.getSize();
-            var text = count.toString();
-
-            textureContext.clearRect(0, 0, size.width, size.height);
-
-            textureContext.font = "bold 120px Calibri";
-            var textSize = textureContext.measureText(text);
-            textureContext.fillStyle = "white";
-            textureContext.fillText(text, (size.width - textSize.width) / 2, (size.height - 120) / 2);
-
-            planeTexture.update();
-
-            count++;
-        }
-        
-        // Background
-        background0.texture.uOffset += 0.001;
-    });
-
-    return scene;
-};

BIN
Samples/Scenes/Dude/0.jpg


BIN
Samples/Scenes/Dude/1.jpg


BIN
Samples/Scenes/Dude/2.jpg


BIN
Samples/Scenes/Dude/3.jpg


File diff suppressed because it is too large
+ 0 - 1
Samples/Scenes/Dude/Dude.babylon


+ 0 - 0
Samples/Scenes/Espilit/Blanc.jpg


Some files were not shown because too many files changed in this diff