浏览代码

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 年之前
父节点
当前提交
74981c3091
共有 1 个文件被更改,包括 12 次插入1 次删除
  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 );