diff --git a/.changeset/afraid-glasses-carry.md b/.changeset/afraid-glasses-carry.md new file mode 100644 index 00000000..924fb056 --- /dev/null +++ b/.changeset/afraid-glasses-carry.md @@ -0,0 +1,5 @@ +--- +"planck": patch +--- + +Improve world.queueUpdate diff --git a/src/dynamics/World.ts b/src/dynamics/World.ts index 3956b4bb..bd4103a9 100644 --- a/src/dynamics/World.ts +++ b/src/dynamics/World.ts @@ -128,7 +128,7 @@ export class World { /** @internal */ m_positionIterations: number; /** @internal */ m_t: number; - /** @internal */ m_step_callback: ((world: World) => unknown)[] = []; + /** @internal */ m_step_callback: ((world: World) => unknown)[]; // TODO /** @internal */ _listeners: { @@ -186,6 +186,8 @@ export class World { this.m_positionIterations = def.positionIterations; this.m_t = 0; + + this.m_step_callback = []; } /** @internal */ @@ -861,7 +863,7 @@ export class World { this.m_locked = false; let callback: (world: World) => unknown; - while(callback = this.m_step_callback.pop()) { + while(callback = this.m_step_callback.shift()) { callback(this); }