Przeglądaj źródła

Fix bug with IE and Float32Array.slice

David Catuhe 7 lat temu
rodzic
commit
677f044b3d

Plik diff jest za duży
+ 4210 - 4203
Playground/babylon.d.txt


Plik diff jest za duży
+ 7110 - 7103
dist/preview release/babylon.d.ts


Plik diff jest za duży
+ 7 - 7
dist/preview release/babylon.js


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

@@ -6768,6 +6768,17 @@ var BABYLON;
             }
             return fn;
         };
+        /**
+         * Provides a slice function that will work even on IE
+         * @param data defines the array to slice
+         * @returns the new sliced array
+         */
+        Tools.Slice = function (data) {
+            if (data.slice) {
+                return data.slice();
+            }
+            return Array.prototype.slice.call(data);
+        };
         Tools.SetImmediate = function (action) {
             if (window.setImmediate) {
                 window.setImmediate(action);
@@ -25884,7 +25895,7 @@ var BABYLON;
         Mesh.prototype._getPositionData = function (applySkeleton) {
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             if (data && applySkeleton && this.skeleton) {
-                data = data.slice();
+                data = BABYLON.Tools.Slice(data);
                 var matricesIndicesData = this.getVerticesData(BABYLON.VertexBuffer.MatricesIndicesKind);
                 var matricesWeightsData = this.getVerticesData(BABYLON.VertexBuffer.MatricesWeightsKind);
                 if (matricesWeightsData && matricesIndicesData) {

Plik diff jest za duży
+ 7 - 7
dist/preview release/babylon.worker.js


Plik diff jest za duży
+ 664 - 657
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


Plik diff jest za duży
+ 7 - 7
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 12 - 1
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -6768,6 +6768,17 @@ var BABYLON;
             }
             return fn;
         };
+        /**
+         * Provides a slice function that will work even on IE
+         * @param data defines the array to slice
+         * @returns the new sliced array
+         */
+        Tools.Slice = function (data) {
+            if (data.slice) {
+                return data.slice();
+            }
+            return Array.prototype.slice.call(data);
+        };
         Tools.SetImmediate = function (action) {
             if (window.setImmediate) {
                 window.setImmediate(action);
@@ -25884,7 +25895,7 @@ var BABYLON;
         Mesh.prototype._getPositionData = function (applySkeleton) {
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             if (data && applySkeleton && this.skeleton) {
-                data = data.slice();
+                data = BABYLON.Tools.Slice(data);
                 var matricesIndicesData = this.getVerticesData(BABYLON.VertexBuffer.MatricesIndicesKind);
                 var matricesWeightsData = this.getVerticesData(BABYLON.VertexBuffer.MatricesWeightsKind);
                 if (matricesWeightsData && matricesIndicesData) {

+ 12 - 1
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js

@@ -6754,6 +6754,17 @@ var BABYLON;
             }
             return fn;
         };
+        /**
+         * Provides a slice function that will work even on IE
+         * @param data defines the array to slice
+         * @returns the new sliced array
+         */
+        Tools.Slice = function (data) {
+            if (data.slice) {
+                return data.slice();
+            }
+            return Array.prototype.slice.call(data);
+        };
         Tools.SetImmediate = function (action) {
             if (window.setImmediate) {
                 window.setImmediate(action);
@@ -25870,7 +25881,7 @@ var BABYLON;
         Mesh.prototype._getPositionData = function (applySkeleton) {
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             if (data && applySkeleton && this.skeleton) {
-                data = data.slice();
+                data = BABYLON.Tools.Slice(data);
                 var matricesIndicesData = this.getVerticesData(BABYLON.VertexBuffer.MatricesIndicesKind);
                 var matricesWeightsData = this.getVerticesData(BABYLON.VertexBuffer.MatricesWeightsKind);
                 if (matricesWeightsData && matricesIndicesData) {

+ 12 - 1
dist/preview release/es6.js

@@ -6754,6 +6754,17 @@ var BABYLON;
             }
             return fn;
         };
+        /**
+         * Provides a slice function that will work even on IE
+         * @param data defines the array to slice
+         * @returns the new sliced array
+         */
+        Tools.Slice = function (data) {
+            if (data.slice) {
+                return data.slice();
+            }
+            return Array.prototype.slice.call(data);
+        };
         Tools.SetImmediate = function (action) {
             if (window.setImmediate) {
                 window.setImmediate(action);
@@ -25870,7 +25881,7 @@ var BABYLON;
         Mesh.prototype._getPositionData = function (applySkeleton) {
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             if (data && applySkeleton && this.skeleton) {
-                data = data.slice();
+                data = BABYLON.Tools.Slice(data);
                 var matricesIndicesData = this.getVerticesData(BABYLON.VertexBuffer.MatricesIndicesKind);
                 var matricesWeightsData = this.getVerticesData(BABYLON.VertexBuffer.MatricesWeightsKind);
                 if (matricesWeightsData && matricesIndicesData) {

Plik diff jest za duży
+ 4 - 4
dist/preview release/viewer/babylon.viewer.js


+ 1 - 1
src/Mesh/babylon.mesh.ts

@@ -775,7 +775,7 @@
             var data = this.getVerticesData(VertexBuffer.PositionKind);
 
             if (data && applySkeleton && this.skeleton) {
-                data = data.slice();
+                data = Tools.Slice(data);
 
                 var matricesIndicesData = this.getVerticesData(VertexBuffer.MatricesIndicesKind);
                 var matricesWeightsData = this.getVerticesData(VertexBuffer.MatricesWeightsKind);

+ 34 - 0
src/Tools/babylon.promise.ts

@@ -0,0 +1,34 @@
+// module BABYLON {
+//     export class Promise<T> {
+//         public constructor(resolver: (
+//                 resolve:(value:T) => void, 
+//                 reject: (reason: string) => void
+//             ) => void) {
+
+//             try {
+
+//             } catch(e) {
+//                 this._reject((<Error>e).message);
+//             }
+//         }
+
+//         public catch(onRejected: (reason: string) => void): Promise<T> {
+//             return this.then(undefined, onRejected);
+//         }
+
+//         public then(onFulfilled?: (fulfillment: T) => void, onRejected?: (reason: string) => void): Promise<T> {
+//             return this;
+//         }        
+
+//         private _reject(reason: string): void {
+            
+//         }
+
+//         // public static resolve(): Promise<T> {
+            
+//         // }
+//         // public static reject(reason: string): Promise<T> {
+//         //     let newPromise = 
+//         // }
+//     }
+// }

+ 13 - 0
src/Tools/babylon.tools.ts

@@ -113,6 +113,19 @@
             return fn;
         }
 
+        /**
+         * Provides a slice function that will work even on IE
+         * @param data defines the array to slice
+         * @returns the new sliced array
+         */
+        public static Slice(data: FloatArray): FloatArray {
+            if (data.slice) {
+                return data.slice();
+            }
+
+            return Array.prototype.slice.call(data);
+        }
+
         public static SetImmediate(action: () => void) {
             if (window.setImmediate) {
                 window.setImmediate(action);