How to rotate listenerOrientation
Hi there. Love the library - think it's my favourite way of doing web audio. But... I'm having a little trouble with 3D sound, in particular rotating the listener position, representing turning the player around, etc.
From looking at the example, it's very Thre.JS specific. However, the reason I came to sono was that I found Three.js a bit too heavy for just doing simple 3D sound in the web when you're not using any visuals. So I've been trying to crack it without it. I think when I understand this all a bit more I might try upping the documentation of it a bit.
So far, I've been minorly successful making a sound pan from left to right when I rotate, except the jump is huge and it doesn't go all the way around for some reason. I think my maths is wrong here.
Here's what I have, with pov being an instance of my PointOfView class.
In index.ts:
function inGameKeyPressHandler(ev: KeyboardEvent): void {
switch (ev.which) {
case Key.LeftArrow:
pov.rotateLeft(45)
console.log("Orientation: ", pov.OrientationX, pov.OrientationY, pov.OrientationZ)
break
case Key.RightArrow:
pov.rotateRight(45)
console.log("Orientation: ", pov.OrientationX, pov.OrientationY, pov.OrientationZ)
break
}
}
And in PointOfView class I have:
/** The orientation X direction of the POV */
OrientationX: number
/** The orientation Y direction of the POV */
OrientationY: number
/** The orientation Z direction of the POV */
OrientationZ: number
rotateLeft(degrees: number) {
this.OrientationX -= degrees * Math.PI / 180
sono.panner.setListenerOrientation(this.OrientationX, this.OrientationY, this.OrientationZ)
}
rotateRight(degrees: number) {
this.OrientationX += degrees * Math.PI / 180
sono.panner.setListenerOrientation(this.OrientationX, this.OrientationY, this.OrientationZ)
}
Am I even close?
Sorry if this isn't the right forum to ask questions on library use, happy to move it if needs be.