auto-git:

[change] src/document/scene-document-validation.ts
This commit is contained in:
2026-05-01 17:43:22 +02:00
parent 4a22b5d3e8
commit ab0f99b2c2

View File

@@ -130,6 +130,7 @@ export interface SceneDocumentValidationResult {
export interface ValidateSceneDocumentOptions { export interface ValidateSceneDocumentOptions {
projectScheduling?: "scene" | "skip"; projectScheduling?: "scene" | "skip";
terrainSampleValues?: "full" | "skip";
} }
export function createDiagnostic( export function createDiagnostic(
@@ -2663,7 +2664,8 @@ function validateTerrain(
terrain: Terrain, terrain: Terrain,
path: string, path: string,
document: SceneDocument, document: SceneDocument,
diagnostics: SceneDiagnostic[] diagnostics: SceneDiagnostic[],
options: ValidateSceneDocumentOptions = {}
) { ) {
if (!isBoolean(terrain.visible)) { if (!isBoolean(terrain.visible)) {
diagnostics.push( diagnostics.push(
@@ -2770,19 +2772,21 @@ function validateTerrain(
); );
} }
for (let index = 0; index < terrain.heights.length; index += 1) { if (options.terrainSampleValues !== "skip") {
if (isFiniteNumber(terrain.heights[index])) { for (let index = 0; index < terrain.heights.length; index += 1) {
continue; if (isFiniteNumber(terrain.heights[index])) {
} continue;
}
diagnostics.push( diagnostics.push(
createDiagnostic( createDiagnostic(
"error", "error",
"invalid-terrain-height", "invalid-terrain-height",
"Terrain heights must remain finite.", "Terrain heights must remain finite.",
`${path}.heights.${index}` `${path}.heights.${index}`
) )
); );
}
} }
if (terrain.layers.length !== TERRAIN_LAYER_COUNT) { if (terrain.layers.length !== TERRAIN_LAYER_COUNT) {
@@ -2829,21 +2833,23 @@ function validateTerrain(
); );
} }
for (let index = 0; index < terrain.paintWeights.length; index += 1) { if (options.terrainSampleValues !== "skip") {
const paintWeight = terrain.paintWeights[index]; for (let index = 0; index < terrain.paintWeights.length; index += 1) {
const paintWeight = terrain.paintWeights[index];
if (isFiniteNumber(paintWeight) && paintWeight >= 0 && paintWeight <= 1) { if (isFiniteNumber(paintWeight) && paintWeight >= 0 && paintWeight <= 1) {
continue; continue;
}
diagnostics.push(
createDiagnostic(
"error",
"invalid-terrain-paint-weight",
"Terrain paint weights must remain finite values between 0 and 1.",
`${path}.paintWeights.${index}`
)
);
} }
diagnostics.push(
createDiagnostic(
"error",
"invalid-terrain-paint-weight",
"Terrain paint weights must remain finite values between 0 and 1.",
`${path}.paintWeights.${index}`
)
);
} }
} }