Skip to content

Commit 29fa3e4

Browse files
authored
fix(useRapier): prevent gravity leakage across worlds by passing a copy of the GRAVITY constant (#1469)
1 parent 9c8c6df commit 29fa3e4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

packages/rapier/src/composables/useRapier.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ const [
1919
const RAPIER = await import('@dimforge/rapier3d-compat')
2020
await RAPIER.init()
2121
rapier.value = RAPIER
22-
world.value = new RAPIER.World(GRAVITY)
22+
// Copy: World stores the vector by reference and Physics mutates it in place,
23+
// so passing the shared constant would leak gravity across every world.
24+
world.value = new RAPIER.World({ ...GRAVITY })
2325
}
2426

2527
const setWorld = (w: World) => {

0 commit comments

Comments
 (0)