📄 AnimationLoader.js
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 2 |
🧱 Classes | 1 |
📦 Imports | 3 |
📊 Variables & Constants | 3 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 src/loaders/AnimationLoader.js
📦 Imports¶
Name | Source |
---|---|
AnimationClip |
../animation/AnimationClip.js |
FileLoader |
./FileLoader.js |
Loader |
./Loader.js |
Variables & Constants¶
Name | Type | Kind | Value | Exported |
---|---|---|---|---|
scope |
this |
let/var | this |
✗ |
loader |
FileLoader |
let/var | new FileLoader( this.manager ) |
✗ |
animations |
any[] |
let/var | [] |
✗ |
Functions¶
AnimationLoader.load(url: string, onLoad: (arg0: AnimationClip[]) => any, onProgress: onProgressCallback, onError: onErrorCallback): void
¶
JSDoc:
/**
* Starts loading from the given URL and pass the loaded animations as an array
* holding instances of {@link AnimationClip} to the `onLoad()` callback.
*
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
* @param {function(Array<AnimationClip>)} onLoad - Executed when the loading process has been finished.
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
* @param {onErrorCallback} onError - Executed when errors occur.
*/
Parameters:
url
string
onLoad
(arg0: AnimationClip[]) => any
onProgress
onProgressCallback
onError
onErrorCallback
Returns: void
Calls:
loader.setPath
loader.setRequestHeader
loader.setWithCredentials
loader.load
onLoad
scope.parse
JSON.parse
onError
console.error
scope.manager.itemError
Code
load( url, onLoad, onProgress, onError ) {
const scope = this;
const loader = new FileLoader( this.manager );
loader.setPath( this.path );
loader.setRequestHeader( this.requestHeader );
loader.setWithCredentials( this.withCredentials );
loader.load( url, function ( text ) {
try {
onLoad( scope.parse( JSON.parse( text ) ) );
} catch ( e ) {
if ( onError ) {
onError( e );
} else {
console.error( e );
}
scope.manager.itemError( url );
}
}, onProgress, onError );
}
AnimationLoader.parse(json: any): AnimationClip[]
¶
JSDoc:
/**
* Parses the given JSON object and returns an array of animation clips.
*
* @param {Object} json - The serialized animation clips.
* @return {Array<AnimationClip>} The parsed animation clips.
*/
Parameters:
json
any
Returns: AnimationClip[]
Calls:
AnimationClip.parse
animations.push
Code
Classes¶
AnimationLoader
¶
Class Code
class AnimationLoader extends Loader {
/**
* Constructs a new animation loader.
*
* @param {LoadingManager} [manager] - The loading manager.
*/
constructor( manager ) {
super( manager );
}
/**
* Starts loading from the given URL and pass the loaded animations as an array
* holding instances of {@link AnimationClip} to the `onLoad()` callback.
*
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
* @param {function(Array<AnimationClip>)} onLoad - Executed when the loading process has been finished.
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
* @param {onErrorCallback} onError - Executed when errors occur.
*/
load( url, onLoad, onProgress, onError ) {
const scope = this;
const loader = new FileLoader( this.manager );
loader.setPath( this.path );
loader.setRequestHeader( this.requestHeader );
loader.setWithCredentials( this.withCredentials );
loader.load( url, function ( text ) {
try {
onLoad( scope.parse( JSON.parse( text ) ) );
} catch ( e ) {
if ( onError ) {
onError( e );
} else {
console.error( e );
}
scope.manager.itemError( url );
}
}, onProgress, onError );
}
/**
* Parses the given JSON object and returns an array of animation clips.
*
* @param {Object} json - The serialized animation clips.
* @return {Array<AnimationClip>} The parsed animation clips.
*/
parse( json ) {
const animations = [];
for ( let i = 0; i < json.length; i ++ ) {
const clip = AnimationClip.parse( json[ i ] );
animations.push( clip );
}
return animations;
}
}
Methods¶
load(url: string, onLoad: (arg0: AnimationClip[]) => any, onProgress: onProgressCallback, onError: onErrorCallback): void
¶
Code
load( url, onLoad, onProgress, onError ) {
const scope = this;
const loader = new FileLoader( this.manager );
loader.setPath( this.path );
loader.setRequestHeader( this.requestHeader );
loader.setWithCredentials( this.withCredentials );
loader.load( url, function ( text ) {
try {
onLoad( scope.parse( JSON.parse( text ) ) );
} catch ( e ) {
if ( onError ) {
onError( e );
} else {
console.error( e );
}
scope.manager.itemError( url );
}
}, onProgress, onError );
}