Add function to create flat foliage mask values for terrain
This commit is contained in:
@@ -275,6 +275,29 @@ export function createFlatTerrainPaintWeights(
|
|||||||
).fill(0);
|
).fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createFlatTerrainFoliageMaskValues(
|
||||||
|
resolutionX: number,
|
||||||
|
resolutionZ: number,
|
||||||
|
value = 0
|
||||||
|
): number[] {
|
||||||
|
const normalizedResolutionX = normalizeTerrainSampleCount(
|
||||||
|
resolutionX,
|
||||||
|
"Terrain foliage mask resolutionX"
|
||||||
|
);
|
||||||
|
const normalizedResolutionZ = normalizeTerrainSampleCount(
|
||||||
|
resolutionZ,
|
||||||
|
"Terrain foliage mask resolutionZ"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!Number.isFinite(value)) {
|
||||||
|
throw new Error("Terrain foliage mask values must remain finite.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Array(normalizedResolutionX * normalizedResolutionZ).fill(
|
||||||
|
clamp(value, 0, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function getTerrainSampleIndex(
|
export function getTerrainSampleIndex(
|
||||||
terrain: Pick<Terrain, "sampleCountX" | "sampleCountZ">,
|
terrain: Pick<Terrain, "sampleCountX" | "sampleCountZ">,
|
||||||
sampleX: number,
|
sampleX: number,
|
||||||
|
|||||||
Reference in New Issue
Block a user