From 74da9dbabe822ea2406206df00b76b7f77baf0b8 Mon Sep 17 00:00:00 2001 From: Arjun Satarkar Date: Fri, 1 Nov 2024 10:24:28 -0400 Subject: Don't recreate EventQueue every frame --- src/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 059ba68..67e6087 100644 --- a/src/index.js +++ b/src/index.js @@ -62,10 +62,9 @@ RAPIER.init().then(() => { let score = 0; let highScore = score; let lastScoredAt = performance.now(); + const eventQueue = new RAPIER.EventQueue(true); let mainLoop = () => { - let eventQueue = new RAPIER.EventQueue(true); - world.step(eventQueue); eventQueue.drainCollisionEvents((handle1, handle2, started) => { @@ -119,8 +118,6 @@ RAPIER.init().then(() => { objElement.style.width = `${objSize.x}px`; objElement.style.height = `${objSize.y}px`; - eventQueue.free(); - setTimeout(mainLoop, STEP_MS); }; -- cgit v1.2.3-57-g22cb