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

AudioContext: Added getContext() and setContext().

上级 3c02fefe
var outro = `
Object.defineProperty( exports, 'AudioContext', {
get: function () {
return exports.getAudioContext();
}
});`;
function glsl () {
return {
transform ( code, id ) {
......@@ -42,6 +34,5 @@ export default {
dest: 'build/three.modules.js'
}
],
outro: outro,
sourceMap: true
};
......@@ -63,7 +63,7 @@ export { CubeCamera } from './cameras/CubeCamera.js';
export { Camera } from './cameras/Camera.js';
export { AudioListener } from './audio/AudioListener.js';
export { PositionalAudio } from './audio/PositionalAudio.js';
export { getAudioContext } from './audio/AudioContext.js';
export { AudioContext } from './audio/AudioContext.js';
export { AudioAnalyser } from './audio/AudioAnalyser.js';
export { Audio } from './audio/Audio.js';
export { VectorKeyframeTrack } from './animation/tracks/VectorKeyframeTrack.js';
......
var context;
export function getAudioContext() {
function AudioContext() {}
if ( context === undefined ) {
Object.assign( AudioContext, {
context = new ( window.AudioContext || window.webkitAudioContext )();
getContext: function () {
if ( context === undefined ) {
context = new ( window.AudioContext || window.webkitAudioContext )();
}
return context;
},
setContext: function ( value ) {
context = value;
}
return context;
} );
}
export { AudioContext };
......@@ -5,7 +5,7 @@
import { Vector3 } from '../math/Vector3';
import { Quaternion } from '../math/Quaternion';
import { Object3D } from '../core/Object3D';
import { getAudioContext } from './AudioContext';
import { AudioContext } from './AudioContext';
function AudioListener() {
......@@ -13,7 +13,7 @@ function AudioListener() {
this.type = 'AudioListener';
this.context = getAudioContext();
this.context = AudioContext.getContext();
this.gain = this.context.createGain();
this.gain.connect( this.context.destination );
......
import { getAudioContext } from '../audio/AudioContext';
import { AudioContext } from '../audio/AudioContext';
import { FileLoader } from './FileLoader';
import { DefaultLoadingManager } from './LoadingManager';
......@@ -20,7 +20,7 @@ Object.assign( AudioLoader.prototype, {
loader.setResponseType( 'arraybuffer' );
loader.load( url, function ( buffer ) {
var context = getAudioContext();
var context = AudioContext.getContext();
context.decodeAudioData( buffer, function ( audioBuffer ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册