Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use with Babylon JS to play prebaked ambisonic audio #110

Open
gschian0 opened this issue May 25, 2022 · 0 comments
Open

Use with Babylon JS to play prebaked ambisonic audio #110

gschian0 opened this issue May 25, 2022 · 0 comments

Comments

@gschian0
Copy link

gschian0 commented May 25, 2022

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
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant