diff --git a/docs/api/en/loaders/Loader.html b/docs/api/en/loaders/Loader.html
index 8deb4a7e065ab9e8434e2850cfbe7fe2bac1c81d..5e2708086c69ad51ea8e4393def8b3ea5b4a210d 100644
--- a/docs/api/en/loaders/Loader.html
+++ b/docs/api/en/loaders/Loader.html
@@ -16,9 +16,12 @@
Constructor
- [name]()
+ [name]( [param:LoadingManager manager] )
- Creates a new [name]. This should be called as base class.
+ [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
+
+
+ Creates a new [name].
@@ -27,7 +30,51 @@
[property:string crossOrigin]
The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
- Default is *"anonymous"*.
+ Default is *anonymous*.
+
+
+ [property:LoadingManager manager]
+
+ The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
+
+
+ [property:String path]
+
+ The base path from which the asset will be loaded.
+ Default is the empty string.
+
+
+ [property:String resourcePath]
+
+ The base path from which additional resources like textures will be loaded.
+ Default is the empty string.
+
+
+ Methods
+
+ [method:void load]()
+
+ This method needs to be implement by all concrete loaders. It holds the logic for loading the asset from the backend.
+
+
+ [method:void parse]()
+
+ This method needs to be implement by all concrete loaders. It holds the logic for parsing the asset into three.js entities.
+
+
+ [method:Loader setCrossOrigin]( [param:String crossOrigin] )
+
+ [page:String crossOrigin] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
+
+
+ [method:Loader setPath]( [param:String path] )
+
+ [page:String path] — Set the base path for the asset.
+
+
+ [method:Loader setResourcePath]( [param:String resourcePath] )
+
+ [page:String resourcePath] — Set the base path for dependent resources like textures.
Handlers
diff --git a/docs/api/en/loaders/ObjectLoader.html b/docs/api/en/loaders/ObjectLoader.html
index 75c8acc58e713f7cdd43c16807913c264943711e..deb57706879eef46d0840eb645311d0535af2339 100644
--- a/docs/api/en/loaders/ObjectLoader.html
+++ b/docs/api/en/loaders/ObjectLoader.html
@@ -8,6 +8,8 @@
+ [page:Loader] →
+
[name]
@@ -66,27 +68,11 @@
Creates a new [name].
-
Properties
-
- [property:String crossOrigin]
-
- If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
- attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *"anonymous"*.
-
-
- [property:LoadingManager manager]
-
- The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
-
-
- [property:String resourcePath]
-
- The base path or URL from which additional resources like textuures will be loaded. See [page:.setResourcePath].
- Default is the empty string.
-
+ See the base [page:Loader] class for common properties.
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] )
@@ -206,21 +192,6 @@
- [method:ObjectLoader setCrossOrigin]( [param:String value] )
-
- [page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
-
-
- [method:ObjectLoader setPath]( [param:String value] )
-
- Set the base path for the original file.
-
-
- [method:ObjectLoader setResourcePath]( [param:String value] )
-
- Set the base path for dependent resources like textures.
-
-
Source
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
diff --git a/src/loaders/Loader.d.ts b/src/loaders/Loader.d.ts
index 81ff4a1ef2a0c60dda0a15923e6489be64a51596..0e337fab68e58d7bc145e5610a627f125d1a5c2e 100644
--- a/src/loaders/Loader.d.ts
+++ b/src/loaders/Loader.d.ts
@@ -1,19 +1,26 @@
import { LoaderHandler } from './FileLoader';
-
-// Loaders //////////////////////////////////////////////////////////////////////////////////
+import { LoadingManager } from './LoadingManager';
/**
* Base class for implementing loaders.
*/
export class Loader {
- constructor();
+ constructor( manager?: LoadingManager );
- /**
- * default — anonymous.
- * If set, assigns the crossOrigin attribute of the image to the value of crossOrigin, prior to starting the load.
- */
crossOrigin: string;
+ path: string;
+ resourcePath: string;
+ manager: LoadingManager;
+
+ /*
+ load(): void;
+ parse(): void;
+ */
+
+ setCrossOrigin( crossOrigin: string ): this;
+ setPath( path: string ): this;
+ setResourcePath( resourcePath: string ): this;
static Handlers: LoaderHandler;
diff --git a/src/loaders/Loader.js b/src/loaders/Loader.js
index aaa1611ecb4c3e7c6452e85174ebda87da7a1bb3..fad23314a2868b45ae7d18d3410edcc9e51d037a 100644
--- a/src/loaders/Loader.js
+++ b/src/loaders/Loader.js
@@ -1,8 +1,49 @@
+import { DefaultLoadingManager } from './LoadingManager.js';
+
/**
* @author alteredq / http://alteredqualia.com/
*/
-function Loader() {}
+function Loader( manager ) {
+
+ this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
+
+ this.crossOrigin = 'anonymous';
+ this.path = '';
+ this.resourcePath = '';
+
+}
+
+Object.assign( Loader.prototype, {
+
+ load: function ( /* url, onLoad, onProgress, onError */ ) {},
+
+ parse: function ( /* data */ ) {},
+
+ setCrossOrigin: function ( crossOrigin ) {
+
+ this.crossOrigin = crossOrigin;
+ return this;
+
+ },
+
+ setPath: function ( path ) {
+
+ this.path = path;
+ return this;
+
+ },
+
+ setResourcePath: function ( resourcePath ) {
+
+ this.resourcePath = resourcePath;
+ return this;
+
+ }
+
+} );
+
+//
Loader.Handlers = {
@@ -37,11 +78,5 @@ Loader.Handlers = {
};
-Object.assign( Loader.prototype, {
-
- crossOrigin: 'anonymous'
-
-} );
-
export { Loader };
diff --git a/src/loaders/ObjectLoader.d.ts b/src/loaders/ObjectLoader.d.ts
index 295524f8291cc6ed4a98b899710cfa53942dff2b..857eb77b31fca2919b7c8534426ce2f957bc7c1c 100644
--- a/src/loaders/ObjectLoader.d.ts
+++ b/src/loaders/ObjectLoader.d.ts
@@ -1,25 +1,20 @@
+import { Loader } from './Loader';
import { LoadingManager } from './LoadingManager';
import { Object3D } from './../core/Object3D';
import { Texture } from './../textures/Texture';
import { Material } from './../materials/Material';
import { AnimationClip } from './../animation/AnimationClip';
-export class ObjectLoader {
+export class ObjectLoader extends Loader {
constructor( manager?: LoadingManager );
- manager: LoadingManager;
- texturePass: string;
- crossOrigin: string;
-
load(
url: string,
onLoad?: ( object: ObjectType ) => void,
onProgress?: ( event: ProgressEvent ) => void,
onError?: ( event: Error | ErrorEvent ) => void
): void;
- setTexturePath( value: string ): void;
- setCrossOrigin( crossOrigin: string ): void;
parse( json: any, onLoad?: ( object: Object3D ) => void ): T;
parseGeometries( json: any ): any[]; // Array of BufferGeometry or Geometry or Geometry2.
parseMaterials( json: any, textures: Texture[] ): Material[]; // Array of Classes that inherits from Matrial.
diff --git a/src/loaders/ObjectLoader.js b/src/loaders/ObjectLoader.js
index 40174fb8057ce22c3ecbec39061789b62ab22eb1..d2b2afeea56f060b58839a1d20d6996a188b96bf 100644
--- a/src/loaders/ObjectLoader.js
+++ b/src/loaders/ObjectLoader.js
@@ -45,11 +45,12 @@ import { Scene } from '../scenes/Scene.js';
import { CubeTexture } from '../textures/CubeTexture.js';
import { Texture } from '../textures/Texture.js';
import { ImageLoader } from './ImageLoader.js';
-import { LoadingManager, DefaultLoadingManager } from './LoadingManager.js';
+import { LoadingManager } from './LoadingManager.js';
import { AnimationClip } from '../animation/AnimationClip.js';
import { MaterialLoader } from './MaterialLoader.js';
import { LoaderUtils } from './LoaderUtils.js';
import { BufferGeometryLoader } from './BufferGeometryLoader.js';
+import { Loader } from './Loader.js';
import { FileLoader } from './FileLoader.js';
import * as Geometries from '../geometries/Geometries.js';
import * as Curves from '../extras/curves/Curves.js';
@@ -60,20 +61,19 @@ import * as Curves from '../extras/curves/Curves.js';
function ObjectLoader( manager ) {
- this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
- this.resourcePath = '';
+ Loader.call( this, manager );
}
-Object.assign( ObjectLoader.prototype, {
+ObjectLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
- crossOrigin: 'anonymous',
+ constructor: ObjectLoader,
load: function ( url, onLoad, onProgress, onError ) {
var scope = this;
- var path = ( this.path === undefined ) ? LoaderUtils.extractUrlBase( url ) : this.path;
+ var path = ( this.path === '' ) ? LoaderUtils.extractUrlBase( url ) : this.path;
this.resourcePath = this.resourcePath || path;
var loader = new FileLoader( scope.manager );
@@ -111,27 +111,6 @@ Object.assign( ObjectLoader.prototype, {
},
- setPath: function ( value ) {
-
- this.path = value;
- return this;
-
- },
-
- setResourcePath: function ( value ) {
-
- this.resourcePath = value;
- return this;
-
- },
-
- setCrossOrigin: function ( value ) {
-
- this.crossOrigin = value;
- return this;
-
- },
-
parse: function ( json, onLoad ) {
var shapes = this.parseShape( json.shapes );