未验证 提交 042bd735 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #14030 from takahirox/GLTFLoaderSetResourcePath

GLTFLoader: Rename .setPath with .setResourcePath
......@@ -160,7 +160,15 @@
Begin loading from url and call the callback function with the parsed response content.
</p>
<h3>[method:null setPath]( [param:String path] )</h3>
<h3>[method:GLTFLoader setPath]( [param:String path] )</h3>
<p>
[page:String path] — Base path.
</p>
<p>
Set the base path for the .gltf/.glb file.
</p>
<h3>[method:GLTFLoader setResourcePath]( [param:String path] )</h3>
<p>
[page:String path] — Base path for loading additional resources e.g. textures and .bin data.
</p>
......
......@@ -25,7 +25,21 @@ THREE.GLTFLoader = ( function () {
var scope = this;
var path = this.path !== undefined ? 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 );
}
// Tells the LoadingManager to track an extra item, which resolves after
// the model is fully loaded. This means the count of items loaded will
......@@ -51,13 +65,14 @@ THREE.GLTFLoader = ( function () {
var loader = new THREE.FileLoader( scope.manager );
loader.setPath( this.path );
loader.setResponseType( 'arraybuffer' );
loader.load( url, function ( data ) {
try {
scope.parse( data, path, function ( gltf ) {
scope.parse( data, resourcePath, function ( gltf ) {
onLoad( gltf );
......@@ -89,6 +104,13 @@ THREE.GLTFLoader = ( function () {
},
setResourcePath: function ( value ) {
this.resourcePath = value;
return this;
},
setDRACOLoader: function ( dracoLoader ) {
this.dracoLoader = dracoLoader;
......@@ -186,7 +208,7 @@ THREE.GLTFLoader = ( function () {
var parser = new GLTFParser( json, extensions, {
path: path || this.path || '',
path: path || this.resourcePath || '',
crossOrigin: this.crossOrigin,
manager: this.manager
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册