fix(simulation): keep runtime stable on settings save

This commit is contained in:
DCCONSTRUCTIONS
2026-08-26 16:15:37 +03:00
parent ac1dc7d930
commit 1696b4742b
2 changed files with 9 additions and 2 deletions
@@ -62,6 +62,7 @@ export function SimulationViewport({
project.viewerSettings.camera.invertVertical,
);
const [settingsError, setSettingsError] = useState<string | null>(null);
const worldManifestRevision = JSON.stringify(project.worldManifest);
useEffect(() => {
const settings = project.viewerSettings;
@@ -142,7 +143,10 @@ export function SimulationViewport({
runtime.dispose();
runtimeRef.current = null;
};
}, [project.projectId, project.worldManifest]);
// Saving viewer preferences returns a fresh project object. Restart the GPU
// runtime only when the manifest content changes, not when its object identity
// changes after an otherwise unrelated settings PUT.
}, [project.projectId, worldManifestRevision]);
const collisionAvailable = project.worldManifest?.collision.available ?? false;
const commitViewerSettings = (settings: SimulationViewerSettings) => {
@@ -19,7 +19,7 @@ test("simulation is a dedicated Polygon workspace with a bounded feature slice",
assert.match(productModel, /id: "simulations"[\s\S]*root: "polygon"[\s\S]*kind: "simulations"/);
assert.match(workspaceHub, /case "simulations":[\s\S]*<SimulationWorkspace \/>/);
assert.match(workspace, /simulation-catalog__table/);
assert.match(workspace, /<SimulationViewport project=\{selected\}/);
assert.match(workspace, /<SimulationViewport[\s\S]*project=\{selected\}/);
assert.match(workspace, /<ConfirmationModal/);
assert.match(styles, /styles\/simulation\.css/);
});
@@ -103,4 +103,7 @@ test("PlayCanvas owns the realtime scene graph without an iframe or React entity
assert.match(viewport, /Ось инверсии collision-слоя/);
assert.match(viewport, /saveSimulationViewerSettings/);
assert.match(viewport, /onProjectChange\?\.\(saved\)/);
assert.match(viewport, /const worldManifestRevision = JSON\.stringify\(project\.worldManifest\)/);
assert.match(viewport, /\[project\.projectId, worldManifestRevision\]/);
assert.doesNotMatch(viewport, /\[project\.projectId, project\.worldManifest\]/);
});