physicsImpostor.sleep() with ammo.js

It seems physicsImpostor.sleep() not working with ammo.js. Is there any workaround on this?

My racing game using track border planes to define the track limit and the car can not overpass it.
Because the sleep method not working on track change I dispose those plane physicsImpostors and then the new map I create it with the new planes, but
yesterday I realized that sometimes this crashes the game.
This is the error in the console:
D[e[((e[(r >> 2)] + 4) >> 2)]] is not a function.
Do you have any ideas?

I found this topic:

what do you mean with ‘sometimes’? did you find a case where it repros all the time?

Unfortunately it is not clear what causes it, sometimes the error occurs sometimes not. I cannot reproduce it clearly. But if I remove the part of the code that instantiates the physics impostor and the dispose part it never freezes.

These are the lines that cause the issue

plane.physicsImpostor = new PhysicsImpostor(
          { mass: 0, friction: 0.0, restitution: 0.0 },

For me, it would be enough to be able to turn them on/off. Because then I could make them in pre-built and just switch on the ones I need when I change tracks.
Currently, in the 3D world, I move these planes far away so that the player can’t touch them and when I need them, I move them back into position. :smiley: It works perfectly fine, but I would like a nicer solution.

mass = 0, so it’s a static physics entity. it’s not dynamic, so it can’t sleep. There should be a warning instead of a crash but I’m not really surpised here. You should add a check to not put to sleep static impostors.

But how can I turn on/off these planes so that they don’t participate in the simulation if not needed?

If I increase the mass value, the planes can be moved by the player and will fall due to gravity.

these static impostor are part or the map you are trying to create? so I imagine you dispose all static impostor and create new ones?

This is what I did before (before the reposition workaround), but If I recreating the impostors, sometimes I get the error and the game freezes.

Please try to repro in a PG if you can.

I have created a PG, but I can not reproduce. So there is something else that causes the game to freeze when I use together. No idea what is it :frowning:
Here is the PG link:

There are two constant:
• enableStressTest: every 50 frame map change happens, and much more planes in the scene. And even with the quick map change I can’t experience the ammo js problem.

• useSleep: use sleep and wakeUp instead of creating and destroying impostors. Just for recehcking the static physics entity can not be sleep.

So now I don’t know where to look any further. My planes in the game, connecting to each other, maybe this can affect maybe not.
The game has a btRaycast vehicle model, maybe it’s causing the issue somehow.

Maybe you can go the other way around and reduce the scope of your app until the problem disappear.
Sometimes this kind of bug is a side effect of something you would never think of.