Download node_modules/three/src/loaders/AudioLoader.js from SimWorld-AI/industrial-harbor-viewer: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/spaces/SimWorld-AI/industrial-harbor-viewer/resolve/main/node_modules/three/src/loaders/AudioLoader.js
- Command line
-
hf download hf://spaces/SimWorld-AI/industrial-harbor-viewer/node_modules/three/src/loaders/AudioLoader.js
-
curl -L -o AudioLoader.js https://huggingface.co/spaces/SimWorld-AI/industrial-harbor-viewer/resolve/main/node_modules/three/src/loaders/AudioLoader.js
1.19 kB
| import { AudioContext } from '../audio/AudioContext.js'; | |
| import { FileLoader } from './FileLoader.js'; | |
| import { Loader } from './Loader.js'; | |
| class AudioLoader extends Loader { | |
| constructor( manager ) { | |
| super( manager ); | |
| } | |
| load( url, onLoad, onProgress, onError ) { | |
| const scope = this; | |
| const loader = new FileLoader( this.manager ); | |
| loader.setResponseType( 'arraybuffer' ); | |
| loader.setPath( this.path ); | |
| loader.setRequestHeader( this.requestHeader ); | |
| loader.setWithCredentials( this.withCredentials ); | |
| loader.load( url, function ( buffer ) { | |
| try { | |
| // Create a copy of the buffer. The `decodeAudioData` method | |
| // detaches the buffer when complete, preventing reuse. | |
| const bufferCopy = buffer.slice( 0 ); | |
| const context = AudioContext.getContext(); | |
| context.decodeAudioData( bufferCopy, function ( audioBuffer ) { | |
| onLoad( audioBuffer ); | |
| } ).catch( handleError ); | |
| } catch ( e ) { | |
| handleError( e ); | |
| } | |
| }, onProgress, onError ); | |
| function handleError( e ) { | |
| if ( onError ) { | |
| onError( e ); | |
| } else { | |
| console.error( e ); | |
| } | |
| scope.manager.itemError( url ); | |
| } | |
| } | |
| } | |
| export { AudioLoader }; | |