GoogleChrome / GoogleChrome/omnitone
Use with Babylon JS to play prebaked ambisonic audio
- Dominant language
- JavaScript
- Stars
- 911
- Forks
- 118
- Avg merge
- 2m
- Merged PRs (30d)
- 3
Description
I’m getting this error attempting to get the camera rotation from Babylon JS and copy it to the listener position in Omnitone.
uisng : [https://googlechrome.github.io/omnitone/#home](https://github.localhost/url)
`omnitone.min.js:17 Uncaught TypeError: Cannot read properties of undefined (reading '0') at Object.A.invertMatrix4 (omnitone.min.js:17:446) at z.setRotationMatrixFromCamera (omnitone.min.js:17:18117) at eval (Game.js:118:20) at e._renderLoop (babylon.js:16:98406) A.invertMatrix4 @ omnitone.min.js:17 z.setRotationMatrixFromCamera @ omnitone.min.js:17 eval @ Game.js:118 e._renderLoop @ babylon.js:16 requestAnimationFrame (async) e.QueueNewFrame @ babylon.js:16 e._renderLoop @ babylon.js:16 requestAnimationFrame (async) e.QueueNewFrame @ babylon.js:16 e.runRenderLoop @ babylon.js:16 doRender @ Game.js:114 eval @ index.js:10`
My Constructor :
`constructor(canvasId) { this.canvas = document.getElementById(canvasId); this.engine = new BABYLON.Engine(this.canvas, true); this.time = 0; this.audioCtx = new AudioContext(); this.FOH = Omnitone.createFOARenderer(this.audioCtx, { // The example audio is in the FuMa ordering (W,X,Y,Z). So remap the // channels to the ACN format. channelMap: [0, 3, 1, 2], });
my render :
doRender() { this.engine.runRenderLoop(() => { const shaderMaterial = this.scene.getMaterialByName("shader"); shaderMaterial.setFloat("time", this.time); this.time += 0.02; this.FOH.setRotationMatrixFromCamera(this.camera);
shaderMaterial.setVector3( "cameraPosition", this.scene.activeCamera.position ); this.scene.render(); }); window.addEventListener("resize", () => { this.engine.resize(); }); }`
Camera Declaration :
`this.camera = new BABYLON.FreeCamera( "camera1", new BABYLON.Vector3(0, 5, -10), this.scene ); this.camera.setTarget(BABYLON.Vector3.Zero()); this.camera.attachControl(this.canvas, false);`
I would like to be able to rotate the camera view and have the audio mix rotation copy the camera rotation matrix… I’m hot sure how to translate these two types any help would be appreciated.
Bless,
-Gennaro
Contributor guide
Assessment
This issue has not been assessed yet.