Update framework

This commit is contained in:
2022-11-26 02:22:02 +01:00
parent 9a6ce1f832
commit ae057940af
508 changed files with 26011 additions and 14248 deletions

View File

@@ -0,0 +1,14 @@
import ResonatorAudioContext from '../audio-context';
import EventEmitter from 'eventemitter3';
export default class Scene extends EventEmitter {
scene: any;
context: ResonatorAudioContext;
listener: AudioListener;
constructor(context: ResonatorAudioContext);
init(): void;
createSource(): any;
getOutput(): any;
getInput(): any;
setListenerPosition(x: number, y: number, z: number): void;
setListenerOrientation(forward: any, rawup: any): void;
}

View File

@@ -0,0 +1,40 @@
// The code that deals with 3d audio
import ResonanceAudio from '../vendor/resonance-es6/main';
import EventEmitter from 'eventemitter3';
import vec3 from '../../tsm/vec3';
export default class Scene extends EventEmitter {
constructor(context) {
super();
this.context = context;
this.scene = new ResonanceAudio(this.context.getContext(), {
ambisonicOrder: 3
});
this.listener = this.context.getContext().listener;
this.init();
}
init() {
// this.scene.output.connect(this.context.getOutputDestination());
}
createSource() {
const source = this.scene.createSource();
return Object.assign(Object.assign({}, source), { getInput: () => source.input });
}
getOutput() {
return this.scene.output;
}
getInput() {
return this.scene.input;
}
setListenerPosition(x, y, z) {
this.scene.setListenerPosition(x, y, z);
}
setListenerOrientation(forward, rawup) {
let fwd = new vec3([forward.x, forward.y, forward.z]);
let up = fwd.copy();
vec3.cross(up, new vec3([rawup.x, rawup.y, rawup.z]), up);
vec3.cross(up, fwd, up);
fwd.normalize();
up.normalize();
this.scene.setListenerOrientation(forward.x, forward.y, forward.z, rawup.x, rawup.y, rawup.z);
}
}

View File

@@ -0,0 +1,14 @@
import ResonatorAudioContext from '../audio-context';
import EventEmitter from 'eventemitter3';
export default class ResonatorScene extends EventEmitter {
scene: GainNode;
context: ResonatorAudioContext;
listener: AudioListener;
constructor(context: ResonatorAudioContext);
init(): void;
createSource(): any;
getOutput(): any;
getInput(): any;
setListenerPosition(x: number, y: number, z: number): void;
setListenerOrientation(forward: any, rawup: any): void;
}

View File

@@ -0,0 +1,42 @@
// The code that deals with 3d audio
import EventEmitter from 'eventemitter3';
import vec3 from '../../tsm/vec3';
export default class ResonatorScene extends EventEmitter {
constructor(context) {
super();
this.context = context;
this.scene = this.context.getContext().createGain();
this.listener = this.context.getContext().listener;
this.init();
}
init() {
// this.scene.output.connect(this.context.getOutputDestination());
}
createSource() {
const node = this.context.getContext().createPanner();
node.panningModel = 'HRTF';
node.distanceModel = 'linear';
node.maxDistance = 20;
node.refDistance = 2;
node.connect(this.scene);
return node;
}
getOutput() {
return this.scene;
}
getInput() {
return this.scene;
}
setListenerPosition(x, y, z) {
this.listener.setPosition(x, y, z);
}
setListenerOrientation(forward, rawup) {
let fwd = new vec3([forward.x, forward.y, forward.z]);
let up = fwd.copy();
vec3.cross(up, new vec3([rawup.x, rawup.y, rawup.z]), up);
vec3.cross(up, fwd, up);
fwd.normalize();
up.normalize();
this.listener.setOrientation(fwd.x, fwd.y, fwd.z, up.x, up.y, up.z);
}
}