diff --git a/src/mol-geo/representation/structure/spacefill.ts b/src/mol-geo/representation/structure/spacefill.ts index 49e15e20733c3827431b1b54d40bf76c6802581f..f2ace9de14d7738082a88ccd2dbc7284745933dc 100644 --- a/src/mol-geo/representation/structure/spacefill.ts +++ b/src/mol-geo/representation/structure/spacefill.ts @@ -14,7 +14,7 @@ import { Unit, Element, Queries } from 'mol-model/structure'; import { UnitsRepresentation, DefaultStructureProps } from './index'; import { Task } from 'mol-task' import { MeshBuilder } from '../../shape/mesh-builder'; -import { createTransforms, createColors, createFlags } from './utils'; +import { createTransforms, createColors, createFlags, createEmptyFlags } from './utils'; import VertexMap from '../../shape/vertex-map'; import { icosahedronVertexCount } from '../../primitive/icosahedron'; import { deepEqual, defaults } from 'mol-util'; @@ -165,7 +165,11 @@ export default function Spacefill(): UnitsRepresentation<SpacefillProps> { if (newProps.hoverSelection !== currentProps.hoverSelection) { await ctx.update('Computing spacefill flags'); - createFlags(currentGroup, newProps.hoverSelection.instanceId, newProps.hoverSelection.elementId, spheres.values) + if (newProps.hoverSelection.objectId === spheres.id) { + createFlags(currentGroup, newProps.hoverSelection.instanceId, newProps.hoverSelection.elementId, spheres.values) + } else { + createEmptyFlags(spheres.values) + } } ValueCell.updateIfChanged(spheres.values.uAlpha, newProps.alpha) diff --git a/src/mol-geo/representation/structure/utils.ts b/src/mol-geo/representation/structure/utils.ts index 594588a2f54772c4eb649f01762712d138a81dfe..cee35dd1e16cb3b1591730cfd374ddf53e1df746 100644 --- a/src/mol-geo/representation/structure/utils.ts +++ b/src/mol-geo/representation/structure/utils.ts @@ -82,9 +82,15 @@ export function createFlags(group: Unit.SymmetryGroup, instanceId: number, eleme } const emptyFlagTexture = { array: new Uint8Array(1), width: 1, height: 1 } -export function createEmptyFlags() { - return { - tFlag: ValueCell.create(emptyFlagTexture), - uFlagTexSize: ValueCell.create(Vec2.create(1, 1)), +export function createEmptyFlags(flagData?: FlagData) { + if (flagData) { + ValueCell.update(flagData.tFlag, emptyFlagTexture) + ValueCell.update(flagData.uFlagTexSize, Vec2.create(1, 1)) + return flagData + } else { + return { + tFlag: ValueCell.create(emptyFlagTexture), + uFlagTexSize: ValueCell.create(Vec2.create(1, 1)), + } } } \ No newline at end of file diff --git a/src/mol-view/viewer.ts b/src/mol-view/viewer.ts index 4dd8480a1d5d1c181cace7aa808bcab3374c3369..3dbda0a42e025ab675288980e1dee1f4caebc0bd 100644 --- a/src/mol-view/viewer.ts +++ b/src/mol-view/viewer.ts @@ -83,12 +83,12 @@ namespace Viewer { const info = repr.getLabel(p) if (info) { label = info.label - // TODO do better, take objectId fully into account - repr.update({ hoverSelection: p }).run().then(() => { - scene.update() - requestDraw() - }) } + // TODO do better, take objectId fully into account + repr.update({ hoverSelection: p }).run().then(() => { + scene.update() + requestDraw() + }) }) identified.next(`Object: ${p.objectId}, Instance: ${p.instanceId}, Element: ${p.elementId}, Label: ${label}`) })