瀏覽代碼

Fix issue with gltfloader when ArrayBufferView.forEach is not defined (mostly ios and IE)

David Catuhe 8 年之前
父節點
當前提交
ee540f50b8

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


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


+ 1 - 1
dist/preview release/babylon.max.js

@@ -60379,7 +60379,7 @@ var BABYLON;
                             if (!info.isCompressed && info.isFourCC) {
                             if (!info.isCompressed && info.isFourCC) {
                                 dataLength = width * height * 4;
                                 dataLength = width * height * 4;
                                 var floatArray;
                                 var floatArray;
-                                if (engine.badOS) {
+                                if (engine.badOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) {
                                     if (bpp === 128) {
                                     if (bpp === 128) {
                                         floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
                                         floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
                                     }
                                     }

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


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


+ 2 - 2
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -482,11 +482,11 @@ module BABYLON.GLTF2 {
                         var values = <Float32Array>data;
                         var values = <Float32Array>data;
                         switch (semantic) {
                         switch (semantic) {
                             case "NORMAL":
                             case "NORMAL":
-                                values.forEach((v, i) => values[i] += vertexData.normals[i]);
+                                GLTFUtils.ForEach(values, (v, i) => values[i] += vertexData.normals[i]);
                                 babylonMorphTarget.setNormals(values);
                                 babylonMorphTarget.setNormals(values);
                                 break;
                                 break;
                             case "POSITION":
                             case "POSITION":
-                                values.forEach((v, i) => values[i] += vertexData.positions[i]);
+                                GLTFUtils.ForEach(values, (v, i) => values[i] += vertexData.positions[i]);
                                 babylonMorphTarget.setPositions(values);
                                 babylonMorphTarget.setPositions(values);
                                 break;
                                 break;
                             case "TANGENT":
                             case "TANGENT":

+ 6 - 0
loaders/src/glTF/2.0/babylon.glTFLoaderUtils.ts

@@ -29,6 +29,12 @@ module BABYLON.GLTF2 {
             return bufferView.buffer;
             return bufferView.buffer;
         }
         }
 
 
+        public static ForEach(view: Uint16Array | Uint32Array | Float32Array, func: (nvalue: number, index:number) => void) : void {
+            for (var index = 0; index < view.length; index++) {
+                func(view[index], index);
+            }
+        }
+
         /**
         /**
         * Returns the wrap mode of the texture
         * Returns the wrap mode of the texture
         * @param mode: the mode value
         * @param mode: the mode value