Skip to content

Commit

Permalink
Merge pull request mrdoob#17331 from Mugen87/dev29
Browse files Browse the repository at this point in the history
MaterialLoader: Inherit from Loader.
  • Loading branch information
Mugen87 authored Aug 24, 2019
2 parents db15431 + e7532f4 commit 54aac70
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 35 deletions.
18 changes: 4 additions & 14 deletions docs/api/en/loaders/MaterialLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Loader] &rarr;

<h1>[name]</h1>

<p class="desc">
Expand Down Expand Up @@ -54,17 +56,13 @@ <h3>[name]( [param:LoadingManager manager] )</h3>
</p>

<h2>Properties</h2>

<h3>[property:LoadingManager manager]</h3>
<p>
The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
</p>
<p>See the base [page:Loader] class for common properties.</p>

<h3>[property:Object textures]</h3>
<p>Object holding any textures used by the material. See [page:.setTextures].</p>


<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
Expand All @@ -84,14 +82,6 @@ <h3>[method:Material parse]( [param:Object json] )</h3>
Parse a <em>JSON</em> structure and create a new [page:Material] of the type [page:String json.type] with parameters defined in the json object.
</p>

<h3>[method:MaterialLoader setPath]( [param:String path] )</h3>
<p>
[page:String path] — Base path of the file to load.<br /><br />

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.
</p>

<h3>[method:MaterialLoader setTextures]( [param:Object textures] )</h3>
<p>
[page:Object textures] — object containing any textures used by the material.
Expand Down
11 changes: 4 additions & 7 deletions docs/api/zh/loaders/MaterialLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Loader] &rarr;

<h1>[name]</h1>

<p class="desc">
Expand Down Expand Up @@ -54,17 +56,14 @@ <h3>[name]( [param:LoadingManager manager] )</h3>
</p>

<h2>属性</h2>

<h3>[property:LoadingManager manager]</h3>
<p>
加载器正在使用的[page:LoadingManager loadingManager],默认为[page:DefaultLoadingManager].
</p>
<p>See the base [page:Loader] class for common properties.</p>

<h3>[property:Object textures]</h3>
<p>持有材质的任何纹理的对象,请参考 [page:.setTextures].</p>


<h2>方法</h2>
<p>See the base [page:Loader] class for common methods.</p>

<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
Expand All @@ -89,8 +88,6 @@ <h3>[method:null setTextures]( [param:Object textures] )</h3>
[page:Object textures] — 对象包含任何被材质所使用的纹理。
</p>



<h2></h2>

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
Expand Down
7 changes: 3 additions & 4 deletions src/loaders/MaterialLoader.d.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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;

}
16 changes: 6 additions & 10 deletions src/loaders/MaterialLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand All @@ -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 ) {

Expand Down Expand Up @@ -239,13 +242,6 @@ Object.assign( MaterialLoader.prototype, {

},

setPath: function ( value ) {

this.path = value;
return this;

},

setTextures: function ( value ) {

this.textures = value;
Expand Down

0 comments on commit 54aac70

Please sign in to comment.