Uncaught TypeError: bi is undefined cannon.js:13514:12

I have multiple objects in my scene and I use

bricks.forEach(i=>{
i.physicsImpostor.onCollideEvent = async function(brick,t) {
if(t.object.name==‘box’){
//some actions
}
})

everything worked until at one moment there was a simultaneous collision of a box with two bricks.

there was an error
Uncaught TypeError: bi is undefined cannon.js:13514:12

is there a way to avoid this problem?

PS
I created the scene, but I can’t repeat the error

Apparently I’m getting this error because I’m using
mesh.dispose() during collision.

as a temporary solution i used

engine.runRenderLoop(function() {
try {glob_scene.render()}
catch(err) {console.log(err.message)}

});

I guess a better solution is to dispose one frame after? a very naive approach would be to do something like this:

scene.onBeforeRenderObservable.addOnce(() => {
  mesh.dispose()
});

Hello @kostiunindima1 just checking in, was your question answered?

1 Like