浏览代码

Merge pull request #15618 from gilnoycloudinary/dev

GLTFLoader  - Support Host Relative URL
Mr.doob 6 年之前
父节点
当前提交
50d7a5b3a6
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      examples/js/loaders/GLTFLoader.js

+ 7 - 0
examples/js/loaders/GLTFLoader.js

@@ -1187,6 +1187,13 @@ THREE.GLTFLoader = ( function () {
 
 
 		// Invalid URL
 		// Invalid URL
 		if ( typeof url !== 'string' || url === '' ) return '';
 		if ( typeof url !== 'string' || url === '' ) return '';
+		
+		// Host Relative URL
+		if ( /^https?:\/\//i.test( path ) && /^\//.test( url ) ) {
+
+			path = path.replace( /(^https?:\/\/[^\/]+).*/i , '$1' );
+
+		}
 
 
 		// Absolute URL http://,https://,//
 		// Absolute URL http://,https://,//
 		if ( /^(https?:)?\/\//i.test( url ) ) return url;
 		if ( /^(https?:)?\/\//i.test( url ) ) return url;