Skip to content

Commit bf62980

Browse files
AmirMohammad CheraghaliAmirMohammad Cheraghali
authored andcommitted
feat: Add Cinematic Mode (SSAO) renderer and UI toggle
1 parent 4dab5b1 commit bf62980

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

src/App.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function App() {
4242

4343
// Presentation State
4444
const [isSpinning, setIsSpinning] = useState(initialUrlState.isSpinning || false);
45+
const [isCinematic, setIsCinematic] = useState(false);
4546
const [isCleanMode, setIsCleanMode] = useState(false);
4647
const [showContactMap, setShowContactMap] = useState(false);
4748

@@ -462,6 +463,8 @@ function App() {
462463
onDeleteMovie={handleDeleteMovie}
463464
isSpinning={isSpinning}
464465
setIsSpinning={setIsSpinning}
466+
isCinematic={isCinematic}
467+
setIsCinematic={setIsCinematic}
465468
isCleanMode={isCleanMode}
466469
setIsCleanMode={setIsCleanMode}
467470
onSaveSession={handleSaveSession}
@@ -488,6 +491,7 @@ function App() {
488491
showSurface={showSurface}
489492
showLigands={showLigands}
490493
isSpinning={isSpinning}
494+
isCinematic={isCinematic}
491495

492496
className="w-full h-full"
493497
/>

src/components/Controls.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ interface ControlsProps {
6262
onDeleteSnapshot: (id: string) => void;
6363
isSpinning: boolean;
6464
setIsSpinning: (spinning: boolean) => void;
65+
isCinematic: boolean;
66+
setIsCinematic: (cinematic: boolean) => void;
6567
isCleanMode: boolean;
6668
setIsCleanMode: (clean: boolean) => void;
6769
onSaveSession: () => void;
@@ -107,6 +109,8 @@ export const Controls: React.FC<ControlsProps> = ({
107109
onDeleteSnapshot,
108110
isSpinning,
109111
setIsSpinning,
112+
isCinematic,
113+
setIsCinematic,
110114
isCleanMode,
111115
setIsCleanMode,
112116
onSaveSession,
@@ -398,6 +402,14 @@ export const Controls: React.FC<ControlsProps> = ({
398402
<RefreshCw className={`w-3 h-3 ${isSpinning ? 'animate-spin' : ''}`} />
399403
</button>
400404
</div>
405+
<button
406+
onClick={() => setIsCinematic(!isCinematic)}
407+
className={`flex items-center justify-between px-3 py-2 rounded-lg border transition-all ${isCinematic ? 'bg-purple-500/10 border-purple-500 text-purple-500' : `${cardBg} opacity-80 hover:opacity-100`}`}
408+
>
409+
<span className="text-xs font-medium">Cinematic</span>
410+
<div className={`w-2 h-2 rounded-full ${isCinematic ? 'bg-purple-500 animate-pulse' : 'bg-neutral-500'}`} />
411+
</button>
412+
401413

402414
{/* Style & Color Dropdowns */}
403415
<div className="space-y-1.5">

src/components/ProteinViewer.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ interface ProteinViewerProps {
4444
showLigands?: boolean;
4545
isSpinning?: boolean;
4646
isMeasurementMode?: boolean;
47+
isCinematic?: boolean;
4748
}
4849

4950
export interface ProteinViewerRef {
@@ -86,8 +87,9 @@ export const ProteinViewer = forwardRef<ProteinViewerRef, ProteinViewerProps>(({
8687
showLigands = false,
8788
isSpinning = false,
8889
isMeasurementMode = false,
90+
isCinematic = false
91+
}: ProteinViewerProps, ref: React.Ref<ProteinViewerRef>) => {
8992

90-
}, ref) => {
9193
const containerRef = useRef<HTMLDivElement>(null);
9294
const stageRef = useRef<any>(null);
9395
const componentRef = useRef<any>(null);
@@ -884,6 +886,31 @@ export const ProteinViewer = forwardRef<ProteinViewerRef, ProteinViewerProps>(({
884886
}
885887
}, [backgroundColor]);
886888

889+
// Handle Cinematic Mode
890+
useEffect(() => {
891+
if (stageRef.current) {
892+
if (isCinematic) {
893+
// High Quality "Studio" Settings
894+
stageRef.current.setParameters({
895+
ambientOcclusion: true,
896+
ambientShadow: true,
897+
ambientIntensity: 1.0,
898+
lightIntensity: 0.8,
899+
sampleLevel: 3 // High quality sampling
900+
});
901+
} else {
902+
// Standard Performance Settings
903+
stageRef.current.setParameters({
904+
ambientOcclusion: false,
905+
ambientShadow: false, // Turn off for speed
906+
ambientIntensity: 0.2,
907+
lightIntensity: 1.0,
908+
sampleLevel: 0
909+
});
910+
}
911+
}
912+
}, [isCinematic]);
913+
887914
useEffect(() => {
888915
isMounted.current = true;
889916
return () => { isMounted.current = false; };

0 commit comments

Comments
 (0)