提交 e207eb57 编写于 作者: M Mr.doob

Added THREE.AudioContext.

上级 9e21864f
......@@ -78,9 +78,6 @@
var listener = new THREE.AudioListener();
camera.add( listener );
var audioLoader = new THREE.AudioLoader(listener.context);
scene = new THREE.Scene();
scene.fog = new THREE.FogExp2( 0x000000, 0.0025 );
......@@ -96,6 +93,8 @@
// sound spheres
var audioLoader = new THREE.AudioLoader();
var mesh1 = new THREE.Mesh( sphere, material_sphere1 );
mesh1.position.set( -250, 30, 0 );
scene.add( mesh1 );
......
......@@ -41,12 +41,14 @@ THREE.Audio.prototype.load = function ( file ) {
console.warn( 'THREE.Audio: .load has been deprecated. Please use THREE.AudioLoader.' );
var audioLoader = new THREE.AudioLoader( this.context );
var scope = this;
var audioLoader = new THREE.AudioLoader();
audioLoader.load( file, function ( buffer ) {
scope.setBuffer( buffer );
});
} );
return this;
......
/**
* @author mrdoob / http://mrdoob.com/
*/
Object.defineProperty( THREE, 'AudioContext', {
get: ( function () {
var context;
return function () {
if ( context === undefined ) {
context = new ( window.AudioContext || window.webkitAudioContext )();
}
return context;
};
} )()
} );
......@@ -8,7 +8,7 @@ THREE.AudioListener = function () {
this.type = 'AudioListener';
this.context = new ( window.AudioContext || window.webkitAudioContext )();
this.context = THREE.AudioContext;
this.gain = this.context.createGain();
this.gain.connect( this.context.destination );
......
......@@ -2,9 +2,7 @@
* @author Reece Aaron Lecrivain / http://reecenotes.com/
*/
THREE.AudioLoader = function ( context, manager ) {
this.context = ( context !== undefined ) ? context : new ( window.AudioContext || window.webkitAudioContext )();
THREE.AudioLoader = function ( manager ) {
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
......@@ -16,13 +14,13 @@ THREE.AudioLoader.prototype = {
load: function ( url, onLoad, onProgress, onError ) {
var scope = this;
var loader = new THREE.XHRLoader( this.manager );
loader.setResponseType( 'arraybuffer' );
loader.load( url, function ( buffer ) {
scope.context.decodeAudioData( buffer, function ( audioBuffer ) {
var context = THREE.AudioContext;
context.decodeAudioData( buffer, function ( audioBuffer ) {
onLoad( audioBuffer );
......
......@@ -54,6 +54,7 @@
"src/animation/tracks/VectorKeyframeTrack.js",
"src/audio/Audio.js",
"src/audio/AudioAnalyser.js",
"src/audio/AudioContext.js",
"src/audio/PositionalAudio.js",
"src/audio/AudioListener.js",
"src/cameras/Camera.js",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册