<World>
This component provides the basic physics context and loads rapier.
All components that rely on physics (e.g. <RigidBody> or <Collider>) must be a child of <World>.
Structure
Section titled “Structure”A typical structure of a physics-enabled wrapper component might look like this:
<script lang="ts"> import { Canvas } from '@threlte/core' import { World } from '@threlte/rapier' import Scene from './Scene.svelte'</script>
<Canvas> <World> <Scene /> <!-- Everything is happening inside this component --> </World></Canvas>This structure ensures that all components inside the component <Scene> have access to the physics context.
Fallback
Section titled “Fallback”rapier is a Rust-based physics engine and as such bundled and used as a WASM module. If loading of rapier fails for any reason, a slot with the name fallback is mounted to e.g. display a fallback scene without physics.
<script lang="ts"> import { Canvas } from '@threlte/core' import { World } from '@threlte/rapier' import Scene from './Scene.svelte' import FallbackScene from './FallbackScene.svelte'</script>
<Canvas> <World> <Scene /> {#snippet fallback()} <FallbackScene /> {/snippet} </World></Canvas>