I’ve been looking to add collision to a mesh entity that can change its scale which as I understand is not synced? So I thought as a quick workaround I’d remove the collision component on scale change and re add it. This seems to work but after a minute or so I get an out of memory exception from ammosjs suggesting that remove collision component does not free up the reference on ammo js.
yeah just had a look at the code, I can see theres an internal event for “onInsert” but nothing regarding to onRemove so basically it appears that adding collision just leaks memory
Not sure what is causing OOM here. A small repro project would help. What are those addCollision(x, { type: "mesh" })?
If you disable an entity or remove the collision component, then the rigidbody and its collision mesh is destroyed in the physics world. onInsert is related to inserting compound children to a parent. The safest option is to disable the entity, do your changes, then enable it. A repro project would be nice.