瀏覽代碼

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

# Conflicts:
#	dist/preview release/inspector/babylon.inspector.bundle.js
#	dist/preview release/inspector/babylon.inspector.min.js
Julian 8 年之前
父節點
當前提交
c921a038d1
共有 81 個文件被更改,包括 15843 次插入10684 次删除
  1. 33 33
      Playground/debug.html
  2. 34 33
      Playground/frame.html
  3. 33 33
      Playground/index.html
  4. 4 0
      Tools/Gulp/config.json
  5. 16 0
      dist/materialsLibrary/babylon.customMaterial.d.ts
  6. 403 0
      dist/materialsLibrary/babylon.customMaterial.js
  7. 1 0
      dist/materialsLibrary/babylon.customMaterial.min.js
  8. 28 0
      dist/materialsLibrary/babylon.fireMaterial.d.ts
  9. 323 0
      dist/materialsLibrary/babylon.fireMaterial.js
  10. 1 0
      dist/materialsLibrary/babylon.fireMaterial.min.js
  11. 43 0
      dist/materialsLibrary/babylon.furMaterial.d.ts
  12. 471 0
      dist/materialsLibrary/babylon.furMaterial.js
  13. 1 0
      dist/materialsLibrary/babylon.furMaterial.min.js
  14. 30 0
      dist/materialsLibrary/babylon.gradientMaterial.d.ts
  15. 327 0
      dist/materialsLibrary/babylon.gradientMaterial.js
  16. 1 0
      dist/materialsLibrary/babylon.gradientMaterial.min.js
  17. 55 0
      dist/materialsLibrary/babylon.gridMaterial.d.ts
  18. 202 0
      dist/materialsLibrary/babylon.gridMaterial.js
  19. 1 0
      dist/materialsLibrary/babylon.gridMaterial.min.js
  20. 34 0
      dist/materialsLibrary/babylon.lavaMaterial.d.ts
  21. 371 0
      dist/materialsLibrary/babylon.lavaMaterial.js
  22. 1 0
      dist/materialsLibrary/babylon.lavaMaterial.min.js
  23. 26 0
      dist/materialsLibrary/babylon.normalMaterial.d.ts
  24. 326 0
      dist/materialsLibrary/babylon.normalMaterial.js
  25. 1 0
      dist/materialsLibrary/babylon.normalMaterial.min.js
  26. 21 0
      dist/materialsLibrary/babylon.shadowOnlyMaterial.d.ts
  27. 214 0
      dist/materialsLibrary/babylon.shadowOnlyMaterial.js
  28. 1 0
      dist/materialsLibrary/babylon.shadowOnlyMaterial.min.js
  29. 27 0
      dist/materialsLibrary/babylon.simpleMaterial.d.ts
  30. 292 0
      dist/materialsLibrary/babylon.simpleMaterial.js
  31. 1 0
      dist/materialsLibrary/babylon.simpleMaterial.min.js
  32. 32 0
      dist/materialsLibrary/babylon.skyMaterial.d.ts
  33. 255 0
      dist/materialsLibrary/babylon.skyMaterial.js
  34. 1 0
      dist/materialsLibrary/babylon.skyMaterial.min.js
  35. 34 0
      dist/materialsLibrary/babylon.terrainMaterial.d.ts
  36. 357 0
      dist/materialsLibrary/babylon.terrainMaterial.js
  37. 1 0
      dist/materialsLibrary/babylon.terrainMaterial.min.js
  38. 35 0
      dist/materialsLibrary/babylon.triPlanarMaterial.d.ts
  39. 350 0
      dist/materialsLibrary/babylon.triPlanarMaterial.js
  40. 1 0
      dist/materialsLibrary/babylon.triPlanarMaterial.min.js
  41. 99 0
      dist/materialsLibrary/babylon.waterMaterial.d.ts
  42. 593 0
      dist/materialsLibrary/babylon.waterMaterial.js
  43. 1 0
      dist/materialsLibrary/babylon.waterMaterial.min.js
  44. 4971 4962
      dist/preview release/babylon.d.ts
  45. 40 40
      dist/preview release/babylon.js
  46. 154 93
      dist/preview release/babylon.max.js
  47. 4971 4962
      dist/preview release/babylon.module.d.ts
  48. 41 41
      dist/preview release/babylon.worker.js
  49. 11 11
      dist/preview release/canvas2D/babylon.canvas2d.min.js
  50. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  51. 5 51
      dist/preview release/loaders/babylon.glTF2FileLoader.d.ts
  52. 76 59
      dist/preview release/loaders/babylon.glTF2FileLoader.js
  53. 1 1
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  54. 5 51
      dist/preview release/loaders/babylon.glTFFileLoader.d.ts
  55. 76 59
      dist/preview release/loaders/babylon.glTFFileLoader.js
  56. 2 2
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  57. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  58. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  59. 1 1
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  60. 1 1
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  61. 1 1
      dist/preview release/serializers/babylon.objSerializer.d.ts
  62. 44 26
      dist/preview release/serializers/babylon.objSerializer.js
  63. 1 1
      dist/preview release/serializers/babylon.objSerializer.min.js
  64. 155 26
      loaders/src/glTF/2.0/babylon.glTFLoader.ts
  65. 3 56
      loaders/src/glTF/2.0/babylon.glTFLoaderInterfaces.ts
  66. 3 2
      loaders/src/glTF/2.0/babylon.glTFLoaderUtils.ts
  67. 6 0
      readme.md
  68. 10 6
      sandbox/index.html
  69. 3 4
      src/Cameras/babylon.arcRotateCamera.ts
  70. 1 1
      src/Materials/babylon.pbrMaterial.ts
  71. 20 2
      src/Materials/babylon.shaderMaterial.ts
  72. 29 37
      src/Math/babylon.math.ts
  73. 44 54
      src/Mesh/babylon.abstractMesh.ts
  74. 19 17
      src/Mesh/babylon.linesMesh.ts
  75. 6 4
      src/Mesh/babylon.mesh.vertexData.ts
  76. 8 0
      src/Morph/babylon.morphTargetManager.ts
  77. 10 1
      src/Shaders/color.fragment.fx
  78. 21 2
      src/Shaders/color.vertex.fx
  79. 1 1
      src/Shaders/pbr.fragment.fx
  80. 9 1
      src/babylon.engine.ts
  81. 9 5
      tests/validation/validation.js

+ 33 - 33
Playground/debug.html

@@ -16,39 +16,39 @@
     <!--Monaco-->
     <script src="node_modules/monaco-editor/min/vs/loader.js"></script>
     <!-- Babylon.js -->
-    <script src="https://www.babylonjs.com/cannon.js"></script>
-    <script src="https://www.babylonjs.com/Oimo.js"></script>
-    <script src="https://www.babylonjs.com/babylon.max.js"></script>
-    <script src="https://www.babylonjs.com/babylon.canvas2d.js"></script>
-    <script src="https://www.babylonjs.com/babylon.inspector.bundle.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.fireMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.waterMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.lavaMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.normalMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.skyMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.triPlanarMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.terrainMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.gradientMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.furMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.gridMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.shadowOnlyMaterial.min.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.brickProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.cloudProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.fireProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.grassProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.marbleProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.roadProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.starfieldProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.woodProceduralTexture.min.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.asciiArtPostProcess.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.digitalRainPostProcess.min.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.glTFFileLoader.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.objFileLoader.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.stlFileLoader.js"></script>
+    <script src="https://preview.babylonjs.com/cannon.js"></script>
+    <script src="https://preview.babylonjs.com/Oimo.js"></script>
+    <script src="https://preview.babylonjs.com/babylon.max.js"></script>    
+    <script src="https://preview.babylonjs.com/canvas2D/babylon.canvas2d.js"></script>
+    <script src="https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js"></script>
+
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.fireMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.waterMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.lavaMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.normalMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.skyMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.triPlanarMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.terrainMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.gradientMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.furMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.gridMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.shadowOnlyMaterial.min.js"></script>
+
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.brickProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.cloudProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.fireProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.grassProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.marbleProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.roadProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.woodProceduralTexture.min.js"></script>
+
+    <script src="https://preview.babylonjs.com/postProcessesLibrary/babylon.asciiArtPostProcess.min.js"></script>
+    <script src="https://preview.babylonjs.com/postProcessesLibrary/babylon.digitalRainPostProcess.min.js"></script>
+
+    <script src="https://preview.babylonjs.com/loaders/babylon.glTFFileLoader.js"></script>
+    <script src="https://preview.babylonjs.com/loaders/babylon.objFileLoader.js"></script>
+    <script src="https://preview.babylonjs.com/loaders/babylon.stlFileLoader.js"></script>
 
     <script src="https://rawgit.com/BabylonJS/Extensions/master/ClonerSystem/src/babylonx.cloner.js"></script>
 

+ 34 - 33
Playground/frame.html

@@ -5,39 +5,40 @@
     <title>Babylon.js Playground</title>
     <script src="https://code.jquery.com/pep/0.4.2/pep.min.js"></script>
     <!-- Babylon.js -->
-    <script src="https://www.babylonjs.com/cannon.js"></script>
-    <script src="https://www.babylonjs.com/Oimo.js"></script>
-    <script src="https://www.babylonjs.com/babylon.js"></script>
-    <script src="https://www.babylonjs.com/babylon.canvas2d.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.fireMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.waterMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.lavaMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.normalMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.skyMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.triPlanarMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.terrainMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.gradientMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.furMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.gridMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.shadowOnlyMaterial.min.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.brickProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.cloudProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.fireProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.grassProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.marbleProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.roadProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.starfieldProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.woodProceduralTexture.min.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.asciiArtPostProcess.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.digitalRainPostProcess.min.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.glTFFileLoader.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.objFileLoader.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.stlFileLoader.js"></script>
-
+    <script src="https://preview.babylonjs.com/cannon.js"></script>
+    <script src="https://preview.babylonjs.com/Oimo.js"></script>
+    <script src="https://preview.babylonjs.com/babylon.js"></script>    
+    <script src="https://preview.babylonjs.com/canvas2D/babylon.canvas2d.js"></script>
+    <script src="https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js"></script>
+
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.fireMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.waterMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.lavaMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.normalMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.skyMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.triPlanarMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.terrainMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.gradientMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.furMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.gridMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.shadowOnlyMaterial.min.js"></script>
+
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.brickProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.cloudProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.fireProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.grassProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.marbleProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.roadProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.woodProceduralTexture.min.js"></script>
+
+    <script src="https://preview.babylonjs.com/postProcessesLibrary/babylon.asciiArtPostProcess.min.js"></script>
+    <script src="https://preview.babylonjs.com/postProcessesLibrary/babylon.digitalRainPostProcess.min.js"></script>
+
+    <script src="https://preview.babylonjs.com/loaders/babylon.glTFFileLoader.js"></script>
+    <script src="https://preview.babylonjs.com/loaders/babylon.objFileLoader.js"></script>
+    <script src="https://preview.babylonjs.com/loaders/babylon.stlFileLoader.js"></script>
+    
     <script src="https://rawgit.com/BabylonJS/Extensions/master/ClonerSystem/src/babylonx.cloner.js"></script>
     <script src="https://rawgit.com/BabylonJS/Extensions/master/CompoundShader/src/babylonx.CompoundShader.js"></script>
     <link href="frame.css" rel="stylesheet" />

+ 33 - 33
Playground/index.html

@@ -16,39 +16,39 @@
     <!--Monaco-->
     <script src="node_modules/monaco-editor/min/vs/loader.js"></script>
     <!-- Babylon.js -->
-    <script src="https://www.babylonjs.com/cannon.js"></script>
-    <script src="https://www.babylonjs.com/Oimo.js"></script>
-    <script src="https://www.babylonjs.com/babylon.js"></script>
-    <script src="https://www.babylonjs.com/babylon.canvas2d.js"></script>
-    <script src="https://www.babylonjs.com/babylon.inspector.bundle.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.fireMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.waterMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.lavaMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.normalMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.skyMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.triPlanarMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.terrainMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.gradientMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.furMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.gridMaterial.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.shadowOnlyMaterial.min.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.brickProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.cloudProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.fireProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.grassProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.marbleProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.roadProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.starfieldProceduralTexture.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.woodProceduralTexture.min.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.asciiArtPostProcess.min.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.digitalRainPostProcess.min.js"></script>
-
-    <script src="https://www.babylonjs.com/lib/babylon.glTFFileLoader.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.objFileLoader.js"></script>
-    <script src="https://www.babylonjs.com/lib/babylon.stlFileLoader.js"></script>
+    <script src="https://preview.babylonjs.com/cannon.js"></script>
+    <script src="https://preview.babylonjs.com/Oimo.js"></script>
+    <script src="https://preview.babylonjs.com/babylon.js"></script>    
+    <script src="https://preview.babylonjs.com/canvas2D/babylon.canvas2d.js"></script>
+    <script src="https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js"></script>
+
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.fireMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.waterMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.lavaMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.normalMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.skyMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.triPlanarMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.terrainMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.gradientMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.furMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.gridMaterial.min.js"></script>
+    <script src="https://preview.babylonjs.com/materialsLibrary/babylon.shadowOnlyMaterial.min.js"></script>
+
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.brickProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.cloudProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.fireProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.grassProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.marbleProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.roadProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.min.js"></script>
+    <script src="https://preview.babylonjs.com/proceduralTexturesLibrary/babylon.woodProceduralTexture.min.js"></script>
+
+    <script src="https://preview.babylonjs.com/postProcessesLibrary/babylon.asciiArtPostProcess.min.js"></script>
+    <script src="https://preview.babylonjs.com/postProcessesLibrary/babylon.digitalRainPostProcess.min.js"></script>
+
+    <script src="https://preview.babylonjs.com/loaders/babylon.glTFFileLoader.js"></script>
+    <script src="https://preview.babylonjs.com/loaders/babylon.objFileLoader.js"></script>
+    <script src="https://preview.babylonjs.com/loaders/babylon.stlFileLoader.js"></script>
 
     <script src="https://rawgit.com/BabylonJS/Extensions/master/ClonerSystem/src/babylonx.cloner.js"></script>
 

+ 4 - 0
Tools/Gulp/config.json

@@ -854,6 +854,10 @@
             ],
             "dependUpon" : [
                 "core"
+            ],
+            "shaders" : [
+                "layer.vertex",
+                "layer.fragment"
             ]
         }
     },

+ 16 - 0
dist/materialsLibrary/babylon.customMaterial.d.ts

@@ -0,0 +1,16 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class CustomShaderHelper {
+    }
+    interface ICustomMaterialBuilder {
+        (builder: CustomShaderHelper, name: string, mainPart: string, diffusePart: string, vertexPositionPart: string): string;
+    }
+    class CustomMaterial extends StandardMaterial {
+        builder: ICustomMaterialBuilder;
+        private _mainPart;
+        private _diffusePart;
+        private _vertexPositionPart;
+        constructor(name: string, builder: ICustomMaterialBuilder, scene: Scene);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+    }
+}

+ 403 - 0
dist/materialsLibrary/babylon.customMaterial.js

@@ -0,0 +1,403 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+var __extends = (this && this.__extends) || (function () {
+    var extendStatics = Object.setPrototypeOf ||
+        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
+    return function (d, b) {
+        extendStatics(d, b);
+        function __() { this.constructor = d; }
+        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+    };
+})();
+var BABYLON;
+(function (BABYLON) {
+    var CustomShaderHelper = (function () {
+        function CustomShaderHelper() {
+        }
+        return CustomShaderHelper;
+    }());
+    BABYLON.CustomShaderHelper = CustomShaderHelper;
+    var CustomMaterial = (function (_super) {
+        __extends(CustomMaterial, _super);
+        function CustomMaterial(name, builder, scene) {
+            var _this = _super.call(this, name, scene) || this;
+            _this._mainPart = 'void main(void) {';
+            _this._diffusePart = 'vec3 diffuseColor=vDiffuseColor.rgb;';
+            _this._vertexPositionPart = 'gl_Position=viewProjection*finalWorld*vec4(position,1.0);';
+            _this.builder = builder;
+            return _this;
+        }
+        CustomMaterial.prototype.isReady = function (mesh, useInstances) {
+            if (this.isFrozen) {
+                if (this._wasPreviouslyReady) {
+                    return true;
+                }
+            }
+            var scene = this.getScene();
+            var engine = scene.getEngine();
+            var needUVs = false;
+            var needNormals = false;
+            this._defines.reset();
+            // Lights
+            if (scene.lightsEnabled && !this.disableLighting) {
+                needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, this._defines, this.maxSimultaneousLights);
+            }
+            if (!this.checkReadyOnEveryCall) {
+                if (this._renderId === scene.getRenderId()) {
+                    if (this._checkCache(scene, mesh, useInstances)) {
+                        return true;
+                    }
+                }
+            }
+            // Textures
+            if (scene.texturesEnabled) {
+                if (this.diffuseTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
+                    if (!this.diffuseTexture.isReady()) {
+                        return false;
+                    }
+                    else {
+                        needUVs = true;
+                        this._defines.DIFFUSE = true;
+                    }
+                }
+                if (this.ambientTexture && BABYLON.StandardMaterial.AmbientTextureEnabled) {
+                    if (!this.ambientTexture.isReady()) {
+                        return false;
+                    }
+                    else {
+                        needUVs = true;
+                        this._defines.AMBIENT = true;
+                    }
+                }
+                if (this.opacityTexture && BABYLON.StandardMaterial.OpacityTextureEnabled) {
+                    if (!this.opacityTexture.isReady()) {
+                        return false;
+                    }
+                    else {
+                        needUVs = true;
+                        this._defines.OPACITY = true;
+                        if (this.opacityTexture.getAlphaFromRGB) {
+                            this._defines.OPACITYRGB = true;
+                        }
+                    }
+                }
+                if (this.reflectionTexture && BABYLON.StandardMaterial.ReflectionTextureEnabled) {
+                    if (!this.reflectionTexture.isReady()) {
+                        return false;
+                    }
+                    else {
+                        needNormals = true;
+                        this._defines.REFLECTION = true;
+                        if (this.roughness > 0) {
+                            this._defines.ROUGHNESS = true;
+                        }
+                        if (this.useReflectionOverAlpha) {
+                            this._defines.REFLECTIONOVERALPHA = true;
+                        }
+                        if (this.reflectionTexture.coordinatesMode === BABYLON.Texture.INVCUBIC_MODE) {
+                            this._defines.INVERTCUBICMAP = true;
+                        }
+                        this._defines.REFLECTIONMAP_3D = this.reflectionTexture.isCube;
+                        switch (this.reflectionTexture.coordinatesMode) {
+                            case BABYLON.Texture.CUBIC_MODE:
+                            case BABYLON.Texture.INVCUBIC_MODE:
+                                this._defines.REFLECTIONMAP_CUBIC = true;
+                                break;
+                            case BABYLON.Texture.EXPLICIT_MODE:
+                                this._defines.REFLECTIONMAP_EXPLICIT = true;
+                                break;
+                            case BABYLON.Texture.PLANAR_MODE:
+                                this._defines.REFLECTIONMAP_PLANAR = true;
+                                break;
+                            case BABYLON.Texture.PROJECTION_MODE:
+                                this._defines.REFLECTIONMAP_PROJECTION = true;
+                                break;
+                            case BABYLON.Texture.SKYBOX_MODE:
+                                this._defines.REFLECTIONMAP_SKYBOX = true;
+                                break;
+                            case BABYLON.Texture.SPHERICAL_MODE:
+                                this._defines.REFLECTIONMAP_SPHERICAL = true;
+                                break;
+                            case BABYLON.Texture.EQUIRECTANGULAR_MODE:
+                                this._defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
+                                break;
+                            case BABYLON.Texture.FIXED_EQUIRECTANGULAR_MODE:
+                                this._defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
+                                break;
+                        }
+                    }
+                }
+                if (this.emissiveTexture && BABYLON.StandardMaterial.EmissiveTextureEnabled) {
+                    if (!this.emissiveTexture.isReady()) {
+                        return false;
+                    }
+                    else {
+                        needUVs = true;
+                        this._defines.EMISSIVE = true;
+                    }
+                }
+                if (this.lightmapTexture && BABYLON.StandardMaterial.LightmapTextureEnabled) {
+                    if (!this.lightmapTexture.isReady()) {
+                        return false;
+                    }
+                    else {
+                        needUVs = true;
+                        this._defines.LIGHTMAP = true;
+                        this._defines.USELIGHTMAPASSHADOWMAP = this.useLightmapAsShadowmap;
+                    }
+                }
+                if (this.specularTexture && BABYLON.StandardMaterial.SpecularTextureEnabled) {
+                    if (!this.specularTexture.isReady()) {
+                        return false;
+                    }
+                    else {
+                        needUVs = true;
+                        this._defines.SPECULAR = true;
+                        this._defines.GLOSSINESS = this.useGlossinessFromSpecularMapAlpha;
+                    }
+                }
+                if (scene.getEngine().getCaps().standardDerivatives && this.bumpTexture && BABYLON.StandardMaterial.BumpTextureEnabled) {
+                    if (!this.bumpTexture.isReady()) {
+                        return false;
+                    }
+                    else {
+                        needUVs = true;
+                        this._defines.BUMP = true;
+                        if (this.useParallax) {
+                            this._defines.PARALLAX = true;
+                            if (this.useParallaxOcclusion) {
+                                this._defines.PARALLAXOCCLUSION = true;
+                            }
+                        }
+                        if (this.invertNormalMapX) {
+                            this._defines.INVERTNORMALMAPX = true;
+                        }
+                        if (this.invertNormalMapY) {
+                            this._defines.INVERTNORMALMAPY = true;
+                        }
+                        if (scene._mirroredCameraPosition) {
+                            this._defines.INVERTNORMALMAPX = !this._defines.INVERTNORMALMAPX;
+                            this._defines.INVERTNORMALMAPY = !this._defines.INVERTNORMALMAPY;
+                        }
+                    }
+                }
+                if (this.refractionTexture && BABYLON.StandardMaterial.RefractionTextureEnabled) {
+                    if (!this.refractionTexture.isReady()) {
+                        return false;
+                    }
+                    else {
+                        needUVs = true;
+                        this._defines.REFRACTION = true;
+                        this._defines.REFRACTIONMAP_3D = this.refractionTexture.isCube;
+                    }
+                }
+                if (this.cameraColorGradingTexture && BABYLON.StandardMaterial.ColorGradingTextureEnabled) {
+                    if (!this.cameraColorGradingTexture.isReady()) {
+                        return false;
+                    }
+                    else {
+                        this._defines.CAMERACOLORGRADING = true;
+                    }
+                }
+            }
+            // Effect
+            if (scene.clipPlane) {
+                this._defines.CLIPPLANE = true;
+            }
+            if (engine.getAlphaTesting()) {
+                this._defines.ALPHATEST = true;
+            }
+            if (this._shouldUseAlphaFromDiffuseTexture()) {
+                this._defines.ALPHAFROMDIFFUSE = true;
+            }
+            if (this.useEmissiveAsIllumination) {
+                this._defines.EMISSIVEASILLUMINATION = true;
+            }
+            if (this.linkEmissiveWithDiffuse) {
+                this._defines.LINKEMISSIVEWITHDIFFUSE = true;
+            }
+            if (this.useLogarithmicDepth) {
+                this._defines.LOGARITHMICDEPTH = true;
+            }
+            if (this.cameraColorCurves) {
+                this._defines.CAMERACOLORCURVES = true;
+            }
+            // Point size
+            if (this.pointsCloud || scene.forcePointsCloud) {
+                this._defines.POINTSIZE = true;
+            }
+            // Fog
+            if (scene.fogEnabled && mesh && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
+                this._defines.FOG = true;
+            }
+            if (BABYLON.StandardMaterial.FresnelEnabled) {
+                // Fresnel
+                if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled ||
+                    this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled ||
+                    this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled ||
+                    this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled ||
+                    this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
+                    if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
+                        this._defines.DIFFUSEFRESNEL = true;
+                    }
+                    if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
+                        this._defines.OPACITYFRESNEL = true;
+                    }
+                    if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
+                        this._defines.REFLECTIONFRESNEL = true;
+                        if (this.useReflectionFresnelFromSpecular) {
+                            this._defines.REFLECTIONFRESNELFROMSPECULAR = true;
+                        }
+                    }
+                    if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
+                        this._defines.REFRACTIONFRESNEL = true;
+                    }
+                    if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
+                        this._defines.EMISSIVEFRESNEL = true;
+                    }
+                    needNormals = true;
+                    this._defines.FRESNEL = true;
+                }
+            }
+            if (this._defines.SPECULARTERM && this.useSpecularOverAlpha) {
+                this._defines.SPECULAROVERALPHA = true;
+            }
+            // Attribs
+            if (mesh) {
+                if (needNormals && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.NormalKind)) {
+                    this._defines.NORMAL = true;
+                }
+                if (needUVs) {
+                    if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
+                        this._defines.UV1 = true;
+                    }
+                    if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind)) {
+                        this._defines.UV2 = true;
+                    }
+                }
+                if (mesh.useVertexColors && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.ColorKind)) {
+                    this._defines.VERTEXCOLOR = true;
+                    if (mesh.hasVertexAlpha) {
+                        this._defines.VERTEXALPHA = true;
+                    }
+                }
+                if (mesh.useBones && mesh.computeBonesUsingShaders) {
+                    this._defines.NUM_BONE_INFLUENCERS = mesh.numBoneInfluencers;
+                    this._defines.BonesPerMesh = (mesh.skeleton.bones.length + 1);
+                }
+                // Instances
+                if (useInstances) {
+                    this._defines.INSTANCES = true;
+                }
+            }
+            // Get correct effect      
+            if (!this._defines.isEqual(this._cachedDefines)) {
+                this._defines.cloneTo(this._cachedDefines);
+                scene.resetCachedMaterial();
+                // Fallbacks
+                var fallbacks = new BABYLON.EffectFallbacks();
+                if (this._defines.REFLECTION) {
+                    fallbacks.addFallback(0, "REFLECTION");
+                }
+                if (this._defines.SPECULAR) {
+                    fallbacks.addFallback(0, "SPECULAR");
+                }
+                if (this._defines.BUMP) {
+                    fallbacks.addFallback(0, "BUMP");
+                }
+                if (this._defines.PARALLAX) {
+                    fallbacks.addFallback(1, "PARALLAX");
+                }
+                if (this._defines.PARALLAXOCCLUSION) {
+                    fallbacks.addFallback(0, "PARALLAXOCCLUSION");
+                }
+                if (this._defines.SPECULAROVERALPHA) {
+                    fallbacks.addFallback(0, "SPECULAROVERALPHA");
+                }
+                if (this._defines.FOG) {
+                    fallbacks.addFallback(1, "FOG");
+                }
+                if (this._defines.POINTSIZE) {
+                    fallbacks.addFallback(0, "POINTSIZE");
+                }
+                if (this._defines.LOGARITHMICDEPTH) {
+                    fallbacks.addFallback(0, "LOGARITHMICDEPTH");
+                }
+                BABYLON.MaterialHelper.HandleFallbacksForShadows(this._defines, fallbacks, this.maxSimultaneousLights);
+                if (this._defines.SPECULARTERM) {
+                    fallbacks.addFallback(0, "SPECULARTERM");
+                }
+                if (this._defines.DIFFUSEFRESNEL) {
+                    fallbacks.addFallback(1, "DIFFUSEFRESNEL");
+                }
+                if (this._defines.OPACITYFRESNEL) {
+                    fallbacks.addFallback(2, "OPACITYFRESNEL");
+                }
+                if (this._defines.REFLECTIONFRESNEL) {
+                    fallbacks.addFallback(3, "REFLECTIONFRESNEL");
+                }
+                if (this._defines.EMISSIVEFRESNEL) {
+                    fallbacks.addFallback(4, "EMISSIVEFRESNEL");
+                }
+                if (this._defines.FRESNEL) {
+                    fallbacks.addFallback(4, "FRESNEL");
+                }
+                //Attributes
+                var attribs = [BABYLON.VertexBuffer.PositionKind];
+                if (this._defines.NORMAL) {
+                    attribs.push(BABYLON.VertexBuffer.NormalKind);
+                }
+                if (this._defines.UV1) {
+                    attribs.push(BABYLON.VertexBuffer.UVKind);
+                }
+                if (this._defines.UV2) {
+                    attribs.push(BABYLON.VertexBuffer.UV2Kind);
+                }
+                if (this._defines.VERTEXCOLOR) {
+                    attribs.push(BABYLON.VertexBuffer.ColorKind);
+                }
+                BABYLON.MaterialHelper.PrepareAttributesForBones(attribs, mesh, this._defines, fallbacks);
+                BABYLON.MaterialHelper.PrepareAttributesForInstances(attribs, this._defines);
+                var shaderName = "default";
+                if (this.builder) {
+                    shaderName = this.builder(new CustomShaderHelper(), shaderName, this._mainPart, this._diffusePart, this._vertexPositionPart);
+                }
+                var join = this._defines.toString();
+                var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
+                    "vFogInfos", "vFogColor", "pointSize",
+                    "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
+                    "mBones",
+                    "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
+                    "depthValues",
+                    "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
+                    "logarithmicDepthConstant"
+                ];
+                var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler"];
+                if (this._defines.CAMERACOLORCURVES) {
+                    BABYLON.ColorCurves.PrepareUniforms(uniforms);
+                }
+                if (this._defines.CAMERACOLORGRADING) {
+                    BABYLON.ColorGradingTexture.PrepareUniformsAndSamplers(uniforms, samplers);
+                }
+                BABYLON.MaterialHelper.PrepareUniformsAndSamplersList(uniforms, samplers, this._defines, this.maxSimultaneousLights);
+                this._effect = scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, fallbacks, this.onCompiled, this.onError, { maxSimultaneousLights: this.maxSimultaneousLights - 1 });
+            }
+            if (!this._effect.isReady()) {
+                return false;
+            }
+            this._renderId = scene.getRenderId();
+            this._wasPreviouslyReady = true;
+            if (mesh) {
+                if (!mesh._materialDefines) {
+                    mesh._materialDefines = new BABYLON.StandardMaterialDefines();
+                }
+                this._defines.cloneTo(mesh._materialDefines);
+            }
+            return true;
+        };
+        return CustomMaterial;
+    }(BABYLON.StandardMaterial));
+    BABYLON.CustomMaterial = CustomMaterial;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.customMaterial.js.map

File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.customMaterial.min.js


+ 28 - 0
dist/materialsLibrary/babylon.fireMaterial.d.ts

@@ -0,0 +1,28 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class FireMaterial extends Material {
+        diffuseTexture: BaseTexture;
+        distortionTexture: BaseTexture;
+        opacityTexture: BaseTexture;
+        diffuseColor: Color3;
+        speed: number;
+        private _scaledDiffuse;
+        private _renderId;
+        private _defines;
+        private _cachedDefines;
+        private _lastTime;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): BaseTexture;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): FireMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): FireMaterial;
+    }
+}

File diff suppressed because it is too large
+ 323 - 0
dist/materialsLibrary/babylon.fireMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.fireMaterial.min.js


+ 43 - 0
dist/materialsLibrary/babylon.furMaterial.d.ts

@@ -0,0 +1,43 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class FurMaterial extends Material {
+        diffuseTexture: BaseTexture;
+        heightTexture: BaseTexture;
+        diffuseColor: Color3;
+        furLength: number;
+        furAngle: number;
+        furColor: Color3;
+        furOffset: number;
+        furSpacing: number;
+        furGravity: Vector3;
+        furSpeed: number;
+        furDensity: number;
+        furTexture: DynamicTexture;
+        disableLighting: boolean;
+        highLevelFur: boolean;
+        maxSimultaneousLights: number;
+        _meshes: AbstractMesh[];
+        private _worldViewProjectionMatrix;
+        private _renderId;
+        private _furTime;
+        private _defines;
+        private _cachedDefines;
+        constructor(name: string, scene: Scene);
+        furTime: number;
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): BaseTexture;
+        updateFur(): void;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): FurMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): FurMaterial;
+        static GenerateTexture(name: string, scene: Scene): DynamicTexture;
+        static FurifyMesh(sourceMesh: Mesh, quality: number): Mesh[];
+    }
+}

File diff suppressed because it is too large
+ 471 - 0
dist/materialsLibrary/babylon.furMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.furMaterial.min.js


+ 30 - 0
dist/materialsLibrary/babylon.gradientMaterial.d.ts

@@ -0,0 +1,30 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class GradientMaterial extends Material {
+        topColor: Color3;
+        topColorAlpha: number;
+        bottomColor: Color3;
+        bottomColorAlpha: number;
+        offset: number;
+        smoothness: number;
+        disableLighting: boolean;
+        private _worldViewProjectionMatrix;
+        private _scaledDiffuse;
+        private _renderId;
+        private _defines;
+        private _cachedDefines;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): BaseTexture;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): GradientMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): GradientMaterial;
+    }
+}

File diff suppressed because it is too large
+ 327 - 0
dist/materialsLibrary/babylon.gradientMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.gradientMaterial.min.js


+ 55 - 0
dist/materialsLibrary/babylon.gridMaterial.d.ts

@@ -0,0 +1,55 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    /**
+     * The grid materials allows you to wrap any shape with a grid.
+     * Colors are customizable.
+     */
+    class GridMaterial extends BABYLON.Material {
+        /**
+         * Main color of the grid (e.g. between lines)
+         */
+        mainColor: Color3;
+        /**
+         * Color of the grid lines.
+         */
+        lineColor: Color3;
+        /**
+         * The scale of the grid compared to unit.
+         */
+        gridRatio: number;
+        /**
+         * The frequency of thicker lines.
+         */
+        majorUnitFrequency: number;
+        /**
+         * The visibility of minor units in the grid.
+         */
+        minorUnitVisibility: number;
+        /**
+         * The grid opacity outside of the lines.
+         */
+        opacity: number;
+        private _gridControl;
+        private _renderId;
+        private _defines;
+        private _cachedDefines;
+        /**
+         * constructor
+         * @param name The name given to the material in order to identify it afterwards.
+         * @param scene The scene the material is used in.
+         */
+        constructor(name: string, scene: Scene);
+        /**
+         * Returns wehter or not the grid requires alpha blending.
+         */
+        needAlphaBlending(): boolean;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): GridMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): GridMaterial;
+    }
+}

File diff suppressed because it is too large
+ 202 - 0
dist/materialsLibrary/babylon.gridMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.gridMaterial.min.js


+ 34 - 0
dist/materialsLibrary/babylon.lavaMaterial.d.ts

@@ -0,0 +1,34 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class LavaMaterial extends Material {
+        diffuseTexture: BaseTexture;
+        noiseTexture: BaseTexture;
+        fogColor: Color3;
+        speed: number;
+        movingSpeed: number;
+        lowFrequencySpeed: number;
+        fogDensity: number;
+        private _lastTime;
+        diffuseColor: Color3;
+        disableLighting: boolean;
+        maxSimultaneousLights: number;
+        private _worldViewProjectionMatrix;
+        private _scaledDiffuse;
+        private _renderId;
+        private _defines;
+        private _cachedDefines;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): BaseTexture;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): LavaMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): LavaMaterial;
+    }
+}

File diff suppressed because it is too large
+ 371 - 0
dist/materialsLibrary/babylon.lavaMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.lavaMaterial.min.js


+ 26 - 0
dist/materialsLibrary/babylon.normalMaterial.d.ts

@@ -0,0 +1,26 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class NormalMaterial extends Material {
+        diffuseTexture: BaseTexture;
+        diffuseColor: Color3;
+        disableLighting: boolean;
+        private _worldViewProjectionMatrix;
+        private _scaledDiffuse;
+        private _renderId;
+        private _defines;
+        private _cachedDefines;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): BaseTexture;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): NormalMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): NormalMaterial;
+    }
+}

File diff suppressed because it is too large
+ 326 - 0
dist/materialsLibrary/babylon.normalMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.normalMaterial.min.js


+ 21 - 0
dist/materialsLibrary/babylon.shadowOnlyMaterial.d.ts

@@ -0,0 +1,21 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class ShadowOnlyMaterial extends Material {
+        private _worldViewProjectionMatrix;
+        private _scaledDiffuse;
+        private _renderId;
+        private _defines;
+        private _cachedDefines;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): BaseTexture;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        clone(name: string): ShadowOnlyMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): ShadowOnlyMaterial;
+    }
+}

File diff suppressed because it is too large
+ 214 - 0
dist/materialsLibrary/babylon.shadowOnlyMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.shadowOnlyMaterial.min.js


+ 27 - 0
dist/materialsLibrary/babylon.simpleMaterial.d.ts

@@ -0,0 +1,27 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class SimpleMaterial extends Material {
+        diffuseTexture: BaseTexture;
+        diffuseColor: Color3;
+        disableLighting: boolean;
+        maxSimultaneousLights: number;
+        private _worldViewProjectionMatrix;
+        private _scaledDiffuse;
+        private _renderId;
+        private _defines;
+        private _cachedDefines;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): BaseTexture;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): SimpleMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): SimpleMaterial;
+    }
+}

File diff suppressed because it is too large
+ 292 - 0
dist/materialsLibrary/babylon.simpleMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.simpleMaterial.min.js


+ 32 - 0
dist/materialsLibrary/babylon.skyMaterial.d.ts

@@ -0,0 +1,32 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class SkyMaterial extends Material {
+        luminance: number;
+        turbidity: number;
+        rayleigh: number;
+        mieCoefficient: number;
+        mieDirectionalG: number;
+        distance: number;
+        inclination: number;
+        azimuth: number;
+        sunPosition: Vector3;
+        useSunPosition: boolean;
+        private _cameraPosition;
+        private _renderId;
+        private _defines;
+        private _cachedDefines;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): BaseTexture;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): SkyMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): SkyMaterial;
+    }
+}

File diff suppressed because it is too large
+ 255 - 0
dist/materialsLibrary/babylon.skyMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.skyMaterial.min.js


+ 34 - 0
dist/materialsLibrary/babylon.terrainMaterial.d.ts

@@ -0,0 +1,34 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class TerrainMaterial extends Material {
+        mixTexture: BaseTexture;
+        diffuseTexture1: Texture;
+        diffuseTexture2: Texture;
+        diffuseTexture3: Texture;
+        bumpTexture1: Texture;
+        bumpTexture2: Texture;
+        bumpTexture3: Texture;
+        diffuseColor: Color3;
+        specularColor: Color3;
+        specularPower: number;
+        disableLighting: boolean;
+        maxSimultaneousLights: number;
+        private _worldViewProjectionMatrix;
+        private _renderId;
+        private _defines;
+        private _cachedDefines;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): BaseTexture;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): TerrainMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): TerrainMaterial;
+    }
+}

File diff suppressed because it is too large
+ 357 - 0
dist/materialsLibrary/babylon.terrainMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.terrainMaterial.min.js


+ 35 - 0
dist/materialsLibrary/babylon.triPlanarMaterial.d.ts

@@ -0,0 +1,35 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class TriPlanarMaterial extends Material {
+        mixTexture: BaseTexture;
+        diffuseTextureX: Texture;
+        diffuseTextureY: Texture;
+        diffuseTextureZ: Texture;
+        normalTextureX: Texture;
+        normalTextureY: Texture;
+        normalTextureZ: Texture;
+        tileSize: number;
+        diffuseColor: Color3;
+        specularColor: Color3;
+        specularPower: number;
+        disableLighting: boolean;
+        maxSimultaneousLights: number;
+        private _worldViewProjectionMatrix;
+        private _renderId;
+        private _defines;
+        private _cachedDefines;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): BaseTexture;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): TriPlanarMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): TriPlanarMaterial;
+    }
+}

File diff suppressed because it is too large
+ 350 - 0
dist/materialsLibrary/babylon.triPlanarMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.triPlanarMaterial.min.js


+ 99 - 0
dist/materialsLibrary/babylon.waterMaterial.d.ts

@@ -0,0 +1,99 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class WaterMaterial extends Material {
+        renderTargetSize: Vector2;
+        bumpTexture: BaseTexture;
+        diffuseColor: Color3;
+        specularColor: Color3;
+        specularPower: number;
+        disableLighting: boolean;
+        maxSimultaneousLights: number;
+        /**
+        * @param {number}: Represents the wind force
+        */
+        windForce: number;
+        /**
+        * @param {Vector2}: The direction of the wind in the plane (X, Z)
+        */
+        windDirection: Vector2;
+        /**
+        * @param {number}: Wave height, represents the height of the waves
+        */
+        waveHeight: number;
+        /**
+        * @param {number}: Bump height, represents the bump height related to the bump map
+        */
+        bumpHeight: number;
+        /**
+         * @param {boolean}: Add a smaller moving bump to less steady waves.
+         */
+        bumpSuperimpose: boolean;
+        /**
+         * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
+         */
+        fresnelSeparate: boolean;
+        /**
+         * @param {boolean}: bump Waves modify the reflection.
+         */
+        bumpAffectsReflection: boolean;
+        /**
+        * @param {number}: The water color blended with the refraction (near)
+        */
+        waterColor: Color3;
+        /**
+        * @param {number}: The blend factor related to the water color
+        */
+        colorBlendFactor: number;
+        /**
+         * @param {number}: The water color blended with the reflection (far)
+         */
+        waterColor2: Color3;
+        /**
+         * @param {number}: The blend factor related to the water color (reflection, far)
+         */
+        colorBlendFactor2: number;
+        /**
+        * @param {number}: Represents the maximum length of a wave
+        */
+        waveLength: number;
+        /**
+        * @param {number}: Defines the waves speed
+        */
+        waveSpeed: number;
+        private _mesh;
+        private _refractionRTT;
+        private _reflectionRTT;
+        private _material;
+        private _reflectionTransform;
+        private _lastTime;
+        private _renderId;
+        private _defines;
+        private _cachedDefines;
+        private _useLogarithmicDepth;
+        /**
+        * Constructor
+        */
+        constructor(name: string, scene: Scene, renderTargetSize?: Vector2);
+        useLogarithmicDepth: boolean;
+        readonly refractionTexture: RenderTargetTexture;
+        readonly reflectionTexture: RenderTargetTexture;
+        addToRenderList(node: any): void;
+        enableRenderTargets(enable: boolean): void;
+        getRenderList(): AbstractMesh[];
+        readonly renderTargetsEnabled: boolean;
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): BaseTexture;
+        private _checkCache(scene, mesh?, useInstances?);
+        isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
+        bindOnlyWorldMatrix(world: Matrix): void;
+        bind(world: Matrix, mesh?: Mesh): void;
+        private _createRenderTargets(scene, renderTargetSize);
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): WaterMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): WaterMaterial;
+        static CreateDefaultMesh(name: string, scene: Scene): Mesh;
+    }
+}

File diff suppressed because it is too large
+ 593 - 0
dist/materialsLibrary/babylon.waterMaterial.js


File diff suppressed because it is too large
+ 1 - 0
dist/materialsLibrary/babylon.waterMaterial.min.js


File diff suppressed because it is too large
+ 4971 - 4962
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 40 - 40
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 154 - 93
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 4971 - 4962
dist/preview release/babylon.module.d.ts


File diff suppressed because it is too large
+ 41 - 41
dist/preview release/babylon.worker.js


File diff suppressed because it is too large
+ 11 - 11
dist/preview release/canvas2D/babylon.canvas2d.min.js


File diff suppressed because it is too large
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


+ 5 - 51
dist/preview release/loaders/babylon.glTF2FileLoader.d.ts

@@ -32,10 +32,6 @@ declare module BABYLON.GLTF2 {
     /**
     * Enums
     */
-    enum EBufferViewTarget {
-        ARRAY_BUFFER = 34962,
-        ELEMENT_ARRAY_BUFFER = 34963,
-    }
     enum EComponentType {
         BYTE = 5120,
         UNSIGNED_BYTE = 5121,
@@ -53,29 +49,6 @@ declare module BABYLON.GLTF2 {
         TRIANGLE_STRIP = 5,
         TRIANGLE_FAN = 6,
     }
-    enum EParameterType {
-        BYTE = 5120,
-        UNSIGNED_BYTE = 5121,
-        SHORT = 5122,
-        UNSIGNED_SHORT = 5123,
-        INT = 5124,
-        UNSIGNED_INT = 5125,
-        FLOAT = 5126,
-        FLOAT_VEC2 = 35664,
-        FLOAT_VEC3 = 35665,
-        FLOAT_VEC4 = 35666,
-        INT_VEC2 = 35667,
-        INT_VEC3 = 35668,
-        INT_VEC4 = 35669,
-        BOOL = 35670,
-        BOOL_VEC2 = 35671,
-        BOOL_VEC3 = 35672,
-        BOOL_VEC4 = 35673,
-        FLOAT_MAT2 = 35674,
-        FLOAT_MAT3 = 35675,
-        FLOAT_MAT4 = 35676,
-        SAMPLER_2D = 35678,
-    }
     enum ETextureMagFilter {
         NEAREST = 9728,
         LINEAR = 9729,
@@ -88,22 +61,6 @@ declare module BABYLON.GLTF2 {
         NEAREST_MIPMAP_LINEAR = 9986,
         LINEAR_MIPMAP_LINEAR = 9987,
     }
-    enum ETextureFormat {
-        ALPHA = 6406,
-        RGB = 6407,
-        RGBA = 6408,
-        LUMINANCE = 6409,
-        LUMINANCE_ALPHA = 6410,
-    }
-    enum ETextureTarget {
-        TEXTURE_2D = 3553,
-    }
-    enum ETextureType {
-        UNSIGNED_BYTE = 5121,
-        UNSIGNED_SHORT_5_6_5 = 33635,
-        UNSIGNED_SHORT_4_4_4_4 = 32819,
-        UNSIGNED_SHORT_5_5_5_1 = 32820,
-    }
     enum ETextureWrapMode {
         CLAMP_TO_EDGE = 33071,
         MIRRORED_REPEAT = 33648,
@@ -178,10 +135,9 @@ declare module BABYLON.GLTF2 {
     }
     interface IGLTFBufferView extends IGLTFChildRootProperty {
         buffer: number;
-        byteOffset: number;
+        byteOffset?: number;
         byteLength: number;
         byteStride?: number;
-        target?: EBufferViewTarget;
     }
     interface IGLTFCameraOrthographic extends IGLTFProperty {
         xmag: number;
@@ -236,7 +192,9 @@ declare module BABYLON.GLTF2 {
         indices?: number;
         material?: number;
         mode?: EMeshPrimitiveMode;
-        targets?: number[];
+        targets?: [{
+            [name: string]: number;
+        }];
     }
     interface IGLTFMesh extends IGLTFChildRootProperty {
         primitives: IGLTFMeshPrimitive[];
@@ -270,12 +228,8 @@ declare module BABYLON.GLTF2 {
         babylonSkeleton?: Skeleton;
     }
     interface IGLTFTexture extends IGLTFChildRootProperty {
-        format?: ETextureFormat;
-        internalFormat?: ETextureFormat;
-        sampler: number;
+        sampler?: number;
         source: number;
-        target?: ETextureTarget;
-        type?: ETextureType;
         babylonTextures: Texture[];
         blobURL: string;
     }

+ 76 - 59
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -235,11 +235,6 @@ var BABYLON;
         /**
         * Enums
         */
-        var EBufferViewTarget;
-        (function (EBufferViewTarget) {
-            EBufferViewTarget[EBufferViewTarget["ARRAY_BUFFER"] = 34962] = "ARRAY_BUFFER";
-            EBufferViewTarget[EBufferViewTarget["ELEMENT_ARRAY_BUFFER"] = 34963] = "ELEMENT_ARRAY_BUFFER";
-        })(EBufferViewTarget = GLTF2.EBufferViewTarget || (GLTF2.EBufferViewTarget = {}));
         var EComponentType;
         (function (EComponentType) {
             EComponentType[EComponentType["BYTE"] = 5120] = "BYTE";
@@ -259,30 +254,6 @@ var BABYLON;
             EMeshPrimitiveMode[EMeshPrimitiveMode["TRIANGLE_STRIP"] = 5] = "TRIANGLE_STRIP";
             EMeshPrimitiveMode[EMeshPrimitiveMode["TRIANGLE_FAN"] = 6] = "TRIANGLE_FAN";
         })(EMeshPrimitiveMode = GLTF2.EMeshPrimitiveMode || (GLTF2.EMeshPrimitiveMode = {}));
-        var EParameterType;
-        (function (EParameterType) {
-            EParameterType[EParameterType["BYTE"] = 5120] = "BYTE";
-            EParameterType[EParameterType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
-            EParameterType[EParameterType["SHORT"] = 5122] = "SHORT";
-            EParameterType[EParameterType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
-            EParameterType[EParameterType["INT"] = 5124] = "INT";
-            EParameterType[EParameterType["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT";
-            EParameterType[EParameterType["FLOAT"] = 5126] = "FLOAT";
-            EParameterType[EParameterType["FLOAT_VEC2"] = 35664] = "FLOAT_VEC2";
-            EParameterType[EParameterType["FLOAT_VEC3"] = 35665] = "FLOAT_VEC3";
-            EParameterType[EParameterType["FLOAT_VEC4"] = 35666] = "FLOAT_VEC4";
-            EParameterType[EParameterType["INT_VEC2"] = 35667] = "INT_VEC2";
-            EParameterType[EParameterType["INT_VEC3"] = 35668] = "INT_VEC3";
-            EParameterType[EParameterType["INT_VEC4"] = 35669] = "INT_VEC4";
-            EParameterType[EParameterType["BOOL"] = 35670] = "BOOL";
-            EParameterType[EParameterType["BOOL_VEC2"] = 35671] = "BOOL_VEC2";
-            EParameterType[EParameterType["BOOL_VEC3"] = 35672] = "BOOL_VEC3";
-            EParameterType[EParameterType["BOOL_VEC4"] = 35673] = "BOOL_VEC4";
-            EParameterType[EParameterType["FLOAT_MAT2"] = 35674] = "FLOAT_MAT2";
-            EParameterType[EParameterType["FLOAT_MAT3"] = 35675] = "FLOAT_MAT3";
-            EParameterType[EParameterType["FLOAT_MAT4"] = 35676] = "FLOAT_MAT4";
-            EParameterType[EParameterType["SAMPLER_2D"] = 35678] = "SAMPLER_2D";
-        })(EParameterType = GLTF2.EParameterType || (GLTF2.EParameterType = {}));
         var ETextureMagFilter;
         (function (ETextureMagFilter) {
             ETextureMagFilter[ETextureMagFilter["NEAREST"] = 9728] = "NEAREST";
@@ -297,25 +268,6 @@ var BABYLON;
             ETextureMinFilter[ETextureMinFilter["NEAREST_MIPMAP_LINEAR"] = 9986] = "NEAREST_MIPMAP_LINEAR";
             ETextureMinFilter[ETextureMinFilter["LINEAR_MIPMAP_LINEAR"] = 9987] = "LINEAR_MIPMAP_LINEAR";
         })(ETextureMinFilter = GLTF2.ETextureMinFilter || (GLTF2.ETextureMinFilter = {}));
-        var ETextureFormat;
-        (function (ETextureFormat) {
-            ETextureFormat[ETextureFormat["ALPHA"] = 6406] = "ALPHA";
-            ETextureFormat[ETextureFormat["RGB"] = 6407] = "RGB";
-            ETextureFormat[ETextureFormat["RGBA"] = 6408] = "RGBA";
-            ETextureFormat[ETextureFormat["LUMINANCE"] = 6409] = "LUMINANCE";
-            ETextureFormat[ETextureFormat["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA";
-        })(ETextureFormat = GLTF2.ETextureFormat || (GLTF2.ETextureFormat = {}));
-        var ETextureTarget;
-        (function (ETextureTarget) {
-            ETextureTarget[ETextureTarget["TEXTURE_2D"] = 3553] = "TEXTURE_2D";
-        })(ETextureTarget = GLTF2.ETextureTarget || (GLTF2.ETextureTarget = {}));
-        var ETextureType;
-        (function (ETextureType) {
-            ETextureType[ETextureType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
-            ETextureType[ETextureType["UNSIGNED_SHORT_5_6_5"] = 33635] = "UNSIGNED_SHORT_5_6_5";
-            ETextureType[ETextureType["UNSIGNED_SHORT_4_4_4_4"] = 32819] = "UNSIGNED_SHORT_4_4_4_4";
-            ETextureType[ETextureType["UNSIGNED_SHORT_5_5_5_1"] = 32820] = "UNSIGNED_SHORT_5_5_5_1";
-        })(ETextureType = GLTF2.ETextureType || (GLTF2.ETextureType = {}));
         var ETextureWrapMode;
         (function (ETextureWrapMode) {
             ETextureWrapMode[ETextureWrapMode["CLAMP_TO_EDGE"] = 33071] = "CLAMP_TO_EDGE";
@@ -740,11 +692,12 @@ var BABYLON;
             var verticesCounts = [];
             var indexStarts = [];
             var indexCounts = [];
+            var morphTargetManager = new BABYLON.MorphTargetManager();
             // Positions, normals and UVs
-            for (var index = 0; index < mesh.primitives.length; index++) {
+            for (var primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex++) {
                 // Temporary vertex data
                 var tempVertexData = new BABYLON.VertexData();
-                var primitive = mesh.primitives[index];
+                var primitive = mesh.primitives[primitiveIndex];
                 if (primitive.mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
                     // continue;
                 }
@@ -804,8 +757,8 @@ var BABYLON;
                 else {
                     // Set indices on the fly
                     var indices = [];
-                    for (var j = 0; j < tempVertexData.positions.length / 3; j++) {
-                        indices.push(j);
+                    for (var index = 0; index < tempVertexData.positions.length / 3; index++) {
+                        indices.push(index);
                     }
                     tempVertexData.indices = new Int32Array(indices);
                     indexCounts.push(tempVertexData.indices.length);
@@ -815,6 +768,65 @@ var BABYLON;
                 // Sub material
                 var material = getMaterial(runtime, primitive.material);
                 multiMat.subMaterials.push(material);
+                // Morph Targets
+                if (primitive.targets !== undefined) {
+                    for (var targetsIndex = 0; targetsIndex < primitive.targets.length; targetsIndex++) {
+                        var target = primitive.targets[targetsIndex];
+                        var weight = 0.0;
+                        if (node.weights !== undefined) {
+                            weight = node.weights[targetsIndex];
+                        }
+                        else if (mesh.weights !== undefined) {
+                            weight = mesh.weights[targetsIndex];
+                        }
+                        var morph = new BABYLON.MorphTarget("morph" + targetsIndex, weight);
+                        for (var semantic in target) {
+                            // Link accessor and buffer view
+                            accessor = runtime.gltf.accessors[target[semantic]];
+                            buffer = GLTF2.GLTFUtils.GetBufferFromAccessor(runtime, accessor);
+                            if (accessor.name !== undefined) {
+                                morph.name = accessor.name;
+                            }
+                            // glTF stores morph target information as deltas
+                            // while babylon.js expects the final data.
+                            // As a result we have to add the original data to the delta to calculate
+                            // the final data.
+                            if (semantic === "NORMAL") {
+                                for (var bufferIndex = 0; bufferIndex < buffer.length; bufferIndex++) {
+                                    buffer[bufferIndex] += vertexData.normals[bufferIndex];
+                                }
+                                morph.setNormals(buffer);
+                            }
+                            else if (semantic === "POSITION") {
+                                for (var bufferIndex = 0; bufferIndex < buffer.length; bufferIndex++) {
+                                    buffer[bufferIndex] += vertexData.positions[bufferIndex];
+                                }
+                                morph.setPositions(buffer);
+                            }
+                            else if (semantic === "TANGENT") {
+                                // Tangent data for morph targets is stored as xyz delta.
+                                // The vertexData.tangent is stored as xyzw.
+                                // So we need to skip every fourth vertexData.tangent.
+                                for (var bufferIndex = 0, tangentsIndex = 0; bufferIndex < buffer.length; bufferIndex++, tangentsIndex++) {
+                                    buffer[bufferIndex] += vertexData.tangents[tangentsIndex];
+                                    if ((bufferIndex + 1) % 3 == 0) {
+                                        tangentsIndex++;
+                                    }
+                                }
+                                morph.setTangents(buffer);
+                            }
+                            else {
+                                BABYLON.Tools.Warn("Ignoring unrecognized semantic '" + semantic + "'");
+                            }
+                        }
+                        if (morph.getPositions() !== undefined) {
+                            morphTargetManager.addTarget(morph);
+                        }
+                        else {
+                            BABYLON.Tools.Warn("Not adding morph target '" + morph.name + "' because it has no position data");
+                        }
+                    }
+                }
                 // Update vertices start and index start
                 verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]);
                 indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]);
@@ -822,13 +834,17 @@ var BABYLON;
             // Apply geometry
             geometry.setAllVerticesData(vertexData, false);
             babylonMesh.computeWorldMatrix(true);
+            // Set morph target manager after all vertices data has been processed
+            if (morphTargetManager !== undefined && morphTargetManager.numInfluencers > 0) {
+                babylonMesh.morphTargetManager = morphTargetManager;
+            }
             // Apply submeshes
             babylonMesh.subMeshes = [];
-            for (var index = 0; index < mesh.primitives.length; index++) {
-                if (mesh.primitives[index].mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
+            for (var primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex++) {
+                if (mesh.primitives[primitiveIndex].mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
                     //continue;
                 }
-                var subMesh = new BABYLON.SubMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], babylonMesh, babylonMesh, true);
+                var subMesh = new BABYLON.SubMesh(primitiveIndex, verticesStarts[primitiveIndex], verticesCounts[primitiveIndex], indexStarts[primitiveIndex], indexCounts[primitiveIndex], babylonMesh, babylonMesh, true);
             }
             // Finish
             return babylonMesh;
@@ -1217,9 +1233,9 @@ var BABYLON;
                 GLTFLoader._createTextureAsync(runtime, texture, texCoord, sourceURL, onSuccess, onError);
             };
             GLTFLoader._createTextureAsync = function (runtime, texture, texCoord, url, onSuccess, onError) {
-                var sampler = texture.sampler ? runtime.gltf.samplers[texture.sampler] : {};
+                var sampler = (texture.sampler === undefined ? {} : runtime.gltf.samplers[texture.sampler]);
                 var noMipMaps = (sampler.minFilter === GLTF2.ETextureMinFilter.NEAREST || sampler.minFilter === GLTF2.ETextureMinFilter.LINEAR);
-                var samplingMode = BABYLON.Texture.BILINEAR_SAMPLINGMODE;
+                var samplingMode = GLTF2.GLTFUtils.GetTextureFilterMode(sampler.minFilter);
                 var babylonTexture = new BABYLON.Texture(url, runtime.babylonScene, noMipMaps, true, samplingMode, function () {
                     onSuccess(babylonTexture);
                 }, onError);
@@ -1461,7 +1477,7 @@ var BABYLON;
                 }
             };
             GLTFUtils.GetBufferFromBufferView = function (runtime, bufferView, byteOffset, byteLength, componentType) {
-                var byteOffset = bufferView.byteOffset + byteOffset;
+                byteOffset += (bufferView.byteOffset || 0);
                 var loadedBufferView = runtime.gltf.buffers[bufferView.buffer].loadedBufferView;
                 if (byteOffset + byteLength > loadedBufferView.byteLength) {
                     throw new Error("Buffer access is out of range");
@@ -1484,8 +1500,9 @@ var BABYLON;
              */
             GLTFUtils.GetBufferFromAccessor = function (runtime, accessor) {
                 var bufferView = runtime.gltf.bufferViews[accessor.bufferView];
+                var byteOffset = accessor.byteOffset || 0;
                 var byteLength = accessor.count * GLTFUtils.GetByteStrideFromType(accessor);
-                return GLTFUtils.GetBufferFromBufferView(runtime, bufferView, accessor.byteOffset, byteLength, accessor.componentType);
+                return GLTFUtils.GetBufferFromBufferView(runtime, bufferView, byteOffset, byteLength, accessor.componentType);
             };
             /**
              * Decodes a buffer view into a string

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 5 - 51
dist/preview release/loaders/babylon.glTFFileLoader.d.ts

@@ -527,10 +527,6 @@ declare module BABYLON.GLTF2 {
     /**
     * Enums
     */
-    enum EBufferViewTarget {
-        ARRAY_BUFFER = 34962,
-        ELEMENT_ARRAY_BUFFER = 34963,
-    }
     enum EComponentType {
         BYTE = 5120,
         UNSIGNED_BYTE = 5121,
@@ -548,29 +544,6 @@ declare module BABYLON.GLTF2 {
         TRIANGLE_STRIP = 5,
         TRIANGLE_FAN = 6,
     }
-    enum EParameterType {
-        BYTE = 5120,
-        UNSIGNED_BYTE = 5121,
-        SHORT = 5122,
-        UNSIGNED_SHORT = 5123,
-        INT = 5124,
-        UNSIGNED_INT = 5125,
-        FLOAT = 5126,
-        FLOAT_VEC2 = 35664,
-        FLOAT_VEC3 = 35665,
-        FLOAT_VEC4 = 35666,
-        INT_VEC2 = 35667,
-        INT_VEC3 = 35668,
-        INT_VEC4 = 35669,
-        BOOL = 35670,
-        BOOL_VEC2 = 35671,
-        BOOL_VEC3 = 35672,
-        BOOL_VEC4 = 35673,
-        FLOAT_MAT2 = 35674,
-        FLOAT_MAT3 = 35675,
-        FLOAT_MAT4 = 35676,
-        SAMPLER_2D = 35678,
-    }
     enum ETextureMagFilter {
         NEAREST = 9728,
         LINEAR = 9729,
@@ -583,22 +556,6 @@ declare module BABYLON.GLTF2 {
         NEAREST_MIPMAP_LINEAR = 9986,
         LINEAR_MIPMAP_LINEAR = 9987,
     }
-    enum ETextureFormat {
-        ALPHA = 6406,
-        RGB = 6407,
-        RGBA = 6408,
-        LUMINANCE = 6409,
-        LUMINANCE_ALPHA = 6410,
-    }
-    enum ETextureTarget {
-        TEXTURE_2D = 3553,
-    }
-    enum ETextureType {
-        UNSIGNED_BYTE = 5121,
-        UNSIGNED_SHORT_5_6_5 = 33635,
-        UNSIGNED_SHORT_4_4_4_4 = 32819,
-        UNSIGNED_SHORT_5_5_5_1 = 32820,
-    }
     enum ETextureWrapMode {
         CLAMP_TO_EDGE = 33071,
         MIRRORED_REPEAT = 33648,
@@ -673,10 +630,9 @@ declare module BABYLON.GLTF2 {
     }
     interface IGLTFBufferView extends IGLTFChildRootProperty {
         buffer: number;
-        byteOffset: number;
+        byteOffset?: number;
         byteLength: number;
         byteStride?: number;
-        target?: EBufferViewTarget;
     }
     interface IGLTFCameraOrthographic extends IGLTFProperty {
         xmag: number;
@@ -731,7 +687,9 @@ declare module BABYLON.GLTF2 {
         indices?: number;
         material?: number;
         mode?: EMeshPrimitiveMode;
-        targets?: number[];
+        targets?: [{
+            [name: string]: number;
+        }];
     }
     interface IGLTFMesh extends IGLTFChildRootProperty {
         primitives: IGLTFMeshPrimitive[];
@@ -765,12 +723,8 @@ declare module BABYLON.GLTF2 {
         babylonSkeleton?: Skeleton;
     }
     interface IGLTFTexture extends IGLTFChildRootProperty {
-        format?: ETextureFormat;
-        internalFormat?: ETextureFormat;
-        sampler: number;
+        sampler?: number;
         source: number;
-        target?: ETextureTarget;
-        type?: ETextureType;
         babylonTextures: Texture[];
         blobURL: string;
     }

+ 76 - 59
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -2385,11 +2385,6 @@ var BABYLON;
         /**
         * Enums
         */
-        var EBufferViewTarget;
-        (function (EBufferViewTarget) {
-            EBufferViewTarget[EBufferViewTarget["ARRAY_BUFFER"] = 34962] = "ARRAY_BUFFER";
-            EBufferViewTarget[EBufferViewTarget["ELEMENT_ARRAY_BUFFER"] = 34963] = "ELEMENT_ARRAY_BUFFER";
-        })(EBufferViewTarget = GLTF2.EBufferViewTarget || (GLTF2.EBufferViewTarget = {}));
         var EComponentType;
         (function (EComponentType) {
             EComponentType[EComponentType["BYTE"] = 5120] = "BYTE";
@@ -2409,30 +2404,6 @@ var BABYLON;
             EMeshPrimitiveMode[EMeshPrimitiveMode["TRIANGLE_STRIP"] = 5] = "TRIANGLE_STRIP";
             EMeshPrimitiveMode[EMeshPrimitiveMode["TRIANGLE_FAN"] = 6] = "TRIANGLE_FAN";
         })(EMeshPrimitiveMode = GLTF2.EMeshPrimitiveMode || (GLTF2.EMeshPrimitiveMode = {}));
-        var EParameterType;
-        (function (EParameterType) {
-            EParameterType[EParameterType["BYTE"] = 5120] = "BYTE";
-            EParameterType[EParameterType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
-            EParameterType[EParameterType["SHORT"] = 5122] = "SHORT";
-            EParameterType[EParameterType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
-            EParameterType[EParameterType["INT"] = 5124] = "INT";
-            EParameterType[EParameterType["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT";
-            EParameterType[EParameterType["FLOAT"] = 5126] = "FLOAT";
-            EParameterType[EParameterType["FLOAT_VEC2"] = 35664] = "FLOAT_VEC2";
-            EParameterType[EParameterType["FLOAT_VEC3"] = 35665] = "FLOAT_VEC3";
-            EParameterType[EParameterType["FLOAT_VEC4"] = 35666] = "FLOAT_VEC4";
-            EParameterType[EParameterType["INT_VEC2"] = 35667] = "INT_VEC2";
-            EParameterType[EParameterType["INT_VEC3"] = 35668] = "INT_VEC3";
-            EParameterType[EParameterType["INT_VEC4"] = 35669] = "INT_VEC4";
-            EParameterType[EParameterType["BOOL"] = 35670] = "BOOL";
-            EParameterType[EParameterType["BOOL_VEC2"] = 35671] = "BOOL_VEC2";
-            EParameterType[EParameterType["BOOL_VEC3"] = 35672] = "BOOL_VEC3";
-            EParameterType[EParameterType["BOOL_VEC4"] = 35673] = "BOOL_VEC4";
-            EParameterType[EParameterType["FLOAT_MAT2"] = 35674] = "FLOAT_MAT2";
-            EParameterType[EParameterType["FLOAT_MAT3"] = 35675] = "FLOAT_MAT3";
-            EParameterType[EParameterType["FLOAT_MAT4"] = 35676] = "FLOAT_MAT4";
-            EParameterType[EParameterType["SAMPLER_2D"] = 35678] = "SAMPLER_2D";
-        })(EParameterType = GLTF2.EParameterType || (GLTF2.EParameterType = {}));
         var ETextureMagFilter;
         (function (ETextureMagFilter) {
             ETextureMagFilter[ETextureMagFilter["NEAREST"] = 9728] = "NEAREST";
@@ -2447,25 +2418,6 @@ var BABYLON;
             ETextureMinFilter[ETextureMinFilter["NEAREST_MIPMAP_LINEAR"] = 9986] = "NEAREST_MIPMAP_LINEAR";
             ETextureMinFilter[ETextureMinFilter["LINEAR_MIPMAP_LINEAR"] = 9987] = "LINEAR_MIPMAP_LINEAR";
         })(ETextureMinFilter = GLTF2.ETextureMinFilter || (GLTF2.ETextureMinFilter = {}));
-        var ETextureFormat;
-        (function (ETextureFormat) {
-            ETextureFormat[ETextureFormat["ALPHA"] = 6406] = "ALPHA";
-            ETextureFormat[ETextureFormat["RGB"] = 6407] = "RGB";
-            ETextureFormat[ETextureFormat["RGBA"] = 6408] = "RGBA";
-            ETextureFormat[ETextureFormat["LUMINANCE"] = 6409] = "LUMINANCE";
-            ETextureFormat[ETextureFormat["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA";
-        })(ETextureFormat = GLTF2.ETextureFormat || (GLTF2.ETextureFormat = {}));
-        var ETextureTarget;
-        (function (ETextureTarget) {
-            ETextureTarget[ETextureTarget["TEXTURE_2D"] = 3553] = "TEXTURE_2D";
-        })(ETextureTarget = GLTF2.ETextureTarget || (GLTF2.ETextureTarget = {}));
-        var ETextureType;
-        (function (ETextureType) {
-            ETextureType[ETextureType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
-            ETextureType[ETextureType["UNSIGNED_SHORT_5_6_5"] = 33635] = "UNSIGNED_SHORT_5_6_5";
-            ETextureType[ETextureType["UNSIGNED_SHORT_4_4_4_4"] = 32819] = "UNSIGNED_SHORT_4_4_4_4";
-            ETextureType[ETextureType["UNSIGNED_SHORT_5_5_5_1"] = 32820] = "UNSIGNED_SHORT_5_5_5_1";
-        })(ETextureType = GLTF2.ETextureType || (GLTF2.ETextureType = {}));
         var ETextureWrapMode;
         (function (ETextureWrapMode) {
             ETextureWrapMode[ETextureWrapMode["CLAMP_TO_EDGE"] = 33071] = "CLAMP_TO_EDGE";
@@ -2890,11 +2842,12 @@ var BABYLON;
             var verticesCounts = [];
             var indexStarts = [];
             var indexCounts = [];
+            var morphTargetManager = new BABYLON.MorphTargetManager();
             // Positions, normals and UVs
-            for (var index = 0; index < mesh.primitives.length; index++) {
+            for (var primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex++) {
                 // Temporary vertex data
                 var tempVertexData = new BABYLON.VertexData();
-                var primitive = mesh.primitives[index];
+                var primitive = mesh.primitives[primitiveIndex];
                 if (primitive.mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
                     // continue;
                 }
@@ -2954,8 +2907,8 @@ var BABYLON;
                 else {
                     // Set indices on the fly
                     var indices = [];
-                    for (var j = 0; j < tempVertexData.positions.length / 3; j++) {
-                        indices.push(j);
+                    for (var index = 0; index < tempVertexData.positions.length / 3; index++) {
+                        indices.push(index);
                     }
                     tempVertexData.indices = new Int32Array(indices);
                     indexCounts.push(tempVertexData.indices.length);
@@ -2965,6 +2918,65 @@ var BABYLON;
                 // Sub material
                 var material = getMaterial(runtime, primitive.material);
                 multiMat.subMaterials.push(material);
+                // Morph Targets
+                if (primitive.targets !== undefined) {
+                    for (var targetsIndex = 0; targetsIndex < primitive.targets.length; targetsIndex++) {
+                        var target = primitive.targets[targetsIndex];
+                        var weight = 0.0;
+                        if (node.weights !== undefined) {
+                            weight = node.weights[targetsIndex];
+                        }
+                        else if (mesh.weights !== undefined) {
+                            weight = mesh.weights[targetsIndex];
+                        }
+                        var morph = new BABYLON.MorphTarget("morph" + targetsIndex, weight);
+                        for (var semantic in target) {
+                            // Link accessor and buffer view
+                            accessor = runtime.gltf.accessors[target[semantic]];
+                            buffer = GLTF2.GLTFUtils.GetBufferFromAccessor(runtime, accessor);
+                            if (accessor.name !== undefined) {
+                                morph.name = accessor.name;
+                            }
+                            // glTF stores morph target information as deltas
+                            // while babylon.js expects the final data.
+                            // As a result we have to add the original data to the delta to calculate
+                            // the final data.
+                            if (semantic === "NORMAL") {
+                                for (var bufferIndex = 0; bufferIndex < buffer.length; bufferIndex++) {
+                                    buffer[bufferIndex] += vertexData.normals[bufferIndex];
+                                }
+                                morph.setNormals(buffer);
+                            }
+                            else if (semantic === "POSITION") {
+                                for (var bufferIndex = 0; bufferIndex < buffer.length; bufferIndex++) {
+                                    buffer[bufferIndex] += vertexData.positions[bufferIndex];
+                                }
+                                morph.setPositions(buffer);
+                            }
+                            else if (semantic === "TANGENT") {
+                                // Tangent data for morph targets is stored as xyz delta.
+                                // The vertexData.tangent is stored as xyzw.
+                                // So we need to skip every fourth vertexData.tangent.
+                                for (var bufferIndex = 0, tangentsIndex = 0; bufferIndex < buffer.length; bufferIndex++, tangentsIndex++) {
+                                    buffer[bufferIndex] += vertexData.tangents[tangentsIndex];
+                                    if ((bufferIndex + 1) % 3 == 0) {
+                                        tangentsIndex++;
+                                    }
+                                }
+                                morph.setTangents(buffer);
+                            }
+                            else {
+                                BABYLON.Tools.Warn("Ignoring unrecognized semantic '" + semantic + "'");
+                            }
+                        }
+                        if (morph.getPositions() !== undefined) {
+                            morphTargetManager.addTarget(morph);
+                        }
+                        else {
+                            BABYLON.Tools.Warn("Not adding morph target '" + morph.name + "' because it has no position data");
+                        }
+                    }
+                }
                 // Update vertices start and index start
                 verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]);
                 indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]);
@@ -2972,13 +2984,17 @@ var BABYLON;
             // Apply geometry
             geometry.setAllVerticesData(vertexData, false);
             babylonMesh.computeWorldMatrix(true);
+            // Set morph target manager after all vertices data has been processed
+            if (morphTargetManager !== undefined && morphTargetManager.numInfluencers > 0) {
+                babylonMesh.morphTargetManager = morphTargetManager;
+            }
             // Apply submeshes
             babylonMesh.subMeshes = [];
-            for (var index = 0; index < mesh.primitives.length; index++) {
-                if (mesh.primitives[index].mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
+            for (var primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex++) {
+                if (mesh.primitives[primitiveIndex].mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
                     //continue;
                 }
-                var subMesh = new BABYLON.SubMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], babylonMesh, babylonMesh, true);
+                var subMesh = new BABYLON.SubMesh(primitiveIndex, verticesStarts[primitiveIndex], verticesCounts[primitiveIndex], indexStarts[primitiveIndex], indexCounts[primitiveIndex], babylonMesh, babylonMesh, true);
             }
             // Finish
             return babylonMesh;
@@ -3367,9 +3383,9 @@ var BABYLON;
                 GLTFLoader._createTextureAsync(runtime, texture, texCoord, sourceURL, onSuccess, onError);
             };
             GLTFLoader._createTextureAsync = function (runtime, texture, texCoord, url, onSuccess, onError) {
-                var sampler = texture.sampler ? runtime.gltf.samplers[texture.sampler] : {};
+                var sampler = (texture.sampler === undefined ? {} : runtime.gltf.samplers[texture.sampler]);
                 var noMipMaps = (sampler.minFilter === GLTF2.ETextureMinFilter.NEAREST || sampler.minFilter === GLTF2.ETextureMinFilter.LINEAR);
-                var samplingMode = BABYLON.Texture.BILINEAR_SAMPLINGMODE;
+                var samplingMode = GLTF2.GLTFUtils.GetTextureFilterMode(sampler.minFilter);
                 var babylonTexture = new BABYLON.Texture(url, runtime.babylonScene, noMipMaps, true, samplingMode, function () {
                     onSuccess(babylonTexture);
                 }, onError);
@@ -3611,7 +3627,7 @@ var BABYLON;
                 }
             };
             GLTFUtils.GetBufferFromBufferView = function (runtime, bufferView, byteOffset, byteLength, componentType) {
-                var byteOffset = bufferView.byteOffset + byteOffset;
+                byteOffset += (bufferView.byteOffset || 0);
                 var loadedBufferView = runtime.gltf.buffers[bufferView.buffer].loadedBufferView;
                 if (byteOffset + byteLength > loadedBufferView.byteLength) {
                     throw new Error("Buffer access is out of range");
@@ -3634,8 +3650,9 @@ var BABYLON;
              */
             GLTFUtils.GetBufferFromAccessor = function (runtime, accessor) {
                 var bufferView = runtime.gltf.bufferViews[accessor.bufferView];
+                var byteOffset = accessor.byteOffset || 0;
                 var byteLength = accessor.count * GLTFUtils.GetByteStrideFromType(accessor);
-                return GLTFUtils.GetBufferFromBufferView(runtime, bufferView, accessor.byteOffset, byteLength, accessor.componentType);
+                return GLTFUtils.GetBufferFromBufferView(runtime, bufferView, byteOffset, byteLength, accessor.componentType);
             };
             /**
              * Decodes a buffer view into a string

File diff suppressed because it is too large
+ 2 - 2
dist/preview release/loaders/babylon.glTFFileLoader.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/materialsLibrary/babylon.waterMaterial.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


+ 1 - 1
dist/preview release/serializers/babylon.objSerializer.d.ts

@@ -1,7 +1,7 @@
 /// <reference path="../../../dist/preview release/babylon.d.ts" />
 declare module BABYLON {
     class OBJExport {
-        static OBJ(mesh: Mesh, materials?: boolean, matlibname?: string): string;
+        static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
         static MTL(mesh: Mesh): string;
     }
 }

+ 44 - 26
dist/preview release/serializers/babylon.objSerializer.js

@@ -4,44 +4,62 @@ var BABYLON;
     var OBJExport = (function () {
         function OBJExport() {
         }
-        //Exports the geometry of a Mesh in .OBJ file format (text)
-        OBJExport.OBJ = function (mesh, materials, matlibname) {
+        //Exports the geometrys of a Mesh array in .OBJ file format (text)
+        OBJExport.OBJ = function (mesh, materials, matlibname, globalposition) {
             var output = [];
-            var g = mesh.geometry;
-            var trunkVerts = g.getVerticesData('position');
-            var trunkNormals = g.getVerticesData('normal');
-            var trunkUV = g.getVerticesData('uv');
-            var trunkFaces = g.getIndices();
+            var v = 1;
             if (materials) {
                 if (!matlibname) {
                     matlibname = 'mat';
                 }
                 output.push("mtllib " + matlibname + ".mtl");
             }
-            for (var i = 0; i < trunkVerts.length; i += 3) {
-                output.push("v " + trunkVerts[i] + " " + trunkVerts[i + 1] + " " + trunkVerts[i + 2]);
-            }
-            for (i = 0; i < trunkNormals.length; i += 3) {
-                output.push("vn " + trunkNormals[i] + " " + trunkNormals[i + 1] + " " + trunkNormals[i + 2]);
-            }
-            for (i = 0; i < trunkUV.length; i += 2) {
-                output.push("vt " + trunkUV[i] + " " + trunkUV[i + 1]);
-            }
-            //TODO: submeshes (groups)
-            //TODO: smoothing groups (s 1, s off)
-            output.push("g gr1");
-            if (materials) {
-                output.push("usemtl mat1");
-            }
-            for (i = 0; i < trunkFaces.length; i += 3) {
-                output.push("f " + (trunkFaces[i + 2] + 1) + "/" + (trunkFaces[i + 2] + 1) + "/" + (trunkFaces[i + 2] + 1) +
-                    " " + (trunkFaces[i + 1] + 1) + "/" + (trunkFaces[i + 1] + 1) + "/" + (trunkFaces[i + 1] + 1) +
-                    " " + (trunkFaces[i] + 1) + "/" + (trunkFaces[i] + 1) + "/" + (trunkFaces[i] + 1));
+            for (var j = 0; j < mesh.length; j++) {
+                output.push("g object" + j);
+                output.push("o object_" + j);
+                //Uses the position of the item in the scene, to the file (this back to normal in the end)
+                if (globalposition) {
+                    var newMatrix = BABYLON.Matrix.Translation(mesh[j].position.x, mesh[j].position.y, mesh[j].position.z);
+                    var lastMatrix = BABYLON.Matrix.Translation(-(mesh[j].position.x), -(mesh[j].position.y), -(mesh[j].position.z));
+                    mesh[j].bakeTransformIntoVertices(newMatrix);
+                }
+                //TODO: submeshes (groups)
+                //TODO: smoothing groups (s 1, s off);
+                if (materials) {
+                    output.push("usemtl " + mesh[j].material.id);
+                }
+                var g = mesh[j].geometry;
+                var trunkVerts = g.getVerticesData('position');
+                var trunkNormals = g.getVerticesData('normal');
+                var trunkUV = g.getVerticesData('uv');
+                var trunkFaces = g.getIndices();
+                var curV = 0;
+                for (var i = 0; i < trunkVerts.length; i += 3) {
+                    output.push("v " + trunkVerts[i] + " " + trunkVerts[i + 1] + " " + trunkVerts[i + 2]);
+                    curV++;
+                }
+                for (i = 0; i < trunkNormals.length; i += 3) {
+                    output.push("vn " + trunkNormals[i] + " " + trunkNormals[i + 1] + " " + trunkNormals[i + 2]);
+                }
+                for (i = 0; i < trunkUV.length; i += 2) {
+                    output.push("vt " + trunkUV[i] + " " + trunkUV[i + 1]);
+                }
+                for (i = 0; i < trunkFaces.length; i += 3) {
+                    output.push("f " + (trunkFaces[i + 2] + v) + "/" + (trunkFaces[i + 2] + v) + "/" + (trunkFaces[i + 2] + v) +
+                        " " + (trunkFaces[i + 1] + v) + "/" + (trunkFaces[i + 1] + v) + "/" + (trunkFaces[i + 1] + v) +
+                        " " + (trunkFaces[i] + v) + "/" + (trunkFaces[i] + v) + "/" + (trunkFaces[i] + v));
+                }
+                //back de previous matrix, to not change the original mesh in the scene
+                if (globalposition) {
+                    mesh[j].bakeTransformIntoVertices(lastMatrix);
+                }
+                v += curV;
             }
             var text = output.join("\n");
             return (text);
         };
         //Exports the material(s) of a mesh in .MTL file format (text)
+        //TODO: Export the materials of mesh array
         OBJExport.MTL = function (mesh) {
             var output = [];
             var m = mesh.material;

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/serializers/babylon.objSerializer.min.js


+ 155 - 26
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -4,8 +4,8 @@ module BABYLON.GLTF2 {
     /**
     * Values
     */
-    var glTFAnimationPaths = ["translation", "rotation", "scale"];
-    var babylonAnimationPaths = ["position", "rotationQuaternion", "scaling"];
+    var glTFAnimationPaths = ["translation", "rotation", "scale", "weights"];
+    var babylonAnimationPaths = ["position", "rotationQuaternion", "scaling", "influence"];
 
     /**
     * Utils
@@ -80,8 +80,9 @@ module BABYLON.GLTF2 {
                 }
 
                 var isBone = targetNode instanceof Bone;
+                var numTargets = 0;
 
-                // Get target path (position, rotation or scaling)
+                // Get target path (position, rotation, scaling, or weights)
                 var targetPath = channel.target.path;
                 var targetPathIndex = glTFAnimationPaths.indexOf(targetPath);
 
@@ -89,6 +90,8 @@ module BABYLON.GLTF2 {
                     targetPath = babylonAnimationPaths[targetPathIndex];
                 }
 
+                var isMorph = targetPath === "influence";
+
                 // Determine animation type
                 var animationType = Animation.ANIMATIONTYPE_MATRIX;
 
@@ -97,6 +100,10 @@ module BABYLON.GLTF2 {
                         animationType = Animation.ANIMATIONTYPE_QUATERNION;
                         targetNode.rotationQuaternion = new Quaternion();
                     }
+                    else if (isMorph) {
+                        animationType = Animation.ANIMATIONTYPE_FLOAT;
+                        numTargets = (<Mesh>targetNode).morphTargetManager.numTargets;
+                    }
                     else {
                         animationType = Animation.ANIMATIONTYPE_VECTOR3;
                     }
@@ -113,19 +120,30 @@ module BABYLON.GLTF2 {
                     modifyKey = true;
                 }
 
-                if (!modifyKey) {
-                    var animationName = animation.name || "anim" + animationIndex;
-                    babylonAnimation = new Animation(animationName, isBone ? "_matrix" : targetPath, 1, animationType, Animation.ANIMATIONLOOPMODE_CYCLE);
+                // Each morph animation may have more than one more, so we need a
+                // multi dimensional array.
+                if (isMorph) {
+                    for (var influence = 0; influence < numTargets; influence++) {
+                        keys[influence] = [];
+                    }
                 }
 
                 // For each frame
-                for (var j = 0; j < bufferInput.length; j++) {
+                for (var frameIndex = 0; frameIndex < bufferInput.length; frameIndex++) {
                     var value: any = null;
 
                     if (targetPath === "rotationQuaternion") { // VEC4
                         value = Quaternion.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2], bufferOutput[arrayOffset + 3]]);
                         arrayOffset += 4;
                     }
+                    else if (isMorph) { // FLOAT
+                        value = [];
+                        // There is 1 value for each morph target for each frame
+                        for (var influence = 0; influence < numTargets; influence++) {
+                            value.push(bufferOutput[arrayOffset + influence]);
+                        }
+                        arrayOffset += numTargets;
+                    }
                     else { // Position and scaling are VEC3
                         value = Vector3.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2]]);
                         arrayOffset += 3;
@@ -141,7 +159,7 @@ module BABYLON.GLTF2 {
                         var mat = bone.getBaseMatrix();
 
                         if (modifyKey) {
-                            mat = lastAnimation.getKeys()[j].value;
+                            mat = lastAnimation.getKeys()[frameIndex].value;
                         }
 
                         mat.decompose(scaling, rotationQuaternion, translation);
@@ -160,26 +178,64 @@ module BABYLON.GLTF2 {
                     }
 
                     if (!modifyKey) {
-                        keys.push({
-                            frame: bufferInput[j],
-                            value: value
-                        });
+                        if (isMorph) {
+                            for (var influence = 0; influence < numTargets; influence++) {
+                                keys[influence].push({
+                                    frame: bufferInput[frameIndex],
+                                    value: value[influence]
+                                });
+                            }
+                        }
+                        else {
+                            keys.push({
+                                frame: bufferInput[frameIndex],
+                                value: value
+                            });
+                        }
                     }
                     else {
-                        lastAnimation.getKeys()[j].value = value;
+                        lastAnimation.getKeys()[frameIndex].value = value;
                     }
                 }
 
                 // Finish
                 if (!modifyKey) {
-                    babylonAnimation.setKeys(keys);
-                    targetNode.animations.push(babylonAnimation);
+                    if (isMorph) {
+                        for (var influence = 0; influence < numTargets; influence++) {
+                            var morphTarget = (<Mesh>targetNode).morphTargetManager.getTarget(influence);
+                            if ((<any>morphTarget).animations === undefined) {
+                                (<any>morphTarget).animations = [];
+                            }
+
+                            var animationName = (animation.name || "anim" + animationIndex) + "_" + influence;
+                            babylonAnimation = new Animation(animationName, targetPath, 1, animationType, Animation.ANIMATIONLOOPMODE_CYCLE);
+
+                            babylonAnimation.setKeys(keys[influence]);
+                            (<any>morphTarget).animations.push(babylonAnimation);
+                        }
+                    }
+                    else {
+                        var animationName = animation.name || "anim" + animationIndex;
+                        babylonAnimation = new Animation(animationName, isBone ? "_matrix" : targetPath, 1, animationType, Animation.ANIMATIONLOOPMODE_CYCLE);
+                
+                        babylonAnimation.setKeys(keys);
+                        targetNode.animations.push(babylonAnimation);
+                    }
                 }
 
                 lastAnimation = babylonAnimation;
 
-                runtime.babylonScene.stopAnimation(targetNode);
-                runtime.babylonScene.beginAnimation(targetNode, 0, bufferInput[bufferInput.length - 1], true, 1.0);
+                if (isMorph) {
+                    for (var influence = 0; influence < numTargets; influence++) {
+                        var morph = (<Mesh>targetNode).morphTargetManager.getTarget(influence);
+                        runtime.babylonScene.stopAnimation(morph);
+                        runtime.babylonScene.beginAnimation(morph, 0, bufferInput[bufferInput.length - 1], true, 1.0);
+                    }
+                }
+                else {
+                    runtime.babylonScene.stopAnimation(targetNode);
+                    runtime.babylonScene.beginAnimation(targetNode, 0, bufferInput[bufferInput.length - 1], true, 1.0);
+                }
             }
         }
     };
@@ -508,12 +564,14 @@ module BABYLON.GLTF2 {
         var indexStarts = [];
         var indexCounts = [];
 
+        var morphTargetManager = new BABYLON.MorphTargetManager();
+
         // Positions, normals and UVs
-        for (var index = 0; index < mesh.primitives.length; index++) {
+        for (var primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex++) {
             // Temporary vertex data
             var tempVertexData = new VertexData();
 
-            var primitive = mesh.primitives[index];
+            var primitive = mesh.primitives[primitiveIndex];
             if (primitive.mode !== EMeshPrimitiveMode.TRIANGLES) {
                 // continue;
             }
@@ -579,8 +637,8 @@ module BABYLON.GLTF2 {
             else {
                 // Set indices on the fly
                 var indices: number[] = [];
-                for (var j = 0; j < tempVertexData.positions.length / 3; j++) {
-                    indices.push(j);
+                for (var index = 0; index < tempVertexData.positions.length / 3; index++) {
+                    indices.push(index);
                 }
 
                 tempVertexData.indices = new Int32Array(indices);
@@ -594,6 +652,72 @@ module BABYLON.GLTF2 {
             var material = getMaterial(runtime, primitive.material);
             multiMat.subMaterials.push(material);
 
+            // Morph Targets
+            if (primitive.targets !== undefined) {
+                for (var targetsIndex = 0; targetsIndex < primitive.targets.length; targetsIndex++) {
+                    var target = primitive.targets[targetsIndex];
+
+                    var weight = 0.0;
+                    if (node.weights !== undefined) {
+                        weight = node.weights[targetsIndex];
+                    }
+                    else if (mesh.weights !== undefined) {
+                        weight = mesh.weights[targetsIndex];
+                    }
+
+                    var morph = new BABYLON.MorphTarget("morph" + targetsIndex, weight);
+
+                    for (var semantic in target) {
+                        // Link accessor and buffer view
+                        accessor = runtime.gltf.accessors[target[semantic]];
+                        buffer = GLTFUtils.GetBufferFromAccessor(runtime, accessor);
+
+                        if (accessor.name !== undefined) {
+                            morph.name = accessor.name;
+                        }
+
+                        // glTF stores morph target information as deltas
+                        // while babylon.js expects the final data.
+                        // As a result we have to add the original data to the delta to calculate
+                        // the final data.
+                        if (semantic === "NORMAL") {
+                            for (var bufferIndex = 0; bufferIndex < buffer.length; bufferIndex++) {
+                                buffer[bufferIndex] += (<Float32Array>vertexData.normals)[bufferIndex];
+                            }
+                            morph.setNormals(buffer);
+                        }
+                        else if (semantic === "POSITION") {
+                            for (var bufferIndex = 0; bufferIndex < buffer.length; bufferIndex++) {
+                                buffer[bufferIndex] += (<Float32Array>vertexData.positions)[bufferIndex];
+                            }
+                            morph.setPositions(buffer);
+                        }
+                        else if (semantic === "TANGENT") {
+                            // Tangent data for morph targets is stored as xyz delta.
+                            // The vertexData.tangent is stored as xyzw.
+                            // So we need to skip every fourth vertexData.tangent.
+                            for (var bufferIndex = 0, tangentsIndex = 0; bufferIndex < buffer.length; bufferIndex++, tangentsIndex++) {
+                                buffer[bufferIndex] += (<Float32Array>vertexData.tangents)[tangentsIndex];
+                                if ((bufferIndex + 1) % 3 == 0) {
+                                    tangentsIndex++;
+                                }
+                            }
+                            morph.setTangents(buffer);
+                        }
+                        else {
+                            Tools.Warn("Ignoring unrecognized semantic '" + semantic + "'");
+                        }
+                    }
+                    
+                    if (morph.getPositions() !== undefined) {
+                        morphTargetManager.addTarget(morph);
+                    }
+                    else {
+                        Tools.Warn("Not adding morph target '" + morph.name + "' because it has no position data");
+                    }
+                }
+            }
+
             // Update vertices start and index start
             verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]);
             indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]);
@@ -603,14 +727,19 @@ module BABYLON.GLTF2 {
         geometry.setAllVerticesData(vertexData, false);
         babylonMesh.computeWorldMatrix(true);
 
+        // Set morph target manager after all vertices data has been processed
+        if (morphTargetManager !== undefined && morphTargetManager.numTargets > 0) {
+            babylonMesh.morphTargetManager = morphTargetManager;
+        }
+
         // Apply submeshes
         babylonMesh.subMeshes = [];
-        for (var index = 0; index < mesh.primitives.length; index++) {
-            if (mesh.primitives[index].mode !== EMeshPrimitiveMode.TRIANGLES) {
+        for (var primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex++) {
+            if (mesh.primitives[primitiveIndex].mode !== EMeshPrimitiveMode.TRIANGLES) {
                 //continue;
             }
 
-            var subMesh = new SubMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], babylonMesh, babylonMesh, true);
+            var subMesh = new SubMesh(primitiveIndex, verticesStarts[primitiveIndex], verticesCounts[primitiveIndex], indexStarts[primitiveIndex], indexCounts[primitiveIndex], babylonMesh, babylonMesh, true);
         }
 
         // Finish
@@ -1081,9 +1210,9 @@ module BABYLON.GLTF2 {
         }
 
         private static _createTextureAsync(runtime: IGLTFRuntime, texture: IGLTFTexture, texCoord: number, url: string, onSuccess: (babylonTexture: Texture) => void, onError: () => void): void {
-            var sampler: IGLTFSampler = texture.sampler ? runtime.gltf.samplers[texture.sampler] : {};
+            var sampler: IGLTFSampler = (texture.sampler === undefined ? {} : runtime.gltf.samplers[texture.sampler]);
             var noMipMaps = (sampler.minFilter === ETextureMinFilter.NEAREST || sampler.minFilter === ETextureMinFilter.LINEAR);
-            var samplingMode = Texture.BILINEAR_SAMPLINGMODE;
+            var samplingMode = GLTFUtils.GetTextureFilterMode(sampler.minFilter);
 
             var babylonTexture = new Texture(url, runtime.babylonScene, noMipMaps, true, samplingMode, () => {
                 onSuccess(babylonTexture);

+ 3 - 56
loaders/src/glTF/2.0/babylon.glTFLoaderInterfaces.ts

@@ -4,11 +4,6 @@ module BABYLON.GLTF2 {
     /**
     * Enums
     */
-    export enum EBufferViewTarget {
-        ARRAY_BUFFER = 34962,
-        ELEMENT_ARRAY_BUFFER = 34963
-    }
-
     export enum EComponentType {
         BYTE = 5120,
         UNSIGNED_BYTE = 5121,
@@ -28,30 +23,6 @@ module BABYLON.GLTF2 {
         TRIANGLE_FAN = 6
     }
 
-    export enum EParameterType {
-        BYTE = 5120,
-        UNSIGNED_BYTE = 5121,
-        SHORT = 5122,
-        UNSIGNED_SHORT = 5123,
-        INT = 5124,
-        UNSIGNED_INT = 5125,
-        FLOAT = 5126,
-        FLOAT_VEC2 = 35664,
-        FLOAT_VEC3 = 35665,
-        FLOAT_VEC4 = 35666,
-        INT_VEC2 = 35667,
-        INT_VEC3 = 35668,
-        INT_VEC4 = 35669,
-        BOOL = 35670,
-        BOOL_VEC2 = 35671,
-        BOOL_VEC3 = 35672,
-        BOOL_VEC4 = 35673,
-        FLOAT_MAT2 = 35674,
-        FLOAT_MAT3 = 35675,
-        FLOAT_MAT4 = 35676,
-        SAMPLER_2D = 35678
-    }
-
     export enum ETextureMagFilter {
         NEAREST = 9728,
         LINEAR = 9729,
@@ -66,25 +37,6 @@ module BABYLON.GLTF2 {
         LINEAR_MIPMAP_LINEAR = 9987
     }
 
-    export enum ETextureFormat {
-        ALPHA = 6406,
-        RGB = 6407,
-        RGBA = 6408,
-        LUMINANCE = 6409,
-        LUMINANCE_ALPHA = 6410
-    }
-
-    export enum ETextureTarget {
-        TEXTURE_2D = 3553
-    }
-
-    export enum ETextureType {
-        UNSIGNED_BYTE = 5121,
-        UNSIGNED_SHORT_5_6_5 = 33635,
-        UNSIGNED_SHORT_4_4_4_4 = 32819,
-        UNSIGNED_SHORT_5_5_5_1 = 32820
-    }
-
     export enum ETextureWrapMode {
         CLAMP_TO_EDGE = 33071,
         MIRRORED_REPEAT = 33648,
@@ -175,10 +127,9 @@ module BABYLON.GLTF2 {
 
     export interface IGLTFBufferView extends IGLTFChildRootProperty {
         buffer: number;
-        byteOffset: number;
+        byteOffset?: number;
         byteLength: number;
         byteStride?: number;
-        target?: EBufferViewTarget;
     }
 
     export interface IGLTFCameraOrthographic extends IGLTFProperty {
@@ -242,7 +193,7 @@ module BABYLON.GLTF2 {
         indices?: number;
         material?: number;
         mode?: EMeshPrimitiveMode;
-        targets?: number[];
+        targets?: [ { [name: string]: number } ];
     }
 
     export interface IGLTFMesh extends IGLTFChildRootProperty {
@@ -286,12 +237,8 @@ module BABYLON.GLTF2 {
     }
 
     export interface IGLTFTexture extends IGLTFChildRootProperty {
-        format?: ETextureFormat;
-        internalFormat?: ETextureFormat;
-        sampler: number;
+        sampler?: number;
         source: number;
-        target?: ETextureTarget;
-        type?: ETextureType;
 
         // Babylon.js values (optimize, one per coordinate index)
         babylonTextures: Texture[];

+ 3 - 2
loaders/src/glTF/2.0/babylon.glTFLoaderUtils.ts

@@ -77,7 +77,7 @@ module BABYLON.GLTF2 {
         }
 
         public static GetBufferFromBufferView(runtime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView {
-            var byteOffset = bufferView.byteOffset + byteOffset;
+            byteOffset += (bufferView.byteOffset || 0);
 
             var loadedBufferView = runtime.gltf.buffers[bufferView.buffer].loadedBufferView;
             if (byteOffset + byteLength > loadedBufferView.byteLength) {
@@ -104,8 +104,9 @@ module BABYLON.GLTF2 {
          */
         public static GetBufferFromAccessor(runtime: IGLTFRuntime, accessor: IGLTFAccessor): any {
             var bufferView = runtime.gltf.bufferViews[accessor.bufferView];
+            var byteOffset = accessor.byteOffset || 0;
             var byteLength = accessor.count * GLTFUtils.GetByteStrideFromType(accessor);
-            return GLTFUtils.GetBufferFromBufferView(runtime, bufferView, accessor.byteOffset, byteLength, accessor.componentType);
+            return GLTFUtils.GetBufferFromBufferView(runtime, bufferView, byteOffset, byteLength, accessor.componentType);
         }
 
         /**

+ 6 - 0
readme.md

@@ -13,6 +13,12 @@ Getting started? Play directly with the Babylon.js API via our [playground](http
 - http://cdn.babylonjs.com/2-5/babylon.noworker.js 
 - http://cdn.babylonjs.com/2-5/babylon.core.js 
 
+For preview release you can use the following ones:
+
+- http://preview.babylonjs.com/babylon.js 
+- http://preview.babylonjs.com/babylon.max.js 
+- http://preview.babylonjs.com/babylon.worker.js
+
 ## Preview release
 
 **3.0-alpha** can be found [here](https://github.com/BabylonJS/Babylon.js/tree/master/dist/preview%20release)

+ 10 - 6
sandbox/index.html

@@ -5,12 +5,16 @@
     <link href="index.css" rel="stylesheet" />
     <script src="https://code.jquery.com/pep/0.4.2/pep.min.js"></script>
 
-    <script src="https://babylonjs.azurewebsites.net/cannon.js"></script>
-    <script src="https://babylonjs.azurewebsites.net/Oimo.js"></script>
-    <script src="https://babylonjs.azurewebsites.net/babylon.js"></script>
-    <script src="https://babylonjs.azurewebsites.net/lib/babylon.glTFFileLoader.js"></script>
-    <script src="https://babylonjs.azurewebsites.net/lib/babylon.objFileLoader.js"></script>
-    <script src="https://babylonjs.azurewebsites.net/lib/babylon.stlFileLoader.js"></script>    
+    <script src="https://preview.babylonjs.com/cannon.js"></script>
+    <script src="https://preview.babylonjs.com/Oimo.js"></script>
+    <script src="https://preview.babylonjs.com/babylon.js"></script>
+    <script src="https://preview.babylonjs.com/canvas2D/babylon.canvas2d.js"></script>
+    <script src="https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js"></script>
+
+    <script src="https://preview.babylonjs.com/loaders/babylon.glTFFileLoader.js"></script>
+    <script src="https://preview.babylonjs.com/loaders/babylon.objFileLoader.js"></script>
+    <script src="https://preview.babylonjs.com/loaders/babylon.stlFileLoader.js"></script>
+
 </head>
 <body>
     <canvas id="renderCanvas"></canvas>

+ 3 - 4
src/Cameras/babylon.arcRotateCamera.ts

@@ -210,10 +210,9 @@ module BABYLON {
         constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene) {
             super(name, Vector3.Zero(), scene);
 
-            if (!target) {
-                this._target = Vector3.Zero();
-            } else {
-                this._target = target;
+            this._target = Vector3.Zero();
+            if (target) {
+                this.setTarget(target);
             }
 
             this.alpha = alpha;

+ 1 - 1
src/Materials/babylon.pbrMaterial.ts

@@ -996,7 +996,7 @@
 
             // Attribs
             if (mesh) {
-                if (!mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
+                if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
                     mesh.createNormals(true);
                     Tools.Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
                 }

+ 20 - 2
src/Materials/babylon.shaderMaterial.ts

@@ -175,6 +175,7 @@
 
             // Instances
             var defines = [];
+            var attribs = [];
             var fallbacks = new EffectFallbacks();
             if (useInstances) {
                 defines.push("#define INSTANCES");
@@ -184,12 +185,29 @@
                 defines.push(this._options.defines[index]);
             }
 
+            for (var index = 0; index < this._options.attributes.length; index++) {
+                attribs.push(this._options.attributes[index]);
+            }
+
+            if (mesh.isVerticesDataPresent(VertexBuffer.ColorKind)) {
+                attribs.push(VertexBuffer.ColorKind);
+                defines.push("#define VERTEXCOLOR");
+            }
+            
             // Bones
             if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
+                attribs.push(VertexBuffer.MatricesIndicesKind);
+                attribs.push(VertexBuffer.MatricesWeightsKind);
+                if (mesh.numBoneInfluencers > 4) {
+                    attribs.push(VertexBuffer.MatricesIndicesExtraKind);
+                    attribs.push(VertexBuffer.MatricesWeightsExtraKind);
+                }
                 defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
                 defines.push("#define BonesPerMesh " + (mesh.skeleton.bones.length + 1));
                 fallbacks.addCPUSkinningFallback(0, mesh);
-            }
+            } else {
+                defines.push("#define NUM_BONE_INFLUENCERS 0");
+            }  
 
             // Textures
             for (var name in this._textures) {
@@ -207,7 +225,7 @@
             var join = defines.join("\n");
 
             this._effect = engine.createEffect(this._shaderPath, <EffectCreationOptions>{
-                    attributes: this._options.attributes,
+                    attributes: attribs,
                     uniformsNames: this._options.uniforms,
                     uniformBuffersNames: this._options.uniformBuffers,
                     samplers: this._options.samplers,

+ 29 - 37
src/Math/babylon.math.ts

@@ -315,9 +315,9 @@
         }
 
         /**
-         * Creates a new Vector3 from the startind index of the passed array.  
+         * Creates a new Vector3 from the startind index of the passed array.
          */
-        public static FromArray(array: number[], offset: number = 0): Color3 {
+        public static FromArray(array: ArrayLike<number>, offset: number = 0): Color3 {
             return new Color3(array[offset], array[offset + 1], array[offset + 2]);
         }
 
@@ -566,9 +566,9 @@
         }
 
         /**
-         * Creates a new Color4 from the starting index element of the passed array.  
+         * Creates a new Color4 from the starting index element of the passed array.
          */
-        public static FromArray(array: number[], offset: number = 0): Color4 {
+        public static FromArray(array: ArrayLike<number>, offset: number = 0): Color4 {
             return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
         }
 
@@ -850,16 +850,15 @@
             return new Vector2(0, 0);
         }
         /**
-         * Returns a new Vector2 set from the passed index element of the passed array or Float32Array.  
+         * Returns a new Vector2 set from the passed index element of the passed array.
          */
-        public static FromArray(array: number[] | Float32Array, offset: number = 0): Vector2 {
+        public static FromArray(array: ArrayLike<number>, offset: number = 0): Vector2 {
             return new Vector2(array[offset], array[offset + 1]);
         }
         /**
-         * Sets "result" from the passed index element of the passed array or Float32Array.  
-         * Returns the Vector2.  
+         * Sets "result" from the passed index element of the passed array.
          */
-        public static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector2): void {
+        public static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void {
             result.x = array[offset];
             result.y = array[offset + 1];
         }
@@ -1396,9 +1395,9 @@
         }
 
         /**
-         * Returns a new Vector3 set from the index "offset" of the passed array or Float32Array.  
+         * Returns a new Vector3 set from the index "offset" of the passed array.
          */
-        public static FromArray(array: number[] | Float32Array, offset?: number): Vector3 {
+        public static FromArray(array: ArrayLike<number>, offset?: number): Vector3 {
             if (!offset) {
                 offset = 0;
             }
@@ -1406,20 +1405,17 @@
         }
 
         /**
-         * Returns a new Vector3 set from the index "offset" of the passed Float32Array.  
+         * Returns a new Vector3 set from the index "offset" of the passed Float32Array.
+         * This function is deprecated.  Use FromArray instead.
          */
         public static FromFloatArray(array: Float32Array, offset?: number): Vector3 {
-            if (!offset) {
-                offset = 0;
-            }
-
-            return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
+            return Vector3.FromArray(array, offset);
         }
 
         /**
-         * Sets the passed vector "result" with the element values from the index "offset" of the passed array or Float32Array.
+         * Sets the passed vector "result" with the element values from the index "offset" of the passed array.
          */
-        public static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector3): void {
+        public static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void {
             result.x = array[offset];
             result.y = array[offset + 1];
             result.z = array[offset + 2];
@@ -1427,11 +1423,10 @@
 
         /**
          * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array.
+         * This function is deprecated.  Use FromArrayToRef instead.
          */
         public static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void {
-            result.x = array[offset];
-            result.y = array[offset + 1];
-            result.z = array[offset + 2];
+            return Vector3.FromArrayToRef(array, offset, result);
         }
 
         /**
@@ -2142,18 +2137,18 @@
 
         // Statics
         /**
-         * Returns a new Vector4 set from the starting index of the passed array.  
+         * Returns a new Vector4 set from the starting index of the passed array.
          */
-        public static FromArray(array: number[] | Float32Array, offset?: number): Vector4 {
+        public static FromArray(array: ArrayLike<number>, offset?: number): Vector4 {
             if (!offset) {
                 offset = 0;
             }
             return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
         }
         /**
-         * Updates the passed vector "result" from the starting index of the passed array.  
+         * Updates the passed vector "result" from the starting index of the passed array.
          */
-        public static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector4): void {
+        public static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void {
             result.x = array[offset];
             result.y = array[offset + 1];
             result.z = array[offset + 2];
@@ -2163,10 +2158,7 @@
          * Updates the passed vector "result" from the starting index of the passed Float32Array.
          */
         public static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void {
-            result.x = array[offset];
-            result.y = array[offset + 1];
-            result.z = array[offset + 2];
-            result.w = array[offset + 3];
+            Vector4.FromArrayToRef(array, offset, result);
         }
         /**
          * Updates the passed vector "result" coordinates from the passed floats.  
@@ -2739,9 +2731,9 @@
             return result;
         }
         /**
-         * Retuns a new Quaternion set from the starting index of the passed array.  
+         * Retuns a new Quaternion set from the starting index of the passed array.
          */
-        public static FromArray(array: number[], offset?: number): Quaternion {
+        public static FromArray(array: ArrayLike<number>, offset?: number): Quaternion {
             if (!offset) {
                 offset = 0;
             }
@@ -3294,9 +3286,9 @@
 
         // Statics
         /**
-         * Returns a new Matrix set from the starting index of the passed array.  
+         * Returns a new Matrix set from the starting index of the passed array.
          */
-        public static FromArray(array: number[], offset?: number): Matrix {
+        public static FromArray(array: ArrayLike<number>, offset?: number): Matrix {
             var result = new Matrix();
 
             if (!offset) {
@@ -3306,9 +3298,9 @@
             return result;
         }
         /**
-         * Sets the passed "result" matrix from the starting index of the passed array.  
+         * Sets the passed "result" matrix from the starting index of the passed array.
          */
-        public static FromArrayToRef(array: number[], offset: number, result: Matrix) {
+        public static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix) {
             for (var index = 0; index < 16; index++) {
                 result.m[index] = array[index + offset];
             }
@@ -4315,7 +4307,7 @@
         /**
          * Returns a new Plane from the passed array.  
          */
-        static FromArray(array: number[]): Plane {
+        static FromArray(array: ArrayLike<number>): Plane {
             return new Plane(array[0], array[1], array[2], array[3]);
         }
         /**

+ 44 - 54
src/Mesh/babylon.abstractMesh.ts

@@ -1822,76 +1822,67 @@
 
         /**
          * Defines the passed mesh as the parent of the current mesh.  
-         * If keepWorldPositionRotation is set to `true` (default `false`), the current mesh position and rotation are kept.
          * Returns the AbstractMesh.  
          */
-        public setParent(mesh:AbstractMesh, keepWorldPositionRotation = false): AbstractMesh {
-
+        public setParent(mesh:AbstractMesh): AbstractMesh {
+            
             var child = this;
             var parent = mesh;
 
             if(mesh == null){
 
-                if(child.parent && keepWorldPositionRotation){
-                  
-                    var rotation = Tmp.Quaternion[0];
-                    var position = Tmp.Vector3[0];
-                    var scale = Tmp.Vector3[1];
-
-                    child.getWorldMatrix().decompose(scale, rotation, position);
+                var rotation = Tmp.Quaternion[0];
+                var position = Tmp.Vector3[0];
+                var scale = Tmp.Vector3[1];
 
-                    if (child.rotationQuaternion) {
-                        child.rotationQuaternion.copyFrom(rotation);
-                    } else {
-                        rotation.toEulerAnglesToRef(child.rotation);
-                    }
+                child.getWorldMatrix().decompose(scale, rotation, position);
 
-                    child.position.x = position.x;
-                    child.position.y = position.y;
-                    child.position.z = position.z;
+                if (child.rotationQuaternion) {
+                    child.rotationQuaternion.copyFrom(rotation);
+                } else {
+                    rotation.toEulerAnglesToRef(child.rotation);
+                }
 
-               }
+                child.position.x = position.x;
+                child.position.y = position.y;
+                child.position.z = position.z;
 
             } else {
+  
+                var rotation = Tmp.Quaternion[0];
+                var position = Tmp.Vector3[0];
+                var scale = Tmp.Vector3[1];
+                var m1 = Tmp.Matrix[0];
+                var m2 = Tmp.Matrix[1];
 
-                if(keepWorldPositionRotation){
-                    
-                    var rotation = Tmp.Quaternion[0];
-                    var position = Tmp.Vector3[0];
-                    var scale = Tmp.Vector3[1];
-                    var m1 = Tmp.Matrix[0];
-                    var m2 = Tmp.Matrix[1];
-
-                    parent.getWorldMatrix().decompose(scale, rotation, position);
+                parent.getWorldMatrix().decompose(scale, rotation, position);
 
-                    rotation.toRotationMatrix(m1);
-                    m2.setTranslation(position);
+                rotation.toRotationMatrix(m1);
+                m2.setTranslation(position);
 
-                    m2.multiplyToRef(m1, m1);
+                m2.multiplyToRef(m1, m1);
 
-                    var invParentMatrix = Matrix.Invert(m1);
+                var invParentMatrix = Matrix.Invert(m1);
 
-                    var m = child.getWorldMatrix().multiply(invParentMatrix);
+                var m = child.getWorldMatrix().multiply(invParentMatrix);
 
-                    m.decompose(scale, rotation, position);
+                m.decompose(scale, rotation, position);
 
-                    if (child.rotationQuaternion) {
-                        child.rotationQuaternion.copyFrom(rotation);
-                    } else {
-                        rotation.toEulerAnglesToRef(child.rotation);
-                    }
-
-                    invParentMatrix = Matrix.Invert(parent.getWorldMatrix());
+                if (child.rotationQuaternion) {
+                    child.rotationQuaternion.copyFrom(rotation);
+                } else {
+                    rotation.toEulerAnglesToRef(child.rotation);
+                }
 
-                    var m = child.getWorldMatrix().multiply(invParentMatrix);
+                invParentMatrix = Matrix.Invert(parent.getWorldMatrix());
 
-                    m.decompose(scale, rotation, position);
+                var m = child.getWorldMatrix().multiply(invParentMatrix);
 
-                    child.position.x = position.x;
-                    child.position.y = position.y;
-                    child.position.z = position.z;
+                m.decompose(scale, rotation, position);
 
-                }
+                child.position.x = position.x;
+                child.position.y = position.y;
+                child.position.z = position.z;
 
             }
             child.parent = parent;
@@ -1900,11 +1891,10 @@
 
         /**
          * Adds the passed mesh as a child to the current mesh.  
-         * If keepWorldPositionRotation is set to `true` (default `false`), the child world position and rotation are kept.  
          * Returns the AbstractMesh.  
          */
-        public addChild(mesh:AbstractMesh, keepWorldPositionRotation = false): AbstractMesh {
-            mesh.setParent(this, keepWorldPositionRotation);
+        public addChild(mesh:AbstractMesh): AbstractMesh {
+            mesh.setParent(this);
             return this;
         }
 
@@ -1912,8 +1902,8 @@
          * Removes the passed mesh from the current mesh children list.  
          * Returns the AbstractMesh.  
          */
-        public removeChild(mesh:AbstractMesh, keepWorldPositionRotation = false): AbstractMesh {
-            mesh.setParent(null, keepWorldPositionRotation);
+        public removeChild(mesh:AbstractMesh): AbstractMesh {
+            mesh.setParent(null);
             return this;
         }
 
@@ -2190,8 +2180,8 @@
             } else {
                 normals = [];
             }
-            
-            VertexData.ComputeNormals(positions, indices, normals);
+
+            VertexData.ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
             this.setVerticesData(VertexBuffer.NormalKind, normals, updatable);
         } 
 

+ 19 - 17
src/Mesh/babylon.linesMesh.ts

@@ -5,8 +5,6 @@ module BABYLON {
         public color = new Color3(1, 1, 1);
         public alpha = 1;
 
-        private _positionBuffer: { [key: string]: VertexBuffer } = {};
-
         /**
          * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
          * This margin is expressed in world space coordinates, so its value may vary.
@@ -36,23 +34,29 @@ module BABYLON {
         private _intersectionThreshold: number;
         private _colorShader: ShaderMaterial;
 
-        constructor(name: string, scene: Scene, parent: Node = null, source?: LinesMesh, doNotCloneChildren?: boolean) {
+        constructor(name: string, scene: Scene, parent: Node = null, source?: LinesMesh, doNotCloneChildren?: boolean, public useVertexColor? : boolean) {
             super(name, scene, parent, source, doNotCloneChildren);
 
             if (source) {
                 this.color = source.color.clone();
                 this.alpha = source.alpha;
+                this.useVertexColor = source.useVertexColor;
             }
 
             this._intersectionThreshold = 0.1;
-            this._colorShader = new ShaderMaterial("colorShader", scene, "color",
-                {
-                    attributes: [VertexBuffer.PositionKind],
-                    uniforms: ["worldViewProjection", "color"],
-                    needAlphaBlending: true
-                });
-
-            this._positionBuffer[VertexBuffer.PositionKind] = null;
+            
+            var options = {
+                attributes: [VertexBuffer.PositionKind],
+                uniforms: ["world", "viewProjection"],
+                needAlphaBlending: false,
+            };
+            
+            if (!useVertexColor) {
+                options.uniforms.push("color");
+                options.needAlphaBlending = true;
+            }
+
+            this._colorShader = new ShaderMaterial("colorShader", scene, "color", options);
         }
 
         /**
@@ -76,15 +80,13 @@ module BABYLON {
         }
 
         public _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh {
-            var engine = this.getScene().getEngine();
-
-            this._positionBuffer[VertexBuffer.PositionKind] = this._geometry.getVertexBuffer(VertexBuffer.PositionKind);
-
             // VBOs
-            engine.bindBuffers(this._positionBuffer, this._geometry.getIndexBuffer(), this._colorShader.getEffect());
+            this._geometry._bind(this._colorShader.getEffect() );
 
             // Color
-            this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
+            if (!this.useVertexColor) {
+                this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
+            }
             return this;
         }
 

+ 6 - 4
src/Mesh/babylon.mesh.vertexData.ts

@@ -2126,7 +2126,7 @@
          * bInfo : optional bounding info, required for facetPartitioning computation
          */
         public static ComputeNormals(positions: any, indices: any, normals: any,
-            options?: { facetNormals?: any, facetPositions?: any, facetPartitioning?: any, ratio?: number, bInfo?: any, bbSize?: Vector3, subDiv?: any}): void {
+            options?: { facetNormals?: any, facetPositions?: any, facetPartitioning?: any, ratio?: number, bInfo?: any, bbSize?: Vector3, subDiv?: any, useRightHandedSystem?: boolean }): void {
 
             // temporary scalar variables
             var index = 0;                      // facet index     
@@ -2152,10 +2152,12 @@
             var computeFacetNormals = false;
             var computeFacetPositions = false;
             var computeFacetPartitioning = false;
+            var faceNormalSign = 1;
             if (options) {
                 computeFacetNormals = (options.facetNormals) ? true : false;
                 computeFacetPositions = (options.facetPositions) ? true : false;
                 computeFacetPartitioning = (options.facetPartitioning) ? true : false;
+                faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
             }
 
             // facetPartitioning reinit if needed
@@ -2215,9 +2217,9 @@
                 p3p2z = positions[v3z] - positions[v2z];
 
                 // compute the face normal with the cross product
-                faceNormalx = p1p2y * p3p2z - p1p2z * p3p2y;
-                faceNormaly = p1p2z * p3p2x - p1p2x * p3p2z;
-                faceNormalz = p1p2x * p3p2y - p1p2y * p3p2x;
+                faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
+                faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
+                faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
                 // normalize this normal and store it in the array facetData
                 length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
                 length = (length === 0) ? 1.0 : length;

+ 8 - 0
src/Morph/babylon.morphTargetManager.ts

@@ -38,6 +38,10 @@ module BABYLON {
             return this._supportsTangents;
         }
 
+        public get numTargets(): number {
+            return this._targets.length;
+        }
+
         public get numInfluencers(): number {
             return this._activeTargets.length;
         }
@@ -49,6 +53,10 @@ module BABYLON {
         public getActiveTarget(index: number): MorphTarget {
             return this._activeTargets.data[index];
         }
+
+        public getTarget(index: number): MorphTarget {
+            return this._targets[index];
+        }
        
         public addTarget(target: MorphTarget): void {
             if (this._vertexCount) {

+ 10 - 1
src/Shaders/color.fragment.fx

@@ -1,5 +1,14 @@
-uniform vec4 color;
+
+#ifdef VERTEXCOLOR
+varying vec4 vColor;
+#else
+uniform vec4 color;
+#endif
 
 void main(void) {
+#ifdef VERTEXCOLOR
+	gl_FragColor = vColor;
+#else
 	gl_FragColor = color;
+#endif
 }

+ 21 - 2
src/Shaders/color.vertex.fx

@@ -1,9 +1,28 @@
 // Attributes
 attribute vec3 position;
 
+#ifdef VERTEXCOLOR
+attribute vec4 color;
+#endif
+
+#include<bonesDeclaration>
+
 // Uniforms
-uniform mat4 worldViewProjection;
+uniform mat4 viewProjection;
+uniform mat4 world;
+
+// Output
+#ifdef VERTEXCOLOR
+varying vec4 vColor;
+#endif
 
 void main(void) {
-	gl_Position = worldViewProjection * vec4(position, 1.0);
+    mat4 finalWorld = world;
+#include<bonesVertex>
+	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
+
+#ifdef VERTEXCOLOR
+	// Vertex color
+	vColor = color;
+#endif
 }

+ 1 - 1
src/Shaders/pbr.fragment.fx

@@ -144,7 +144,7 @@ void main(void) {
 #ifdef NORMAL
 	vec3 normalW = normalize(vNormalW);
 #else
-	vec3 normalW = vec3(1.0, 1.0, 1.0);
+	vec3 normalW = normalize(cross(dFdx(vPositionW), dFdy(vPositionW)));
 #endif
 
 #include<bumpFragment>

+ 9 - 1
src/babylon.engine.ts

@@ -966,6 +966,14 @@
             this._stencilState.stencilOpStencilDepthPass = operation;
         }
 
+        public setDitheringState(value: boolean): void {
+            if (value) {
+                this._gl.enable(this._gl.DITHER);
+            } else {
+                this._gl.disable(this._gl.DITHER);
+            }
+        }
+
         /**
          * stop executing a render loop function and remove it from the execution array
          * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
@@ -1663,7 +1671,7 @@
             var boundBuffer;
             for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
                 var instancesBuffer = this._currentInstanceBuffers[i];
-                if (boundBuffer != instancesBuffer) {
+                if (boundBuffer != instancesBuffer && instancesBuffer.references) {
                     boundBuffer = instancesBuffer;
                     this.bindArrayBuffer(instancesBuffer);
                 }

+ 9 - 5
tests/validation/validation.js

@@ -5,6 +5,9 @@ var canvas;
 var currentScene;
 var config;
 
+var thresold = 25;
+var errorRatio = 5;
+
 function compare(renderData, referenceCanvas) {
     var width = referenceCanvas.width;
     var height = referenceCanvas.height;
@@ -16,9 +19,9 @@ function compare(renderData, referenceCanvas) {
 
     var differencesCount = 0;
     for (var index = 0; index < size; index += 4) {
-        if (renderData[index] === referenceData.data[index] &&
-            renderData[index + 1] === referenceData.data[index + 1] &&
-            renderData[index + 2] === referenceData.data[index + 2]) {
+        if (Math.abs(renderData[index] - referenceData.data[index]) < threshold &&
+            Math.abs(renderData[index + 1] - referenceData.data[index + 1]) < threshold &&
+            Math.abs(renderData[index + 2] - referenceData.data[index + 2]) < threshold) {
             continue;
         }
 
@@ -30,7 +33,7 @@ function compare(renderData, referenceCanvas) {
 
     referenceContext.putImageData(referenceData, 0, 0);
 
-    return (differencesCount * 100) / (width * height);
+    return (differencesCount * 100) / (width * height) > errorRatio;
 }
 
 function getRenderData(canvas, engine) {
@@ -76,7 +79,7 @@ function evaluate(test, resultCanvas, result, renderImage, index, waitRing) {
     var renderData = getRenderData(canvas, engine);
     if (!test.onlyVisual) {
 
-        if (compare(renderData, resultCanvas) > 5) { // More than 5% of pixels are different
+        if (compare(renderData, resultCanvas)) { 
             result.classList.add("failed");
             result.innerHTML = "×";
             console.log("failed");
@@ -222,6 +225,7 @@ canvas = document.createElement("canvas");
 canvas.className = "renderCanvas";
 document.body.appendChild(canvas);
 engine = new BABYLON.Engine(canvas, false);
+engine.setDitheringState(false);
 
 // Loading tests
 var xhr = new XMLHttpRequest();