瀏覽代碼

Merge pull request #3477 from BabylonJS/master

Nightly
David Catuhe 7 年之前
父節點
當前提交
8a8323acf3

文件差異過大導致無法顯示
+ 1301 - 1296
Playground/babylon.d.txt


文件差異過大導致無法顯示
+ 1151 - 1146
dist/preview release/babylon.d.ts


文件差異過大導致無法顯示
+ 22 - 22
dist/preview release/babylon.js


+ 14 - 16
dist/preview release/babylon.max.js

@@ -8724,7 +8724,7 @@ var BABYLON;
         });
         Object.defineProperty(Engine, "Version", {
             get: function () {
-                return "3.2.0-alpha1";
+                return "3.2.0-alpha2";
             },
             enumerable: true,
             configurable: true
@@ -27588,7 +27588,7 @@ var BABYLON;
         };
         Effect.prototype.bindUniformBuffer = function (buffer, name) {
             var bufferName = this._uniformBuffersNames[name];
-            if (Effect._baseCache[bufferName] === buffer) {
+            if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
                 return;
             }
             Effect._baseCache[bufferName] = buffer;
@@ -30232,10 +30232,10 @@ var BABYLON;
          * Creates the VertexData of the TiledGround.
          */
         VertexData.CreateTiledGround = function (options) {
-            var xmin = options.xmin || -1.0;
-            var zmin = options.zmin || -1.0;
-            var xmax = options.xmax || 1.0;
-            var zmax = options.zmax || 1.0;
+            var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
+            var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
+            var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
+            var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
             var subdivisions = options.subdivisions || { w: 1, h: 1 };
             var precision = options.precision || { w: 1, h: 1 };
             var indices = new Array();
@@ -34638,9 +34638,10 @@ var BABYLON;
         MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
             if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
             if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
-            for (var i = 0, len = mesh._lightSources.length, light, iAsString; i < len; i++) {
-                light = mesh._lightSources[i];
-                iAsString = i.toString();
+            var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
+            for (var i = 0; i < len; i++) {
+                var light = mesh._lightSources[i];
+                var iAsString = i.toString();
                 var scaledIntensity = light.getScaledIntensity();
                 light._uniformBuffer.bindToEffect(effect, "Light" + i);
                 MaterialHelper.BindLightProperties(light, effect, i);
@@ -34655,8 +34656,6 @@ var BABYLON;
                     this.BindLightShadow(light, scene, mesh, iAsString, effect);
                 }
                 light._uniformBuffer.update();
-                if (i === maxSimultaneousLights)
-                    break;
             }
         };
         MaterialHelper.BindFogParameters = function (scene, mesh, effect) {
@@ -81195,6 +81194,7 @@ var BABYLON;
                 groundMirrorFresnelWeight: 1,
                 groundMirrorFallOffDistance: 0,
                 groundMirrorTextureType: BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT,
+                groundYBias: 0.00001,
                 createSkybox: true,
                 skyboxSize: 20,
                 skyboxTexture: this._skyboxTextureCDNUrl,
@@ -81429,24 +81429,22 @@ var BABYLON;
             }
             var sceneExtends = this._scene.getWorldExtends();
             var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
-            var bias = 0.0001;
             if (this._options.sizeAuto) {
                 if (this._scene.activeCamera instanceof BABYLON.ArcRotateCamera &&
                     this._scene.activeCamera.upperRadiusLimit) {
                     groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
-                }
-                if (this._scene.activeCamera) {
-                    bias = (this._scene.activeCamera.maxZ - this._scene.activeCamera.minZ) / 10000;
+                    skyboxSize = groundSize;
                 }
                 var sceneDiagonalLenght = sceneDiagonal.length();
                 if (sceneDiagonalLenght > groundSize) {
                     groundSize = sceneDiagonalLenght * 2;
+                    skyboxSize = groundSize;
                 }
                 // 10 % bigger.
                 groundSize *= 1.1;
                 skyboxSize *= 1.5;
                 rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
-                rootPosition.y = sceneExtends.min.y - bias;
+                rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
             }
             return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
         };

文件差異過大導致無法顯示
+ 27 - 27
dist/preview release/babylon.worker.js


文件差異過大導致無法顯示
+ 7840 - 7835
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


文件差異過大導致無法顯示
+ 23 - 23
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 13 - 15
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -27588,7 +27588,7 @@ var BABYLON;
         };
         Effect.prototype.bindUniformBuffer = function (buffer, name) {
             var bufferName = this._uniformBuffersNames[name];
-            if (Effect._baseCache[bufferName] === buffer) {
+            if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
                 return;
             }
             Effect._baseCache[bufferName] = buffer;
@@ -30232,10 +30232,10 @@ var BABYLON;
          * Creates the VertexData of the TiledGround.
          */
         VertexData.CreateTiledGround = function (options) {
-            var xmin = options.xmin || -1.0;
-            var zmin = options.zmin || -1.0;
-            var xmax = options.xmax || 1.0;
-            var zmax = options.zmax || 1.0;
+            var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
+            var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
+            var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
+            var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
             var subdivisions = options.subdivisions || { w: 1, h: 1 };
             var precision = options.precision || { w: 1, h: 1 };
             var indices = new Array();
@@ -34638,9 +34638,10 @@ var BABYLON;
         MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
             if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
             if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
-            for (var i = 0, len = mesh._lightSources.length, light, iAsString; i < len; i++) {
-                light = mesh._lightSources[i];
-                iAsString = i.toString();
+            var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
+            for (var i = 0; i < len; i++) {
+                var light = mesh._lightSources[i];
+                var iAsString = i.toString();
                 var scaledIntensity = light.getScaledIntensity();
                 light._uniformBuffer.bindToEffect(effect, "Light" + i);
                 MaterialHelper.BindLightProperties(light, effect, i);
@@ -34655,8 +34656,6 @@ var BABYLON;
                     this.BindLightShadow(light, scene, mesh, iAsString, effect);
                 }
                 light._uniformBuffer.update();
-                if (i === maxSimultaneousLights)
-                    break;
             }
         };
         MaterialHelper.BindFogParameters = function (scene, mesh, effect) {
@@ -80691,6 +80690,7 @@ var BABYLON;
                 groundMirrorFresnelWeight: 1,
                 groundMirrorFallOffDistance: 0,
                 groundMirrorTextureType: BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT,
+                groundYBias: 0.00001,
                 createSkybox: true,
                 skyboxSize: 20,
                 skyboxTexture: this._skyboxTextureCDNUrl,
@@ -80925,24 +80925,22 @@ var BABYLON;
             }
             var sceneExtends = this._scene.getWorldExtends();
             var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
-            var bias = 0.0001;
             if (this._options.sizeAuto) {
                 if (this._scene.activeCamera instanceof BABYLON.ArcRotateCamera &&
                     this._scene.activeCamera.upperRadiusLimit) {
                     groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
-                }
-                if (this._scene.activeCamera) {
-                    bias = (this._scene.activeCamera.maxZ - this._scene.activeCamera.minZ) / 10000;
+                    skyboxSize = groundSize;
                 }
                 var sceneDiagonalLenght = sceneDiagonal.length();
                 if (sceneDiagonalLenght > groundSize) {
                     groundSize = sceneDiagonalLenght * 2;
+                    skyboxSize = groundSize;
                 }
                 // 10 % bigger.
                 groundSize *= 1.1;
                 skyboxSize *= 1.5;
                 rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
-                rootPosition.y = sceneExtends.min.y - bias;
+                rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
             }
             return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
         };

文件差異過大導致無法顯示
+ 32 - 32
dist/preview release/viewer/babylon.viewer.js


+ 11 - 7
src/Helpers/babylon.environmentHelper.ts

@@ -81,6 +81,11 @@ namespace BABYLON {
          * Unsigned Int by Default.
          */
         groundMirrorTextureType: number;
+        /**
+         * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
+         * the shown objects.
+         */
+        groundYBias: number;
 
         /**
          * Specifies wether or not to create a skybox.
@@ -204,6 +209,8 @@ namespace BABYLON {
                 groundMirrorFallOffDistance: 0,
                 groundMirrorTextureType: Engine.TEXTURETYPE_UNSIGNED_INT,
 
+                groundYBias: 0.00001,
+
                 createSkybox: true,
                 skyboxSize: 20,
                 skyboxTexture: this._skyboxTextureCDNUrl,
@@ -471,28 +478,25 @@ namespace BABYLON {
 
             const sceneExtends = this._scene.getWorldExtends();
             const sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
-            let bias = 0.0001;
 
             if (this._options.sizeAuto) {
                 if (this._scene.activeCamera instanceof ArcRotateCamera &&
                     this._scene.activeCamera.upperRadiusLimit) {
                     groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
-                }
-
-                if (this._scene.activeCamera) {
-                    bias = (this._scene.activeCamera.maxZ - this._scene.activeCamera.minZ) / 10000;
+                    skyboxSize = groundSize;
                 }
 
                 const sceneDiagonalLenght = sceneDiagonal.length();
                 if (sceneDiagonalLenght > groundSize) {
                     groundSize = sceneDiagonalLenght * 2;
+                    skyboxSize = groundSize;
                 }
 
                 // 10 % bigger.
                 groundSize *= 1.1;
                 skyboxSize *= 1.5;
                 rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
-                rootPosition.y = sceneExtends.min.y - bias;
+                rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
             }
 
             return { groundSize, skyboxSize, rootPosition };
@@ -506,7 +510,7 @@ namespace BABYLON {
                 this._ground = Mesh.CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
                 this._ground.rotation.x = Math.PI / 2; // Face up by default.
                 this._ground.parent = this._rootMesh;
-                this._ground.onDisposeObservable.add(() => { this._ground = null; })
+                this._ground.onDisposeObservable.add(() => { this._ground = null; });
             }
 
             this._ground.receiveShadows = this._options.enableGroundShadow;

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

@@ -763,7 +763,7 @@
 
         public bindUniformBuffer(buffer: WebGLBuffer, name: string): void {
             let bufferName = this._uniformBuffersNames[name];
-            if (Effect._baseCache[bufferName] === buffer) {
+            if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
                 return;
             }
             Effect._baseCache[bufferName] = buffer;

+ 18 - 18
src/Materials/babylon.materialHelper.ts

@@ -3,10 +3,10 @@
 
         public static BindEyePosition(effect: Effect, scene: Scene): void {
             if (scene._forcedViewPosition) {
-                effect.setVector3("vEyePosition", scene._forcedViewPosition);            
+                effect.setVector3("vEyePosition", scene._forcedViewPosition);
                 return;
             }
-            effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera!.globalPosition);            
+            effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera!.globalPosition);
         }
 
         public static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void {
@@ -57,13 +57,13 @@
             if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
                 defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
                 changed = true;
-            }            
+            }
 
             if (defines["INSTANCES"] !== useInstances) {
                 defines["INSTANCES"] = useInstances;
                 changed = true;
             }
-            
+
             if (changed) {
                 defines.markAsUnprocessed();
             }
@@ -76,7 +76,7 @@
 
             defines._normals = defines._needNormals;
             defines._uvs = defines._needUVs;
-            
+
             defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(VertexBuffer.NormalKind));
 
             if (defines._needNormals && mesh.isVerticesDataPresent(VertexBuffer.TangentKind)) {
@@ -111,7 +111,7 @@
                 var manager = (<Mesh>mesh).morphTargetManager;
                 if (manager) {
                     defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
-                    defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"] ;
+                    defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
                     defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
                     defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
                 } else {
@@ -146,7 +146,7 @@
                     }
 
                     defines["LIGHT" + lightIndex] = true;
-                    
+
                     defines["SPOTLIGHT" + lightIndex] = false;
                     defines["HEMILIGHT" + lightIndex] = false;
                     defines["POINTLIGHT" + lightIndex] = false;
@@ -184,7 +184,7 @@
                         }
                     }
 
-                    if (light.lightmapMode != Light.LIGHTMAP_DEFAULT ) {
+                    if (light.lightmapMode != Light.LIGHTMAP_DEFAULT) {
                         lightmapMode = true;
                         defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
                         defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == Light.LIGHTMAP_SHADOWSONLY);
@@ -208,7 +208,7 @@
                     defines["LIGHT" + index] = false;
                     defines["HEMILIGHT" + lightIndex] = false;
                     defines["POINTLIGHT" + lightIndex] = false;
-                    defines["DIRLIGHT" + lightIndex] = false;                    
+                    defines["DIRLIGHT" + lightIndex] = false;
                     defines["SPOTLIGHT" + lightIndex] = false;
                     defines["SHADOW" + lightIndex] = false;
                 }
@@ -220,9 +220,9 @@
                 needRebuild = true;
             }
 
-            defines["SHADOWFLOAT"] = shadowEnabled && 
-                                    ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
-                                         (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
+            defines["SHADOWFLOAT"] = shadowEnabled &&
+                ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
+                    (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
             defines["LIGHTMAPEXCLUDED"] = lightmapMode;
 
             if (needRebuild) {
@@ -370,9 +370,12 @@
         }
 
         public static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights = 4, usePhysicalLightFalloff = false) {
-            for (var i = 0, len = mesh._lightSources.length, light, iAsString; i < len; i++) {
-                light = mesh._lightSources[i];
-                iAsString = i.toString();
+            let len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
+
+            for (var i = 0; i < len; i++) {
+
+                let light = mesh._lightSources[i];
+                let iAsString = i.toString();
 
                 let scaledIntensity = light.getScaledIntensity();
                 light._uniformBuffer.bindToEffect(effect, "Light" + i);
@@ -391,9 +394,6 @@
                     this.BindLightShadow(light, scene, mesh, iAsString, effect);
                 }
                 light._uniformBuffer.update();
-
-                if (i === maxSimultaneousLights)
-                    break;
             }
         }
 

+ 40 - 39
src/Mesh/babylon.mesh.vertexData.ts

@@ -1,6 +1,5 @@
 module BABYLON {
-    export interface IGetSetVerticesData
-    {
+    export interface IGetSetVerticesData {
         isVerticesDataPresent(kind: string): boolean;
         getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
         getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
@@ -346,7 +345,7 @@
                 if (length === 0 || length === other.length) {
                     return other;
                 }
-                
+
                 var padding = new Float32Array(length - other.length);
                 padding.fill(defaultValue);
                 return this._mergeElement(padding, other, length);
@@ -744,7 +743,7 @@
             var positions32 = new Float32Array(positions);
             var normals32 = new Float32Array(normals);
             var uvs32 = new Float32Array(uvs);
-            
+
             vertexData.indices = indices;
             vertexData.positions = positions32;
             vertexData.normals = normals32;
@@ -1401,10 +1400,10 @@
          * Creates the VertexData of the TiledGround.  
          */
         public static CreateTiledGround(options: { xmin: number, zmin: number, xmax: number, zmax: number, subdivisions?: { w: number; h: number; }, precision?: { w: number; h: number; } }): VertexData {
-            var xmin = options.xmin || -1.0;
-            var zmin = options.zmin || -1.0;
-            var xmax = options.xmax || 1.0;
-            var zmax = options.zmax || 1.0;
+            var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
+            var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
+            var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
+            var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
             var subdivisions = options.subdivisions || { w: 1, h: 1 };
             var precision = options.precision || { w: 1, h: 1 };
 
@@ -1494,7 +1493,7 @@
             var uvs = [];
             var row, col;
             var filter = options.colorFilter || new Color3(0.3, 0.59, 0.11);
-            
+
             // Vertices
             for (row = 0; row <= options.subdivisions; row++) {
                 for (col = 0; col <= options.subdivisions; col++) {
@@ -1659,8 +1658,8 @@
         /**
          * Re-creates the VertexData of the Polygon for sideOrientation.  
          */
-        public static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?:Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4) {
-			var faceUV: Vector4[] = fUV || new Array<Vector4>(3);
+        public static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4) {
+            var faceUV: Vector4[] = fUV || new Array<Vector4>(3);
             var faceColors = fColors;
             var colors = [];
 
@@ -1673,39 +1672,39 @@
                     faceColors[f] = new Color4(1, 1, 1, 1);
                 }
             }
-            
+
             var positions = <FloatArray>polygon.getVerticesData(VertexBuffer.PositionKind);
-			var normals = <FloatArray>polygon.getVerticesData(VertexBuffer.NormalKind);
-			var uvs = <FloatArray>polygon.getVerticesData(VertexBuffer.UVKind);
+            var normals = <FloatArray>polygon.getVerticesData(VertexBuffer.NormalKind);
+            var uvs = <FloatArray>polygon.getVerticesData(VertexBuffer.UVKind);
             var indices = <IndicesArray>polygon.getIndices();
-            
+
             // set face colours and textures
             var idx: number = 0;
             var face: number = 0;
-            for (var index = 0; index < normals.length; index += 3) { 
+            for (var index = 0; index < normals.length; index += 3) {
                 //Edge Face  no. 1
-                if(Math.abs(normals[index + 1]) < 0.001) {
-                   face = 1; 
+                if (Math.abs(normals[index + 1]) < 0.001) {
+                    face = 1;
                 }
                 //Top Face  no. 0
-                if(Math.abs(normals[index + 1] - 1) < 0.001 ) {
-                   face = 0; 
+                if (Math.abs(normals[index + 1] - 1) < 0.001) {
+                    face = 0;
                 }
                 //Bottom Face  no. 2
-                if(Math.abs(normals[index + 1] + 1) < 0.001 ) {
-                   face = 2; 
+                if (Math.abs(normals[index + 1] + 1) < 0.001) {
+                    face = 2;
                 }
                 idx = index / 3;
-                uvs[2*idx] = (1 - uvs[2*idx])*faceUV[face].x + uvs[2*idx]*faceUV[face].z;
-                uvs[2*idx + 1] = (1 - uvs[2*idx + 1])*faceUV[face].y + uvs[2*idx + 1]*faceUV[face].w;
+                uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
+                uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
                 if (faceColors) {
                     colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
                 }
             }
 
-			// sides
+            // sides
             VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
-            
+
             // Result
             var vertexData = new VertexData();
             vertexData.indices = indices;
@@ -1719,8 +1718,8 @@
             }
 
             return vertexData;
-			
-		}
+
+        }
 
         /**
          * Creates the VertexData of the IcoSphere.  
@@ -2234,8 +2233,10 @@
          * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
          */
         public static ComputeNormals(positions: any, indices: any, normals: any,
-            options?: { facetNormals?: any, facetPositions?: any, facetPartitioning?: any, ratio?: number, bInfo?: any, bbSize?: Vector3, subDiv?: any, 
-                useRightHandedSystem?: boolean, depthSort?: boolean, distanceTo?: Vector3, depthSortedFacets?: any }): void {
+            options?: {
+                facetNormals?: any, facetPositions?: any, facetPartitioning?: any, ratio?: number, bInfo?: any, bbSize?: Vector3, subDiv?: any,
+                useRightHandedSystem?: boolean, depthSort?: boolean, distanceTo?: Vector3, depthSortedFacets?: any
+            }): void {
 
             // temporary scalar variables
             var index = 0;                      // facet index     
@@ -2276,7 +2277,7 @@
                 if (computeDepthSort) {
                     if (distanceTo === undefined) {
                         distanceTo = Vector3.Zero();
-                    } 
+                    }
                     var depthSortedFacets = options.depthSortedFacets;
                 }
             }
@@ -2319,7 +2320,7 @@
             }
 
             // Loop : 1 indice triplet = 1 facet
-            var nbFaces = (indices.length / 3)|0;
+            var nbFaces = (indices.length / 3) | 0;
             for (index = 0; index < nbFaces; index++) {
 
                 // get the indexes of the coordinates of each vertex of the facet
@@ -2386,10 +2387,10 @@
                     block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
                     block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
 
-                    options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] :new Array();
-                    options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] :new Array();
-                    options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] :new Array();
-                    options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] :new Array();
+                    options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
+                    options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
+                    options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
+                    options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
 
                     // push each facet index in each block containing the vertex
                     options.facetPartitioning[block_idx_v1].push(index);
@@ -2488,12 +2489,12 @@
                     var lu: number = uvs.length;
                     var u: number = 0;
                     for (u = 0; u < lu; u++) {
-                        uvs[u + lu] = uvs[u];                       
+                        uvs[u + lu] = uvs[u];
                     }
                     frontUVs = frontUVs ? frontUVs : new Vector4(0.0, 0.0, 1.0, 1.0);
-                    backUVs = backUVs ? backUVs : new Vector4(0.0, 0.0, 1.0, 1.0); 
+                    backUVs = backUVs ? backUVs : new Vector4(0.0, 0.0, 1.0, 1.0);
                     u = 0;
-                    for (i = 0; i < lu / 2; i++) {    
+                    for (i = 0; i < lu / 2; i++) {
                         uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
                         uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
                         uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];

+ 1 - 1
src/babylon.scene.ts

@@ -879,7 +879,7 @@
         private _pendingData = new Array();
         private _isDisposed = false;
 
-        public dispatchAllSubMeshesOfActiveMeshes:boolean = false;
+        public dispatchAllSubMeshesOfActiveMeshes: boolean = false;
         private _activeMeshes = new SmartArray<AbstractMesh>(256);
         private _processedMaterials = new SmartArray<Material>(256);
         private _renderTargets = new SmartArrayNoDuplicate<RenderTargetTexture>(256);

+ 22 - 11
tests/validation/validation.js

@@ -79,17 +79,28 @@ function saveRenderImage(data, canvas) {
 function evaluate(test, resultCanvas, result, renderImage, index, waitRing, done) {
     var renderData = getRenderData(canvas, engine);
     var testRes = true;
-    if (!test.onlyVisual) {
-
-        if (compare(renderData, resultCanvas)) {
-            result.classList.add("failed");
-            result.innerHTML = "×";
-            testRes = false;
-            console.log('%c failed', 'color: red');
-        } else {
-            result.innerHTML = "✔";
-            testRes = true;
-            console.log('%c validated', 'color: green');
+
+    // gl check
+    var gl = engine._gl;
+    if (gl.getError() !== 0) {
+        result.classList.add("failed");
+        result.innerHTML = "×";
+        testRes = false;
+        console.log('%c failed (gl error)', 'color: red');
+    } else {
+
+        // Visual check
+        if (!test.onlyVisual) {
+            if (compare(renderData, resultCanvas)) {
+                result.classList.add("failed");
+                result.innerHTML = "×";
+                testRes = false;
+                console.log('%c failed', 'color: red');
+            } else {
+                result.innerHTML = "✔";
+                testRes = true;
+                console.log('%c validated', 'color: green');
+            }
         }
     }
     waitRing.classList.add("hidden");