Skip to content

Commit 78e23dd

Browse files
AmirMohammad CheraghaliAmirMohammad Cheraghali
authored andcommitted
Fix double rendering of ligands when using atomic representations
1 parent 323385f commit 78e23dd

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/components/ProteinViewer.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,8 +1819,19 @@ export const ProteinViewer = forwardRef<ProteinViewerRef, ProteinViewerProps>(({
18191819
try { component.addRepresentation(r, { color: c, sele: sele, ...params }); } catch (e) { }
18201820
};
18211821

1822+
// Fix for "Licorice looks like Ball+Stick":
1823+
// If we are visualizing a chemical/small molecule (chainCount <= 1) AND using an atomic representation (licorice/spacefill),
1824+
// the Base Representation (which selects '*') already draws the ligands.
1825+
// We should NOT apply the "Ball+Stick" overlay on top, as it hides the style of the base rep.
1826+
const atomicReps = ['licorice', 'ball+stick', 'spacefill', 'line', 'point', 'hyperball'];
1827+
const isBaseRepAtomic = atomicReps.includes(repType);
1828+
const chainCount = component.structure ? component.structure.chainStore.count : 0;
1829+
const isSmallMoleculeOrSingleChain = chainCount <= 1 || dataSource === 'pubchem';
1830+
1831+
const skipLigandOverlay = isBaseRepAtomic && isSmallMoleculeOrSingleChain;
1832+
18221833
if (showSurface) tryApply('surface', 'white', "*", { opacity: 0.4, depthWrite: false, side: 'front' });
1823-
if (showLigands) tryApply('ball+stick', 'element', 'ligand and not (water or ion)', { scale: 2.0 });
1834+
if (showLigands && !skipLigandOverlay) tryApply('ball+stick', 'element', 'ligand and not (water or ion)', { scale: 2.0 });
18241835
if (showIons) tryApply('ball+stick', 'element', 'ion', { scale: 2.0 });
18251836

18261837
if (stageRef.current?.viewer) {

0 commit comments

Comments
 (0)