提交 2fc1e5bb 编写于 作者: M Mugen87

XLoader: Added setCrossOrigin(), setPath() and setResourcePath()

上级 7406e3c5
...@@ -216,7 +216,6 @@ ...@@ -216,7 +216,6 @@
this.manager = manager !== undefined ? manager : new THREE.DefaultLoadingManager(); this.manager = manager !== undefined ? manager : new THREE.DefaultLoadingManager();
this.texloader = new THREE.TextureLoader( this.manager ); this.texloader = new THREE.TextureLoader( this.manager );
this.url = ""; this.url = "";
this.baseDir = "";
this._putMatLength = 0; this._putMatLength = 0;
this._nowMat = null; this._nowMat = null;
this._nowFrameName = ""; this._nowFrameName = "";
...@@ -238,6 +237,9 @@ ...@@ -238,6 +237,9 @@
} }
createClass( XLoader, [ { createClass( XLoader, [ {
key: 'crossOrigin',
value: 'anonymous'
}, {
key: '_setArgOption', key: '_setArgOption',
value: function _setArgOption( _arg ) { value: function _setArgOption( _arg ) {
...@@ -277,6 +279,7 @@ ...@@ -277,6 +279,7 @@
this._setArgOption( _arg ); this._setArgOption( _arg );
var loader = new THREE.FileLoader( this.manager ); var loader = new THREE.FileLoader( this.manager );
loader.setPath( this.path );
loader.setResponseType( 'arraybuffer' ); loader.setResponseType( 'arraybuffer' );
loader.load( this.url, function ( response ) { loader.load( this.url, function ( response ) {
...@@ -284,6 +287,30 @@ ...@@ -284,6 +287,30 @@
}, onProgress, onError ); }, onProgress, onError );
}
}, {
key: 'setCrossOrigin',
value: function setCrossOrigin( value ) {
this.crossOrigin = value;
return this;
}
}, {
key: 'setPath',
value: function setPath( value ) {
this.path = value;
return this;
}
}, {
key: 'setResourcePath',
value: function setResourcePath( value ) {
this.resourcePath = value;
return this;
} }
}, { }, {
key: 'fromResponsedData', key: 'fromResponsedData',
...@@ -470,11 +497,24 @@ ...@@ -470,11 +497,24 @@
key: '_parseASCII', key: '_parseASCII',
value: function _parseASCII() { value: function _parseASCII() {
if ( this.url.lastIndexOf( "/" ) > 0 ) { var path;
if ( this.resourcePath !== undefined ) {
path = this.resourcePath;
} else if ( this.path !== undefined ) {
this.baseDir = this.url.substr( 0, this.url.lastIndexOf( "/" ) + 1 ); path = this.path;
} else {
path = THREE.LoaderUtils.extractUrlBase( this.url );
} }
this.texloader.setPath( path ).setCrossOrigin( this.crossOrigin );
var endRead = 16; var endRead = 16;
this.Hierarchies.children = []; this.Hierarchies.children = [];
this._hierarchieParse( this.Hierarchies, endRead ); this._hierarchieParse( this.Hierarchies, endRead );
...@@ -1180,21 +1220,21 @@ ...@@ -1180,21 +1220,21 @@
switch ( localObject.type ) { switch ( localObject.type ) {
case "TextureFilename": case "TextureFilename":
_nowMat.map = this.texloader.load( this.baseDir + fileName ); _nowMat.map = this.texloader.load( fileName );
break; break;
case "BumpMapFilename": case "BumpMapFilename":
_nowMat.bumpMap = this.texloader.load( this.baseDir + fileName ); _nowMat.bumpMap = this.texloader.load( fileName );
_nowMat.bumpScale = 0.05; _nowMat.bumpScale = 0.05;
break; break;
case "NormalMapFilename": case "NormalMapFilename":
_nowMat.normalMap = this.texloader.load( this.baseDir + fileName ); _nowMat.normalMap = this.texloader.load( fileName );
_nowMat.normalScale = new THREE.Vector2( 2, 2 ); _nowMat.normalScale = new THREE.Vector2( 2, 2 );
break; break;
case "EmissiveMapFilename": case "EmissiveMapFilename":
_nowMat.emissiveMap = this.texloader.load( this.baseDir + fileName ); _nowMat.emissiveMap = this.texloader.load( fileName );
break; break;
case "LightMapFilename": case "LightMapFilename":
_nowMat.lightMap = this.texloader.load( this.baseDir + fileName ); _nowMat.lightMap = this.texloader.load( fileName );
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册