summaryrefslogtreecommitdiff
path: root/src/index.js
diff options
context:
space:
mode:
authorArjun Satarkar <me@arjunsatarkar.net>2024-11-01 14:24:28 +0000
committerArjun Satarkar <me@arjunsatarkar.net>2024-11-01 14:24:28 +0000
commit74da9dbabe822ea2406206df00b76b7f77baf0b8 (patch)
treedebb56285ff660794cb130a5a8e71915b3c86b16 /src/index.js
parenta3f597a5d39baeabff948d1cd13cfc3915fc4980 (diff)
downloadthrow_simulation-74da9dbabe822ea2406206df00b76b7f77baf0b8.tar
throw_simulation-74da9dbabe822ea2406206df00b76b7f77baf0b8.tar.gz
throw_simulation-74da9dbabe822ea2406206df00b76b7f77baf0b8.zip
Don't recreate EventQueue every frame
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js5
1 files changed, 1 insertions, 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);
};