Feat/map-environment #6

Merged
math-pixel merged 116 commits from feat/map-environment into develop 2026-05-29 00:00:51 +00:00
3 changed files with 13 additions and 5 deletions
Showing only changes of commit 2b08665508 - Show all commits
+2 -2
View File
@@ -91,8 +91,8 @@ export function terrainSurfaceUvFromXZ(
): TerrainSurfaceUv {
const width = bounds.maxX - bounds.minX;
const depth = bounds.maxZ - bounds.minZ;
let u = width === 0 ? 0 : (x - bounds.minX) / width;
let v = depth === 0 ? 0 : (z - bounds.minZ) / depth;
let u = width === 0 ? 0 : x / width + 0.5;
let v = depth === 0 ? 0 : z / depth + 0.5;
if (projection?.flipX) {
u = 1 - u;
+5 -1
View File
@@ -62,7 +62,11 @@ function PathDebugPreview({
const instance = instances[i];
if (!instance) continue;
position.set(instance.position[0], 0.08, instance.position[2]);
position.set(
instance.position[0],
instance.position[1] + 0.08,
instance.position[2],
);
matrix.compose(position, quaternion, scale);
instancedMesh.setMatrixAt(i, matrix);
}
+6 -2
View File
@@ -1,5 +1,6 @@
import { useMemo } from "react";
import { TERRAIN_SURFACE_PROJECTION } from "@/data/world/terrainConfig";
import { useTerrainHeightSampler } from "@/hooks/three/useTerrainHeight";
import { useTerrainSurfaceData } from "@/hooks/world/useTerrainSurfaceData";
import type { Vector3Tuple } from "@/types/three/three";
import { sampleTerrainSurfaceAtXZ } from "@/utils/world/terrainSurfaceSampler";
@@ -25,6 +26,7 @@ function createSampleCenters(min: number, max: number, step: number): number[] {
export function usePathTileData(): MapAssetInstance[] {
const terrainSurfaceData = useTerrainSurfaceData();
const terrainHeight = useTerrainHeightSampler();
return useMemo(() => {
if (!terrainSurfaceData) return [];
@@ -55,8 +57,10 @@ export function usePathTileData(): MapAssetInstance[] {
if (sample.key !== PATH_SURFACE_KEY) continue;
const height = terrainHeight.getHeight(x, z) ?? 0;
instances.push({
position: [x, 0, z],
position: [x, height, z],
rotation: [...PATH_TILE_ROTATION] as Vector3Tuple,
scale: [...PATH_TILE_SCALE] as Vector3Tuple,
});
@@ -64,5 +68,5 @@ export function usePathTileData(): MapAssetInstance[] {
}
return instances;
}, [terrainSurfaceData]);
}, [terrainHeight, terrainSurfaceData]);
}