Why physicsImpostor.physicsBody is undefined?

I made a function to create all physics impostors in one place for all meshes (tell me if you think this is good pattern) and I cant figure out why sometimes physicsImpostor.physicsBody is undefined. It looks as it is somehow asynchronous because when i console.log it in line 24 its undefined and line after when I log physicsImpostor i can get to the value of the body in console. I added if statement and it works and sets the collisionFilterGroup correctly for all 3 impostors but if you remove line 27 the code will crash.
Here is the playground demo

I also tried to clone physics impostor then I clone the mesh in line 48 by passing true as 4th parameter but this doesn’t seem to work. Would be handy :grin:

thanks in advance

Hi KW… just wanted to ring-in, and say I THINK I saw a similar problem earlier today… in CannonJS… where BJSSomeJoint.physicsJoint… was missing. I was going to comment to @Givo’s thread, but my symptom was different from his, and I was not using Ammo.

I was also trying to use parenting and .ignoreParent and all sorts of other dangerous stuff… so I thought maybe it was me. There is a warning that happens about parenting, and some comments in the code about “We don’t init this physicsImpostor because it has a parent. Wait for parent to init, instead.” (approx).

Anyway, just wanted to tell my story, too. It may be pertinent to your situation.

I’ve been working in Cannon for about 2 hours now… no problems seen, but I’m not playing with parenting anymore. Anyone know if work is happening on the BJS impostor class or other related areas?