Skip to content

Commit

Permalink
Revert Rapier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Gugustinette committed Jul 6, 2024
1 parent 76a7e4f commit 1ba01c5
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions packages/2d/src/FScene2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,26 @@ export class FScene2d extends FScene {
}

async initPhysics() {
return new Promise<void>((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()
}
})
}

Expand Down

0 comments on commit 1ba01c5

Please sign in to comment.