调整植被生成为指定模式

This commit is contained in:
2026-03-26 11:06:07 +08:00
parent df6d78236d
commit 2061e97d5c
2 changed files with 248 additions and 93 deletions

View File

@@ -310,11 +310,40 @@ export class OceanScene {
async initVegetation() {
const vegSystem = new VegetationSystem(this.terrainGenerator, {
grassCount: 28000, // 草簇数量,越大地表覆盖越密
shrubCount: 12, // 灌木和低矮植物数量
treeCount: 9, // 树木数量
terrainSize: 1200, // 植被允许分布的地形范围
waterLevel: 1 // 植被生成时参考的水位,避免贴近海边
grassCount: 0, // 随机草簇数量,设为 0 时只使用 grassAreas
shrubCount: 0, // 随机灌木数量,设为 0 时只使用 shrubPlacements
lowPlantCount: 0, // 随机低矮植物数量,设为 0 时只使用 lowPlantPlacements
treeCount: 0, // 随机树木数量,设为 0 时只使用 treePlacements
terrainSize: 1200, // 随机植被允许分布的地形范围
waterLevel: 1, // 植被生成时参考的水位,避免贴近海边
treePlacements: [ // 手动指定树木坐标
{ x: -180, z: -120, rotation: 0.4, scale: 1.6 },
{ x: -120, z: -40, rotation: 1.2, scale: 1.35 },
// { x: -40, z: -150, rotation: 2.1, scale: 1.75 },
// { x: 70, z: -70, rotation: 2.8, scale: 1.45 },
// { x: 135, z: 15, rotation: 4.1, scale: 1.55 },
// { x: 30, z: 120, rotation: 5.2, scale: 1.7 }
],
shrubPlacements: [ // 手动指定灌木坐标
{ x: -210, z: -65, rotation: 0.3, scale: 1.05 },
{ x: -195, z: -75, rotation: 1.4, scale: 0.95 },
// { x: -20, z: -95, rotation: 2.2, scale: 1.1 },
// { x: 55, z: -5, rotation: 3.6, scale: 0.9 },
// { x: 150, z: -55, rotation: 4.5, scale: 1.15 },
// { x: 185, z: 75, rotation: 5.4, scale: 1.0 }
],
lowPlantPlacements: [ // 手动指定低矮植物坐标
{ x: -235, z: -20, rotation: 0.6, scale: 0.58 },
{ x: -205, z: 15, rotation: 1.8, scale: 0.52 },
// { x: -10, z: -20, rotation: 2.7, scale: 0.48 },
// { x: 82, z: -132, rotation: 3.4, scale: 0.62 },
// { x: 118, z: 58, rotation: 4.2, scale: 0.56 },
// { x: 225, z: 18, rotation: 5.1, scale: 0.6 }
],
grassAreas: [ // 手动指定草簇生成区域
{ centerX: -140, centerZ: -10, width: 220, depth: 170, count: 4200 },
{ centerX: 110, centerZ: 65, width: 210, depth: 160, count: 3800 }
]
});
this.vegetation = vegSystem.generate();