Bläddra i källkod

Examples: Inherit from Loader IV.

Mugen87 5 år sedan
förälder
incheckning
7d603a8077

+ 75 - 82
examples/js/loaders/HDRCubeTextureLoader.js

@@ -5,134 +5,127 @@
 
 THREE.HDRCubeTextureLoader = function ( manager ) {
 
-	this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
+	THREE.Loader.call( this, manager );
+
 	this.hdrLoader = new THREE.RGBELoader();
 	this.type = THREE.UnsignedByteType;
 
 };
 
-THREE.HDRCubeTextureLoader.prototype.load = function ( urls, onLoad, onProgress, onError ) {
+THREE.HDRCubeTextureLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
 
-	if ( ! Array.isArray( urls ) ) {
+	constructor: THREE.HDRCubeTextureLoader,
 
-		console.warn( 'THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead.' );
+	load: function ( urls, onLoad, onProgress, onError ) {
 
-		this.setDataType( urls );
+		if ( ! Array.isArray( urls ) ) {
 
-		urls = onLoad;
-		onLoad = onProgress;
-		onProgress = onError;
-		onError = arguments[ 4 ];
+			console.warn( 'THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead.' );
 
-	}
+			this.setDataType( urls );
 
-	var texture = new THREE.CubeTexture();
+			urls = onLoad;
+			onLoad = onProgress;
+			onProgress = onError;
+			onError = arguments[ 4 ];
 
-	texture.type = this.type;
+		}
 
-	switch ( texture.type ) {
+		var texture = new THREE.CubeTexture();
 
-		case THREE.UnsignedByteType:
+		texture.type = this.type;
 
-			texture.encoding = THREE.RGBEEncoding;
-			texture.format = THREE.RGBAFormat;
-			texture.minFilter = THREE.NearestFilter;
-			texture.magFilter = THREE.NearestFilter;
-			texture.generateMipmaps = false;
-			break;
+		switch ( texture.type ) {
 
-		case THREE.FloatType:
+			case THREE.UnsignedByteType:
 
-			texture.encoding = THREE.LinearEncoding;
-			texture.format = THREE.RGBFormat;
-			texture.minFilter = THREE.LinearFilter;
-			texture.magFilter = THREE.LinearFilter;
-			texture.generateMipmaps = false;
-			break;
+				texture.encoding = THREE.RGBEEncoding;
+				texture.format = THREE.RGBAFormat;
+				texture.minFilter = THREE.NearestFilter;
+				texture.magFilter = THREE.NearestFilter;
+				texture.generateMipmaps = false;
+				break;
 
-		case THREE.HalfFloatType:
+			case THREE.FloatType:
 
-			texture.encoding = THREE.LinearEncoding;
-			texture.format = THREE.RGBFormat;
-			texture.minFilter = THREE.LinearFilter;
-			texture.magFilter = THREE.LinearFilter;
-			texture.generateMipmaps = false;
-			break;
+				texture.encoding = THREE.LinearEncoding;
+				texture.format = THREE.RGBFormat;
+				texture.minFilter = THREE.LinearFilter;
+				texture.magFilter = THREE.LinearFilter;
+				texture.generateMipmaps = false;
+				break;
 
-	}
+			case THREE.HalfFloatType:
 
-	var scope = this;
+				texture.encoding = THREE.LinearEncoding;
+				texture.format = THREE.RGBFormat;
+				texture.minFilter = THREE.LinearFilter;
+				texture.magFilter = THREE.LinearFilter;
+				texture.generateMipmaps = false;
+				break;
 
-	var loaded = 0;
+		}
 
-	function loadHDRData( i, onLoad, onProgress, onError ) {
+		var scope = this;
 
-		new THREE.FileLoader( scope.manager )
-			.setPath( scope.path )
-			.setResponseType( 'arraybuffer' )
-			.load( urls[ i ], function ( buffer ) {
+		var loaded = 0;
 
-				loaded ++;
+		function loadHDRData( i, onLoad, onProgress, onError ) {
 
-				var texData = scope.hdrLoader._parser( buffer );
+			new THREE.FileLoader( scope.manager )
+				.setPath( scope.path )
+				.setResponseType( 'arraybuffer' )
+				.load( urls[ i ], function ( buffer ) {
 
-				if ( ! texData ) return;
+					loaded ++;
 
-				if ( texData.data !== undefined ) {
+					var texData = scope.hdrLoader._parser( buffer );
 
-					var dataTexture = new THREE.DataTexture( texData.data, texData.width, texData.height );
+					if ( ! texData ) return;
 
-					dataTexture.type = texture.type;
-					dataTexture.encoding = texture.encoding;
-					dataTexture.format = texture.format;
-					dataTexture.minFilter = texture.minFilter;
-					dataTexture.magFilter = texture.magFilter;
-					dataTexture.generateMipmaps = texture.generateMipmaps;
+					if ( texData.data !== undefined ) {
 
-					texture.images[ i ] = dataTexture;
+						var dataTexture = new THREE.DataTexture( texData.data, texData.width, texData.height );
 
-				}
+						dataTexture.type = texture.type;
+						dataTexture.encoding = texture.encoding;
+						dataTexture.format = texture.format;
+						dataTexture.minFilter = texture.minFilter;
+						dataTexture.magFilter = texture.magFilter;
+						dataTexture.generateMipmaps = texture.generateMipmaps;
 
-				if ( loaded === 6 ) {
+						texture.images[ i ] = dataTexture;
 
-					texture.needsUpdate = true;
-					if ( onLoad ) onLoad( texture );
+					}
 
-				}
+					if ( loaded === 6 ) {
 
-			}, onProgress, onError );
+						texture.needsUpdate = true;
+						if ( onLoad ) onLoad( texture );
 
-	}
+					}
 
-	for ( var i = 0; i < urls.length; i ++ ) {
+				}, onProgress, onError );
 
-		loadHDRData( i, onLoad, onProgress, onError );
+		}
 
-	}
+		for ( var i = 0; i < urls.length; i ++ ) {
 
-	return texture;
+			loadHDRData( i, onLoad, onProgress, onError );
 
-};
+		}
 
-THREE.HDRCubeTextureLoader.prototype.setPath = function ( value ) {
+		return texture;
 
-	this.path = value;
-	return this;
+	},
 
-};
+	setDataType: function ( value ) {
 
-THREE.HDRCubeTextureLoader.prototype.setDataType = function ( value ) {
+		this.type = value;
+		this.hdrLoader.setDataType( value );
 
-	this.type = value;
-	this.hdrLoader.setDataType( value );
-	return this;
+		return this;
 
-};
-
-THREE.HDRCubeTextureLoader.prototype.setType = function ( value ) {
-
-	console.warn( 'THREE.HDRCubeTextureLoader: .setType() has been renamed to .setDataType().' );
-
-	return this.setDataType( value );
+	}
 
-};
+} );

+ 6 - 11
examples/js/loaders/TTFLoader.js

@@ -10,12 +10,14 @@
 
 THREE.TTFLoader = function ( manager ) {
 
-	this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
+	THREE.Loader.call( this, manager );
+
 	this.reversed = false;
 
 };
 
-THREE.TTFLoader.prototype = {
+
+THREE.TTFLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
 
 	constructor: THREE.TTFLoader,
 
@@ -34,13 +36,6 @@ THREE.TTFLoader.prototype = {
 
 	},
 
-	setPath: function ( value ) {
-
-		this.path = value;
-		return this;
-
-	},
-
 	parse: function ( arraybuffer ) {
 
 		function convert( font, reversed ) {
@@ -49,7 +44,7 @@ THREE.TTFLoader.prototype = {
 
 			var glyphs = {};
 			var scale = ( 100000 ) / ( ( font.unitsPerEm || 2048 ) * 72 );
-			
+
 			var glyphIndexMap = font.encoding.cmap.glyphIndexMap;
 			var unicodes = Object.keys( glyphIndexMap );
 
@@ -202,4 +197,4 @@ THREE.TTFLoader.prototype = {
 
 	}
 
-};
+} );

+ 4 - 26
examples/js/loaders/VRMLoader.js

@@ -17,17 +17,16 @@ THREE.VRMLoader = ( function () {
 
 		}
 
-		this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
+		THREE.Loader.call( this, manager );
+
 		this.gltfLoader = new THREE.GLTFLoader( this.manager );
 
 	}
 
-	VRMLoader.prototype = {
+	VRMLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
 
 		constructor: VRMLoader,
 
-		crossOrigin: 'anonymous',
-
 		load: function ( url, onLoad, onProgress, onError ) {
 
 			var scope = this;
@@ -40,27 +39,6 @@ THREE.VRMLoader = ( function () {
 
 		},
 
-		setCrossOrigin: function ( value ) {
-
-			this.glTFLoader.setCrossOrigin( value );
-			return this;
-
-		},
-
-		setPath: function ( value ) {
-
-			this.glTFLoader.setPath( value );
-			return this;
-
-		},
-
-		setResourcePath: function ( value ) {
-
-			this.glTFLoader.setResourcePath( value );
-			return this;
-
-		},
-
 		setDRACOLoader: function ( dracoLoader ) {
 
 			this.glTFLoader.setDRACOLoader( dracoLoader );
@@ -80,7 +58,7 @@ THREE.VRMLoader = ( function () {
 
 		}
 
-	};
+	} );
 
 	return VRMLoader;
 

+ 4 - 30
examples/js/loaders/XLoader.js

@@ -201,10 +201,11 @@ THREE.XLoader = ( function () {
 
 		function XLoader( manager ) {
 
+			THREE.Loader.call( this, manager );
+
 			classCallCheck( this, XLoader );
 
 			this.debug = false;
-			this.manager = manager !== undefined ? manager : THREE.DefaultLoadingManager;
 			this.texloader = new THREE.TextureLoader( this.manager );
 			this.url = "";
 			this._putMatLength = 0;
@@ -228,9 +229,6 @@ THREE.XLoader = ( function () {
 		}
 
 		createClass( XLoader, [ {
-			key: 'crossOrigin',
-			value: 'anonymous'
-		}, {
 			key: '_setArgOption',
 			value: function _setArgOption( _arg ) {
 
@@ -278,30 +276,6 @@ THREE.XLoader = ( function () {
 
 				}, onProgress, onError );
 
-			}
-		}, {
-			key: 'setCrossOrigin',
-			value: function setCrossOrigin( value ) {
-
-				this.crossOrigin = value;
-				return this;
-
-			}
-		}, {
-			key: 'setPath',
-			value: function setPath( value ) {
-
-				this.path = value;
-				return this;
-
-			}
-		}, {
-			key: 'setResourcePath',
-			value: function setResourcePath( value ) {
-
-				this.resourcePath = value;
-				return this;
-
 			}
 		}, {
 			key: '_readLine',
@@ -482,11 +456,11 @@ THREE.XLoader = ( function () {
 
 				var path;
 
-				if ( this.resourcePath !== undefined ) {
+				if ( this.resourcePath !== '' ) {
 
 					path = this.resourcePath;
 
-				} else if ( this.path !== undefined ) {
+				} else if ( this.path !== '' ) {
 
 					path = this.path;
 

+ 2 - 4
examples/jsm/loaders/HDRCubeTextureLoader.d.ts

@@ -1,19 +1,17 @@
 import {
   CubeTexture,
+  Loader,
   LoadingManager,
   TextureDataType
 } from '../../../src/Three';
 
 import { RGBELoader } from './RGBELoader';
 
-export class HDRCubeTextureLoader {
+export class HDRCubeTextureLoader extends Loader {
   constructor(manager?: LoadingManager);
-  manager: LoadingManager;
   hdrLoader: RGBELoader;
-  path: string;
   type: TextureDataType;
 
   load(urls: string[], onLoad: (texture: CubeTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
-  setPath(value: string): this;
   setDataType(type: TextureDataType): this;
 }

+ 76 - 83
examples/jsm/loaders/HDRCubeTextureLoader.js

@@ -6,12 +6,12 @@
 import {
 	CubeTexture,
 	DataTexture,
-	DefaultLoadingManager,
 	FileLoader,
 	FloatType,
 	HalfFloatType,
 	LinearEncoding,
 	LinearFilter,
+	Loader,
 	NearestFilter,
 	RGBAFormat,
 	RGBEEncoding,
@@ -22,136 +22,129 @@ import { RGBELoader } from "../loaders/RGBELoader.js";
 
 var HDRCubeTextureLoader = function ( manager ) {
 
-	this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
+	Loader.call( this, manager );
+
 	this.hdrLoader = new RGBELoader();
 	this.type = UnsignedByteType;
 
 };
 
-HDRCubeTextureLoader.prototype.load = function ( urls, onLoad, onProgress, onError ) {
+HDRCubeTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
-	if ( ! Array.isArray( urls ) ) {
+	constructor: HDRCubeTextureLoader,
 
-		console.warn( 'THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead.' );
+	load: function ( urls, onLoad, onProgress, onError ) {
 
-		this.setDataType( urls );
+		if ( ! Array.isArray( urls ) ) {
 
-		urls = onLoad;
-		onLoad = onProgress;
-		onProgress = onError;
-		onError = arguments[ 4 ];
+			console.warn( 'THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead.' );
 
-	}
+			this.setDataType( urls );
 
-	var texture = new CubeTexture();
+			urls = onLoad;
+			onLoad = onProgress;
+			onProgress = onError;
+			onError = arguments[ 4 ];
 
-	texture.type = this.type;
+		}
 
-	switch ( texture.type ) {
+		var texture = new CubeTexture();
 
-		case UnsignedByteType:
+		texture.type = this.type;
 
-			texture.encoding = RGBEEncoding;
-			texture.format = RGBAFormat;
-			texture.minFilter = NearestFilter;
-			texture.magFilter = NearestFilter;
-			texture.generateMipmaps = false;
-			break;
+		switch ( texture.type ) {
 
-		case FloatType:
+			case UnsignedByteType:
 
-			texture.encoding = LinearEncoding;
-			texture.format = RGBFormat;
-			texture.minFilter = LinearFilter;
-			texture.magFilter = LinearFilter;
-			texture.generateMipmaps = false;
-			break;
+				texture.encoding = RGBEEncoding;
+				texture.format = RGBAFormat;
+				texture.minFilter = NearestFilter;
+				texture.magFilter = NearestFilter;
+				texture.generateMipmaps = false;
+				break;
 
-		case HalfFloatType:
+			case FloatType:
 
-			texture.encoding = LinearEncoding;
-			texture.format = RGBFormat;
-			texture.minFilter = LinearFilter;
-			texture.magFilter = LinearFilter;
-			texture.generateMipmaps = false;
-			break;
+				texture.encoding = LinearEncoding;
+				texture.format = RGBFormat;
+				texture.minFilter = LinearFilter;
+				texture.magFilter = LinearFilter;
+				texture.generateMipmaps = false;
+				break;
 
-	}
+			case HalfFloatType:
 
-	var scope = this;
+				texture.encoding = LinearEncoding;
+				texture.format = RGBFormat;
+				texture.minFilter = LinearFilter;
+				texture.magFilter = LinearFilter;
+				texture.generateMipmaps = false;
+				break;
 
-	var loaded = 0;
+		}
 
-	function loadHDRData( i, onLoad, onProgress, onError ) {
+		var scope = this;
 
-		new FileLoader( scope.manager )
-			.setPath( scope.path )
-			.setResponseType( 'arraybuffer' )
-			.load( urls[ i ], function ( buffer ) {
+		var loaded = 0;
 
-				loaded ++;
+		function loadHDRData( i, onLoad, onProgress, onError ) {
 
-				var texData = scope.hdrLoader._parser( buffer );
+			new FileLoader( scope.manager )
+				.setPath( scope.path )
+				.setResponseType( 'arraybuffer' )
+				.load( urls[ i ], function ( buffer ) {
 
-				if ( ! texData ) return;
+					loaded ++;
 
-				if ( texData.data !== undefined ) {
+					var texData = scope.hdrLoader._parser( buffer );
 
-					var dataTexture = new DataTexture( texData.data, texData.width, texData.height );
+					if ( ! texData ) return;
 
-					dataTexture.type = texture.type;
-					dataTexture.encoding = texture.encoding;
-					dataTexture.format = texture.format;
-					dataTexture.minFilter = texture.minFilter;
-					dataTexture.magFilter = texture.magFilter;
-					dataTexture.generateMipmaps = texture.generateMipmaps;
+					if ( texData.data !== undefined ) {
 
-					texture.images[ i ] = dataTexture;
+						var dataTexture = new DataTexture( texData.data, texData.width, texData.height );
 
-				}
+						dataTexture.type = texture.type;
+						dataTexture.encoding = texture.encoding;
+						dataTexture.format = texture.format;
+						dataTexture.minFilter = texture.minFilter;
+						dataTexture.magFilter = texture.magFilter;
+						dataTexture.generateMipmaps = texture.generateMipmaps;
 
-				if ( loaded === 6 ) {
+						texture.images[ i ] = dataTexture;
 
-					texture.needsUpdate = true;
-					if ( onLoad ) onLoad( texture );
+					}
 
-				}
+					if ( loaded === 6 ) {
 
-			}, onProgress, onError );
+						texture.needsUpdate = true;
+						if ( onLoad ) onLoad( texture );
 
-	}
+					}
 
-	for ( var i = 0; i < urls.length; i ++ ) {
+				}, onProgress, onError );
 
-		loadHDRData( i, onLoad, onProgress, onError );
+		}
 
-	}
+		for ( var i = 0; i < urls.length; i ++ ) {
 
-	return texture;
+			loadHDRData( i, onLoad, onProgress, onError );
 
-};
+		}
 
-HDRCubeTextureLoader.prototype.setPath = function ( value ) {
+		return texture;
 
-	this.path = value;
-	return this;
+	},
 
-};
+	setDataType: function ( value ) {
 
-HDRCubeTextureLoader.prototype.setDataType = function ( value ) {
+		this.type = value;
+		this.hdrLoader.setDataType( value );
 
-	this.type = value;
-	this.hdrLoader.setDataType( value );
-	return this;
+		return this;
 
-};
-
-HDRCubeTextureLoader.prototype.setType = function ( value ) {
-
-	console.warn( 'THREE.HDRCubeTextureLoader: .setType() has been renamed to .setDataType().' );
-
-	return this.setDataType( value );
+	}
 
-};
+} );
 
 export { HDRCubeTextureLoader };

+ 0 - 1
examples/jsm/loaders/MTLLoader.d.ts

@@ -45,7 +45,6 @@ export class MTLLoader extends Loader {
 
   load(url: string, onLoad: (materialCreator: MaterialCreator) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
   parse(text: string) : MaterialCreator;
-  setBaseUrl(path: string) : void;
   setMaterialOptions(value: MaterialCreatorOptions) : void;
 }
 

+ 2 - 5
examples/jsm/loaders/TTFLoader.d.ts

@@ -1,16 +1,13 @@
 import {
   BufferGeometry,
+  Loader,
   LoadingManager
 } from '../../../src/Three';
 
-export class TTFLoader {
+export class TTFLoader extends Loader {
   constructor(manager?: LoadingManager);
-  manager: LoadingManager;
-  path: string;
   reversed: boolean;
 
   load(url: string, onLoad: (json: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
-  setPath(path: string): this;
-
   parse(arraybuffer: ArrayBuffer): object;
 }

+ 8 - 13
examples/jsm/loaders/TTFLoader.js

@@ -9,18 +9,20 @@
  */
 
 import {
-	DefaultLoadingManager,
-	FileLoader
+	FileLoader,
+	Loader
 } from "../../../build/three.module.js";
 
 var TTFLoader = function ( manager ) {
 
-	this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
+	Loader.call( this, manager );
+
 	this.reversed = false;
 
 };
 
-TTFLoader.prototype = {
+
+TTFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 	constructor: TTFLoader,
 
@@ -39,13 +41,6 @@ TTFLoader.prototype = {
 
 	},
 
-	setPath: function ( value ) {
-
-		this.path = value;
-		return this;
-
-	},
-
 	parse: function ( arraybuffer ) {
 
 		function convert( font, reversed ) {
@@ -54,7 +49,7 @@ TTFLoader.prototype = {
 
 			var glyphs = {};
 			var scale = ( 100000 ) / ( ( font.unitsPerEm || 2048 ) * 72 );
-			
+
 			var glyphIndexMap = font.encoding.cmap.glyphIndexMap;
 			var unicodes = Object.keys( glyphIndexMap );
 
@@ -207,6 +202,6 @@ TTFLoader.prototype = {
 
 	}
 
-};
+} );
 
 export { TTFLoader };

+ 3 - 10
examples/jsm/loaders/VRMLoader.d.ts

@@ -1,23 +1,16 @@
 import {
+  Loader,
   LoadingManager
 } from '../../../src/Three';
 
 import { GLTFLoader, GLTF } from './GLTFLoader';
 import { DRACOLoader } from './DRACOLoader';
 
-export class VRMLoader {
+export class VRMLoader extends Loader {
   constructor(manager?: LoadingManager);
   gltfLoader: GLTFLoader;
-  manager: LoadingManager;
-  path: string;
-  resourcePath: string;
-  crossOrigin: string;
 
   load(url: string, onLoad: (scene: GLTF) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) : void;
-  setDRACOLoader(dracoLoader: DRACOLoader): this;
-  setPath(path: string): this;
-  setResourcePath(path: string): this;
-  setCrossOrigin(path: string): this;
-
   parse(gltf: GLTF, onLoad: (scene: GLTF) => void): void;
+  setDRACOLoader(dracoLoader: DRACOLoader): this;
 }

+ 5 - 27
examples/jsm/loaders/VRMLoader.js

@@ -3,7 +3,7 @@
  */
 
 import {
-	DefaultLoadingManager
+	Loader
 } from "../../../build/three.module.js";
 import { GLTFLoader } from "../loaders/GLTFLoader.js";
 
@@ -22,17 +22,16 @@ var VRMLoader = ( function () {
 
 		}
 
-		this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
+		Loader.call( this, manager );
+
 		this.gltfLoader = new GLTFLoader( this.manager );
 
 	}
 
-	VRMLoader.prototype = {
+	VRMLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		constructor: VRMLoader,
 
-		crossOrigin: 'anonymous',
-
 		load: function ( url, onLoad, onProgress, onError ) {
 
 			var scope = this;
@@ -45,27 +44,6 @@ var VRMLoader = ( function () {
 
 		},
 
-		setCrossOrigin: function ( value ) {
-
-			this.glTFLoader.setCrossOrigin( value );
-			return this;
-
-		},
-
-		setPath: function ( value ) {
-
-			this.glTFLoader.setPath( value );
-			return this;
-
-		},
-
-		setResourcePath: function ( value ) {
-
-			this.glTFLoader.setResourcePath( value );
-			return this;
-
-		},
-
 		setDRACOLoader: function ( dracoLoader ) {
 
 			this.glTFLoader.setDRACOLoader( dracoLoader );
@@ -85,7 +63,7 @@ var VRMLoader = ( function () {
 
 		}
 
-	};
+	} );
 
 	return VRMLoader;
 

+ 3 - 9
examples/jsm/loaders/XLoader.d.ts

@@ -1,5 +1,6 @@
 import {
   Mesh,
+  Loader,
   LoadingManager
 } from '../../../src/Three';
 
@@ -8,16 +9,9 @@ export interface XResult {
   models: Mesh[];
 }
 
-export class VRMLLoader {
+export class XLoader extends Loader {
   constructor(manager?: LoadingManager);
-  crossOrigin: string;
-  manager: LoadingManager;
-  path: string;
-  resourcePath: string;
 
-  load(url: string, onLoad: (object: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
-  setCrossOrigin(path: string): this;
+  load(url: string, onLoad: (object: XResult) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
   parse(data: ArrayBuffer | string, onLoad: (object: object) => void): object;
-  setPath(path: string): this;
-  setResourcePath(path: string): this;
 }

+ 5 - 31
examples/jsm/loaders/XLoader.js

@@ -7,10 +7,10 @@ import {
 	AnimationMixer,
 	Bone,
 	BufferGeometry,
-	DefaultLoadingManager,
 	FileLoader,
 	Float32BufferAttribute,
 	FrontSide,
+	Loader,
 	LoaderUtils,
 	Matrix4,
 	Mesh,
@@ -223,10 +223,11 @@ var XLoader = ( function () {
 
 		function XLoader( manager ) {
 
+			Loader.call( this, manager );
+
 			classCallCheck( this, XLoader );
 
 			this.debug = false;
-			this.manager = manager !== undefined ? manager : DefaultLoadingManager;
 			this.texloader = new TextureLoader( this.manager );
 			this.url = "";
 			this._putMatLength = 0;
@@ -250,9 +251,6 @@ var XLoader = ( function () {
 		}
 
 		createClass( XLoader, [ {
-			key: 'crossOrigin',
-			value: 'anonymous'
-		}, {
 			key: '_setArgOption',
 			value: function _setArgOption( _arg ) {
 
@@ -300,30 +298,6 @@ var XLoader = ( function () {
 
 				}, onProgress, onError );
 
-			}
-		}, {
-			key: 'setCrossOrigin',
-			value: function setCrossOrigin( value ) {
-
-				this.crossOrigin = value;
-				return this;
-
-			}
-		}, {
-			key: 'setPath',
-			value: function setPath( value ) {
-
-				this.path = value;
-				return this;
-
-			}
-		}, {
-			key: 'setResourcePath',
-			value: function setResourcePath( value ) {
-
-				this.resourcePath = value;
-				return this;
-
 			}
 		}, {
 			key: '_readLine',
@@ -504,11 +478,11 @@ var XLoader = ( function () {
 
 				var path;
 
-				if ( this.resourcePath !== undefined ) {
+				if ( this.resourcePath !== '' ) {
 
 					path = this.resourcePath;
 
-				} else if ( this.path !== undefined ) {
+				} else if ( this.path !== '' ) {
 
 					path = this.path;