提交 53838a29 编写于 作者: W WestLangley

Add support for chaining

上级 977ed480
......@@ -47,6 +47,7 @@ THREE.MTLLoader.prototype = {
*
* @see setTexturePath
* @param {String} path
* @return {THREE.MTLLoader}
*
* @example
* mtlLoader.setPath( 'assets/obj/' );
......@@ -55,6 +56,7 @@ THREE.MTLLoader.prototype = {
setPath: function ( path ) {
this.path = path;
return this;
},
......@@ -65,6 +67,7 @@ THREE.MTLLoader.prototype = {
*
* @see setPath
* @param {String} path
* @return {THREE.MTLLoader}
*
* @example
* mtlLoader.setPath( 'assets/obj/' );
......@@ -74,6 +77,7 @@ THREE.MTLLoader.prototype = {
setTexturePath: function ( path ) {
this.texturePath = path;
return this;
},
......@@ -81,19 +85,21 @@ THREE.MTLLoader.prototype = {
console.warn( 'THREE.MTLLoader: .setBaseUrl() is deprecated. Use .setTexturePath( path ) for texture path or .setPath( path ) for general base path instead.' );
this.setTexturePath( path );
return this.setTexturePath( path );
},
setCrossOrigin: function ( value ) {
this.crossOrigin = value;
return this;
},
setMaterialOptions: function ( value ) {
this.materialOptions = value;
return this;
},
......
......@@ -392,6 +392,8 @@ THREE.OBJLoader = ( function () {
this.path = value;
return this;
},
setMaterials: function ( materials ) {
......
......@@ -77,33 +77,37 @@
// model
var onProgress = function ( xhr ) {
if ( xhr.lengthComputable ) {
var percentComplete = xhr.loaded / xhr.total * 100;
console.log( Math.round(percentComplete, 2) + '% downloaded' );
console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
}
};
var onError = function ( xhr ) { };
THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );
var mtlLoader = new THREE.MTLLoader();
mtlLoader.setPath( 'models/obj/male02/' );
mtlLoader.load( 'male02_dds.mtl', function( materials ) {
new THREE.MTLLoader()
.setPath( 'models/obj/male02/' )
.load( 'male02_dds.mtl', function ( materials ) {
materials.preload();
materials.preload();
var objLoader = new THREE.OBJLoader();
objLoader.setMaterials( materials );
objLoader.setPath( 'models/obj/male02/' );
objLoader.load( 'male02.obj', function ( object ) {
new THREE.OBJLoader()
.setMaterials( materials )
.setPath( 'models/obj/male02/' )
.load( 'male02.obj', function ( object ) {
object.position.y = - 95;
scene.add( object );
object.position.y = - 95;
scene.add( object );
}, onProgress, onError );
}, onProgress, onError );
});
} );
//
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册