auto-git:
[add] src/rendering/terrain-layer-material.ts [add] tests/domain/terrains.test.ts [change] src/app/App.tsx [change] src/core/terrain-brush.ts [change] src/document/migrate-scene-document.ts [change] src/document/scene-document-validation.ts [change] src/document/scene-document.ts [change] src/document/terrains.ts [change] src/geometry/terrain-brush.ts [change] src/geometry/terrain-mesh.ts [change] src/runtime-three/rapier-collision-world.ts [change] src/runtime-three/runtime-host.ts [change] src/runtime-three/runtime-scene-build.ts [change] src/viewport-three/ViewportCanvas.tsx [change] src/viewport-three/ViewportPanel.tsx [change] src/viewport-three/viewport-host.ts [change] tests/domain/build-runtime-scene.test.ts [change] tests/domain/rapier-collision-world.test.ts [change] tests/domain/terrain.command.test.ts [change] tests/domain/water-material.test.ts [change] tests/geometry/terrain-brush.test.ts [change] tests/geometry/terrain-mesh.test.ts [change] tests/serialization/scene-document-json.test.ts [change] tests/unit/terrain-foundation.integration.test.tsx [change] tests/unit/viewport-canvas.test.tsx
This commit is contained in:
@@ -66,7 +66,11 @@ import {
|
||||
type ProjectTimeSettings
|
||||
} from "./project-time-settings";
|
||||
import { MIN_SCENE_PATH_POINT_COUNT, type ScenePath } from "./paths";
|
||||
import { MIN_TERRAIN_SAMPLE_COUNT, type Terrain } from "./terrains";
|
||||
import {
|
||||
MIN_TERRAIN_SAMPLE_COUNT,
|
||||
TERRAIN_LAYER_COUNT,
|
||||
type Terrain
|
||||
} from "./terrains";
|
||||
import {
|
||||
isAdvancedRenderingWaterReflectionMode,
|
||||
isAdvancedRenderingShadowMapSize,
|
||||
@@ -1652,6 +1656,7 @@ function validateScenePath(
|
||||
function validateTerrain(
|
||||
terrain: Terrain,
|
||||
path: string,
|
||||
document: SceneDocument,
|
||||
diagnostics: SceneDiagnostic[]
|
||||
) {
|
||||
if (!isBoolean(terrain.visible)) {
|
||||
@@ -1698,6 +1703,17 @@ function validateTerrain(
|
||||
);
|
||||
}
|
||||
|
||||
if (!isBoolean(terrain.collisionEnabled)) {
|
||||
diagnostics.push(
|
||||
createDiagnostic(
|
||||
"error",
|
||||
"invalid-terrain-collision-enabled",
|
||||
"Terrain collisionEnabled must remain a boolean.",
|
||||
`${path}.collisionEnabled`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!isPositiveInteger(terrain.sampleCountX) ||
|
||||
terrain.sampleCountX < MIN_TERRAIN_SAMPLE_COUNT
|
||||
@@ -1762,6 +1778,67 @@ function validateTerrain(
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (terrain.layers.length !== TERRAIN_LAYER_COUNT) {
|
||||
diagnostics.push(
|
||||
createDiagnostic(
|
||||
"error",
|
||||
"invalid-terrain-layer-count",
|
||||
`Terrain layers must contain exactly ${TERRAIN_LAYER_COUNT} authored layer slots.`,
|
||||
`${path}.layers`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
for (let index = 0; index < terrain.layers.length; index += 1) {
|
||||
const layer = terrain.layers[index];
|
||||
|
||||
if (layer.materialId === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (document.materials[layer.materialId] === undefined) {
|
||||
diagnostics.push(
|
||||
createDiagnostic(
|
||||
"error",
|
||||
"invalid-terrain-layer-material",
|
||||
`Terrain layer material reference ${layer.materialId} does not exist in the document material registry.`,
|
||||
`${path}.layers.${index}.materialId`
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const expectedPaintWeightCount =
|
||||
terrain.sampleCountX * terrain.sampleCountZ * (TERRAIN_LAYER_COUNT - 1);
|
||||
|
||||
if (terrain.paintWeights.length !== expectedPaintWeightCount) {
|
||||
diagnostics.push(
|
||||
createDiagnostic(
|
||||
"error",
|
||||
"invalid-terrain-paint-weight-count",
|
||||
`Terrain paint weights must contain exactly ${expectedPaintWeightCount} values.`,
|
||||
`${path}.paintWeights`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
for (let index = 0; index < terrain.paintWeights.length; index += 1) {
|
||||
const paintWeight = terrain.paintWeights[index];
|
||||
|
||||
if (isFiniteNumber(paintWeight) && paintWeight >= 0 && paintWeight <= 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
diagnostics.push(
|
||||
createDiagnostic(
|
||||
"error",
|
||||
"invalid-terrain-paint-weight",
|
||||
"Terrain paint weights must remain finite values between 0 and 1.",
|
||||
`${path}.paintWeights.${index}`
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function validateAuthoredEntityState(
|
||||
@@ -5718,7 +5795,7 @@ export function validateSceneDocument(
|
||||
}
|
||||
|
||||
registerAuthoredId(terrain.id, path, seenIds, diagnostics);
|
||||
validateTerrain(terrain, path, diagnostics);
|
||||
validateTerrain(terrain, path, document, diagnostics);
|
||||
}
|
||||
|
||||
for (const [modelInstanceKey, modelInstance] of Object.entries(
|
||||
|
||||
Reference in New Issue
Block a user