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() + } }) }