webgpu-biome 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +89 -2
- package/lib/canopy.d.ts +75 -0
- package/lib/canopy.d.ts.map +1 -0
- package/lib/canopy.js +295 -0
- package/lib/canopy.js.map +1 -0
- package/lib/climate.d.ts +68 -0
- package/lib/climate.d.ts.map +1 -0
- package/lib/climate.js +105 -0
- package/lib/climate.js.map +1 -0
- package/lib/detail.d.ts +55 -0
- package/lib/detail.d.ts.map +1 -0
- package/lib/detail.js +225 -0
- package/lib/detail.js.map +1 -0
- package/lib/ecotone.d.ts +166 -0
- package/lib/ecotone.d.ts.map +1 -0
- package/lib/ecotone.js +1007 -0
- package/lib/ecotone.js.map +1 -0
- package/lib/engine.d.ts +102 -0
- package/lib/engine.d.ts.map +1 -0
- package/lib/engine.js +773 -0
- package/lib/engine.js.map +1 -0
- package/lib/epiphytes.d.ts +19 -0
- package/lib/epiphytes.d.ts.map +1 -0
- package/lib/epiphytes.js +180 -0
- package/lib/epiphytes.js.map +1 -0
- package/lib/ground.d.ts +43 -0
- package/lib/ground.d.ts.map +1 -0
- package/lib/ground.js +450 -0
- package/lib/ground.js.map +1 -0
- package/lib/horizon.d.ts +20 -0
- package/lib/horizon.d.ts.map +1 -0
- package/lib/horizon.js +625 -0
- package/lib/horizon.js.map +1 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/particles.d.ts +12 -0
- package/lib/particles.d.ts.map +1 -0
- package/lib/particles.js +124 -0
- package/lib/particles.js.map +1 -0
- package/lib/post.d.ts +23 -0
- package/lib/post.d.ts.map +1 -0
- package/lib/post.js +225 -0
- package/lib/post.js.map +1 -0
- package/lib/recipe-specs.d.ts +51 -0
- package/lib/recipe-specs.d.ts.map +1 -0
- package/lib/recipe-specs.js +562 -0
- package/lib/recipe-specs.js.map +1 -0
- package/lib/recipes.d.ts +9 -0
- package/lib/recipes.d.ts.map +1 -0
- package/lib/recipes.js +279 -0
- package/lib/recipes.js.map +1 -0
- package/lib/sandbox.d.ts +183 -0
- package/lib/sandbox.d.ts.map +1 -0
- package/lib/sandbox.js +1060 -0
- package/lib/sandbox.js.map +1 -0
- package/lib/shadows.d.ts +71 -0
- package/lib/shadows.d.ts.map +1 -0
- package/lib/shadows.js +532 -0
- package/lib/shadows.js.map +1 -0
- package/lib/sky.d.ts +16 -0
- package/lib/sky.d.ts.map +1 -0
- package/lib/sky.js +132 -0
- package/lib/sky.js.map +1 -0
- package/lib/substrate.d.ts +124 -0
- package/lib/substrate.d.ts.map +1 -0
- package/lib/substrate.js +988 -0
- package/lib/substrate.js.map +1 -0
- package/lib/turf.d.ts +60 -0
- package/lib/turf.d.ts.map +1 -0
- package/lib/turf.js +278 -0
- package/lib/turf.js.map +1 -0
- package/lib/water.d.ts +41 -0
- package/lib/water.d.ts.map +1 -0
- package/lib/water.js +210 -0
- package/lib/water.js.map +1 -0
- package/package.json +63 -3
package/lib/ecotone.js
ADDED
|
@@ -0,0 +1,1007 @@
|
|
|
1
|
+
// Declarative ecological niche solver: places overstory trees and shrub mantles
|
|
2
|
+
// from terrain/edaphic suitability, bakes canopy shelter & litter, and resolves
|
|
3
|
+
// continuous turf species & bare ground (`NO_GRASS`) masks.
|
|
4
|
+
//
|
|
5
|
+
// Pure TypeScript + `webgpu-trees` math so `node --test` verifies ecology headlessly.
|
|
6
|
+
import { TREE_STRIDE, lifeStageSizes } from "webgpu-trees";
|
|
7
|
+
import { bakeCanopyCpu, sampleCanopyCpu } from "./canopy.js";
|
|
8
|
+
import { ALL_FLORA_SPECIES, FLORA_STRIDE, scatterFlora } from "webgpu-flora";
|
|
9
|
+
import { ALL_ROCK_SPECIES, ROCK_STRIDE, scatterRocks } from "webgpu-rocks";
|
|
10
|
+
import { applyRootHeaveMounds, deriveLitterSoil, sampleSubstrateCpu } from "./substrate.js";
|
|
11
|
+
import { buildTurfSuppression, classifyTurf, createShrubHaloField } from "./turf.js";
|
|
12
|
+
import { placeEpiphytes } from "./epiphytes.js";
|
|
13
|
+
/** Constant matching `NO_GRASS` in `webgpu-grass`. */
|
|
14
|
+
export const BARE_GROUND = 255;
|
|
15
|
+
function hash01(index, seed) {
|
|
16
|
+
let h = Math.imul(index ^ seed, 0x9e3779b1) >>> 0;
|
|
17
|
+
h ^= h >>> 16;
|
|
18
|
+
h = Math.imul(h, 0x7feb352d) >>> 0;
|
|
19
|
+
h ^= h >>> 15;
|
|
20
|
+
h = Math.imul(h, 0x846ca68b) >>> 0;
|
|
21
|
+
h ^= h >>> 16;
|
|
22
|
+
return (h >>> 0) / 4294967296;
|
|
23
|
+
}
|
|
24
|
+
function clamp01(v) {
|
|
25
|
+
return v < 0 ? 0 : v > 1 ? 1 : v;
|
|
26
|
+
}
|
|
27
|
+
function smoothstepNum(e0, e1, x) {
|
|
28
|
+
const t = clamp01((x - e0) / Math.max(1e-5, e1 - e0));
|
|
29
|
+
return t * t * (3 - 2 * t);
|
|
30
|
+
}
|
|
31
|
+
const CLONAL_CARPET_SPECIES = new Set([
|
|
32
|
+
"heather",
|
|
33
|
+
"bellHeather",
|
|
34
|
+
"crowberry",
|
|
35
|
+
"bilberry",
|
|
36
|
+
"bracken",
|
|
37
|
+
"ramsons",
|
|
38
|
+
"woodAnemone",
|
|
39
|
+
"bluebell",
|
|
40
|
+
"woodSorrel",
|
|
41
|
+
"cistusScrub",
|
|
42
|
+
"forestSedge",
|
|
43
|
+
"cottonGrassTussock",
|
|
44
|
+
"cloudberry",
|
|
45
|
+
]);
|
|
46
|
+
function bandScore(v, range, pad) {
|
|
47
|
+
if (!range)
|
|
48
|
+
return 1;
|
|
49
|
+
const [lo, hi] = range;
|
|
50
|
+
if (v >= lo && v <= hi)
|
|
51
|
+
return 1;
|
|
52
|
+
if (v < lo)
|
|
53
|
+
return Math.max(0, 1 - (lo - v) / Math.max(1e-4, pad));
|
|
54
|
+
return Math.max(0, 1 - (v - hi) / Math.max(1e-4, pad));
|
|
55
|
+
}
|
|
56
|
+
/** Smooth trapezoidal ecological suitability score in `[0, 1]`. */
|
|
57
|
+
export function nicheScore(env, sample) {
|
|
58
|
+
if (env.maxSlopeDeg !== undefined && sample.slopeDeg > env.maxSlopeDeg)
|
|
59
|
+
return 0;
|
|
60
|
+
if (env.minSlopeDeg !== undefined && sample.slopeDeg < env.minSlopeDeg)
|
|
61
|
+
return 0;
|
|
62
|
+
const sMaxSlope = env.maxSlopeDeg !== undefined && sample.slopeDeg > env.maxSlopeDeg * 0.85
|
|
63
|
+
? Math.max(0, 1 - (sample.slopeDeg - env.maxSlopeDeg * 0.85) / Math.max(1, env.maxSlopeDeg * 0.15))
|
|
64
|
+
: 1;
|
|
65
|
+
const sMinSlope = env.minSlopeDeg !== undefined && sample.slopeDeg < env.minSlopeDeg * 1.15
|
|
66
|
+
? Math.max(0, (sample.slopeDeg - env.minSlopeDeg) / Math.max(1, env.minSlopeDeg * 0.15))
|
|
67
|
+
: 1;
|
|
68
|
+
return (sMaxSlope *
|
|
69
|
+
sMinSlope *
|
|
70
|
+
bandScore(sample.light, env.light, 0.18) *
|
|
71
|
+
bandScore(sample.moisture, env.moisture, 0.2) *
|
|
72
|
+
bandScore(sample.soilPh, env.soilPh, 0.18) *
|
|
73
|
+
bandScore(sample.fertility, env.fertility, 0.2) *
|
|
74
|
+
bandScore(sample.elevation, env.elevation, 4) *
|
|
75
|
+
bandScore(sample.exposure, env.exposure, 0.22));
|
|
76
|
+
}
|
|
77
|
+
/** Continuous per-tree edaphic foliar tint (`[r, g, b]` linear, `3 * treeCount`) from local moisture, fertility, pH, & exposure. */
|
|
78
|
+
export function computeTreeEdaphicTints(trees, treeCount, effectiveSubstrate) {
|
|
79
|
+
const treeTints = new Float32Array(treeCount * 3);
|
|
80
|
+
for (let t = 0; t < treeCount; t++) {
|
|
81
|
+
const tx = trees[t * TREE_STRIDE];
|
|
82
|
+
const tz = trees[t * TREE_STRIDE + 2];
|
|
83
|
+
const es = sampleSubstrateCpu(effectiveSubstrate, tx, tz);
|
|
84
|
+
const wetLush = smoothstepNum(0.48, 0.86, es.moisture) * (0.45 + 0.55 * es.fertility);
|
|
85
|
+
const dryParched = smoothstepNum(0.44, 0.12, es.moisture) * (0.4 + 0.6 * es.exposure);
|
|
86
|
+
const acidic = smoothstepNum(0.4, 0.16, es.soilPh);
|
|
87
|
+
const r = 1.0 - 0.14 * wetLush + 0.15 * dryParched + 0.05 * acidic;
|
|
88
|
+
const g = 1.0 + 0.08 * wetLush - 0.01 * dryParched - 0.04 * acidic;
|
|
89
|
+
const b = 1.0 - 0.05 * wetLush - 0.22 * dryParched - 0.11 * acidic;
|
|
90
|
+
treeTints[t * 3] = Math.min(1.35, Math.max(0.65, r));
|
|
91
|
+
treeTints[t * 3 + 1] = Math.min(1.25, Math.max(0.75, g));
|
|
92
|
+
treeTints[t * 3 + 2] = Math.min(1.2, Math.max(0.6, b));
|
|
93
|
+
}
|
|
94
|
+
return treeTints;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Solve overstory trees, canopy feedback fields, and turf/forest-floor species grid
|
|
98
|
+
* from terrain `substrate` and declarative `EcotoneRules`.
|
|
99
|
+
*/
|
|
100
|
+
export function solveBiomeStrata(opts) {
|
|
101
|
+
const { substrate, rules, treeSpecies } = opts;
|
|
102
|
+
const seed = opts.seed ?? 1337;
|
|
103
|
+
const spByName = new Map();
|
|
104
|
+
for (let i = 0; i < treeSpecies.length; i++)
|
|
105
|
+
spByName.set(treeSpecies[i].name, i);
|
|
106
|
+
for (const g of rules.overstory) {
|
|
107
|
+
if (!spByName.has(g.speciesName)) {
|
|
108
|
+
throw new Error(`Unknown tree species "${g.speciesName}" in EcotoneRules`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// ---- Stage 0.5: Geological bedrock, cliffs, talus & boulders (`webgpu-rocks`) ----
|
|
112
|
+
let rocks = new Float32Array(0);
|
|
113
|
+
let rockCount = 0;
|
|
114
|
+
let rockCoverGrid = null;
|
|
115
|
+
let haloGrid = null;
|
|
116
|
+
let rockNx = 0;
|
|
117
|
+
let rockNz = 0;
|
|
118
|
+
let rockCell = 1;
|
|
119
|
+
if (rules.rocks && rules.rocks.length > 0) {
|
|
120
|
+
const rockById = new Map();
|
|
121
|
+
for (let i = 0; i < ALL_ROCK_SPECIES.length; i++)
|
|
122
|
+
rockById.set(ALL_ROCK_SPECIES[i].id, i);
|
|
123
|
+
const rockRules = rules.rocks.map((rg) => {
|
|
124
|
+
const spIdx = rockById.get(rg.speciesId);
|
|
125
|
+
if (spIdx === undefined) {
|
|
126
|
+
throw new Error(`Unknown rock species "${rg.speciesId}" in EcotoneRules`);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
speciesIndex: spIdx,
|
|
130
|
+
mode: rg.mode,
|
|
131
|
+
spacing: rg.spacing,
|
|
132
|
+
colonyRadius: rg.colonyRadius,
|
|
133
|
+
scaleRange: rg.scaleRange,
|
|
134
|
+
suppressesTurf: rg.suppressesTurf,
|
|
135
|
+
suitability(s) {
|
|
136
|
+
if (rules.pathFn && rules.pathFn(s.x, s.z) === "mown")
|
|
137
|
+
return 0;
|
|
138
|
+
if (rules.waterLevel !== undefined && s.height < rules.waterLevel - (rg.mode === "streambed" ? 0.65 : 0.15))
|
|
139
|
+
return 0;
|
|
140
|
+
if (rules.waterLevel !== undefined && rg.mode === "streambed" && s.height > rules.waterLevel + 0.35)
|
|
141
|
+
return 0;
|
|
142
|
+
if (rg.minConcavity !== undefined && s.concavity < rg.minConcavity)
|
|
143
|
+
return 0;
|
|
144
|
+
if (rg.maxConcavity !== undefined && s.concavity > rg.maxConcavity)
|
|
145
|
+
return 0;
|
|
146
|
+
return (rg.weight *
|
|
147
|
+
nicheScore(rg.niche, {
|
|
148
|
+
light: 1,
|
|
149
|
+
moisture: s.moisture,
|
|
150
|
+
soilPh: s.soilPh,
|
|
151
|
+
fertility: s.fertility,
|
|
152
|
+
elevation: s.height,
|
|
153
|
+
slopeDeg: s.slopeDeg,
|
|
154
|
+
exposure: s.exposure,
|
|
155
|
+
}));
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
const scatteredRocks = scatterRocks({
|
|
160
|
+
x0: substrate.x0,
|
|
161
|
+
z0: substrate.z0,
|
|
162
|
+
width: substrate.width,
|
|
163
|
+
depth: substrate.depth,
|
|
164
|
+
maxInstances: rules.maxRocks ?? 1800,
|
|
165
|
+
seed: seed + 313,
|
|
166
|
+
species: ALL_ROCK_SPECIES,
|
|
167
|
+
rules: rockRules,
|
|
168
|
+
sampleAt(x, z) {
|
|
169
|
+
const sub = sampleSubstrateCpu(substrate, x, z);
|
|
170
|
+
return {
|
|
171
|
+
x,
|
|
172
|
+
z,
|
|
173
|
+
height: sub.height,
|
|
174
|
+
normalX: sub.normal[0],
|
|
175
|
+
normalY: sub.normal[1],
|
|
176
|
+
normalZ: sub.normal[2],
|
|
177
|
+
slopeDeg: sub.slopeDeg,
|
|
178
|
+
concavity: sub.concavity,
|
|
179
|
+
moisture: sub.moisture,
|
|
180
|
+
soilPh: sub.soilPh,
|
|
181
|
+
fertility: sub.fertility,
|
|
182
|
+
exposure: sub.exposure,
|
|
183
|
+
};
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
rocks = scatteredRocks.instances;
|
|
187
|
+
rockCount = scatteredRocks.count;
|
|
188
|
+
rockCoverGrid = scatteredRocks.rockCoverGrid;
|
|
189
|
+
haloGrid = scatteredRocks.haloGrid;
|
|
190
|
+
rockNx = scatteredRocks.gridNx;
|
|
191
|
+
rockNz = scatteredRocks.gridNz;
|
|
192
|
+
rockCell = scatteredRocks.gridCell;
|
|
193
|
+
}
|
|
194
|
+
const sampleRockMask = (x, z) => {
|
|
195
|
+
if (!rockCoverGrid || !haloGrid)
|
|
196
|
+
return { covered: false, halo: 0 };
|
|
197
|
+
const ri = Math.min(rockNx - 1, Math.max(0, Math.floor((x - substrate.x0) / rockCell)));
|
|
198
|
+
const rj = Math.min(rockNz - 1, Math.max(0, Math.floor((z - substrate.z0) / rockCell)));
|
|
199
|
+
const idx = rj * rockNx + ri;
|
|
200
|
+
return { covered: rockCoverGrid[idx] === 1, halo: haloGrid[idx] };
|
|
201
|
+
};
|
|
202
|
+
const tooCloseToRock = (x, z) => {
|
|
203
|
+
if (sampleRockMask(x, z).covered)
|
|
204
|
+
return true;
|
|
205
|
+
for (let i = 0; i < rockCount; i++) {
|
|
206
|
+
const o = i * ROCK_STRIDE;
|
|
207
|
+
const rx = rocks[o];
|
|
208
|
+
const rz = rocks[o + 2];
|
|
209
|
+
const minR = rocks[o + 5] * 0.65;
|
|
210
|
+
if ((x - rx) * (x - rx) + (z - rz) * (z - rz) < minR * minR)
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
return false;
|
|
214
|
+
};
|
|
215
|
+
// Shrub & sapling collar field (turf.ts) so heather, cistus, ferns & tall tussocks nestle round shrub bases.
|
|
216
|
+
const shrubHalo = createShrubHaloField(substrate);
|
|
217
|
+
const stampShrubHalo = shrubHalo.stamp;
|
|
218
|
+
const sampleShrubHalo = shrubHalo.sample;
|
|
219
|
+
// ---- Stage 1: Hierarchical Multi-Age Groves, Mantle Skirts & Swept Glades ----
|
|
220
|
+
const domainMinSide = Math.min(substrate.width, substrate.depth);
|
|
221
|
+
const gladeBlend = smoothstepNum(140, 230, domainMinSide);
|
|
222
|
+
// Larger domains space primary founder checks wider while nucleating multi-age cohorts around mother trees.
|
|
223
|
+
const spacing = Math.max(1.5, rules.treeSpacing * (1 + 0.35 * gladeBlend));
|
|
224
|
+
const cols = Math.max(1, Math.floor(substrate.width / spacing));
|
|
225
|
+
const rows = Math.max(1, Math.floor(substrate.depth / spacing));
|
|
226
|
+
const placed = [];
|
|
227
|
+
const placedRoles = [];
|
|
228
|
+
const placedCollars = [];
|
|
229
|
+
// Multi-nucleus domain-warped grove field leaving 35-90 m swept open glades between structured multi-age groves.
|
|
230
|
+
const groveCellM = 62;
|
|
231
|
+
const evalGroveField = (x, z, concavity) => {
|
|
232
|
+
if (gladeBlend <= 0.01)
|
|
233
|
+
return 1;
|
|
234
|
+
const wx = x + 9.5 * Math.sin(z * 0.032 + x * 0.019) + 4.2 * Math.cos(x * 0.068 - z * 0.052);
|
|
235
|
+
const wz = z + 9.5 * Math.cos(x * 0.029 - z * 0.021) + 4.2 * Math.sin(z * 0.064 + x * 0.048);
|
|
236
|
+
const gx0 = Math.floor(wx / groveCellM);
|
|
237
|
+
const gz0 = Math.floor(wz / groveCellM);
|
|
238
|
+
let best = 0;
|
|
239
|
+
for (let dz = -1; dz <= 1; dz++) {
|
|
240
|
+
for (let dx = -1; dx <= 1; dx++) {
|
|
241
|
+
const ix = gx0 + dx;
|
|
242
|
+
const iz = gz0 + dz;
|
|
243
|
+
const hCell = (Math.imul(ix, 73856093) ^ Math.imul(iz, 19349663) ^ Math.imul(seed + 409, 83492791)) >>> 0;
|
|
244
|
+
// ~46% of 62 m macro-cells host active woodland groves, preserving genuine open glades & blowouts.
|
|
245
|
+
if (hash01(hCell, seed + 419) > 0.46)
|
|
246
|
+
continue;
|
|
247
|
+
const cx = (ix + 0.2 + 0.6 * hash01(hCell, seed + 431)) * groveCellM;
|
|
248
|
+
const cz = (iz + 0.2 + 0.6 * hash01(hCell, seed + 443)) * groveCellM;
|
|
249
|
+
const reach = 21 + 14 * hash01(hCell, seed + 457);
|
|
250
|
+
const dist = Math.hypot(wx - cx, wz - cz);
|
|
251
|
+
if (dist < reach * 1.45) {
|
|
252
|
+
const val = Math.exp(-((dist / reach) ** 2) * 1.32);
|
|
253
|
+
if (val > best)
|
|
254
|
+
best = val;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const shelterBias = clamp01(best + clamp01(concavity * 0.16) * 0.18);
|
|
259
|
+
return 1 + (shelterBias - 1) * gladeBlend;
|
|
260
|
+
};
|
|
261
|
+
// Spatial grid to prevent unnatural overlapping trunks while allowing dense woods.
|
|
262
|
+
const guardCell = 4;
|
|
263
|
+
const buckets = new Map();
|
|
264
|
+
const canPlace = (x, z, crownR, isMantle, cohortFactor = 0.68) => {
|
|
265
|
+
const cx = Math.floor(x / guardCell);
|
|
266
|
+
const cz = Math.floor(z / guardCell);
|
|
267
|
+
const minFactor = isMantle ? Math.min(0.52, cohortFactor) : cohortFactor;
|
|
268
|
+
for (let dz = -3; dz <= 3; dz++) {
|
|
269
|
+
for (let dx = -3; dx <= 3; dx++) {
|
|
270
|
+
const list = buckets.get(`${cx + dx},${cz + dz}`);
|
|
271
|
+
if (!list)
|
|
272
|
+
continue;
|
|
273
|
+
for (const idx of list) {
|
|
274
|
+
const o = idx * TREE_STRIDE;
|
|
275
|
+
const ox = placed[o];
|
|
276
|
+
const oz = placed[o + 2];
|
|
277
|
+
const or = placed[o + 5];
|
|
278
|
+
if (Math.hypot(x - ox, z - oz) < minFactor * (crownR + or))
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return true;
|
|
284
|
+
};
|
|
285
|
+
const totalCells = rows * cols;
|
|
286
|
+
const order = new Uint32Array(totalCells);
|
|
287
|
+
for (let i = 0; i < totalCells; i++)
|
|
288
|
+
order[i] = i;
|
|
289
|
+
order.sort((a, b) => {
|
|
290
|
+
const ha = hash01(a, seed + 7);
|
|
291
|
+
const hb = hash01(b, seed + 7);
|
|
292
|
+
return ha !== hb ? ha - hb : a - b;
|
|
293
|
+
});
|
|
294
|
+
const mantleGuilds = rules.overstory.filter((g) => g.role === "mantle");
|
|
295
|
+
const sizeForStage = (sp, role, scaleRange, stageIdx, sub, uMult) => {
|
|
296
|
+
const stages = lifeStageSizes(sp);
|
|
297
|
+
const baseSize = stages[Math.min(stages.length - 1, Math.max(0, stageIdx))].size;
|
|
298
|
+
const mult = scaleRange ? scaleRange[0] + uMult * (scaleRange[1] - scaleRange[0]) : 0.88 + uMult * 0.24;
|
|
299
|
+
const isMantle = role === "mantle";
|
|
300
|
+
const isPalm = sp.architecture === "palm";
|
|
301
|
+
const isSapling = !isMantle && stageIdx === 0;
|
|
302
|
+
const isYoung = !isMantle && stageIdx === 1;
|
|
303
|
+
let h = baseSize.height * mult;
|
|
304
|
+
let cr = baseSize.crownRadius * mult;
|
|
305
|
+
let cb = Math.min(h * 0.72, baseSize.crownBase * mult);
|
|
306
|
+
let tr = baseSize.trunkRadius * mult;
|
|
307
|
+
if (isMantle) {
|
|
308
|
+
h = baseSize.height * mult * (0.68 + 0.2 * (1 - sub.exposure));
|
|
309
|
+
cr = baseSize.crownRadius * mult * 1.24;
|
|
310
|
+
cb = Math.min(h * 0.1, baseSize.crownBase * mult * 0.2);
|
|
311
|
+
}
|
|
312
|
+
else if (isSapling) {
|
|
313
|
+
if (isPalm) {
|
|
314
|
+
h = Math.max(2.3, baseSize.height * mult * 0.88);
|
|
315
|
+
cr = baseSize.crownRadius * mult * 1.12;
|
|
316
|
+
cb = Math.max(0.42, h * 0.24);
|
|
317
|
+
tr = Math.min(baseSize.trunkRadius * mult * 0.52, cr * 0.13);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
h = baseSize.height * mult * 0.88;
|
|
321
|
+
cr = Math.max(baseSize.crownRadius * mult * 1.5, h * 0.45);
|
|
322
|
+
cb = Math.min(h * 0.09, 0.2);
|
|
323
|
+
tr = baseSize.trunkRadius * mult * 1.15;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else if (isYoung) {
|
|
327
|
+
if (isPalm) {
|
|
328
|
+
h = baseSize.height * mult * 0.9;
|
|
329
|
+
cr = baseSize.crownRadius * mult * 1.18;
|
|
330
|
+
cb = Math.min(h * 0.36, baseSize.crownBase * mult * 0.62);
|
|
331
|
+
tr = baseSize.trunkRadius * mult * 1.22;
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
h = baseSize.height * mult;
|
|
335
|
+
cr = Math.max(baseSize.crownRadius * mult * 1.32, h * 0.38);
|
|
336
|
+
cb = Math.min(h * (0.14 + 0.08 * (1 - sub.exposure)), baseSize.crownBase * mult * 0.52);
|
|
337
|
+
tr = baseSize.trunkRadius * mult * 1.1;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return { h, cr, cb, tr, isMantle, isPalm, isSapling };
|
|
341
|
+
};
|
|
342
|
+
for (let oi = 0; oi < totalCells && placed.length / TREE_STRIDE < rules.maxTrees; oi++) {
|
|
343
|
+
const cellId = order[oi];
|
|
344
|
+
const r = Math.floor(cellId / cols);
|
|
345
|
+
const c = cellId - r * cols;
|
|
346
|
+
const jx = (hash01(cellId, seed + 11) - 0.5) * 0.85;
|
|
347
|
+
const jz = (hash01(cellId, seed + 23) - 0.5) * 0.85;
|
|
348
|
+
const x = substrate.x0 + (c + 0.5 + jx) * spacing;
|
|
349
|
+
const z = substrate.z0 + (r + 0.5 + jz) * spacing;
|
|
350
|
+
if (rules.pathFn && rules.pathFn(x, z) !== null)
|
|
351
|
+
continue;
|
|
352
|
+
if (tooCloseToRock(x, z))
|
|
353
|
+
continue;
|
|
354
|
+
const sub = sampleSubstrateCpu(substrate, x, z);
|
|
355
|
+
if (rules.waterLevel !== undefined && sub.height < rules.waterLevel + 0.08)
|
|
356
|
+
continue;
|
|
357
|
+
const grove = evalGroveField(x, z, sub.concavity);
|
|
358
|
+
const isGlade = gladeBlend > 0.05 && grove < 0.28;
|
|
359
|
+
const isEdgeBelt = gladeBlend > 0.05 && grove >= 0.26 && grove <= 0.58;
|
|
360
|
+
const isGroveCore = gladeBlend > 0.05 && grove > 0.56;
|
|
361
|
+
let total = 0;
|
|
362
|
+
const candidates = [];
|
|
363
|
+
for (const guild of rules.overstory) {
|
|
364
|
+
let groveGuildMul = 1;
|
|
365
|
+
if (guild.role === "mantle") {
|
|
366
|
+
groveGuildMul = isEdgeBelt ? 3.2 : isGroveCore ? 0.2 : isGlade ? 0.45 : 1;
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
groveGuildMul = isGlade ? 0.14 : isGroveCore ? 1.45 : 1;
|
|
370
|
+
}
|
|
371
|
+
const sc = guild.weight *
|
|
372
|
+
groveGuildMul *
|
|
373
|
+
nicheScore(guild.niche, {
|
|
374
|
+
light: 1,
|
|
375
|
+
moisture: sub.moisture,
|
|
376
|
+
soilPh: sub.soilPh,
|
|
377
|
+
fertility: sub.fertility,
|
|
378
|
+
elevation: sub.height,
|
|
379
|
+
slopeDeg: sub.slopeDeg,
|
|
380
|
+
exposure: sub.exposure,
|
|
381
|
+
});
|
|
382
|
+
if (sc > 0.04) {
|
|
383
|
+
total += sc;
|
|
384
|
+
candidates.push({ guild, spIdx: spByName.get(guild.speciesName), score: sc });
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (total <= 0)
|
|
388
|
+
continue;
|
|
389
|
+
// Presence probability scales with ecological fit and grove field so open glades remain wide and swept.
|
|
390
|
+
const groveGateMul = isGlade ? 0.24 : isEdgeBelt ? 1.18 : 1.05;
|
|
391
|
+
const densityGate = Math.min(0.94, total * 0.42 * groveGateMul);
|
|
392
|
+
if (hash01(cellId, seed + 31) > densityGate)
|
|
393
|
+
continue;
|
|
394
|
+
let pick = hash01(cellId, seed + 37) * total;
|
|
395
|
+
let chosen = candidates[candidates.length - 1];
|
|
396
|
+
for (const cand of candidates) {
|
|
397
|
+
pick -= cand.score;
|
|
398
|
+
if (pick <= 0) {
|
|
399
|
+
chosen = cand;
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
const sp = treeSpecies[chosen.spIdx];
|
|
404
|
+
const uAge = hash01(cellId, seed + 53);
|
|
405
|
+
// In structured groves, primary founders skew mature/veteran and nucleate asymmetric young cohorts.
|
|
406
|
+
const stageIdx = chosen.guild.role === "pioneer"
|
|
407
|
+
? uAge < 0.18
|
|
408
|
+
? 0
|
|
409
|
+
: uAge < 0.52
|
|
410
|
+
? 1
|
|
411
|
+
: uAge < 0.85
|
|
412
|
+
? 2
|
|
413
|
+
: 3
|
|
414
|
+
: chosen.guild.role === "mantle"
|
|
415
|
+
? uAge < 0.2
|
|
416
|
+
? 1
|
|
417
|
+
: uAge < 0.6
|
|
418
|
+
? 2
|
|
419
|
+
: 3
|
|
420
|
+
: isGlade
|
|
421
|
+
? uAge < 0.45
|
|
422
|
+
? 2
|
|
423
|
+
: 3
|
|
424
|
+
: gladeBlend > 0.4
|
|
425
|
+
? uAge < 0.08
|
|
426
|
+
? 1
|
|
427
|
+
: uAge < 0.48
|
|
428
|
+
? 2
|
|
429
|
+
: 3
|
|
430
|
+
: uAge < 0.1
|
|
431
|
+
? 0
|
|
432
|
+
: uAge < 0.28
|
|
433
|
+
? 1
|
|
434
|
+
: uAge < 0.65
|
|
435
|
+
? 2
|
|
436
|
+
: 3;
|
|
437
|
+
const uMult = hash01(cellId, seed + 61);
|
|
438
|
+
const { h, cr, cb, tr, isMantle, isPalm, isSapling } = sizeForStage(sp, chosen.guild.role, chosen.guild.scaleRange, stageIdx, sub, uMult);
|
|
439
|
+
if (!canPlace(x, z, cr, isMantle))
|
|
440
|
+
continue;
|
|
441
|
+
const pushStem = (sx, sy, sz, spIdx, sh, scr, scb, str, syaw, sseed, withCollar, role) => {
|
|
442
|
+
const ti = placed.length / TREE_STRIDE;
|
|
443
|
+
placed.push(sx, sy, sz, spIdx, sh, scr, scb, str, syaw, sseed);
|
|
444
|
+
placedRoles.push(role);
|
|
445
|
+
placedCollars.push(withCollar ? 1 : 0);
|
|
446
|
+
const bk = `${Math.floor(sx / guardCell)},${Math.floor(sz / guardCell)}`;
|
|
447
|
+
let bl = buckets.get(bk);
|
|
448
|
+
if (!bl)
|
|
449
|
+
buckets.set(bk, (bl = []));
|
|
450
|
+
bl.push(ti);
|
|
451
|
+
// From the values the packed row will hold, so the sandbox rebuilds the same field from its records.
|
|
452
|
+
if (withCollar)
|
|
453
|
+
stampShrubHalo(Math.fround(sx), Math.fround(sz), Math.fround(scr));
|
|
454
|
+
};
|
|
455
|
+
const yaw = hash01(cellId, seed + 71) * Math.PI * 2;
|
|
456
|
+
const tSeed = Math.floor(hash01(cellId, seed + 97) * 1_000_000);
|
|
457
|
+
const founderRole = chosen.guild.role ?? "canopy";
|
|
458
|
+
pushStem(x, sub.height, z, chosen.spIdx, h, cr, cb, tr, yaw, tSeed, isMantle || isSapling, founderRole);
|
|
459
|
+
// Mother-tree nucleation: surround mature/veteran founders with 3-7 asymmetric pole/sapling offspring
|
|
460
|
+
// plus 1-3 sunlit mantle skirt shrubs (or dense multi-stemmed cohorts for mantle shrubs).
|
|
461
|
+
if (!isMantle && stageIdx >= 2 && !isGlade && gladeBlend > 0.2) {
|
|
462
|
+
const cohortTarget = 3 + Math.floor(hash01(cellId, seed + 131) * 5);
|
|
463
|
+
const dispAngle = hash01(cellId, seed + 139) * Math.PI * 2;
|
|
464
|
+
for (let sk = 0; sk < cohortTarget && placed.length / TREE_STRIDE < rules.maxTrees; sk++) {
|
|
465
|
+
const arc = dispAngle + (hash01(cellId + sk * 19, seed + 149) - 0.32) * 2.5;
|
|
466
|
+
const sdist = cr * (0.9 + 2.2 * hash01(cellId + sk * 31, seed + 163)) + 1.4;
|
|
467
|
+
const sx = x + Math.cos(arc) * sdist;
|
|
468
|
+
const sz = z + Math.sin(arc) * sdist;
|
|
469
|
+
if (sx < substrate.x0 + 2 ||
|
|
470
|
+
sx > substrate.x0 + substrate.width - 2 ||
|
|
471
|
+
sz < substrate.z0 + 2 ||
|
|
472
|
+
sz > substrate.z0 + substrate.depth - 2) {
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
if (rules.pathFn && rules.pathFn(sx, sz) !== null)
|
|
476
|
+
continue;
|
|
477
|
+
if (tooCloseToRock(sx, sz))
|
|
478
|
+
continue;
|
|
479
|
+
const ssub = sampleSubstrateCpu(substrate, sx, sz);
|
|
480
|
+
if (rules.waterLevel !== undefined && ssub.height < rules.waterLevel + 0.08)
|
|
481
|
+
continue;
|
|
482
|
+
if (ssub.slopeDeg > rules.rockSlopeDeg)
|
|
483
|
+
continue;
|
|
484
|
+
const subStage = hash01(cellId + sk * 41, seed + 173) < 0.56 ? 0 : 1;
|
|
485
|
+
const off = sizeForStage(sp, founderRole, chosen.guild.scaleRange, subStage, ssub, hash01(cellId + sk * 43, seed + 181));
|
|
486
|
+
if (!canPlace(sx, sz, off.cr, false, 0.5))
|
|
487
|
+
continue;
|
|
488
|
+
pushStem(sx, ssub.height, sz, chosen.spIdx, off.h, off.cr, off.cb, off.tr, arc + 0.8, Math.floor(hash01(cellId + sk * 59, seed + 197) * 1_000_000), subStage === 0, founderRole);
|
|
489
|
+
}
|
|
490
|
+
if (mantleGuilds.length > 0 && !isGroveCore) {
|
|
491
|
+
const mTarget = 1 + Math.floor(hash01(cellId, seed + 211) * 3);
|
|
492
|
+
for (let mk = 0; mk < mTarget && placed.length / TREE_STRIDE < rules.maxTrees; mk++) {
|
|
493
|
+
const mg = mantleGuilds[(cellId + mk) % mantleGuilds.length];
|
|
494
|
+
const mspIdx = spByName.get(mg.speciesName);
|
|
495
|
+
if (mspIdx === undefined)
|
|
496
|
+
continue;
|
|
497
|
+
const msp = treeSpecies[mspIdx];
|
|
498
|
+
const arc = dispAngle + (hash01(cellId + mk * 23, seed + 223) - 0.5) * 2.8;
|
|
499
|
+
const mdist = cr * (1.05 + 1.45 * hash01(cellId + mk * 37, seed + 229)) + 1.8;
|
|
500
|
+
const mx = x + Math.cos(arc) * mdist;
|
|
501
|
+
const mz = z + Math.sin(arc) * mdist;
|
|
502
|
+
if (mx < substrate.x0 + 2 ||
|
|
503
|
+
mx > substrate.x0 + substrate.width - 2 ||
|
|
504
|
+
mz < substrate.z0 + 2 ||
|
|
505
|
+
mz > substrate.z0 + substrate.depth - 2) {
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
if (rules.pathFn && rules.pathFn(mx, mz) !== null)
|
|
509
|
+
continue;
|
|
510
|
+
if (tooCloseToRock(mx, mz))
|
|
511
|
+
continue;
|
|
512
|
+
const msub = sampleSubstrateCpu(substrate, mx, mz);
|
|
513
|
+
if (rules.waterLevel !== undefined && msub.height < rules.waterLevel + 0.08)
|
|
514
|
+
continue;
|
|
515
|
+
const mfit = nicheScore(mg.niche, {
|
|
516
|
+
light: 1,
|
|
517
|
+
moisture: msub.moisture,
|
|
518
|
+
soilPh: msub.soilPh,
|
|
519
|
+
fertility: msub.fertility,
|
|
520
|
+
elevation: msub.height,
|
|
521
|
+
slopeDeg: msub.slopeDeg,
|
|
522
|
+
exposure: msub.exposure,
|
|
523
|
+
});
|
|
524
|
+
if (mfit < 0.12)
|
|
525
|
+
continue;
|
|
526
|
+
const mStage = 1 + Math.floor(hash01(cellId + mk * 47, seed + 233) * 2);
|
|
527
|
+
const ms = sizeForStage(msp, "mantle", mg.scaleRange, mStage, msub, hash01(cellId + mk * 53, seed + 239));
|
|
528
|
+
if (!canPlace(mx, mz, ms.cr, true, 0.45))
|
|
529
|
+
continue;
|
|
530
|
+
pushStem(mx, msub.height, mz, mspIdx, ms.h, ms.cr, ms.cb, ms.tr, arc + 1.4, Math.floor(hash01(cellId + mk * 61, seed + 241) * 1_000_000), true, "mantle");
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
// Cluster mantle shrubs & isolated non-palm saplings into multi-stemmed low-crowned cohorts nested in collars.
|
|
536
|
+
const spawnCompanions = isMantle || (isSapling && !isPalm && hash01(cellId, seed + 137) > 0.38);
|
|
537
|
+
if (spawnCompanions) {
|
|
538
|
+
const satTarget = isMantle ? (hash01(cellId, seed + 131) > 0.35 ? 2 : 1) : 1;
|
|
539
|
+
for (let sk = 0; sk < satTarget && placed.length / TREE_STRIDE < rules.maxTrees; sk++) {
|
|
540
|
+
const sang = yaw + (sk + 1) * 2.25 + (hash01(cellId + sk * 17, seed + 149) - 0.5) * 0.9;
|
|
541
|
+
const sdist = isMantle
|
|
542
|
+
? Math.max(0.95, Math.min(2.15, cr * (0.58 + 0.28 * hash01(cellId + sk * 31, seed + 163))))
|
|
543
|
+
: 1.0 + 0.85 * hash01(cellId + sk * 31, seed + 163);
|
|
544
|
+
const sx = x + Math.cos(sang) * sdist;
|
|
545
|
+
const sz = z + Math.sin(sang) * sdist;
|
|
546
|
+
if (sx < substrate.x0 + 2 ||
|
|
547
|
+
sx > substrate.x0 + substrate.width - 2 ||
|
|
548
|
+
sz < substrate.z0 + 2 ||
|
|
549
|
+
sz > substrate.z0 + substrate.depth - 2) {
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
if (rules.pathFn && rules.pathFn(sx, sz) !== null)
|
|
553
|
+
continue;
|
|
554
|
+
if (tooCloseToRock(sx, sz))
|
|
555
|
+
continue;
|
|
556
|
+
const ssub = sampleSubstrateCpu(substrate, sx, sz);
|
|
557
|
+
if (rules.waterLevel !== undefined && ssub.height < rules.waterLevel + 0.1)
|
|
558
|
+
continue;
|
|
559
|
+
if (ssub.slopeDeg > rules.rockSlopeDeg)
|
|
560
|
+
continue;
|
|
561
|
+
const smult = isMantle
|
|
562
|
+
? 0.62 + 0.22 * hash01(cellId + sk * 43, seed + 181)
|
|
563
|
+
: 0.6 + 0.2 * hash01(cellId + sk * 43, seed + 181);
|
|
564
|
+
const sh = h * smult;
|
|
565
|
+
const scr = isMantle ? cr * (0.7 + 0.18 * smult) : Math.max(cr * 0.75, sh * 0.44);
|
|
566
|
+
const scb = isMantle ? Math.min(sh * 0.09, 0.16) : Math.min(sh * 0.08, 0.15);
|
|
567
|
+
const str = Math.max(0.02, tr * smult * 0.85);
|
|
568
|
+
pushStem(sx, ssub.height, sz, chosen.spIdx, sh, scr, scb, str, sang + 1.1, Math.floor(hash01(cellId + sk * 59, seed + 197) * 1_000_000), true, founderRole);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
const trees = Float32Array.from(placed);
|
|
574
|
+
const treeCount = Math.floor(trees.length / TREE_STRIDE);
|
|
575
|
+
// ---- Stage 1.5: Stand-Adaptive Architecture & Physical Phototropic / Shoreline / Wind Leans ----
|
|
576
|
+
const treeLeans = new Float32Array(treeCount * 2);
|
|
577
|
+
const windRad = ((opts.windHeading ?? 235) * Math.PI) / 180;
|
|
578
|
+
const windDirX = Math.sin(windRad);
|
|
579
|
+
const windDirZ = Math.cos(windRad);
|
|
580
|
+
for (let t = 0; t < treeCount; t++) {
|
|
581
|
+
const o = t * TREE_STRIDE;
|
|
582
|
+
const tx = trees[o];
|
|
583
|
+
const tz = trees[o + 2];
|
|
584
|
+
const sp = treeSpecies[Math.round(trees[o + 3])];
|
|
585
|
+
const th = trees[o + 4];
|
|
586
|
+
const tcr = trees[o + 5];
|
|
587
|
+
const tcb = trees[o + 6];
|
|
588
|
+
const ttr = trees[o + 7];
|
|
589
|
+
const tSeed = trees[o + 9];
|
|
590
|
+
const role = placedRoles[t] ?? "canopy";
|
|
591
|
+
const isPalm = sp.architecture === "palm";
|
|
592
|
+
const isMantle = role === "mantle";
|
|
593
|
+
const bx = Math.floor(tx / guardCell);
|
|
594
|
+
const bz = Math.floor(tz / guardCell);
|
|
595
|
+
let closureRaw = 0;
|
|
596
|
+
let openAccX = 0;
|
|
597
|
+
let openAccZ = 0;
|
|
598
|
+
const maxNbrDist = Math.max(12, tcr * 2.4 + 7.5);
|
|
599
|
+
const cellSpan = Math.ceil(maxNbrDist / guardCell);
|
|
600
|
+
for (let dz = -cellSpan; dz <= cellSpan; dz++) {
|
|
601
|
+
for (let dx = -cellSpan; dx <= cellSpan; dx++) {
|
|
602
|
+
const list = buckets.get(`${bx + dx},${bz + dz}`);
|
|
603
|
+
if (!list)
|
|
604
|
+
continue;
|
|
605
|
+
for (const j of list) {
|
|
606
|
+
if (j === t)
|
|
607
|
+
continue;
|
|
608
|
+
const jo = j * TREE_STRIDE;
|
|
609
|
+
const jx = trees[jo];
|
|
610
|
+
const jz = trees[jo + 2];
|
|
611
|
+
const jh = trees[jo + 4];
|
|
612
|
+
const jcr = trees[jo + 5];
|
|
613
|
+
if (jh < th * 0.42 && jh < 4.0)
|
|
614
|
+
continue;
|
|
615
|
+
const reach = Math.max(8, (tcr + jcr) * 1.32 + 4.0);
|
|
616
|
+
const dist = Math.hypot(tx - jx, tz - jz);
|
|
617
|
+
if (dist < 0.05 || dist > reach)
|
|
618
|
+
continue;
|
|
619
|
+
const prox = Math.pow(1 - dist / reach, 1.35) * Math.min(1.4, jh / Math.max(3, th));
|
|
620
|
+
closureRaw += prox;
|
|
621
|
+
openAccX += ((tx - jx) / dist) * prox;
|
|
622
|
+
openAccZ += ((tz - jz) / dist) * prox;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
const closure = 1 - Math.exp(-closureRaw * 0.68);
|
|
627
|
+
const openLen = Math.hypot(openAccX, openAccZ);
|
|
628
|
+
const lopsided = closureRaw > 0.08 ? Math.min(1, openLen / Math.max(0.35, closureRaw + 0.12)) : 0;
|
|
629
|
+
const openX = openLen > 1e-4 ? openAccX / openLen : 0;
|
|
630
|
+
const openZ = openLen > 1e-4 ? openAccZ / openLen : 0;
|
|
631
|
+
const uVar = hash01(t, tSeed + 101);
|
|
632
|
+
const azJit = (hash01(t, tSeed + 313) - 0.5) * 0.85;
|
|
633
|
+
const sub = sampleSubstrateCpu(substrate, tx, tz);
|
|
634
|
+
// Self-pruning in closed stands (`closure > 0.58`) vs low sweeping boughs on open-grown veterans (`closure < 0.24`).
|
|
635
|
+
if (!isMantle && !isPalm && th >= 4.5) {
|
|
636
|
+
if (closure > 0.56) {
|
|
637
|
+
const tClose = smoothstepNum(0.56, 0.86, closure);
|
|
638
|
+
const closedCb = th * (0.56 + 0.15 * uVar);
|
|
639
|
+
trees[o + 6] = Math.min(th * 0.78, tcb + (closedCb - tcb) * tClose);
|
|
640
|
+
trees[o + 5] = tcr * (1 - 0.24 * tClose);
|
|
641
|
+
trees[o + 4] = th * (1 + 0.06 * tClose);
|
|
642
|
+
}
|
|
643
|
+
else if (closure < 0.24 && th >= 5.5) {
|
|
644
|
+
const tOpen = smoothstepNum(0.24, 0.03, closure);
|
|
645
|
+
const openCb = th * (0.12 + 0.09 * uVar);
|
|
646
|
+
trees[o + 6] = Math.min(tcb, tcb + (openCb - tcb) * tOpen);
|
|
647
|
+
trees[o + 5] = tcr * (1 + 0.2 * tOpen);
|
|
648
|
+
trees[o + 7] = ttr * (1 + 0.12 * tOpen);
|
|
649
|
+
}
|
|
650
|
+
// On hillsides, raise crownBase slightly so pistol-butt sweep curves through 24-32% of the bole before straightening vertical.
|
|
651
|
+
if (sub.slopeDeg > 12) {
|
|
652
|
+
const hillMinCb = th * (0.24 + 0.08 * smoothstepNum(12, 30, sub.slopeDeg));
|
|
653
|
+
if (trees[o + 6] < hillMinCb)
|
|
654
|
+
trees[o + 6] = hillMinCb;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
// Gravitropic basal-sweep leans: phototropic gap sweep, varied lagoon palm arches, gentle wind flagging & hillside pistol-butt sweep.
|
|
658
|
+
let lx = 0;
|
|
659
|
+
let lz = 0;
|
|
660
|
+
if (closure > 0.14 && closure < 0.82 && lopsided > 0.2) {
|
|
661
|
+
const photoMag = (0.05 + 0.1 * lopsided) * (isPalm ? 1.1 : 1.0);
|
|
662
|
+
lx += openX * photoMag;
|
|
663
|
+
lz += openZ * photoMag;
|
|
664
|
+
}
|
|
665
|
+
if (isPalm && rules.waterLevel !== undefined) {
|
|
666
|
+
const relWater = sub.height - rules.waterLevel;
|
|
667
|
+
if (relWater >= 0 && relWater < 4.5) {
|
|
668
|
+
let wdx = 0;
|
|
669
|
+
let wdz = 0;
|
|
670
|
+
for (let a = 0; a < 8; a++) {
|
|
671
|
+
const ang = (a * Math.PI) / 4;
|
|
672
|
+
const ax = Math.cos(ang);
|
|
673
|
+
const az = Math.sin(ang);
|
|
674
|
+
const sx = Math.min(substrate.x0 + substrate.width - 1, Math.max(substrate.x0 + 1, tx + ax * 10));
|
|
675
|
+
const sz = Math.min(substrate.z0 + substrate.depth - 1, Math.max(substrate.z0 + 1, tz + az * 10));
|
|
676
|
+
const sh = sampleSubstrateCpu(substrate, sx, sz).height;
|
|
677
|
+
if (sh < sub.height) {
|
|
678
|
+
const drop = sub.height - sh;
|
|
679
|
+
wdx += ax * drop;
|
|
680
|
+
wdz += az * drop;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
const wLen = Math.hypot(wdx, wdz);
|
|
684
|
+
if (wLen > 0.08) {
|
|
685
|
+
// Mix upright, gentle-arc, and ~28% hero curved palms with per-tree azimuth variety rather than parallel clones.
|
|
686
|
+
const shoreFrac = 1 - clamp01(relWater / 4.5);
|
|
687
|
+
const palmLean = uVar > 0.72
|
|
688
|
+
? 0.2 + 0.16 * shoreFrac
|
|
689
|
+
: uVar > 0.34
|
|
690
|
+
? 0.06 + 0.09 * shoreFrac
|
|
691
|
+
: 0.015 + 0.03 * uVar;
|
|
692
|
+
const baseAng = Math.atan2(wdz, wdx) + azJit;
|
|
693
|
+
lx += Math.cos(baseAng) * palmLean;
|
|
694
|
+
lz += Math.sin(baseAng) * palmLean;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
if (sub.exposure > 0.48) {
|
|
699
|
+
const expT = smoothstepNum(0.48, 0.92, sub.exposure);
|
|
700
|
+
const windMag = (0.035 + 0.075 * expT) * (isPalm ? 0.5 : 1.0) * (0.65 + 0.7 * uVar);
|
|
701
|
+
lx += windDirX * windMag;
|
|
702
|
+
lz += windDirZ * windMag;
|
|
703
|
+
// Wind-sheared coastal/alpine stature compaction.
|
|
704
|
+
if (!isPalm) {
|
|
705
|
+
trees[o + 4] *= 1 - 0.13 * expT;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
if (sub.slopeDeg > 10 && !isPalm) {
|
|
709
|
+
const nLenXZ = Math.hypot(sub.normal[0], sub.normal[2]);
|
|
710
|
+
if (nLenXZ > 0.05) {
|
|
711
|
+
const slopeLean = (0.12 + 0.18 * uVar) * smoothstepNum(10, 30, sub.slopeDeg);
|
|
712
|
+
lx += (sub.normal[0] / nLenXZ) * slopeLean;
|
|
713
|
+
lz += (sub.normal[2] / nLenXZ) * slopeLean;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
const leanCap = isPalm ? 0.36 : sub.slopeDeg > 14 ? 0.32 : 0.16;
|
|
717
|
+
const totalMag = Math.hypot(lx, lz);
|
|
718
|
+
if (totalMag > leanCap) {
|
|
719
|
+
const kClamp = leanCap / totalMag;
|
|
720
|
+
lx *= kClamp;
|
|
721
|
+
lz *= kClamp;
|
|
722
|
+
}
|
|
723
|
+
treeLeans[t * 2] = lx;
|
|
724
|
+
treeLeans[t * 2 + 1] = lz;
|
|
725
|
+
}
|
|
726
|
+
// ---- Stage 2: Bake canopy shelter, sky, litter & derive non-mutating topsoil chemistry ----
|
|
727
|
+
const canopy = bakeCanopyCpu({
|
|
728
|
+
bounds: { x0: substrate.x0, z0: substrate.z0, width: substrate.width, depth: substrate.depth },
|
|
729
|
+
cell: opts.canopyCell ?? 2,
|
|
730
|
+
trees,
|
|
731
|
+
species: treeSpecies,
|
|
732
|
+
foliageRetention: opts.foliageRetention,
|
|
733
|
+
});
|
|
734
|
+
const soil = deriveLitterSoil(substrate, canopy.litter, canopy.coniferShare, canopy.nx, canopy.nz);
|
|
735
|
+
const effectiveSubstrate = {
|
|
736
|
+
...substrate,
|
|
737
|
+
soilPh: soil.soilPh,
|
|
738
|
+
fertility: soil.fertility,
|
|
739
|
+
};
|
|
740
|
+
const treeTints = computeTreeEdaphicTints(trees, treeCount, effectiveSubstrate);
|
|
741
|
+
let shelterSum = 0;
|
|
742
|
+
for (let k = 0; k < canopy.shelter.length; k++)
|
|
743
|
+
shelterSum += canopy.shelter[k];
|
|
744
|
+
const meanShelter = canopy.shelter.length > 0 ? shelterSum / canopy.shelter.length : 0;
|
|
745
|
+
// ---- Stage 2.5: Discrete undergrowth & forest fungi (`webgpu-flora`) ----
|
|
746
|
+
let flora = new Float32Array(0);
|
|
747
|
+
let groundFloraCount = 0;
|
|
748
|
+
let epiphyteCount = 0;
|
|
749
|
+
let scatterSuppressesTurf = null;
|
|
750
|
+
if (rules.flora && rules.flora.length > 0) {
|
|
751
|
+
const floraById = new Map();
|
|
752
|
+
for (let i = 0; i < ALL_FLORA_SPECIES.length; i++)
|
|
753
|
+
floraById.set(ALL_FLORA_SPECIES[i].id, i);
|
|
754
|
+
const scatterRules = rules.flora.map((fg) => {
|
|
755
|
+
const spIdx = floraById.get(fg.speciesId);
|
|
756
|
+
if (spIdx === undefined) {
|
|
757
|
+
throw new Error(`Unknown flora species "${fg.speciesId}" in EcotoneRules`);
|
|
758
|
+
}
|
|
759
|
+
return {
|
|
760
|
+
speciesIndex: spIdx,
|
|
761
|
+
spacing: fg.spacing,
|
|
762
|
+
colonyRadius: fg.colonyRadius,
|
|
763
|
+
scaleRange: fg.scaleRange,
|
|
764
|
+
suppressesTurf: fg.suppressesTurf,
|
|
765
|
+
clonal: fg.clonal ?? CLONAL_CARPET_SPECIES.has(fg.speciesId),
|
|
766
|
+
suitability(s) {
|
|
767
|
+
if (rules.pathFn && rules.pathFn(s.x, s.z) !== null)
|
|
768
|
+
return 0;
|
|
769
|
+
let shoreMul = 1;
|
|
770
|
+
if (rules.waterLevel !== undefined) {
|
|
771
|
+
const relH = s.height - rules.waterLevel;
|
|
772
|
+
if (fg.emergentDepth !== undefined && fg.emergentDepth > 0) {
|
|
773
|
+
if (relH < -fg.emergentDepth || (fg.maxAboveWater !== undefined && relH > fg.maxAboveWater))
|
|
774
|
+
return 0;
|
|
775
|
+
// Clumped shoreline reed/sedge colonies wading into sheltered shallow water, avoiding sterile uniform borders.
|
|
776
|
+
const bedWave = 0.5 +
|
|
777
|
+
0.28 * Math.sin(s.x * 0.14 + s.z * 0.11 + spIdx * 1.7) +
|
|
778
|
+
0.22 * Math.cos(s.x * 0.33 - s.z * 0.27);
|
|
779
|
+
if (bedWave < 0.36)
|
|
780
|
+
return 0;
|
|
781
|
+
const edgeBell = Math.max(0.25, 1 - Math.abs(relH + 0.04) / Math.max(0.18, fg.emergentDepth + 0.18));
|
|
782
|
+
shoreMul = edgeBell * (0.75 + 0.85 * Math.min(1, Math.max(0, bedWave)));
|
|
783
|
+
}
|
|
784
|
+
else if (s.height < rules.waterLevel + 0.06) {
|
|
785
|
+
return 0;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
if (fg.minShelter !== undefined && s.shelter < fg.minShelter)
|
|
789
|
+
return 0;
|
|
790
|
+
const isCollarGuild = fg.speciesId === "heather" ||
|
|
791
|
+
fg.speciesId === "bellHeather" ||
|
|
792
|
+
fg.speciesId === "crowberry" ||
|
|
793
|
+
fg.speciesId === "bilberry" ||
|
|
794
|
+
fg.speciesId === "cistusScrub" ||
|
|
795
|
+
fg.speciesId === "bracken" ||
|
|
796
|
+
fg.speciesId === "swordFern" ||
|
|
797
|
+
fg.speciesId === "ladyFern" ||
|
|
798
|
+
fg.speciesId === "forestSedge";
|
|
799
|
+
const isRockSkirtGuild = fg.speciesId === "hartstongueFern" ||
|
|
800
|
+
fg.speciesId === "ladyFern" ||
|
|
801
|
+
fg.speciesId === "swordFern" ||
|
|
802
|
+
fg.speciesId === "woodSorrel" ||
|
|
803
|
+
fg.speciesId === "bilberry" ||
|
|
804
|
+
fg.speciesId === "heather" ||
|
|
805
|
+
fg.speciesId === "forestSedge";
|
|
806
|
+
const shHalo = isCollarGuild ? sampleShrubHalo(s.x, s.z) : 0;
|
|
807
|
+
const rHalo = isRockSkirtGuild ? sampleRockMask(s.x, s.z).halo : 0;
|
|
808
|
+
if (fg.maxShelter !== undefined && s.shelter > fg.maxShelter + shHalo * 0.3)
|
|
809
|
+
return 0;
|
|
810
|
+
if (fg.minMycorrhiza !== undefined && s.mycorrhiza < fg.minMycorrhiza)
|
|
811
|
+
return 0;
|
|
812
|
+
const mycoMul = fg.minMycorrhiza !== undefined ? Math.min(1, s.mycorrhiza / Math.max(0.15, fg.minMycorrhiza)) : 1;
|
|
813
|
+
const collarBoost = (1 + shHalo * 1.45) * (1 + rHalo * 0.95);
|
|
814
|
+
return (fg.weight *
|
|
815
|
+
mycoMul *
|
|
816
|
+
shoreMul *
|
|
817
|
+
collarBoost *
|
|
818
|
+
nicheScore(fg.niche, {
|
|
819
|
+
light: 1 - s.shelter,
|
|
820
|
+
moisture: s.moisture,
|
|
821
|
+
soilPh: s.soilPh,
|
|
822
|
+
fertility: s.fertility,
|
|
823
|
+
elevation: s.height,
|
|
824
|
+
slopeDeg: s.slopeDeg,
|
|
825
|
+
exposure: s.exposure,
|
|
826
|
+
}));
|
|
827
|
+
},
|
|
828
|
+
};
|
|
829
|
+
});
|
|
830
|
+
const scattered = scatterFlora({
|
|
831
|
+
x0: effectiveSubstrate.x0,
|
|
832
|
+
z0: effectiveSubstrate.z0,
|
|
833
|
+
width: effectiveSubstrate.width,
|
|
834
|
+
depth: effectiveSubstrate.depth,
|
|
835
|
+
maxInstances: rules.maxFlora ?? 10000,
|
|
836
|
+
seed: seed + 511,
|
|
837
|
+
species: ALL_FLORA_SPECIES,
|
|
838
|
+
rules: scatterRules,
|
|
839
|
+
sampleAt(x, z) {
|
|
840
|
+
const sub = sampleSubstrateCpu(effectiveSubstrate, x, z);
|
|
841
|
+
const can = sampleCanopyCpu(canopy, x, z);
|
|
842
|
+
const { halo } = sampleRockMask(x, z);
|
|
843
|
+
return {
|
|
844
|
+
x,
|
|
845
|
+
z,
|
|
846
|
+
height: sub.height,
|
|
847
|
+
slopeDeg: sub.slopeDeg,
|
|
848
|
+
moisture: Math.min(1, sub.moisture + halo * 0.14),
|
|
849
|
+
soilPh: sub.soilPh,
|
|
850
|
+
fertility: sub.fertility,
|
|
851
|
+
exposure: sub.exposure,
|
|
852
|
+
shelter: Math.min(1, can.shelter + halo * 0.16),
|
|
853
|
+
litter: can.litter,
|
|
854
|
+
coniferShare: can.coniferShare,
|
|
855
|
+
mycorrhiza: can.mycorrhiza,
|
|
856
|
+
};
|
|
857
|
+
},
|
|
858
|
+
});
|
|
859
|
+
flora = scattered.instances;
|
|
860
|
+
groundFloraCount = scattered.count;
|
|
861
|
+
scatterSuppressesTurf = scattered.suppressesTurf;
|
|
862
|
+
// Colonize fallen nurse logs with saprotrophic bracket/inkcap fungi & log-crest ferns/sorrel.
|
|
863
|
+
const nurseSpIdx = floraById.get("nurseLog");
|
|
864
|
+
const logColonizers = ["inkcap", "woodSorrel", "ladyFern", "swordFern"]
|
|
865
|
+
.map((id) => floraById.get(id))
|
|
866
|
+
.filter((idx) => idx !== undefined);
|
|
867
|
+
const maxGroundFlora = rules.maxFlora ?? 10000;
|
|
868
|
+
if (nurseSpIdx !== undefined && logColonizers.length > 0 && groundFloraCount < maxGroundFlora) {
|
|
869
|
+
const extras = [];
|
|
870
|
+
for (let i = 0; i < groundFloraCount && groundFloraCount + extras.length / FLORA_STRIDE < maxGroundFlora; i++) {
|
|
871
|
+
const o = i * FLORA_STRIDE;
|
|
872
|
+
if (Math.round(flora[o + 3]) !== nurseSpIdx)
|
|
873
|
+
continue;
|
|
874
|
+
const lx = flora[o];
|
|
875
|
+
const ly = flora[o + 1];
|
|
876
|
+
const lz = flora[o + 2];
|
|
877
|
+
const lH = flora[o + 4];
|
|
878
|
+
const lRad = flora[o + 5];
|
|
879
|
+
const lyaw = flora[o + 6];
|
|
880
|
+
const lSeed = flora[o + 7];
|
|
881
|
+
const colCount = lSeed % 3 === 0 ? 1 : 2;
|
|
882
|
+
for (let c = 0; c < colCount && groundFloraCount + extras.length / FLORA_STRIDE < maxGroundFlora; c++) {
|
|
883
|
+
const spCIdx = logColonizers[(lSeed + c) % logColonizers.length];
|
|
884
|
+
const spC = ALL_FLORA_SPECIES[spCIdx];
|
|
885
|
+
const along = (c === 0 ? -0.38 : 0.32) * lRad;
|
|
886
|
+
const cx = lx + Math.cos(lyaw) * along;
|
|
887
|
+
const cz = lz + Math.sin(lyaw) * along;
|
|
888
|
+
const cY = ly + lH * 0.42;
|
|
889
|
+
const scMult = spC.archetype === "rosette" ? 0.52 : 0.85;
|
|
890
|
+
extras.push(cx, cY, cz, spCIdx, spC.height * scMult, spC.radius * scMult, (lSeed + c * 1.9) % (Math.PI * 2), (lSeed + 31 + c * 47) % 1000000);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
if (extras.length > 0) {
|
|
894
|
+
const merged = new Float32Array(flora.length + extras.length);
|
|
895
|
+
merged.set(flora, 0);
|
|
896
|
+
merged.set(extras, flora.length);
|
|
897
|
+
flora = merged;
|
|
898
|
+
groundFloraCount = Math.floor(flora.length / FLORA_STRIDE);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
// Forest-floor woody micro-debris: fallen branch chunks, palm rachises/husks & weathered bark nestled near roots & boulder toes.
|
|
902
|
+
if (nurseSpIdx !== undefined && groundFloraCount < maxGroundFlora) {
|
|
903
|
+
const debrisCap = Math.min(maxGroundFlora - groundFloraCount, Math.max(24, Math.min(260, treeCount + Math.floor(rockCount * 0.35))));
|
|
904
|
+
const nurseSp = ALL_FLORA_SPECIES[nurseSpIdx];
|
|
905
|
+
const dExtras = [];
|
|
906
|
+
for (let t = 0; t < treeCount && dExtras.length / FLORA_STRIDE < debrisCap; t++) {
|
|
907
|
+
const o = t * TREE_STRIDE;
|
|
908
|
+
const tx = trees[o];
|
|
909
|
+
const tz = trees[o + 2];
|
|
910
|
+
const tcr = trees[o + 5];
|
|
911
|
+
const ttr = trees[o + 7];
|
|
912
|
+
const tsIdx = Math.round(trees[o + 3]);
|
|
913
|
+
const tsp = treeSpecies[tsIdx];
|
|
914
|
+
const isPalm = tsp?.architecture === "palm";
|
|
915
|
+
if (!isPalm && ttr < 0.16 && t < treeCount - 1)
|
|
916
|
+
continue;
|
|
917
|
+
const pieceCount = isPalm ? 2 : ttr > 0.28 ? 2 : 1;
|
|
918
|
+
for (let p = 0; p < pieceCount && dExtras.length / FLORA_STRIDE < debrisCap; p++) {
|
|
919
|
+
const hk = t * 53 + p * 17;
|
|
920
|
+
if (hash01(hk, seed + 881) > (isPalm ? 0.62 : 0.42))
|
|
921
|
+
continue;
|
|
922
|
+
const ang = hash01(hk, seed + 887) * Math.PI * 2;
|
|
923
|
+
const dist = ttr * 1.8 + 0.65 + hash01(hk, seed + 907) * (isPalm ? tcr * 0.72 : tcr * 0.48 + 1.2);
|
|
924
|
+
const dx = tx + Math.cos(ang) * dist;
|
|
925
|
+
const dz = tz + Math.sin(ang) * dist;
|
|
926
|
+
if (dx < substrate.x0 + 2 || dx > substrate.x0 + substrate.width - 2 || dz < substrate.z0 + 2 || dz > substrate.z0 + substrate.depth - 2) {
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
if (rules.pathFn && rules.pathFn(dx, dz) !== null)
|
|
930
|
+
continue;
|
|
931
|
+
const dsub = sampleSubstrateCpu(effectiveSubstrate, dx, dz);
|
|
932
|
+
if (rules.waterLevel !== undefined && dsub.height < rules.waterLevel + 0.08)
|
|
933
|
+
continue;
|
|
934
|
+
const sc = isPalm ? 0.18 + hash01(hk, seed + 911) * 0.14 : 0.16 + hash01(hk, seed + 911) * 0.2;
|
|
935
|
+
dExtras.push(dx, dsub.height - sc * 0.06, dz, nurseSpIdx, nurseSp.height * sc, nurseSp.radius * sc, hash01(hk, seed + 919) * Math.PI * 2, Math.floor(hash01(hk, seed + 929) * 1_000_000));
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
if (dExtras.length > 0) {
|
|
939
|
+
const merged = new Float32Array(flora.length + dExtras.length);
|
|
940
|
+
merged.set(flora, 0);
|
|
941
|
+
merged.set(dExtras, flora.length);
|
|
942
|
+
flora = merged;
|
|
943
|
+
groundFloraCount = Math.floor(flora.length / FLORA_STRIDE);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
// ---- Root heave: raise the ground round trunk feet (changes substrate, tree, and ground-flora heights) ----
|
|
948
|
+
if (opts.rootHeave) {
|
|
949
|
+
applyRootHeaveMounds(substrate, trees, treeCount, flora, groundFloraCount, rules.waterLevel);
|
|
950
|
+
}
|
|
951
|
+
// ---- Stage 2.6: Tree-hosted epiphytes (epiphytes.ts, shared with the sandbox) on the trees as they stand ----
|
|
952
|
+
const epiRaw = placeEpiphytes({ rules, trees, treeCount, treeLeans, treeSpecies, substrate: effectiveSubstrate, canopy, seed });
|
|
953
|
+
if (epiRaw.length > 0) {
|
|
954
|
+
epiphyteCount = Math.floor(epiRaw.length / FLORA_STRIDE);
|
|
955
|
+
const merged = new Float32Array(flora.length + epiRaw.length);
|
|
956
|
+
merged.set(flora, 0);
|
|
957
|
+
merged.set(epiRaw, flora.length);
|
|
958
|
+
flora = merged;
|
|
959
|
+
}
|
|
960
|
+
const floraCount = groundFloraCount + epiphyteCount;
|
|
961
|
+
// ---- Stage 3: Solve continuous turf & bare ground (`BARE_GROUND`) grid (turf.ts, shared with the sandbox) ----
|
|
962
|
+
const mapCell = Math.max(0.25, opts.mapCell ?? 0.5);
|
|
963
|
+
const mnx = Math.max(4, Math.floor(effectiveSubstrate.width / mapCell));
|
|
964
|
+
const mnz = Math.max(4, Math.floor(effectiveSubstrate.depth / mapCell));
|
|
965
|
+
const groundFloraSuppressesTurf = new Uint8Array(groundFloraCount);
|
|
966
|
+
if (scatterSuppressesTurf)
|
|
967
|
+
groundFloraSuppressesTurf.set(scatterSuppressesTurf);
|
|
968
|
+
const rockCover = rockCoverGrid ? { grid: rockCoverGrid, nx: rockNx, nz: rockNz, cell: rockCell } : null;
|
|
969
|
+
const ids = classifyTurf({
|
|
970
|
+
substrate: effectiveSubstrate,
|
|
971
|
+
rules,
|
|
972
|
+
canopy,
|
|
973
|
+
layout: { nx: mnx, nz: mnz, x0: effectiveSubstrate.x0, z0: effectiveSubstrate.z0, cell: mapCell },
|
|
974
|
+
rockCover,
|
|
975
|
+
flora,
|
|
976
|
+
groundFloraCount,
|
|
977
|
+
suppression: buildTurfSuppression(effectiveSubstrate, flora, groundFloraCount, groundFloraSuppressesTurf),
|
|
978
|
+
shrubHalo,
|
|
979
|
+
});
|
|
980
|
+
return {
|
|
981
|
+
rocks,
|
|
982
|
+
rockCount,
|
|
983
|
+
trees,
|
|
984
|
+
treeCount,
|
|
985
|
+
treeLeans,
|
|
986
|
+
treeTints,
|
|
987
|
+
canopy,
|
|
988
|
+
meanShelter,
|
|
989
|
+
soil,
|
|
990
|
+
flora,
|
|
991
|
+
groundFloraCount,
|
|
992
|
+
epiphyteCount,
|
|
993
|
+
floraCount,
|
|
994
|
+
grassMap: {
|
|
995
|
+
ids,
|
|
996
|
+
nx: mnx,
|
|
997
|
+
nz: mnz,
|
|
998
|
+
x0: effectiveSubstrate.x0,
|
|
999
|
+
z0: effectiveSubstrate.z0,
|
|
1000
|
+
cell: mapCell,
|
|
1001
|
+
},
|
|
1002
|
+
treeCollars: Uint8Array.from(placedCollars),
|
|
1003
|
+
rockCover,
|
|
1004
|
+
groundFloraSuppressesTurf,
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
//# sourceMappingURL=ecotone.js.map
|