From 132c15a128946ca2a4d6bb510c5a8115f8abc610 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Sun, 30 Sep 2018 12:18:02 +0200 Subject: [PATCH] Examples: Adjusted path handling in VRMLoader and LegacyGLTFLoader. --- examples/js/loaders/VRMLoader.js | 7 +++++ .../js/loaders/deprecated/LegacyGLTFLoader.js | 28 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/examples/js/loaders/VRMLoader.js b/examples/js/loaders/VRMLoader.js index 441497106f..b9ccfe6b5f 100644 --- a/examples/js/loaders/VRMLoader.js +++ b/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 ); diff --git a/examples/js/loaders/deprecated/LegacyGLTFLoader.js b/examples/js/loaders/deprecated/LegacyGLTFLoader.js index 7d9b865ea0..339582a043 100644 --- a/examples/js/loaders/deprecated/LegacyGLTFLoader.js +++ b/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 || '' } ); -- GitLab