Kaynağa Gözat

Merge pull request #7661 from leitzler/leitzler-ignorehttpstatus-1

Added property ignoreHTTPStatus to be able to load from non-http source (i.e. file://)
Mr.doob 9 yıl önce
ebeveyn
işleme
74981c3091
1 değiştirilmiş dosya ile 12 ekleme ve 1 silme
  1. 12 1
      src/loaders/XHRLoader.js

+ 12 - 1
src/loaders/XHRLoader.js

@@ -46,7 +46,18 @@ THREE.XHRLoader.prototype = {
 
 			THREE.Cache.add( url, response );
 
-			if ( this.status === 200 && this.readyState === 4 ) {
+			if ( this.status === 200 ) {
+
+				if ( onLoad ) onLoad( response );
+
+				scope.manager.itemEnd( url );
+
+			} else if ( this.status === 0 ) {
+
+				// Some browsers return HTTP Status 0 when using non-http protocol
+				// e.g. 'file://' or 'data://'. Handle as success.
+
+				console.warn( 'THREE.XHRLoader: HTTP Status 0 received.' );
 
 				if ( onLoad ) onLoad( response );