From 02a466e8b9d10071a26945a1fadc892851bb1b32 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Sat, 13 Feb 2021 11:27:44 -0800 Subject: [PATCH] only update repr visibility when changed - avoids superfluous scene rendering, e.g., when animating --- src/mol-plugin/behavior/static/representation.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mol-plugin/behavior/static/representation.ts b/src/mol-plugin/behavior/static/representation.ts index 50104160a..7d9a7f351 100644 --- a/src/mol-plugin/behavior/static/representation.ts +++ b/src/mol-plugin/behavior/static/representation.ts @@ -76,11 +76,18 @@ export function UpdateRepresentationVisibility(ctx: PluginContext) { ctx.state.data.events.cell.stateUpdated.subscribe(e => { const cell = e.state.cells.get(e.ref)!; 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>) { - 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 -- GitLab