UNPKG

three

Version:

JavaScript 3D library

34 lines (19 loc) 668 B
/** * @author Reece Aaron Lecrivain / http://reecenotes.com/ */ THREE.AudioLoader = function ( manager ) { this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; }; THREE.AudioLoader.prototype = { constructor: THREE.AudioLoader, load: function ( url, onLoad, onProgress, onError ) { var loader = new THREE.XHRLoader( this.manager ); loader.setResponseType( 'arraybuffer' ); loader.load( url, function ( buffer ) { var context = THREE.AudioContext; context.decodeAudioData( buffer, function ( audioBuffer ) { onLoad( audioBuffer ); } ); }, onProgress, onError ); } };