diff --git a/docs/api/en/loaders/MaterialLoader.html b/docs/api/en/loaders/MaterialLoader.html index c9030598d273bd..beb0a82dfc7aed 100644 --- a/docs/api/en/loaders/MaterialLoader.html +++ b/docs/api/en/loaders/MaterialLoader.html @@ -8,6 +8,8 @@ + [page:Loader] → +

[name]

@@ -54,17 +56,13 @@

[name]( [param:LoadingManager manager] )

Properties

- -

[property:LoadingManager manager]

-

- The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager]. -

+

See the base [page:Loader] class for common properties.

[property:Object textures]

Object holding any textures used by the material. See [page:.setTextures].

-

Methods

+

See the base [page:Loader] class for common methods.

[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )

@@ -84,14 +82,6 @@

[method:Material parse]( [param:Object json] )

Parse a JSON structure and create a new [page:Material] of the type [page:String json.type] with parameters defined in the json object.

-

[method:MaterialLoader setPath]( [param:String path] )

-

- [page:String path] — Base path of the file to load.

- - Sets the base path or URL from which to load files. This can be useful if - you are loading many materials from the same directory. -

-

[method:MaterialLoader setTextures]( [param:Object textures] )

[page:Object textures] — object containing any textures used by the material. diff --git a/docs/api/zh/loaders/MaterialLoader.html b/docs/api/zh/loaders/MaterialLoader.html index f73ee5ee2b438b..70fb0e6cc56cbd 100644 --- a/docs/api/zh/loaders/MaterialLoader.html +++ b/docs/api/zh/loaders/MaterialLoader.html @@ -8,6 +8,8 @@ + [page:Loader] → +

[name]

@@ -54,17 +56,14 @@

[name]( [param:LoadingManager manager] )

属性

- -

[property:LoadingManager manager]

-

- 加载器正在使用的[page:LoadingManager loadingManager],默认为[page:DefaultLoadingManager]. -

+

See the base [page:Loader] class for common properties.

[property:Object textures]

持有材质的任何纹理的对象,请参考 [page:.setTextures].

方法

+

See the base [page:Loader] class for common methods.

[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )

@@ -89,8 +88,6 @@

[method:null setTextures]( [param:Object textures] )

[page:Object textures] — 对象包含任何被材质所使用的纹理。

- -

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] diff --git a/src/loaders/MaterialLoader.d.ts b/src/loaders/MaterialLoader.d.ts index eaabcd153e8120..bf9b5d9c22d6a2 100644 --- a/src/loaders/MaterialLoader.d.ts +++ b/src/loaders/MaterialLoader.d.ts @@ -1,12 +1,12 @@ +import { Loader } from './Loader'; import { LoadingManager } from './LoadingManager'; import { Texture } from './../textures/Texture'; import { Material } from './../materials/Material'; -export class MaterialLoader { +export class MaterialLoader extends Loader { constructor( manager?: LoadingManager ); - manager: LoadingManager; textures: { [key: string]: Texture }; load( @@ -15,8 +15,7 @@ export class MaterialLoader { onProgress?: ( event: ProgressEvent ) => void, onError?: ( event: Error | ErrorEvent ) => void ): void; - setTextures( textures: { [key: string]: Texture } ): void; - getTexture( name: string ): Texture; + setTextures( textures: { [key: string]: Texture } ): this; parse( json: any ): Material; } diff --git a/src/loaders/MaterialLoader.js b/src/loaders/MaterialLoader.js index 5fedd361c30e28..e7bb192114c1c0 100644 --- a/src/loaders/MaterialLoader.js +++ b/src/loaders/MaterialLoader.js @@ -5,7 +5,7 @@ import { Vector4 } from '../math/Vector4.js'; import { Matrix3 } from '../math/Matrix3.js'; import { Matrix4 } from '../math/Matrix4.js'; import { FileLoader } from './FileLoader.js'; -import { DefaultLoadingManager } from './LoadingManager.js'; +import { Loader } from './Loader.js'; import * as Materials from '../materials/Materials.js'; /** @@ -14,12 +14,15 @@ import * as Materials from '../materials/Materials.js'; function MaterialLoader( manager ) { - this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; + Loader.call( this, manager ); + this.textures = {}; } -Object.assign( MaterialLoader.prototype, { +MaterialLoader.prototype = Object.assign( Object.create( Loader.prototype ), { + + constructor: MaterialLoader, load: function ( url, onLoad, onProgress, onError ) { @@ -239,13 +242,6 @@ Object.assign( MaterialLoader.prototype, { }, - setPath: function ( value ) { - - this.path = value; - return this; - - }, - setTextures: function ( value ) { this.textures = value;