fix(map): add world plane collision and respawn

This commit is contained in:
Tom Boullay
2026-05-26 23:52:12 +02:00
parent 0696ca2ae3
commit 665d9f9702
13 changed files with 159 additions and 60 deletions
@@ -0,0 +1,38 @@
import { WORLD_BOUNDS_CONFIG } from "@/data/world/worldBoundsConfig";
export function WorldWallsCollision(): React.JSX.Element | null {
if (!WORLD_BOUNDS_CONFIG.enabled) {
return null;
}
const { center, size, wallHeight, wallThickness } = WORLD_BOUNDS_CONFIG;
const [width, depth] = size;
const wallY = center[1] + wallHeight / 2;
const halfWidth = width / 2;
const halfDepth = depth / 2;
return (
<group name="world-walls-collision">
<mesh position={[center[0], wallY, center[2] - halfDepth]}>
<boxGeometry
args={[width + wallThickness * 2, wallHeight, wallThickness]}
/>
<meshBasicMaterial />
</mesh>
<mesh position={[center[0], wallY, center[2] + halfDepth]}>
<boxGeometry
args={[width + wallThickness * 2, wallHeight, wallThickness]}
/>
<meshBasicMaterial />
</mesh>
<mesh position={[center[0] - halfWidth, wallY, center[2]]}>
<boxGeometry args={[wallThickness, wallHeight, depth]} />
<meshBasicMaterial />
</mesh>
<mesh position={[center[0] + halfWidth, wallY, center[2]]}>
<boxGeometry args={[wallThickness, wallHeight, depth]} />
<meshBasicMaterial />
</mesh>
</group>
);
}