Files
blitzkit/packages/website/src/components/GuessRenderer.tsx
T

30 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-05-05 21:05:46 -05:00
import { Canvas } from '@react-three/fiber';
import { GuessEphemeral } from '../stores/guessEphemeral';
import { TankopediaDisplay } from '../stores/tankopediaPersistent/constants';
import { Controls } from './Tankopedia/HeroSection/components/TankSandbox/components/Control';
import { Lighting } from './Tankopedia/HeroSection/components/TankSandbox/components/Lighting';
import { TankModel } from './Tankopedia/HeroSection/components/TankSandbox/components/TankModel';
2025-05-04 13:08:28 -05:00
2025-05-05 21:05:46 -05:00
const BRIGHTNESS = 2 ** -5;
const CONTRAST = 2 ** 2;
2025-05-04 21:02:50 -05:00
2025-05-04 13:08:28 -05:00
export function GuessRenderer() {
2025-05-05 21:05:46 -05:00
const guessState = GuessEphemeral.use((state) => state.guessState);
const isRevealed = guessState !== null;
2025-05-04 13:08:28 -05:00
return (
<Canvas
style={{
2025-05-05 21:05:46 -05:00
filter: `grayscale(${isRevealed ? 0 : 1}) contrast(${isRevealed ? 1 : CONTRAST}) brightness(${isRevealed ? 1 : BRIGHTNESS})`,
// filter: `drop-shadow(0 0 1rem ${Var('black-a11')})`,
transitionDuration: isRevealed ? '2s' : undefined,
transitionProperty: 'filter',
2025-05-04 13:08:28 -05:00
}}
camera={{ position: [-5, 5, -5] }}
>
2025-05-04 21:02:50 -05:00
<Controls distanceScale={2} zoomable={false} />
2025-05-04 13:08:28 -05:00
<Lighting display={TankopediaDisplay.Model} />
<TankModel />
</Canvas>
);
}