2
0
Mr.doob 11 жил өмнө
parent
commit
69cfda0899

+ 5 - 9
examples/js/loaders/gltf/glTF-parser.js

@@ -272,16 +272,12 @@ var global = window;
                     this.baseURL = (i !== 0) ? jsonPath.substring(0, i + 1) : '';
                     var jsonfile = new XMLHttpRequest();
                     jsonfile.open("GET", jsonPath, true);
-                    jsonfile.onreadystatechange = function() {
-                        if (jsonfile.readyState == 4) {
-                            if (jsonfile.status == 200) {
-                                self.json = JSON.parse(jsonfile.responseText);
-                                if (callback) {
-                                    callback(self.json);
-                                }
-                            }
+                    jsonfile.addEventListener( 'load', function ( event ) {
+                        self.json = JSON.parse(jsonfile.responseText);
+                        if (callback) {
+                            callback(self.json);
                         }
-                    };
+                    }, false );
                     jsonfile.send(null);
                } else {
                     if (callback) {

+ 6 - 9
examples/js/loaders/gltf/glTFLoaderUtils.js

@@ -82,15 +82,12 @@ THREE.GLTFLoaderUtils = Object.create(Object, {
 
             //if this is not specified, 1 "big blob" scenes fails to load.
             xhr.setRequestHeader("If-Modified-Since", "Sat, 01 Jan 1970 00:00:00 GMT");
-            xhr.onload = function(e) {
-                if ((xhr.status == 200) || (xhr.status == 206)) {
-
-                    delegate.streamAvailable(path, xhr.response);
-
-                } else {
-                    delegate.handleError(THREE.GLTFLoaderUtils.XMLHTTPREQUEST_STATUS_ERROR, this.status);
-                }
-            };
+            xhr.addEventListener( 'load', function ( event ) {
+                delegate.streamAvailable(path, xhr.response);
+            }, false );
+            xhr.addEventListener( 'error', function ( event ) {
+                delegate.handleError(THREE.GLTFLoaderUtils.XMLHTTPREQUEST_STATUS_ERROR, xhr.status);
+            }, false );
             xhr.send(null);
         }
     },