提交 7d603a80 编写于 作者: M Mugen87

Examples: Inherit from Loader IV.

上级 ba08ba94
......@@ -5,13 +5,18 @@
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 ), {
constructor: THREE.HDRCubeTextureLoader,
load: function ( urls, onLoad, onProgress, onError ) {
if ( ! Array.isArray( urls ) ) {
......@@ -112,27 +117,15 @@ THREE.HDRCubeTextureLoader.prototype.load = function ( urls, onLoad, onProgress,
return texture;
};
THREE.HDRCubeTextureLoader.prototype.setPath = function ( value ) {
this.path = value;
return this;
};
},
THREE.HDRCubeTextureLoader.prototype.setDataType = function ( value ) {
setDataType: function ( value ) {
this.type = value;
this.hdrLoader.setDataType( value );
return this;
};
THREE.HDRCubeTextureLoader.prototype.setType = function ( value ) {
console.warn( 'THREE.HDRCubeTextureLoader: .setType() has been renamed to .setDataType().' );
return this;
return this.setDataType( value );
}
};
} );
......@@ -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 ) {
......@@ -202,4 +197,4 @@ THREE.TTFLoader.prototype = {
}
};
} );
......@@ -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;
......
......@@ -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;
......
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;
}
......@@ -6,12 +6,12 @@
import {
CubeTexture,
DataTexture,
DefaultLoadingManager,
FileLoader,
FloatType,
HalfFloatType,
LinearEncoding,
LinearFilter,
Loader,
NearestFilter,
RGBAFormat,
RGBEEncoding,
......@@ -22,13 +22,18 @@ 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 ), {
constructor: HDRCubeTextureLoader,
load: function ( urls, onLoad, onProgress, onError ) {
if ( ! Array.isArray( urls ) ) {
......@@ -129,29 +134,17 @@ HDRCubeTextureLoader.prototype.load = function ( urls, onLoad, onProgress, onErr
return texture;
};
HDRCubeTextureLoader.prototype.setPath = function ( value ) {
this.path = value;
return this;
};
},
HDRCubeTextureLoader.prototype.setDataType = function ( value ) {
setDataType: function ( value ) {
this.type = value;
this.hdrLoader.setDataType( value );
return this;
};
HDRCubeTextureLoader.prototype.setType = function ( value ) {
console.warn( 'THREE.HDRCubeTextureLoader: .setType() has been renamed to .setDataType().' );
return this;
return this.setDataType( value );
}
};
} );
export { HDRCubeTextureLoader };
......@@ -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;
}
......
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;
}
......@@ -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 ) {
......@@ -207,6 +202,6 @@ TTFLoader.prototype = {
}
};
} );
export { TTFLoader };
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;
}
......@@ -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;
......
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;
}
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册