Add foliage mask weights to derived terrain mesh data structures

This commit is contained in:
2026-05-02 04:16:09 +02:00
parent c8b21682bb
commit 8997800fd3

View File

@@ -2,6 +2,8 @@ import { BufferAttribute, BufferGeometry } from "three";
import type { Vec3 } from "../core/vector"; import type { Vec3 } from "../core/vector";
import { import {
getTerrainFoliageMask,
getTerrainFoliageMaskValueAtSample,
getTerrainHeightAtSample, getTerrainHeightAtSample,
getTerrainSampleLayerWeights, getTerrainSampleLayerWeights,
TERRAIN_LAYER_COUNT, TERRAIN_LAYER_COUNT,
@@ -22,6 +24,7 @@ export interface DerivedTerrainMeshData {
normals: Float32Array; normals: Float32Array;
uvs: Float32Array; uvs: Float32Array;
layerWeights: Float32Array; layerWeights: Float32Array;
foliageMaskWeights: Float32Array;
indices: Uint32Array; indices: Uint32Array;
cellTriangulation: TerrainCellTriangulation[]; cellTriangulation: TerrainCellTriangulation[];
localBounds: { localBounds: {
@@ -42,6 +45,10 @@ export const TERRAIN_LOD_DEBUG_COLORS = [
const TERRAIN_LOD_DISTANCE_MULTIPLIERS = [0.75, 1.5, 3, 6] as const; const TERRAIN_LOD_DISTANCE_MULTIPLIERS = [0.75, 1.5, 3, 6] as const;
const TERRAIN_LOD_HYSTERESIS_RATIO = 0.16; const TERRAIN_LOD_HYSTERESIS_RATIO = 0.16;
interface TerrainMeshBuildOptions {
foliageMaskLayerId?: string | null;
}
export interface TerrainLodLevelMeshData { export interface TerrainLodLevelMeshData {
level: number; level: number;
stride: number; stride: number;
@@ -50,6 +57,7 @@ export interface TerrainLodLevelMeshData {
normals: Float32Array; normals: Float32Array;
uvs: Float32Array; uvs: Float32Array;
layerWeights: Float32Array; layerWeights: Float32Array;
foliageMaskWeights: Float32Array;
indices: Uint32Array; indices: Uint32Array;
skirtVertexCount: number; skirtVertexCount: number;
} }