Skip to content

Commit 085d04d

Browse files
AmirMohammad CheraghaliAmirMohammad Cheraghali
authored andcommitted
fix(visual): Destructure AO props in ProteinViewer
1 parent 46f6f9e commit 085d04d

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

src/components/ProteinViewer.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ export const ProteinViewer = forwardRef<ProteinViewerRef, ProteinViewerProps>(({
125125
onAddMeasurement,
126126
onHover,
127127
isLightMode,
128+
quality = 'medium',
129+
enableAmbientOcclusion = false,
128130
measurementTextColor = 'auto',
129131
}: ProteinViewerProps, ref: React.Ref<ProteinViewerRef>) => {
130132

@@ -1916,6 +1918,33 @@ export const ProteinViewer = forwardRef<ProteinViewerRef, ProteinViewerProps>(({
19161918
}
19171919
};
19181920

1921+
// --- VISUAL ECSTASY: Stage Parameters Update ---
1922+
useEffect(() => {
1923+
if (!stageRef.current) return;
1924+
const stage = stageRef.current;
1925+
1926+
// NGL Stage Parameters for High Quality / Ambient Occlusion
1927+
const params: any = {
1928+
backgroundColor: backgroundColor,
1929+
quality: quality, // 'medium' or 'high'
1930+
lightIntensity: 1.0, // Standard key light
1931+
};
1932+
1933+
if (enableAmbientOcclusion) {
1934+
params.sampleLevel = 2; // -1/0 = off, 1 = low, 2 = medium, 4 = high
1935+
params.ambientColor = 0x202020; // Soft grey shadow rather than pitch black
1936+
params.ambientIntensity = 1.0;
1937+
} else {
1938+
params.sampleLevel = 0;
1939+
params.ambientIntensity = 0.0;
1940+
}
1941+
1942+
try {
1943+
stage.setParameters(params);
1944+
} catch (e) { console.warn("Failed to set stage params", e); }
1945+
1946+
}, [backgroundColor, quality, enableAmbientOcclusion]);
1947+
19191948
useEffect(() => {
19201949
updateRepresentation();
19211950
}, [representation, coloring, customColors, showSurface, showLigands, showIons, colorPalette]);

0 commit comments

Comments
 (0)