Skip to content

Commit c819cb6

Browse files
authored
Merge pull request #14966 from Mugen87/dev9
TDSLoader: Refactor setPath() usage and introduced setResourcePath().
2 parents 37aeb89 + bdd189e commit c819cb6

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

examples/js/loaders/TDSLoader.js

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ THREE.TDSLoader.prototype = {
2828

2929
constructor: THREE.TDSLoader,
3030

31+
crossOrigin: 'anonymous',
32+
3133
/**
3234
* Load 3ds file from url.
3335
*
@@ -44,7 +46,7 @@ THREE.TDSLoader.prototype = {
4446
var path = this.path !== undefined ? this.path : THREE.LoaderUtils.extractUrlBase( url );
4547

4648
var loader = new THREE.FileLoader( this.manager );
47-
49+
loader.setPath( this.path );
4850
loader.setResponseType( 'arraybuffer' );
4951

5052
loader.load( url, function ( data ) {
@@ -520,7 +522,7 @@ THREE.TDSLoader.prototype = {
520522
var texture = {};
521523

522524
var loader = new THREE.TextureLoader( this.manager );
523-
loader.setPath( path );
525+
loader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
524526

525527
while ( next !== 0 ) {
526528

@@ -842,10 +844,10 @@ THREE.TDSLoader.prototype = {
842844
},
843845

844846
/**
845-
* Set resource path used to determine the file path to attached resources.
847+
* Set path to adjust the path to the original 3ds file.
846848
*
847849
* @method setPath
848-
* @param {String} path Path to resources.
850+
* @param {String} path Path to file.
849851
* @return Self for chaining.
850852
*/
851853
setPath: function ( path ) {
@@ -856,6 +858,37 @@ THREE.TDSLoader.prototype = {
856858

857859
},
858860

861+
/**
862+
* Set resource path used to determine the path to attached resources like textures.
863+
*
864+
* @method setResourcePath
865+
* @param {String} resourcePath Path to resources.
866+
* @return Self for chaining.
867+
*/
868+
setResourcePath: function ( resourcePath ) {
869+
870+
this.resourcePath = resourcePath;
871+
872+
return this;
873+
874+
},
875+
876+
/**
877+
* Set crossOrigin value to configure CORS settings
878+
* for the image loading process.
879+
*
880+
* @method setCrossOrigin
881+
* @param {String} crossOrigin crossOrigin string.
882+
* @return Self for chaining.
883+
*/
884+
setCrossOrigin: function ( crossOrigin ) {
885+
886+
this.crossOrigin = crossOrigin;
887+
888+
return this;
889+
890+
},
891+
859892
/**
860893
* Print debug message to the console.
861894
*

examples/webgl_loader_3ds.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
var normal = loader.load( 'models/3ds/portalgun/textures/normal.jpg' );
6565

6666
var loader = new THREE.TDSLoader( );
67-
loader.setPath( 'models/3ds/portalgun/textures/' );
67+
loader.setResourcePath( 'models/3ds/portalgun/textures/' );
6868
loader.load( 'models/3ds/portalgun/portalgun.3ds', function ( object ) {
6969

7070
object.traverse( function ( child ) {

0 commit comments

Comments
 (0)