Implement updateSimulationFrame to synchronize viewport state with running simulation

This commit is contained in:
2026-04-27 15:44:03 +02:00
parent e331e94715
commit 634fb57bed

View File

@@ -1017,6 +1017,7 @@ export class ViewportHost {
) {
this.currentSimulationScene = runtimeScene;
this.currentSimulationClock = clock;
this.simulationInteractableEnabledById.clear();
this.applyWorld();
if (this.currentDocument === null) {
@@ -1029,6 +1030,29 @@ export class ViewportHost {
this.rebuildModelInstances(this.currentDocument, this.currentSelection);
}
updateSimulationFrame(
runtimeScene: RuntimeSceneDefinition | null,
clock: RuntimeClockState | null
) {
if (this.currentSimulationScene !== runtimeScene) {
this.updateSimulation(runtimeScene, clock);
return;
}
this.currentSimulationClock = clock;
this.applyWorld();
if (this.currentDocument === null || runtimeScene === null) {
return;
}
this.syncSimulationLocalLights(runtimeScene);
this.syncSimulationLightVolumes(runtimeScene);
this.syncSimulationNpcs(runtimeScene);
this.syncSimulationInteractables(runtimeScene);
this.syncSimulationModelInstances(runtimeScene);
}
updateSelection(selection: EditorSelection, activeSelectionId: string | null) {
const previousSelection = this.currentSelection;
const selectionChanged = !areEditorSelectionsEqual(