From 1c27d55e5a5886de561e618af4515c8a23e56f61 Mon Sep 17 00:00:00 2001 From: Tom Boullay Date: Tue, 26 May 2026 22:06:13 +0200 Subject: [PATCH] feat(map): add terrain boundary collision --- src/data/world/terrainBoundaryConfig.ts | 10 ++++++ src/world/GameMapCollision.tsx | 2 ++ .../collision/TerrainBoundaryCollision.tsx | 36 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/data/world/terrainBoundaryConfig.ts create mode 100644 src/world/collision/TerrainBoundaryCollision.tsx diff --git a/src/data/world/terrainBoundaryConfig.ts b/src/data/world/terrainBoundaryConfig.ts new file mode 100644 index 0000000..c61d66d --- /dev/null +++ b/src/data/world/terrainBoundaryConfig.ts @@ -0,0 +1,10 @@ +import type { Vector3Tuple } from "@/types/three/three"; + +export const TERRAIN_BOUNDARY_CONFIG = { + enabled: true, + center: [-10, 8, -2] as Vector3Tuple, + radius: 135, + height: 28, + thickness: 3, + segments: 48, +}; diff --git a/src/world/GameMapCollision.tsx b/src/world/GameMapCollision.tsx index 2f5d16b..2d5e498 100644 --- a/src/world/GameMapCollision.tsx +++ b/src/world/GameMapCollision.tsx @@ -11,6 +11,7 @@ import * as THREE from "three"; import { useClonedObject } from "@/hooks/three/useClonedObject"; import { useLoggedGLTF } from "@/hooks/three/useLoggedGLTF"; import { useOctreeGraphNode } from "@/hooks/three/useOctreeGraphNode"; +import { TerrainBoundaryCollision } from "@/world/collision/TerrainBoundaryCollision"; import type { MapNode } from "@/types/editor/editor"; import type { OctreeReadyHandler } from "@/types/three/three"; import type { SceneLoadingChangeHandler } from "@/types/world/sceneLoading"; @@ -173,6 +174,7 @@ export function GameMapCollision({ return ( + {mapReady ? : null} {mapReady ? collisionNodes.map((mapNode, index) => ( + + + , + ); + } + + return segments; +} + +export function TerrainBoundaryCollision(): React.JSX.Element | null { + if (!TERRAIN_BOUNDARY_CONFIG.enabled) { + return null; + } + + return <>{createBoundarySegments()}; +}