Browse Source

MaterialLoader: Inherit from Loader.

Mugen87 6 years ago
parent
commit
e7532f4610

+ 4 - 14
docs/api/en/loaders/MaterialLoader.html

@@ -8,6 +8,8 @@
 		<link type="text/css" rel="stylesheet" href="page.css" />
 	</head>
 	<body>
+		[page:Loader] &rarr;
+
 		<h1>[name]</h1>
 
 		<p class="desc">
@@ -54,17 +56,13 @@
 		</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>
@@ -84,14 +82,6 @@
 		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.

+ 4 - 7
docs/api/zh/loaders/MaterialLoader.html

@@ -8,6 +8,8 @@
 		<link type="text/css" rel="stylesheet" href="page.css" />
 	</head>
 	<body>
+		[page:Loader] &rarr;
+
 		<h1>[name]</h1>
 
 		<p class="desc">
@@ -54,17 +56,14 @@
 		</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>
@@ -89,8 +88,6 @@
 		[page:Object textures] — 对象包含任何被材质所使用的纹理。
 		</p>
 
-
-
 		<h2>源</h2>
 
 		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]

+ 3 - 4
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;
 
 }

+ 6 - 10
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;