diff --git a/src/loaders/AnimationLoader.js b/src/loaders/AnimationLoader.js index eeee815b8d581d..661dab954034cd 100644 --- a/src/loaders/AnimationLoader.js +++ b/src/loaders/AnimationLoader.js @@ -2,24 +2,22 @@ import { AnimationClip } from '../animation/AnimationClip.js'; import { FileLoader } from './FileLoader.js'; import { Loader } from './Loader.js'; -function AnimationLoader( manager ) { +class AnimationLoader extends Loader { - Loader.call( this, manager ); + constructor( manager ) { -} - -AnimationLoader.prototype = Object.assign( Object.create( Loader.prototype ), { + super( manager ); - constructor: AnimationLoader, + } - load: function ( url, onLoad, onProgress, onError ) { + load( url, onLoad, onProgress, onError ) { const scope = this; - const loader = new FileLoader( scope.manager ); - loader.setPath( scope.path ); - loader.setRequestHeader( scope.requestHeader ); - loader.setWithCredentials( scope.withCredentials ); + const loader = new FileLoader( this.manager ); + loader.setPath( this.path ); + loader.setRequestHeader( this.requestHeader ); + loader.setWithCredentials( this.withCredentials ); loader.load( url, function ( text ) { try { @@ -44,9 +42,9 @@ AnimationLoader.prototype = Object.assign( Object.create( Loader.prototype ), { }, onProgress, onError ); - }, + } - parse: function ( json ) { + parse( json ) { const animations = []; @@ -62,7 +60,7 @@ AnimationLoader.prototype = Object.assign( Object.create( Loader.prototype ), { } -} ); +} export { AnimationLoader }; diff --git a/src/loaders/AudioLoader.js b/src/loaders/AudioLoader.js index 68ba89177f3754..857394e4812f71 100644 --- a/src/loaders/AudioLoader.js +++ b/src/loaders/AudioLoader.js @@ -2,25 +2,23 @@ import { AudioContext } from '../audio/AudioContext.js'; import { FileLoader } from './FileLoader.js'; import { Loader } from './Loader.js'; -function AudioLoader( manager ) { +class AudioLoader extends Loader { - Loader.call( this, manager ); + constructor( manager ) { -} - -AudioLoader.prototype = Object.assign( Object.create( Loader.prototype ), { + super( manager ); - constructor: AudioLoader, + } - load: function ( url, onLoad, onProgress, onError ) { + load( url, onLoad, onProgress, onError ) { const scope = this; - const loader = new FileLoader( scope.manager ); + const loader = new FileLoader( this.manager ); loader.setResponseType( 'arraybuffer' ); - loader.setPath( scope.path ); - loader.setRequestHeader( scope.requestHeader ); - loader.setWithCredentials( scope.withCredentials ); + loader.setPath( this.path ); + loader.setRequestHeader( this.requestHeader ); + loader.setWithCredentials( this.withCredentials ); loader.load( url, function ( buffer ) { try { @@ -56,7 +54,7 @@ AudioLoader.prototype = Object.assign( Object.create( Loader.prototype ), { } -} ); +} export { AudioLoader }; diff --git a/src/loaders/BufferGeometryLoader.js b/src/loaders/BufferGeometryLoader.js index de11fd0595e1a3..7ed96a3673dc70 100644 --- a/src/loaders/BufferGeometryLoader.js +++ b/src/loaders/BufferGeometryLoader.js @@ -9,17 +9,15 @@ import { InstancedBufferAttribute } from '../core/InstancedBufferAttribute.js'; import { InterleavedBufferAttribute } from '../core/InterleavedBufferAttribute.js'; import { InterleavedBuffer } from '../core/InterleavedBuffer.js'; -function BufferGeometryLoader( manager ) { +class BufferGeometryLoader extends Loader { - Loader.call( this, manager ); + constructor( manager ) { -} - -BufferGeometryLoader.prototype = Object.assign( Object.create( Loader.prototype ), { + super( manager ); - constructor: BufferGeometryLoader, + } - load: function ( url, onLoad, onProgress, onError ) { + load( url, onLoad, onProgress, onError ) { const scope = this; @@ -51,9 +49,9 @@ BufferGeometryLoader.prototype = Object.assign( Object.create( Loader.prototype }, onProgress, onError ); - }, + } - parse: function ( json ) { + parse( json ) { const interleavedBufferMap = {}; const arrayBufferMap = {}; @@ -211,7 +209,7 @@ BufferGeometryLoader.prototype = Object.assign( Object.create( Loader.prototype } -} ); +} const TYPED_ARRAYS = { Int8Array: Int8Array, diff --git a/src/loaders/CubeTextureLoader.js b/src/loaders/CubeTextureLoader.js index 61a508d3f71d10..2e784a221e8d27 100644 --- a/src/loaders/CubeTextureLoader.js +++ b/src/loaders/CubeTextureLoader.js @@ -2,17 +2,15 @@ import { ImageLoader } from './ImageLoader.js'; import { CubeTexture } from '../textures/CubeTexture.js'; import { Loader } from './Loader.js'; -function CubeTextureLoader( manager ) { +class CubeTextureLoader extends Loader { - Loader.call( this, manager ); + constructor( manager ) { -} - -CubeTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), { + super( manager ); - constructor: CubeTextureLoader, + } - load: function ( urls, onLoad, onProgress, onError ) { + load( urls, onLoad, onProgress, onError ) { const texture = new CubeTexture(); @@ -52,7 +50,7 @@ CubeTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), } -} ); +} export { CubeTextureLoader }; diff --git a/src/loaders/FontLoader.js b/src/loaders/FontLoader.js index 3122f5964b1fc2..986b5adc1cf1ee 100644 --- a/src/loaders/FontLoader.js +++ b/src/loaders/FontLoader.js @@ -2,17 +2,15 @@ import { Font } from '../extras/core/Font.js'; import { FileLoader } from './FileLoader.js'; import { Loader } from './Loader.js'; -function FontLoader( manager ) { +class FontLoader extends Loader { - Loader.call( this, manager ); + constructor( manager ) { -} - -FontLoader.prototype = Object.assign( Object.create( Loader.prototype ), { + super( manager ); - constructor: FontLoader, + } - load: function ( url, onLoad, onProgress, onError ) { + load( url, onLoad, onProgress, onError ) { const scope = this; @@ -41,15 +39,15 @@ FontLoader.prototype = Object.assign( Object.create( Loader.prototype ), { }, onProgress, onError ); - }, + } - parse: function ( json ) { + parse( json ) { return new Font( json ); } -} ); +} export { FontLoader }; diff --git a/src/loaders/ImageLoader.js b/src/loaders/ImageLoader.js index 2f8278931e7074..6a7eaaf01adf2b 100644 --- a/src/loaders/ImageLoader.js +++ b/src/loaders/ImageLoader.js @@ -1,17 +1,15 @@ import { Cache } from './Cache.js'; import { Loader } from './Loader.js'; -function ImageLoader( manager ) { +class ImageLoader extends Loader { - Loader.call( this, manager ); + constructor( manager ) { -} - -ImageLoader.prototype = Object.assign( Object.create( Loader.prototype ), { + super( manager ); - constructor: ImageLoader, + } - load: function ( url, onLoad, onProgress, onError ) { + load( url, onLoad, onProgress, onError ) { if ( this.path !== undefined ) url = this.path + url; @@ -81,7 +79,7 @@ ImageLoader.prototype = Object.assign( Object.create( Loader.prototype ), { } -} ); +} export { ImageLoader }; diff --git a/src/loaders/MaterialLoader.js b/src/loaders/MaterialLoader.js index 25ae862e663024..9014e8bbc508ce 100644 --- a/src/loaders/MaterialLoader.js +++ b/src/loaders/MaterialLoader.js @@ -8,19 +8,16 @@ import { FileLoader } from './FileLoader.js'; import { Loader } from './Loader.js'; import * as Materials from '../materials/Materials.js'; -function MaterialLoader( manager ) { +class MaterialLoader extends Loader { - Loader.call( this, manager ); + constructor( manager ) { - this.textures = {}; + super( manager ); + this.textures = {}; -} - -MaterialLoader.prototype = Object.assign( Object.create( Loader.prototype ), { - - constructor: MaterialLoader, + } - load: function ( url, onLoad, onProgress, onError ) { + load( url, onLoad, onProgress, onError ) { const scope = this; @@ -52,9 +49,9 @@ MaterialLoader.prototype = Object.assign( Object.create( Loader.prototype ), { }, onProgress, onError ); - }, + } - parse: function ( json ) { + parse( json ) { const textures = this.textures; @@ -283,16 +280,16 @@ MaterialLoader.prototype = Object.assign( Object.create( Loader.prototype ), { return material; - }, + } - setTextures: function ( value ) { + setTextures( value ) { this.textures = value; return this; } -} ); +} export { MaterialLoader };