Skip to content
Snippets Groups Projects
Commit 02a466e8 authored by Alexander Rose's avatar Alexander Rose
Browse files

only update repr visibility when changed

- avoids superfluous scene rendering, e.g., when animating
parent 3cb65cbe
No related branches found
No related tags found
No related merge requests found
...@@ -76,11 +76,18 @@ export function UpdateRepresentationVisibility(ctx: PluginContext) { ...@@ -76,11 +76,18 @@ export function UpdateRepresentationVisibility(ctx: PluginContext) {
ctx.state.data.events.cell.stateUpdated.subscribe(e => { ctx.state.data.events.cell.stateUpdated.subscribe(e => {
const cell = e.state.cells.get(e.ref)!; const cell = e.state.cells.get(e.ref)!;
if (!SO.isRepresentation3D(cell.obj)) return; if (!SO.isRepresentation3D(cell.obj)) return;
updateVisibility(cell, cell.obj.data.repr);
ctx.canvas3d?.syncVisibility(); if (updateVisibility(cell, cell.obj.data.repr)) {
ctx.canvas3d?.syncVisibility();
}
}); });
} }
function updateVisibility(cell: StateObjectCell, r: Representation<any>) { function updateVisibility(cell: StateObjectCell, r: Representation<any>) {
r.setState({ visible: !cell.state.isHidden }); if (r.state.visible === cell.state.isHidden) {
r.setState({ visible: !cell.state.isHidden });
return true;
} else {
return false;
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment