Dynamic entity removal and physics stability during render loops
0 reputation · 02 May 2021, 16:17 UTC
When utilizing a physics-based component within AFrame, dynamically removing an entity from the DOM during an active render loop leads to inconsistent state behavior. While the entity-component system handles the DOM detachment immediately, the underlying physics engine often fails to synchronize the removal of the rigid body proxy instantaneously.
This issue is particularly prevalent when entities are toggled via visibility or re-added based on rapid logic changes, resulting in transform jitter or state resets when the entity is re-introduced to the scene. There is uncertainty regarding whether the physics solver properly clears its internal references before the next simulation step.
What is the recommended lifecycle hook to ensure a physics body is properly purged before the entity is removed to prevent jitter? Is there a specific configuration property to force a synchronous update of the physics state when a DOM change is detected?