ソースを参照

Examples: Adjusted path handling in VRMLoader and LegacyGLTFLoader.

Mugen87 6 年 前
コミット
132c15a128

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

@@ -54,6 +54,13 @@ THREE.VRMLoader = ( function () {
 
 		},
 
+		setResourcePath: function ( value ) {
+
+			this.glTFLoader.setResourcePath( value );
+			return this;
+
+		},
+
 		setDRACOLoader: function ( dracoLoader ) {
 
 			this.glTFLoader.setDRACOLoader( dracoLoader );

+ 25 - 3
examples/js/loaders/deprecated/LegacyGLTFLoader.js

@@ -23,15 +23,30 @@ THREE.LegacyGLTFLoader = ( function () {
 
 			var scope = this;
 
-			var path = this.path && ( typeof this.path === "string" ) ? this.path : THREE.LoaderUtils.extractUrlBase( url );
+			var resourcePath;
+
+			if ( this.resourcePath !== undefined ) {
+
+				resourcePath = this.resourcePath;
+
+			} else if ( this.path !== undefined ) {
+
+				resourcePath = this.path;
+
+			} else {
+
+				resourcePath = THREE.LoaderUtils.extractUrlBase( url );
+
+			}
 
 			var loader = new THREE.FileLoader( scope.manager );
 
+			loader.setPath( this.path );
 			loader.setResponseType( 'arraybuffer' );
 
 			loader.load( url, function ( data ) {
 
-				scope.parse( data, path, onLoad );
+				scope.parse( data, resourcePath, onLoad );
 
 			}, onProgress, onError );
 
@@ -50,6 +65,13 @@ THREE.LegacyGLTFLoader = ( function () {
 
 		},
 
+		setResourcePath: function ( value ) {
+
+			this.resourcePath = value;
+			return this;
+
+		},
+
 		parse: function ( data, path, callback ) {
 
 			var content;
@@ -80,7 +102,7 @@ THREE.LegacyGLTFLoader = ( function () {
 
 				crossOrigin: this.crossOrigin,
 				manager: this.manager,
-				path: path || this.path
+				path: path || this.resourcePath || ''
 
 			} );