0l4f Posted June 21, 2018 Share Posted June 21, 2018 I'm not sure whether this qualifies as a babylon.js bug, but here's my scenario: I'm embedding a babylon.js canvas in a WordPress page there's some audio in the scene, but no positional audio when the mouse is outside the canvas when the canvas loads, and the user moves the mouse, this error is thown, and the canvas crashes: Uncaught TypeError: Failed to execute 'setPosition' on 'AudioListener': The provided float value is non-finite. at i._updateAudioParameters (babylon.custom.js:14) at i.render (babylon.custom.js:14) at main.js?v=201806111547:595 at n._renderLoop (babylon.custom.js:6) You can see it happen here: https://studio.rocketclowns.com/agnes/babylon-test/ Same result in Edge, Chrome and Firefox. Help Edit: I'm on Windows 10 and babylon.js is version 3.2.0. Quote Link to comment Share on other sites More sharing options...
Guest Posted June 21, 2018 Share Posted June 21, 2018 Pinging @davrous Quote Link to comment Share on other sites More sharing options...
davrous Posted June 22, 2018 Share Posted June 22, 2018 Hello, In your code: https://studio.rocketclowns.com/agnes/canvas/rocketLander/main.js?v=201806111547 You're updating the camera position with this code: camera.position.x += ((userX * 256) - camera.position.x) * 0.05; camera.position.y += ((userY * -128) - camera.position.y) * 0.05; But scene.pointerX is a undefined at the beginning when the mouse is out the canvas then the camera.position.x & y become NaN and thus the update Audio parameter function fails. The solution is either to test for undefined on pointerX and pointerY before computing your position or to register your "mousemove" event on the canvas element rather that on the window object. David GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
0l4f Posted June 24, 2018 Author Share Posted June 24, 2018 Hello @davrous, ...awesome, thanks for your reply I changed window.addEventListener("mousemove", function () { to canvas.addEventListener("mousemove", function () { and: problem solved! So: user error and not a babylon.js bug. Maybe this thread can be moved to Q&A? Thanks again, guys ? Olaf davrous 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.