From 1ba01c5de4e7a29fe31b8bd7225e57f17248e1e2 Mon Sep 17 00:00:00 2001 From: Gugustinette Date: Sat, 6 Jul 2024 21:04:35 +0200 Subject: [PATCH] Revert Rapier fix --- packages/2d/src/FScene2d.ts | 43 ++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/packages/2d/src/FScene2d.ts b/packages/2d/src/FScene2d.ts index 34a695ee..9837ca2f 100644 --- a/packages/2d/src/FScene2d.ts +++ b/packages/2d/src/FScene2d.ts @@ -123,31 +123,26 @@ export class FScene2d extends FScene { } async initPhysics() { - return new Promise((resolve) => { - // Import Rapier - import('@dimforge/rapier2d').then((RAPIER) => { - // Initialize Rapier world - this.world = new RAPIER.World(this.gravity) - - // Create the ground - const ground = new FSquare(this) - ground.setPosition(0, 0) - ground.setScale(10, 0.1) - ground.initCollider() - this.addComponent(ground) - - // onFrame - this.onFrame((delta) => { - // Physics - if (this.world) { - this.world.timestep = delta - this.world.step() - } - }) + // Import Rapier + const RAPIER = await import('@dimforge/rapier2d') - // Resolve the promise - resolve() - }) + // Initialize Rapier world + this.world = new RAPIER.World(this.gravity) + + // Create the ground + const ground = new FSquare(this) + ground.setPosition(0, 0) + ground.setScale(10, 0.1) + ground.initCollider() + this.addComponent(ground) + + // onFrame + this.onFrame((delta) => { + // Physics + if (this.world) { + this.world.timestep = delta + this.world.step() + } }) }