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:
2026-04-20 02:36:38 +02:00
parent 02f6d058a0
commit 94dec56eb4
25 changed files with 2199 additions and 70 deletions

View File

@@ -145,6 +145,9 @@ import {
import {
BOX_BRUSH_SCENE_DOCUMENT_VERSION,
ANIMATION_PLAYBACK_SCENE_DOCUMENT_VERSION,
AUTHORED_TERRAIN_COLLISION_SCENE_DOCUMENT_VERSION,
AUTHORED_TERRAIN_FOUNDATION_SCENE_DOCUMENT_VERSION,
AUTHORED_TERRAIN_PAINT_SCENE_DOCUMENT_VERSION,
AUTHORED_OBJECT_STATE_SCENE_DOCUMENT_VERSION,
CONTROL_SURFACE_FOUNDATION_SCENE_DOCUMENT_VERSION,
DEFAULT_PROJECT_NAME,
@@ -1855,6 +1858,36 @@ function readTerrain(value: unknown, label: string): Terrain {
const heights = value.heights.map((heightValue, index) =>
expectFiniteNumber(heightValue, `${label}.heights.${index}`)
);
const layers =
value.layers === undefined
? undefined
: (() => {
if (!Array.isArray(value.layers) || value.layers.some((layer) => !isRecord(layer))) {
throw new Error(`${label}.layers must be an array of layer objects.`);
}
return value.layers.map((layerValue, layerIndex) => ({
materialId:
layerValue.materialId === undefined || layerValue.materialId === null
? null
: expectString(
layerValue.materialId,
`${label}.layers.${layerIndex}.materialId`
)
}));
})();
const paintWeights =
value.paintWeights === undefined
? undefined
: (() => {
if (!Array.isArray(value.paintWeights)) {
throw new Error(`${label}.paintWeights must be an array.`);
}
return value.paintWeights.map((paintWeight, index) =>
expectFiniteNumber(paintWeight, `${label}.paintWeights.${index}`)
);
})();
return createTerrain({
id: expectString(value.id, `${label}.id`),
@@ -1863,11 +1896,17 @@ function readTerrain(value: unknown, label: string): Terrain {
),
visible: expectBoolean(value.visible, `${label}.visible`),
enabled: expectBoolean(value.enabled, `${label}.enabled`),
collisionEnabled:
value.collisionEnabled === undefined
? undefined
: expectBoolean(value.collisionEnabled, `${label}.collisionEnabled`),
position: readVec3(value.position, `${label}.position`),
sampleCountX,
sampleCountZ,
cellSize,
heights
heights,
layers,
paintWeights
});
}
@@ -4841,6 +4880,9 @@ export function migrateSceneDocument(source: unknown): SceneDocument {
source.version !== PROJECT_SEQUENCE_EFFECTS_SCENE_DOCUMENT_VERSION &&
source.version !== PROJECT_SEQUENCE_UNIFIED_VISIBILITY_SCENE_DOCUMENT_VERSION &&
source.version !== SCENE_TRANSITION_SEQUENCE_EFFECTS_SCENE_DOCUMENT_VERSION &&
source.version !== AUTHORED_TERRAIN_FOUNDATION_SCENE_DOCUMENT_VERSION &&
source.version !== AUTHORED_TERRAIN_PAINT_SCENE_DOCUMENT_VERSION &&
source.version !== AUTHORED_TERRAIN_COLLISION_SCENE_DOCUMENT_VERSION &&
source.version !== FOLLOW_ACTOR_PATH_SMOOTH_SCENE_DOCUMENT_VERSION
) {
throw new Error(