auto-git:

[change] src/runtime-three/runtime-scene-build.ts
 [change] src/viewport-three/transform-surface-snap.ts
 [change] src/viewport-three/viewport-host.ts
 [change] tests/domain/runtime-interaction-system.test.ts
 [change] tests/domain/transform-session.command.test.ts
 [change] tests/serialization/scene-document-json.test.ts
 [change] tests/unit/runtime-interaction-system.test.ts
 [change] tests/unit/transform-foundation.integration.test.tsx
This commit is contained in:
2026-05-11 14:15:15 +02:00
parent 01ef204dcc
commit 4b76f1a719
8 changed files with 214 additions and 158 deletions

View File

@@ -49,7 +49,10 @@ import {
type WhiteboxVertexId, type WhiteboxVertexId,
type FaceUvState type FaceUvState
} from "../document/brushes"; } from "../document/brushes";
import type { ProjectDocument, SceneDocument } from "../document/scene-document"; import type {
ProjectDocument,
SceneDocument
} from "../document/scene-document";
import { import {
cloneProjectTimeSettings, cloneProjectTimeSettings,
type ProjectTimeSettings type ProjectTimeSettings
@@ -761,9 +764,7 @@ function buildRuntimePlayerMovement(
jump: clonePlayerStartJumpSettings(resolvedTemplate.jump), jump: clonePlayerStartJumpSettings(resolvedTemplate.jump),
sprint: clonePlayerStartSprintSettings(resolvedTemplate.sprint), sprint: clonePlayerStartSprintSettings(resolvedTemplate.sprint),
crouch: clonePlayerStartCrouchSettings(resolvedTemplate.crouch), crouch: clonePlayerStartCrouchSettings(resolvedTemplate.crouch),
edgeAssist: clonePlayerStartEdgeAssistSettings( edgeAssist: clonePlayerStartEdgeAssistSettings(resolvedTemplate.edgeAssist)
resolvedTemplate.edgeAssist
)
}; };
} }
@@ -1196,7 +1197,9 @@ function combineColliderBounds(
}; };
} }
function getRuntimeTerrainSceneBounds(terrain: RuntimeTerrain): RuntimeSceneBounds { function getRuntimeTerrainSceneBounds(
terrain: RuntimeTerrain
): RuntimeSceneBounds {
const bounds = getTerrainBounds({ const bounds = getTerrainBounds({
...terrain, ...terrain,
kind: "terrain", kind: "terrain",
@@ -1397,9 +1400,7 @@ function buildRuntimeControlSurface(
capabilities.push("actorPathFollow"); capabilities.push("actorPathFollow");
} }
targets.push( targets.push(createControlTargetDescriptor(target, capabilities));
createControlTargetDescriptor(target, capabilities)
);
resolved.discrete.push( resolved.discrete.push(
createResolvedActorAnimationPlaybackState({ createResolvedActorAnimationPlaybackState({
target, target,
@@ -1559,7 +1560,9 @@ function buildRuntimeControlSurface(
authoredModelInstance === undefined authoredModelInstance === undefined
? undefined ? undefined
: document.assets[authoredModelInstance.assetId]; : document.assets[authoredModelInstance.assetId];
const target = createModelInstanceControlTargetRef(modelInstance.instanceId); const target = createModelInstanceControlTargetRef(
modelInstance.instanceId
);
const hasAnimationPlayback = const hasAnimationPlayback =
asset !== undefined && asset !== undefined &&
asset.kind === "model" && asset.kind === "model" &&
@@ -2013,7 +2016,9 @@ export function buildRuntimeSceneFromDocument(
case "stopSound": case "stopSound":
return enabledEntityIds.has(link.action.targetSoundEmitterId); return enabledEntityIds.has(link.action.targetSoundEmitterId);
case "runSequence": case "runSequence":
return getInteractionLinkImpulseSteps(link, document.sequences).length > 0; return (
getInteractionLinkImpulseSteps(link, document.sequences).length > 0
);
case "control": case "control":
switch (link.action.effect.target.kind) { switch (link.action.effect.target.kind) {
case "entity": case "entity":

View File

@@ -1,10 +1,4 @@
import { import { Euler, Matrix3, Quaternion, Vector3, type Object3D } from "three";
Euler,
Matrix3,
Quaternion,
Vector3,
type Object3D
} from "three";
import type { ProjectAssetBoundingBox } from "../assets/project-assets"; import type { ProjectAssetBoundingBox } from "../assets/project-assets";
import type { TransformPreview } from "../core/transform-session"; import type { TransformPreview } from "../core/transform-session";

View File

@@ -441,8 +441,7 @@ function isTerrainFoliageMaskTool(
tool: TerrainBrushTool | null | undefined tool: TerrainBrushTool | null | undefined
): boolean { ): boolean {
return ( return (
isTerrainFoliageLayerMaskTool(tool) || isTerrainFoliageLayerMaskTool(tool) || isTerrainFoliageBlockerMaskTool(tool)
isTerrainFoliageBlockerMaskTool(tool)
); );
} }
@@ -1265,9 +1264,8 @@ export class ViewportHost {
versionInfo?.frameVersion ?? this.currentSimulationFrameVersion + 1; versionInfo?.frameVersion ?? this.currentSimulationFrameVersion + 1;
this.currentSimulationMembershipSignatures = this.currentSimulationMembershipSignatures =
createViewportSimulationMembershipSignatures(runtimeScene); createViewportSimulationMembershipSignatures(runtimeScene);
this.simulationActiveNpcEntityIds = this.collectActiveSimulationNpcEntityIds( this.simulationActiveNpcEntityIds =
runtimeScene this.collectActiveSimulationNpcEntityIds(runtimeScene);
);
this.simulationSceneIdentityMismatchWarned = false; this.simulationSceneIdentityMismatchWarned = false;
this.simulationInteractableEnabledById.clear(); this.simulationInteractableEnabledById.clear();
this.cacheSimulationInteractableEnabledState(runtimeScene); this.cacheSimulationInteractableEnabledState(runtimeScene);
@@ -1384,11 +1382,15 @@ export class ViewportHost {
return nextTerrainIds.every( return nextTerrainIds.every(
(terrainId) => (terrainId) =>
previousDocument.terrains[terrainId] === nextDocument.terrains[terrainId] previousDocument.terrains[terrainId] ===
nextDocument.terrains[terrainId]
); );
} }
updateSelection(selection: EditorSelection, activeSelectionId: string | null) { updateSelection(
selection: EditorSelection,
activeSelectionId: string | null
) {
const previousSelection = this.currentSelection; const previousSelection = this.currentSelection;
const selectionChanged = !areEditorSelectionsEqual( const selectionChanged = !areEditorSelectionsEqual(
previousSelection, previousSelection,
@@ -1721,7 +1723,12 @@ export class ViewportHost {
this.cancelActiveTerrainBrushStroke(false); this.cancelActiveTerrainBrushStroke(false);
} }
if (terrainChanged || toolChanged || layerChanged || terrainBrushState === null) { if (
terrainChanged ||
toolChanged ||
layerChanged ||
terrainBrushState === null
) {
this.rebuildDisplayedTerrainState(); this.rebuildDisplayedTerrainState();
} }
@@ -1855,8 +1862,7 @@ export class ViewportHost {
const fitZoom = const fitZoom =
Math.min(visibleWidth, ORTHOGRAPHIC_FRUSTUM_HEIGHT) / fitSize; Math.min(visibleWidth, ORTHOGRAPHIC_FRUSTUM_HEIGHT) / fitSize;
this.orthographicCamera.zoom = this.orthographicCamera.zoom = this.clampOrthographicCameraZoom(fitZoom);
this.clampOrthographicCameraZoom(fitZoom);
this.applyOrthographicCameraPose(); this.applyOrthographicCameraPose();
this.emitCameraStateChange(); this.emitCameraStateChange();
} }
@@ -1990,8 +1996,7 @@ export class ViewportHost {
traceUpdateLoopEvent("ViewportHost.emitCameraStateChange", { traceUpdateLoopEvent("ViewportHost.emitCameraStateChange", {
panelId: this.panelId, panelId: this.panelId,
previousCameraState: previousCameraState: summarizeUpdateLoopCameraState(previousCameraState),
summarizeUpdateLoopCameraState(previousCameraState),
nextCameraState: summarizeUpdateLoopCameraState(nextCameraState), nextCameraState: summarizeUpdateLoopCameraState(nextCameraState),
equalityGuardConsideredDifferent: equalityGuardConsideredDifferent:
previousCameraState === null ? null : !cameraStatesEqual, previousCameraState === null ? null : !cameraStatesEqual,
@@ -4089,18 +4094,18 @@ export class ViewportHost {
return { return {
kind: "entity" as const, kind: "entity" as const,
position: { position: {
...session.target.initialPosition ...session.target.initialPosition
}, },
rotation: { rotation: {
kind: "yaw" as const, kind: "yaw" as const,
yawDegrees: normalizeYawDegrees( yawDegrees: normalizeYawDegrees(
session.target.initialRotation.yawDegrees + pointerDeltaDegrees session.target.initialRotation.yawDegrees + pointerDeltaDegrees
) )
}, },
scale: cloneEntityTransformScaleState(session.target.initialScale) scale: cloneEntityTransformScaleState(session.target.initialScale)
}; };
} }
if (session.target.initialRotation.kind === "direction") { if (session.target.initialRotation.kind === "direction") {
const initialOrientation = new Quaternion().setFromUnitVectors( const initialOrientation = new Quaternion().setFromUnitVectors(
@@ -5358,9 +5363,15 @@ export class ViewportHost {
}; };
if (axisConstraint === null) { if (axisConstraint === null) {
nextScale.x = this.snapScaleValue(item.initialScale.x * scaleFactor); nextScale.x = this.snapScaleValue(
nextScale.y = this.snapScaleValue(item.initialScale.y * scaleFactor); item.initialScale.x * scaleFactor
nextScale.z = this.snapScaleValue(item.initialScale.z * scaleFactor); );
nextScale.y = this.snapScaleValue(
item.initialScale.y * scaleFactor
);
nextScale.z = this.snapScaleValue(
item.initialScale.z * scaleFactor
);
} else { } else {
const scaleAxis = resolveDominantLocalAxisForWorldAxis( const scaleAxis = resolveDominantLocalAxisForWorldAxis(
item.initialRotationDegrees, item.initialRotationDegrees,
@@ -6199,7 +6210,8 @@ export class ViewportHost {
} }
for (const modelInstanceId of targetIds.modelInstanceIds) { for (const modelInstanceId of targetIds.modelInstanceIds) {
const modelInstance = this.currentDocument.modelInstances[modelInstanceId]; const modelInstance =
this.currentDocument.modelInstances[modelInstanceId];
if (modelInstance === undefined) { if (modelInstance === undefined) {
continue; continue;
@@ -6698,9 +6710,8 @@ export class ViewportHost {
return; return;
} }
const nextActiveNpcEntityIds = this.collectActiveSimulationNpcEntityIds( const nextActiveNpcEntityIds =
runtimeScene this.collectActiveSimulationNpcEntityIds(runtimeScene);
);
for (const runtimeNpc of runtimeScene.npcDefinitions) { for (const runtimeNpc of runtimeScene.npcDefinitions) {
const authoredEntity = this.currentDocument.entities[runtimeNpc.entityId]; const authoredEntity = this.currentDocument.entities[runtimeNpc.entityId];
@@ -6779,9 +6790,7 @@ export class ViewportHost {
let addedRenderGroup = false; let addedRenderGroup = false;
for (const modelInstance of runtimeScene.modelInstances) { for (const modelInstance of runtimeScene.modelInstances) {
const renderGroup = this.modelRenderObjects.get( const renderGroup = this.modelRenderObjects.get(modelInstance.instanceId);
modelInstance.instanceId
);
if (renderGroup === undefined) { if (renderGroup === undefined) {
const displayedModelInstance = this.getDisplayedModelInstanceById( const displayedModelInstance = this.getDisplayedModelInstanceById(
@@ -7005,7 +7014,9 @@ export class ViewportHost {
return this.currentDocument.materials[materialId] ?? null; return this.currentDocument.materials[materialId] ?? null;
} }
private getTerrainFoliageMaskPreviewLayerId(terrainId: string): string | null { private getTerrainFoliageMaskPreviewLayerId(
terrainId: string
): string | null {
const brushState = this.currentTerrainBrushState; const brushState = this.currentTerrainBrushState;
if (brushState === null || brushState.terrainId !== terrainId) { if (brushState === null || brushState.terrainId !== terrainId) {
@@ -7022,9 +7033,7 @@ export class ViewportHost {
return brushState.foliageLayerId; return brushState.foliageLayerId;
} }
private isTerrainFoliageBlockerMaskPreviewActive( private isTerrainFoliageBlockerMaskPreviewActive(terrainId: string): boolean {
terrainId: string
): boolean {
return ( return (
this.currentTerrainBrushState !== null && this.currentTerrainBrushState !== null &&
this.currentTerrainBrushState.terrainId === terrainId && this.currentTerrainBrushState.terrainId === terrainId &&
@@ -7084,12 +7093,14 @@ export class ViewportHost {
return createTerrainLayerBlendMaterial({ return createTerrainLayerBlendMaterial({
layerTextures, layerTextures,
foliageMaskPreviewColorHex: foliageMaskPreviewColorHex: this.getTerrainFoliageMaskPreviewColor(
this.getTerrainFoliageMaskPreviewColor(terrain.id), terrain.id
foliageMaskPreviewOpacity: ),
!this.isTerrainFoliageMaskPreviewActive(terrain.id) foliageMaskPreviewOpacity: !this.isTerrainFoliageMaskPreviewActive(
? 0 terrain.id
: 0.62, )
? 0
: 0.62,
emissiveHex: active emissiveHex: active
? TERRAIN_ACTIVE_EMISSIVE ? TERRAIN_ACTIVE_EMISSIVE
: selected : selected
@@ -7106,17 +7117,21 @@ export class ViewportHost {
const selected = isTerrainSelected(this.currentSelection, terrain.id); const selected = isTerrainSelected(this.currentSelection, terrain.id);
const hovered = isTerrainSelected(this.hoveredSelection, terrain.id); const hovered = isTerrainSelected(this.hoveredSelection, terrain.id);
const layerColors = terrain.layers.map((layer) => const layerColors = terrain.layers.map((layer) =>
getTerrainLayerPreviewColor(this.resolveTerrainLayerMaterial(layer.materialId)) getTerrainLayerPreviewColor(
this.resolveTerrainLayerMaterial(layer.materialId)
)
) as [number, number, number, number]; ) as [number, number, number, number];
return createTerrainLayerColorBlendMaterial({ return createTerrainLayerColorBlendMaterial({
layerColors, layerColors,
foliageMaskPreviewColorHex: foliageMaskPreviewColorHex: this.getTerrainFoliageMaskPreviewColor(
this.getTerrainFoliageMaskPreviewColor(terrain.id), terrain.id
foliageMaskPreviewOpacity: ),
!this.isTerrainFoliageMaskPreviewActive(terrain.id) foliageMaskPreviewOpacity: !this.isTerrainFoliageMaskPreviewActive(
? 0 terrain.id
: 0.62, )
? 0
: 0.62,
emissiveHex: active emissiveHex: active
? TERRAIN_ACTIVE_EMISSIVE ? TERRAIN_ACTIVE_EMISSIVE
: selected : selected
@@ -7201,7 +7216,11 @@ export class ViewportHost {
foliageMaskLayerId: this.getTerrainFoliageMaskPreviewLayerId(terrain.id) foliageMaskLayerId: this.getTerrainFoliageMaskPreviewLayerId(terrain.id)
}); });
group.position.set(terrain.position.x, terrain.position.y, terrain.position.z); group.position.set(
terrain.position.x,
terrain.position.y,
terrain.position.z
);
for (const chunk of lodMeshData.chunks) { for (const chunk of lodMeshData.chunks) {
const levelGeometries = chunk.levels.map((level) => level.geometry); const levelGeometries = chunk.levels.map((level) => level.geometry);
@@ -7321,7 +7340,10 @@ export class ViewportHost {
continue; continue;
} }
this.refreshDisplayedTerrainDirtyBounds(terrain.id, dirtyState.dirtyBounds); this.refreshDisplayedTerrainDirtyBounds(
terrain.id,
dirtyState.dirtyBounds
);
} }
} }
@@ -8601,7 +8623,11 @@ export class ViewportHost {
selected, selected,
previewShellColor ?? (selected ? NPC_SELECTED_COLOR : NPC_COLOR) previewShellColor ?? (selected ? NPC_SELECTED_COLOR : NPC_COLOR)
); );
renderObjects.group.scale.set(entity.scale.x, entity.scale.y, entity.scale.z); renderObjects.group.scale.set(
entity.scale.x,
entity.scale.y,
entity.scale.z
);
return renderObjects; return renderObjects;
} }
@@ -9695,15 +9721,16 @@ export class ViewportHost {
this.createFaceMaterial( this.createFaceMaterial(
brush, brush,
faceId, faceId,
this.currentDocument?.materials[ this.currentDocument?.materials[brush.faces[faceId].materialId ?? ""],
brush.faces[faceId].materialId ?? ""
],
this.getFaceHighlightState(brush.id, faceId), this.getFaceHighlightState(brush.id, faceId),
volumeRenderPaths, volumeRenderPaths,
contactPatches contactPatches
) )
); );
this.configureFogVolumeMesh(renderObjects.mesh, renderObjects.mesh.material); this.configureFogVolumeMesh(
renderObjects.mesh,
renderObjects.mesh.material
);
applyRendererRenderCategoryFromMaterial(renderObjects.mesh); applyRendererRenderCategoryFromMaterial(renderObjects.mesh);
this.disposeUniqueMaterials(previousMaterials); this.disposeUniqueMaterials(previousMaterials);
@@ -9778,11 +9805,13 @@ export class ViewportHost {
return; return;
} }
const displayedTerrain = this.getDisplayedTerrainState(terrainId) ?? terrain; const displayedTerrain =
this.getDisplayedTerrainState(terrainId) ?? terrain;
const previousDetailMaterial = renderObjects.detailMaterial; const previousDetailMaterial = renderObjects.detailMaterial;
const previousDistantMaterial = renderObjects.distantMaterial; const previousDistantMaterial = renderObjects.distantMaterial;
const nextDetailMaterial = this.createTerrainMaterial(displayedTerrain); const nextDetailMaterial = this.createTerrainMaterial(displayedTerrain);
const nextDistantMaterial = this.createTerrainDistantMaterial(displayedTerrain); const nextDistantMaterial =
this.createTerrainDistantMaterial(displayedTerrain);
for (const chunk of renderObjects.chunks) { for (const chunk of renderObjects.chunks) {
chunk.mesh.material = chunk.mesh.material =
@@ -9884,8 +9913,9 @@ export class ViewportHost {
chunk.startSampleZ, chunk.startSampleZ,
undefined, undefined,
{ {
foliageMaskLayerId: foliageMaskLayerId: this.getTerrainFoliageMaskPreviewLayerId(
this.getTerrainFoliageMaskPreviewLayerId(terrain.id) terrain.id
)
} }
); );
@@ -10179,8 +10209,8 @@ export class ViewportHost {
layerIndex: toolState.tool === "paint" ? toolState.layerIndex : null, layerIndex: toolState.tool === "paint" ? toolState.layerIndex : null,
foliageLayerId: foliageLayerId:
toolState.tool === "foliagePaint" || toolState.tool === "foliageErase" toolState.tool === "foliagePaint" || toolState.tool === "foliageErase"
? toolState.foliageLayerId ? toolState.foliageLayerId
: null : null
}); });
} }
@@ -10233,7 +10263,9 @@ export class ViewportHost {
const foliageBlockerMaskValueIndices = new Set<number>(); const foliageBlockerMaskValueIndices = new Set<number>();
let lastAppliedPoint = from; let lastAppliedPoint = from;
const stepCount = Math.floor(distance / spacing); const stepCount = Math.floor(distance / spacing);
const mergeDirtyBounds = (nextBounds: TerrainBrushDirtySampleBounds | null) => { const mergeDirtyBounds = (
nextBounds: TerrainBrushDirtySampleBounds | null
) => {
if (nextBounds === null) { if (nextBounds === null) {
return; return;
} }
@@ -10457,8 +10489,7 @@ export class ViewportHost {
); );
this.activeTerrainBrushStroke = { this.activeTerrainBrushStroke = {
...this.activeTerrainBrushStroke, ...this.activeTerrainBrushStroke,
changed: changed: this.activeTerrainBrushStroke.changed || segmentResult.changed,
this.activeTerrainBrushStroke.changed || segmentResult.changed,
dirtyBounds: this.mergeTerrainBrushDirtyBounds( dirtyBounds: this.mergeTerrainBrushDirtyBounds(
this.activeTerrainBrushStroke.dirtyBounds, this.activeTerrainBrushStroke.dirtyBounds,
segmentResult.dirtyBounds segmentResult.dirtyBounds
@@ -10514,17 +10545,15 @@ export class ViewportHost {
const foliageBlockerMaskValueIndices = new Set( const foliageBlockerMaskValueIndices = new Set(
activeStroke.foliageBlockerMaskValueIndices activeStroke.foliageBlockerMaskValueIndices
); );
const mergeStampIndices = ( const mergeStampIndices = (result: {
result: { heightSampleIndices: readonly number[];
heightSampleIndices: readonly number[]; paintWeightIndices: readonly number[];
paintWeightIndices: readonly number[]; foliageMaskValueIndices?: ReturnType<
foliageMaskValueIndices?: ReturnType< typeof applyTerrainBrushStampInPlace
typeof applyTerrainBrushStampInPlace >["foliageMaskValueIndices"];
>["foliageMaskValueIndices"]; foliageMaskValueKeys?: readonly string[];
foliageMaskValueKeys?: readonly string[]; foliageBlockerMaskValueIndices?: readonly number[];
foliageBlockerMaskValueIndices?: readonly number[]; }) => {
}
) => {
for (const sampleIndex of result.heightSampleIndices) { for (const sampleIndex of result.heightSampleIndices) {
heightSampleIndices.add(sampleIndex); heightSampleIndices.add(sampleIndex);
} }
@@ -10533,7 +10562,8 @@ export class ViewportHost {
paintWeightIndices.add(paintWeightIndex); paintWeightIndices.add(paintWeightIndex);
} }
for (const foliageMaskValueIndex of result.foliageMaskValueIndices ?? []) { for (const foliageMaskValueIndex of result.foliageMaskValueIndices ??
[]) {
foliageMaskValueKeys.add( foliageMaskValueKeys.add(
createTerrainFoliageMaskValueKey( createTerrainFoliageMaskValueKey(
foliageMaskValueIndex.layerId, foliageMaskValueIndex.layerId,

View File

@@ -159,7 +159,7 @@ function createRuntimeSceneFixture(): RuntimeSceneDefinition {
prompt: "Disabled Prompt", prompt: "Disabled Prompt",
interactionEnabled: false interactionEnabled: false
} }
], ]
}, },
interactionLinks: [], interactionLinks: [],
control: createEmptyRuntimeControlSurfaceDefinition(), control: createEmptyRuntimeControlSurfaceDefinition(),
@@ -288,7 +288,7 @@ describe("RuntimeInteractionSystem", () => {
playAnimation: () => {}, playAnimation: () => {},
stopAnimation: () => {}, stopAnimation: () => {},
playSound: () => {}, playSound: () => {},
stopSound: () => {}, stopSound: () => {}
} }
); );
interactionSystem.updatePlayerPosition( interactionSystem.updatePlayerPosition(
@@ -309,7 +309,7 @@ describe("RuntimeInteractionSystem", () => {
playAnimation: () => {}, playAnimation: () => {},
stopAnimation: () => {}, stopAnimation: () => {},
playSound: () => {}, playSound: () => {},
stopSound: () => {}, stopSound: () => {}
} }
); );
@@ -423,7 +423,7 @@ describe("RuntimeInteractionSystem", () => {
dispatches.push(`${link.id}:${instanceId}`); dispatches.push(`${link.id}:${instanceId}`);
}, },
playSound: () => {}, playSound: () => {},
stopSound: () => {}, stopSound: () => {}
} }
); );
@@ -462,7 +462,9 @@ describe("RuntimeInteractionSystem", () => {
throw new Error("Expected a camera rig entity control target."); throw new Error("Expected a camera rig entity control target.");
} }
dispatches.push(`${link.id}:${effect.type}:${effect.target.entityId}`); dispatches.push(
`${link.id}:${effect.type}:${effect.target.entityId}`
);
} }
}) })
); );
@@ -480,7 +482,9 @@ describe("RuntimeInteractionSystem", () => {
throw new Error("Expected a camera rig entity control target."); throw new Error("Expected a camera rig entity control target.");
} }
dispatches.push(`${link.id}:${effect.type}:${effect.target.entityId}`); dispatches.push(
`${link.id}:${effect.type}:${effect.target.entityId}`
);
} }
}) })
); );
@@ -515,7 +519,9 @@ describe("RuntimeInteractionSystem", () => {
throw new Error("Expected a camera rig entity control target."); throw new Error("Expected a camera rig entity control target.");
} }
dispatches.push(`${link.id}:${effect.type}:${effect.target.entityId}`); dispatches.push(
`${link.id}:${effect.type}:${effect.target.entityId}`
);
} }
}) })
); );
@@ -564,7 +570,7 @@ describe("RuntimeInteractionSystem", () => {
playAnimation: () => {}, playAnimation: () => {},
stopAnimation: () => {}, stopAnimation: () => {},
playSound: () => {}, playSound: () => {},
stopSound: () => {}, stopSound: () => {}
} }
); );
interactionSystem.updatePlayerPosition( interactionSystem.updatePlayerPosition(
@@ -590,7 +596,7 @@ describe("RuntimeInteractionSystem", () => {
playAnimation: () => {}, playAnimation: () => {},
stopAnimation: () => {}, stopAnimation: () => {},
playSound: () => {}, playSound: () => {},
stopSound: () => {}, stopSound: () => {}
} }
); );
@@ -728,7 +734,7 @@ describe("RuntimeInteractionSystem", () => {
playAnimation: () => {}, playAnimation: () => {},
stopAnimation: () => {}, stopAnimation: () => {},
playSound: () => {}, playSound: () => {},
stopSound: () => {}, stopSound: () => {}
} }
); );
@@ -779,7 +785,7 @@ describe("RuntimeInteractionSystem", () => {
}, },
stopSound: (soundEmitterId, link) => { stopSound: (soundEmitterId, link) => {
dispatches.push(`${link.id}:${soundEmitterId}`); dispatches.push(`${link.id}:${soundEmitterId}`);
}, }
} }
); );
@@ -1402,7 +1408,9 @@ describe("RuntimeInteractionSystem", () => {
runtimeScene, runtimeScene,
{ {
teleportPlayer: () => { teleportPlayer: () => {
throw new Error("Teleport should not dispatch for a scene transition."); throw new Error(
"Teleport should not dispatch for a scene transition."
);
}, },
startSceneTransition: (request) => { startSceneTransition: (request) => {
dispatches.push( dispatches.push(
@@ -1410,12 +1418,14 @@ describe("RuntimeInteractionSystem", () => {
); );
}, },
toggleBrushVisibility: () => { toggleBrushVisibility: () => {
throw new Error("Visibility should not dispatch for a scene transition."); throw new Error(
"Visibility should not dispatch for a scene transition."
);
}, },
playAnimation: () => {}, playAnimation: () => {},
stopAnimation: () => {}, stopAnimation: () => {},
playSound: () => {}, playSound: () => {},
stopSound: () => {}, stopSound: () => {}
} }
); );

View File

@@ -248,19 +248,25 @@ describe("transform session commit commands", () => {
expect( expect(
supportsTransformOperation( supportsTransformOperation(
pathPointResolved.target as NonNullable<typeof pathPointResolved.target>, pathPointResolved.target as NonNullable<
typeof pathPointResolved.target
>,
"translate" "translate"
) )
).toBe(true); ).toBe(true);
expect( expect(
supportsTransformOperation( supportsTransformOperation(
pathPointResolved.target as NonNullable<typeof pathPointResolved.target>, pathPointResolved.target as NonNullable<
typeof pathPointResolved.target
>,
"rotate" "rotate"
) )
).toBe(false); ).toBe(false);
expect( expect(
supportsTransformOperation( supportsTransformOperation(
pathPointResolved.target as NonNullable<typeof pathPointResolved.target>, pathPointResolved.target as NonNullable<
typeof pathPointResolved.target
>,
"scale" "scale"
) )
).toBe(false); ).toBe(false);
@@ -1343,12 +1349,13 @@ describe("transform session commit commands", () => {
}; };
store.executeCommand( store.executeCommand(
createCommitTransformSessionCommand(store.getState().document, scaleSession) createCommitTransformSessionCommand(
store.getState().document,
scaleSession
)
); );
expect( expect(store.getState().document.entities[triggerVolume.id]).toMatchObject({
store.getState().document.entities[triggerVolume.id]
).toMatchObject({
position: { position: {
x: 1, x: 1,
y: 1, y: 1,
@@ -1367,9 +1374,7 @@ describe("transform session commit commands", () => {
}); });
expect(store.undo()).toBe(true); expect(store.undo()).toBe(true);
expect( expect(store.getState().document.entities[triggerVolume.id]).toMatchObject({
store.getState().document.entities[triggerVolume.id]
).toMatchObject({
rotationDegrees: { rotationDegrees: {
x: 0, x: 0,
y: 45, y: 45,
@@ -1379,9 +1384,7 @@ describe("transform session commit commands", () => {
}); });
expect(store.redo()).toBe(true); expect(store.redo()).toBe(true);
expect( expect(store.getState().document.entities[triggerVolume.id]).toMatchObject({
store.getState().document.entities[triggerVolume.id]
).toMatchObject({
size: { size: {
x: 4, x: 4,
y: 3, y: 3,
@@ -1726,7 +1729,9 @@ describe("transform session commit commands", () => {
createCommitTransformSessionCommand(store.getState().document, session) createCommitTransformSessionCommand(store.getState().document, session)
); );
expect(store.getState().document.modelInstances[modelInstanceA.id]).toMatchObject({ expect(
store.getState().document.modelInstances[modelInstanceA.id]
).toMatchObject({
position: { position: {
x: -2, x: -2,
y: 0, y: 0,
@@ -1738,7 +1743,9 @@ describe("transform session commit commands", () => {
z: 2 z: 2
} }
}); });
expect(store.getState().document.modelInstances[modelInstanceB.id]).toMatchObject({ expect(
store.getState().document.modelInstances[modelInstanceB.id]
).toMatchObject({
position: { position: {
x: 2, x: 2,
y: 0, y: 0,
@@ -1760,7 +1767,9 @@ describe("transform session commit commands", () => {
); );
expect(store.redo()).toBe(true); expect(store.redo()).toBe(true);
expect(store.getState().document.modelInstances[modelInstanceA.id]).toMatchObject({ expect(
store.getState().document.modelInstances[modelInstanceA.id]
).toMatchObject({
position: { position: {
x: -2, x: -2,
y: 0, y: 0,

View File

@@ -237,9 +237,11 @@ describe("scene document JSON", () => {
) as Record<string, unknown>; ) as Record<string, unknown>;
legacyDocument.version = FOLIAGE_FOUNDATION_SCENE_DOCUMENT_VERSION; legacyDocument.version = FOLIAGE_FOUNDATION_SCENE_DOCUMENT_VERSION;
delete ((legacyDocument.terrains as Record<string, Record<string, unknown>>)[ delete (
terrain.id (legacyDocument.terrains as Record<string, Record<string, unknown>>)[
] as Record<string, unknown>).foliageMasks; terrain.id
] as Record<string, unknown>
).foliageMasks;
const migratedDocument = parseSceneDocumentJson( const migratedDocument = parseSceneDocumentJson(
JSON.stringify(legacyDocument) JSON.stringify(legacyDocument)
@@ -264,18 +266,18 @@ describe("scene document JSON", () => {
) as Record<string, unknown>; ) as Record<string, unknown>;
legacyDocument.version = FOLIAGE_QUALITY_SCENE_DOCUMENT_VERSION; legacyDocument.version = FOLIAGE_QUALITY_SCENE_DOCUMENT_VERSION;
delete ((legacyDocument.terrains as Record<string, Record<string, unknown>>)[ delete (
terrain.id (legacyDocument.terrains as Record<string, Record<string, unknown>>)[
] as Record<string, unknown>).foliageBlockerMask; terrain.id
] as Record<string, unknown>
).foliageBlockerMask;
const migratedDocument = parseSceneDocumentJson( const migratedDocument = parseSceneDocumentJson(
JSON.stringify(legacyDocument) JSON.stringify(legacyDocument)
); );
expect(migratedDocument.version).toBe(SCENE_DOCUMENT_VERSION); expect(migratedDocument.version).toBe(SCENE_DOCUMENT_VERSION);
expect( expect(migratedDocument.terrains[terrain.id]?.foliageBlockerMask).toEqual({
migratedDocument.terrains[terrain.id]?.foliageBlockerMask
).toEqual({
resolutionX: 2, resolutionX: 2,
resolutionZ: 2, resolutionZ: 2,
values: [0, 0, 0, 0] values: [0, 0, 0, 0]
@@ -805,9 +807,7 @@ describe("scene document JSON", () => {
const migratedDocument = migrateSceneDocument(legacyDocument); const migratedDocument = migrateSceneDocument(legacyDocument);
expect(migratedDocument.version).toBe(SCENE_DOCUMENT_VERSION); expect(migratedDocument.version).toBe(SCENE_DOCUMENT_VERSION);
expect( expect(migratedDocument.brushes[brush.id].faces.posZ.climbable).toBe(false);
migratedDocument.brushes[brush.id].faces.posZ.climbable
).toBe(false);
}); });
it("round-trips whitebox box volume settings", () => { it("round-trips whitebox box volume settings", () => {

View File

@@ -26,7 +26,9 @@ function createClickLink(sourceEntityId: string): InteractionLink {
}; };
} }
function createNpc(overrides: Partial<RuntimeNpc> & { entityId: string }): RuntimeNpc { function createNpc(
overrides: Partial<RuntimeNpc> & { entityId: string }
): RuntimeNpc {
return { return {
entityId: overrides.entityId, entityId: overrides.entityId,
actorId: overrides.actorId ?? "", actorId: overrides.actorId ?? "",
@@ -38,13 +40,12 @@ function createNpc(overrides: Partial<RuntimeNpc> & { entityId: string }): Runti
modelAssetId: overrides.modelAssetId ?? null, modelAssetId: overrides.modelAssetId ?? null,
dialogues: overrides.dialogues ?? [], dialogues: overrides.dialogues ?? [],
defaultDialogueId: overrides.defaultDialogueId ?? null, defaultDialogueId: overrides.defaultDialogueId ?? null,
collider: collider: overrides.collider ?? {
overrides.collider ?? { mode: "capsule",
mode: "capsule", radius: 0.35,
radius: 0.35, height: 1.8,
height: 1.8, eyeHeight: 1.6
eyeHeight: 1.6 },
},
activeRoutineTitle: overrides.activeRoutineTitle ?? null, activeRoutineTitle: overrides.activeRoutineTitle ?? null,
animationClipName: overrides.animationClipName ?? null, animationClipName: overrides.animationClipName ?? null,
animationLoop: overrides.animationLoop, animationLoop: overrides.animationLoop,
@@ -102,7 +103,10 @@ describe("runtime interaction targeting", () => {
const scene = createRuntimeSceneFixture({ const scene = createRuntimeSceneFixture({
npcs: [centerNpc], npcs: [centerNpc],
interactables: [sideInteractable], interactables: [sideInteractable],
links: [createClickLink(centerNpc.entityId), createClickLink(sideInteractable.entityId)] links: [
createClickLink(centerNpc.entityId),
createClickLink(sideInteractable.entityId)
]
}); });
const candidates = resolveRuntimeTargetCandidates({ const candidates = resolveRuntimeTargetCandidates({

View File

@@ -9,9 +9,7 @@ import {
createProjectAssetStorageKey, createProjectAssetStorageKey,
type ModelAssetRecord type ModelAssetRecord
} from "../../src/assets/project-assets"; } from "../../src/assets/project-assets";
import type { import type { ActiveTransformSession } from "../../src/core/transform-session";
ActiveTransformSession
} from "../../src/core/transform-session";
import { createBoxBrush } from "../../src/document/brushes"; import { createBoxBrush } from "../../src/document/brushes";
import { createEmptySceneDocument } from "../../src/document/scene-document"; import { createEmptySceneDocument } from "../../src/document/scene-document";
import { createPlayerStartEntity } from "../../src/entities/entity-instances"; import { createPlayerStartEntity } from "../../src/entities/entity-instances";
@@ -275,7 +273,9 @@ async function renderMultiSelectionFixtureApp() {
await waitFor(() => { await waitFor(() => {
expect(viewportHostInstances.length).toBeGreaterThan(0); expect(viewportHostInstances.length).toBeGreaterThan(0);
expect(getTopLeftViewportHost().setBrushSelectionChangeHandler).toHaveBeenCalled(); expect(
getTopLeftViewportHost().setBrushSelectionChangeHandler
).toHaveBeenCalled();
}); });
return { return {
@@ -611,9 +611,10 @@ describe("transform foundation integration", () => {
}); });
expect(store.getState().whiteboxSelectionMode).toBe("edge"); expect(store.getState().whiteboxSelectionMode).toBe("edge");
expect( expect(screen.getByTestId("whitebox-selection-mode-edge")).toHaveAttribute(
screen.getByTestId("whitebox-selection-mode-edge") "aria-pressed",
).toHaveAttribute("aria-pressed", "true"); "true"
);
fireEvent.keyDown(window, { fireEvent.keyDown(window, {
key: "3", key: "3",
@@ -635,7 +636,9 @@ describe("transform foundation integration", () => {
expect( expect(
screen.getByTestId("whitebox-selection-mode-object") screen.getByTestId("whitebox-selection-mode-object")
).toHaveAttribute("aria-pressed", "true"); ).toHaveAttribute("aria-pressed", "true");
expect(screen.getByText(/selection mode set to object/i)).toBeInTheDocument(); expect(
screen.getByText(/selection mode set to object/i)
).toBeInTheDocument();
}); });
it("keeps outliner and viewport selection state synchronized for same-kind multi-selection", async () => { it("keeps outliner and viewport selection state synchronized for same-kind multi-selection", async () => {
@@ -660,9 +663,10 @@ describe("transform foundation integration", () => {
expect(screen.getByText("2 selected")).toBeInTheDocument(); expect(screen.getByText("2 selected")).toBeInTheDocument();
expect(screen.getByText("Brush Multi B")).toBeInTheDocument(); expect(screen.getByText("Brush Multi B")).toBeInTheDocument();
const selectionHandler = viewportHost.setBrushSelectionChangeHandler.mock.calls.at( const selectionHandler =
-1 viewportHost.setBrushSelectionChangeHandler.mock.calls.at(
)?.[0] as ((selection: { kind: "entities"; ids: string[] }) => void); -1
)?.[0] as (selection: { kind: "entities"; ids: string[] }) => void;
act(() => { act(() => {
selectionHandler({ selectionHandler({