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

Examples: Inherit from Loader IV.

上级 ba08ba94
...@@ -5,134 +5,127 @@ ...@@ -5,134 +5,127 @@
THREE.HDRCubeTextureLoader = function ( manager ) { THREE.HDRCubeTextureLoader = function ( manager ) {
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; THREE.Loader.call( this, manager );
this.hdrLoader = new THREE.RGBELoader(); this.hdrLoader = new THREE.RGBELoader();
this.type = THREE.UnsignedByteType; 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; console.warn( 'THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead.' );
onLoad = onProgress;
onProgress = onError;
onError = arguments[ 4 ];
} 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; switch ( texture.type ) {
texture.format = THREE.RGBAFormat;
texture.minFilter = THREE.NearestFilter;
texture.magFilter = THREE.NearestFilter;
texture.generateMipmaps = false;
break;
case THREE.FloatType: case THREE.UnsignedByteType:
texture.encoding = THREE.LinearEncoding; texture.encoding = THREE.RGBEEncoding;
texture.format = THREE.RGBFormat; texture.format = THREE.RGBAFormat;
texture.minFilter = THREE.LinearFilter; texture.minFilter = THREE.NearestFilter;
texture.magFilter = THREE.LinearFilter; texture.magFilter = THREE.NearestFilter;
texture.generateMipmaps = false; texture.generateMipmaps = false;
break; break;
case THREE.HalfFloatType: case THREE.FloatType:
texture.encoding = THREE.LinearEncoding; texture.encoding = THREE.LinearEncoding;
texture.format = THREE.RGBFormat; texture.format = THREE.RGBFormat;
texture.minFilter = THREE.LinearFilter; texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter; texture.magFilter = THREE.LinearFilter;
texture.generateMipmaps = false; texture.generateMipmaps = false;
break; 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 ) var loaded = 0;
.setPath( scope.path )
.setResponseType( 'arraybuffer' )
.load( urls[ i ], function ( buffer ) {
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; if ( texData.data !== undefined ) {
dataTexture.encoding = texture.encoding;
dataTexture.format = texture.format;
dataTexture.minFilter = texture.minFilter;
dataTexture.magFilter = texture.magFilter;
dataTexture.generateMipmaps = texture.generateMipmaps;
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; return this;
this.hdrLoader.setDataType( value );
return this;
}; }
THREE.HDRCubeTextureLoader.prototype.setType = function ( value ) {
console.warn( 'THREE.HDRCubeTextureLoader: .setType() has been renamed to .setDataType().' );
return this.setDataType( value );
}; } );
...@@ -10,12 +10,14 @@ ...@@ -10,12 +10,14 @@
THREE.TTFLoader = function ( manager ) { THREE.TTFLoader = function ( manager ) {
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; THREE.Loader.call( this, manager );
this.reversed = false; this.reversed = false;
}; };
THREE.TTFLoader.prototype = {
THREE.TTFLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
constructor: THREE.TTFLoader, constructor: THREE.TTFLoader,
...@@ -34,13 +36,6 @@ THREE.TTFLoader.prototype = { ...@@ -34,13 +36,6 @@ THREE.TTFLoader.prototype = {
}, },
setPath: function ( value ) {
this.path = value;
return this;
},
parse: function ( arraybuffer ) { parse: function ( arraybuffer ) {
function convert( font, reversed ) { function convert( font, reversed ) {
...@@ -49,7 +44,7 @@ THREE.TTFLoader.prototype = { ...@@ -49,7 +44,7 @@ THREE.TTFLoader.prototype = {
var glyphs = {}; var glyphs = {};
var scale = ( 100000 ) / ( ( font.unitsPerEm || 2048 ) * 72 ); var scale = ( 100000 ) / ( ( font.unitsPerEm || 2048 ) * 72 );
var glyphIndexMap = font.encoding.cmap.glyphIndexMap; var glyphIndexMap = font.encoding.cmap.glyphIndexMap;
var unicodes = Object.keys( glyphIndexMap ); var unicodes = Object.keys( glyphIndexMap );
...@@ -202,4 +197,4 @@ THREE.TTFLoader.prototype = { ...@@ -202,4 +197,4 @@ THREE.TTFLoader.prototype = {
} }
}; } );
...@@ -17,17 +17,16 @@ THREE.VRMLoader = ( function () { ...@@ -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 ); this.gltfLoader = new THREE.GLTFLoader( this.manager );
} }
VRMLoader.prototype = { VRMLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
constructor: VRMLoader, constructor: VRMLoader,
crossOrigin: 'anonymous',
load: function ( url, onLoad, onProgress, onError ) { load: function ( url, onLoad, onProgress, onError ) {
var scope = this; var scope = this;
...@@ -40,27 +39,6 @@ THREE.VRMLoader = ( function () { ...@@ -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 ) { setDRACOLoader: function ( dracoLoader ) {
this.glTFLoader.setDRACOLoader( dracoLoader ); this.glTFLoader.setDRACOLoader( dracoLoader );
...@@ -80,7 +58,7 @@ THREE.VRMLoader = ( function () { ...@@ -80,7 +58,7 @@ THREE.VRMLoader = ( function () {
} }
}; } );
return VRMLoader; return VRMLoader;
......
...@@ -201,10 +201,11 @@ THREE.XLoader = ( function () { ...@@ -201,10 +201,11 @@ THREE.XLoader = ( function () {
function XLoader( manager ) { function XLoader( manager ) {
THREE.Loader.call( this, manager );
classCallCheck( this, XLoader ); classCallCheck( this, XLoader );
this.debug = false; this.debug = false;
this.manager = manager !== undefined ? manager : THREE.DefaultLoadingManager;
this.texloader = new THREE.TextureLoader( this.manager ); this.texloader = new THREE.TextureLoader( this.manager );
this.url = ""; this.url = "";
this._putMatLength = 0; this._putMatLength = 0;
...@@ -228,9 +229,6 @@ THREE.XLoader = ( function () { ...@@ -228,9 +229,6 @@ THREE.XLoader = ( function () {
} }
createClass( XLoader, [ { createClass( XLoader, [ {
key: 'crossOrigin',
value: 'anonymous'
}, {
key: '_setArgOption', key: '_setArgOption',
value: function _setArgOption( _arg ) { value: function _setArgOption( _arg ) {
...@@ -278,30 +276,6 @@ THREE.XLoader = ( function () { ...@@ -278,30 +276,6 @@ THREE.XLoader = ( function () {
}, onProgress, onError ); }, 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', key: '_readLine',
...@@ -482,11 +456,11 @@ THREE.XLoader = ( function () { ...@@ -482,11 +456,11 @@ THREE.XLoader = ( function () {
var path; var path;
if ( this.resourcePath !== undefined ) { if ( this.resourcePath !== '' ) {
path = this.resourcePath; path = this.resourcePath;
} else if ( this.path !== undefined ) { } else if ( this.path !== '' ) {
path = this.path; path = this.path;
......
import { import {
CubeTexture, CubeTexture,
Loader,
LoadingManager, LoadingManager,
TextureDataType TextureDataType
} from '../../../src/Three'; } from '../../../src/Three';
import { RGBELoader } from './RGBELoader'; import { RGBELoader } from './RGBELoader';
export class HDRCubeTextureLoader { export class HDRCubeTextureLoader extends Loader {
constructor(manager?: LoadingManager); constructor(manager?: LoadingManager);
manager: LoadingManager;
hdrLoader: RGBELoader; hdrLoader: RGBELoader;
path: string;
type: TextureDataType; type: TextureDataType;
load(urls: string[], onLoad: (texture: CubeTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; load(urls: string[], onLoad: (texture: CubeTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
setPath(value: string): this;
setDataType(type: TextureDataType): this; setDataType(type: TextureDataType): this;
} }
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
import { import {
CubeTexture, CubeTexture,
DataTexture, DataTexture,
DefaultLoadingManager,
FileLoader, FileLoader,
FloatType, FloatType,
HalfFloatType, HalfFloatType,
LinearEncoding, LinearEncoding,
LinearFilter, LinearFilter,
Loader,
NearestFilter, NearestFilter,
RGBAFormat, RGBAFormat,
RGBEEncoding, RGBEEncoding,
...@@ -22,136 +22,129 @@ import { RGBELoader } from "../loaders/RGBELoader.js"; ...@@ -22,136 +22,129 @@ import { RGBELoader } from "../loaders/RGBELoader.js";
var HDRCubeTextureLoader = function ( manager ) { var HDRCubeTextureLoader = function ( manager ) {
this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; Loader.call( this, manager );
this.hdrLoader = new RGBELoader(); this.hdrLoader = new RGBELoader();
this.type = UnsignedByteType; 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; console.warn( 'THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead.' );
onLoad = onProgress;
onProgress = onError;
onError = arguments[ 4 ];
} 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; switch ( texture.type ) {
texture.format = RGBAFormat;
texture.minFilter = NearestFilter;
texture.magFilter = NearestFilter;
texture.generateMipmaps = false;
break;
case FloatType: case UnsignedByteType:
texture.encoding = LinearEncoding; texture.encoding = RGBEEncoding;
texture.format = RGBFormat; texture.format = RGBAFormat;
texture.minFilter = LinearFilter; texture.minFilter = NearestFilter;
texture.magFilter = LinearFilter; texture.magFilter = NearestFilter;
texture.generateMipmaps = false; texture.generateMipmaps = false;
break; break;
case HalfFloatType: case FloatType:
texture.encoding = LinearEncoding; texture.encoding = LinearEncoding;
texture.format = RGBFormat; texture.format = RGBFormat;
texture.minFilter = LinearFilter; texture.minFilter = LinearFilter;
texture.magFilter = LinearFilter; texture.magFilter = LinearFilter;
texture.generateMipmaps = false; texture.generateMipmaps = false;
break; 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 ) var loaded = 0;
.setPath( scope.path )
.setResponseType( 'arraybuffer' )
.load( urls[ i ], function ( buffer ) {
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; if ( texData.data !== undefined ) {
dataTexture.encoding = texture.encoding;
dataTexture.format = texture.format;
dataTexture.minFilter = texture.minFilter;
dataTexture.magFilter = texture.magFilter;
dataTexture.generateMipmaps = texture.generateMipmaps;
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; return this;
this.hdrLoader.setDataType( value );
return this;
}; }
HDRCubeTextureLoader.prototype.setType = function ( value ) {
console.warn( 'THREE.HDRCubeTextureLoader: .setType() has been renamed to .setDataType().' );
return this.setDataType( value );
}; } );
export { HDRCubeTextureLoader }; export { HDRCubeTextureLoader };
...@@ -45,7 +45,6 @@ export class MTLLoader extends Loader { ...@@ -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; load(url: string, onLoad: (materialCreator: MaterialCreator) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
parse(text: string) : MaterialCreator; parse(text: string) : MaterialCreator;
setBaseUrl(path: string) : void;
setMaterialOptions(value: MaterialCreatorOptions) : void; setMaterialOptions(value: MaterialCreatorOptions) : void;
} }
......
import { import {
BufferGeometry, BufferGeometry,
Loader,
LoadingManager LoadingManager
} from '../../../src/Three'; } from '../../../src/Three';
export class TTFLoader { export class TTFLoader extends Loader {
constructor(manager?: LoadingManager); constructor(manager?: LoadingManager);
manager: LoadingManager;
path: string;
reversed: boolean; reversed: boolean;
load(url: string, onLoad: (json: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; load(url: string, onLoad: (json: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
setPath(path: string): this;
parse(arraybuffer: ArrayBuffer): object; parse(arraybuffer: ArrayBuffer): object;
} }
...@@ -9,18 +9,20 @@ ...@@ -9,18 +9,20 @@
*/ */
import { import {
DefaultLoadingManager, FileLoader,
FileLoader Loader
} from "../../../build/three.module.js"; } from "../../../build/three.module.js";
var TTFLoader = function ( manager ) { var TTFLoader = function ( manager ) {
this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; Loader.call( this, manager );
this.reversed = false; this.reversed = false;
}; };
TTFLoader.prototype = {
TTFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
constructor: TTFLoader, constructor: TTFLoader,
...@@ -39,13 +41,6 @@ TTFLoader.prototype = { ...@@ -39,13 +41,6 @@ TTFLoader.prototype = {
}, },
setPath: function ( value ) {
this.path = value;
return this;
},
parse: function ( arraybuffer ) { parse: function ( arraybuffer ) {
function convert( font, reversed ) { function convert( font, reversed ) {
...@@ -54,7 +49,7 @@ TTFLoader.prototype = { ...@@ -54,7 +49,7 @@ TTFLoader.prototype = {
var glyphs = {}; var glyphs = {};
var scale = ( 100000 ) / ( ( font.unitsPerEm || 2048 ) * 72 ); var scale = ( 100000 ) / ( ( font.unitsPerEm || 2048 ) * 72 );
var glyphIndexMap = font.encoding.cmap.glyphIndexMap; var glyphIndexMap = font.encoding.cmap.glyphIndexMap;
var unicodes = Object.keys( glyphIndexMap ); var unicodes = Object.keys( glyphIndexMap );
...@@ -207,6 +202,6 @@ TTFLoader.prototype = { ...@@ -207,6 +202,6 @@ TTFLoader.prototype = {
} }
}; } );
export { TTFLoader }; export { TTFLoader };
import { import {
Loader,
LoadingManager LoadingManager
} from '../../../src/Three'; } from '../../../src/Three';
import { GLTFLoader, GLTF } from './GLTFLoader'; import { GLTFLoader, GLTF } from './GLTFLoader';
import { DRACOLoader } from './DRACOLoader'; import { DRACOLoader } from './DRACOLoader';
export class VRMLoader { export class VRMLoader extends Loader {
constructor(manager?: LoadingManager); constructor(manager?: LoadingManager);
gltfLoader: GLTFLoader; 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; 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; parse(gltf: GLTF, onLoad: (scene: GLTF) => void): void;
setDRACOLoader(dracoLoader: DRACOLoader): this;
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
import { import {
DefaultLoadingManager Loader
} from "../../../build/three.module.js"; } from "../../../build/three.module.js";
import { GLTFLoader } from "../loaders/GLTFLoader.js"; import { GLTFLoader } from "../loaders/GLTFLoader.js";
...@@ -22,17 +22,16 @@ var VRMLoader = ( function () { ...@@ -22,17 +22,16 @@ var VRMLoader = ( function () {
} }
this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; Loader.call( this, manager );
this.gltfLoader = new GLTFLoader( this.manager ); this.gltfLoader = new GLTFLoader( this.manager );
} }
VRMLoader.prototype = { VRMLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
constructor: VRMLoader, constructor: VRMLoader,
crossOrigin: 'anonymous',
load: function ( url, onLoad, onProgress, onError ) { load: function ( url, onLoad, onProgress, onError ) {
var scope = this; var scope = this;
...@@ -45,27 +44,6 @@ var VRMLoader = ( function () { ...@@ -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 ) { setDRACOLoader: function ( dracoLoader ) {
this.glTFLoader.setDRACOLoader( dracoLoader ); this.glTFLoader.setDRACOLoader( dracoLoader );
...@@ -85,7 +63,7 @@ var VRMLoader = ( function () { ...@@ -85,7 +63,7 @@ var VRMLoader = ( function () {
} }
}; } );
return VRMLoader; return VRMLoader;
......
import { import {
Mesh, Mesh,
Loader,
LoadingManager LoadingManager
} from '../../../src/Three'; } from '../../../src/Three';
...@@ -8,16 +9,9 @@ export interface XResult { ...@@ -8,16 +9,9 @@ export interface XResult {
models: Mesh[]; models: Mesh[];
} }
export class VRMLLoader { export class XLoader extends Loader {
constructor(manager?: LoadingManager); 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; load(url: string, onLoad: (object: XResult) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
setCrossOrigin(path: string): this;
parse(data: ArrayBuffer | string, onLoad: (object: object) => void): object; parse(data: ArrayBuffer | string, onLoad: (object: object) => void): object;
setPath(path: string): this;
setResourcePath(path: string): this;
} }
...@@ -7,10 +7,10 @@ import { ...@@ -7,10 +7,10 @@ import {
AnimationMixer, AnimationMixer,
Bone, Bone,
BufferGeometry, BufferGeometry,
DefaultLoadingManager,
FileLoader, FileLoader,
Float32BufferAttribute, Float32BufferAttribute,
FrontSide, FrontSide,
Loader,
LoaderUtils, LoaderUtils,
Matrix4, Matrix4,
Mesh, Mesh,
...@@ -223,10 +223,11 @@ var XLoader = ( function () { ...@@ -223,10 +223,11 @@ var XLoader = ( function () {
function XLoader( manager ) { function XLoader( manager ) {
Loader.call( this, manager );
classCallCheck( this, XLoader ); classCallCheck( this, XLoader );
this.debug = false; this.debug = false;
this.manager = manager !== undefined ? manager : DefaultLoadingManager;
this.texloader = new TextureLoader( this.manager ); this.texloader = new TextureLoader( this.manager );
this.url = ""; this.url = "";
this._putMatLength = 0; this._putMatLength = 0;
...@@ -250,9 +251,6 @@ var XLoader = ( function () { ...@@ -250,9 +251,6 @@ var XLoader = ( function () {
} }
createClass( XLoader, [ { createClass( XLoader, [ {
key: 'crossOrigin',
value: 'anonymous'
}, {
key: '_setArgOption', key: '_setArgOption',
value: function _setArgOption( _arg ) { value: function _setArgOption( _arg ) {
...@@ -300,30 +298,6 @@ var XLoader = ( function () { ...@@ -300,30 +298,6 @@ var XLoader = ( function () {
}, onProgress, onError ); }, 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', key: '_readLine',
...@@ -504,11 +478,11 @@ var XLoader = ( function () { ...@@ -504,11 +478,11 @@ var XLoader = ( function () {
var path; var path;
if ( this.resourcePath !== undefined ) { if ( this.resourcePath !== '' ) {
path = this.resourcePath; path = this.resourcePath;
} else if ( this.path !== undefined ) { } else if ( this.path !== '' ) {
path = this.path; path = this.path;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册