feat: show environment

This commit is contained in:
TrèsAbhi committed 2024-02-01 12:28:56 -06:00
1 parent e9c3953085
commit 082996b152
4 files changed
+24 -3

No files matched your search

@@ -1,14 +1,18 @@
import { Environment } from '@react-three/drei'; import { Environment } from '@react-three/drei';
import { useModel } from '../../../../../hooks/useModel'; import { useModel } from '../../../../../hooks/useModel';
import { useDuel } from '../../../../../stores/duel'; import { useDuel } from '../../../../../stores/duel';
import { useTankopediaPersistent } from '../../../../../stores/tankopedia';
export function Lighting() { export function Lighting() {
const protagonist = useDuel((state) => state.protagonist!); const protagonist = useDuel((state) => state.protagonist!);
const { hasPbr } = useModel(protagonist.tank.id); const { hasPbr } = useModel(protagonist.tank.id);
const showEnvironment = useTankopediaPersistent(
(state) => state.model.visual.showEnvironment,
);
return ( return (
<> <>
<Environment preset="warehouse" /> <Environment preset="warehouse" background={showEnvironment} blur={0} />
<directionalLight <directionalLight
position={[1, 1, -1]} position={[1, 1, -1]}
intensity={hasPbr ? 1 : 5} intensity={hasPbr ? 1 : 5}
@@ -8,7 +8,6 @@ import { Button, DropdownMenu, Flex } from '@radix-ui/themes';
import { RefObject } from 'react'; import { RefObject } from 'react';
import { Pose, poseEvent } from '../../../../../../../core/blitzkrieg/pose'; import { Pose, poseEvent } from '../../../../../../../core/blitzkrieg/pose';
import mutateTankopediaPersistent, { import mutateTankopediaPersistent, {
mutateTankopediaTemporary,
useTankopediaPersistent, useTankopediaPersistent,
} from '../../../../../../../stores/tankopedia'; } from '../../../../../../../stores/tankopedia';
@@ -21,6 +20,9 @@ export function Options({ isFullScreen, canvas }: OptionsProps) {
const showGrid = useTankopediaPersistent( const showGrid = useTankopediaPersistent(
(state) => state.model.visual.showGrid, (state) => state.model.visual.showGrid,
); );
const showEnvironment = useTankopediaPersistent(
(state) => state.model.visual.showEnvironment,
);
const greenPenetration = useTankopediaPersistent( const greenPenetration = useTankopediaPersistent(
(state) => state.model.visual.greenPenetration, (state) => state.model.visual.greenPenetration,
); );
@@ -87,6 +89,16 @@ export function Options({ isFullScreen, canvas }: OptionsProps) {
> >
Green penetration Green penetration
</DropdownMenu.CheckboxItem> </DropdownMenu.CheckboxItem>
<DropdownMenu.CheckboxItem
checked={showEnvironment}
onCheckedChange={(checked) => {
mutateTankopediaPersistent((draft) => {
draft.model.visual.showEnvironment = checked;
});
}}
>
Show environment
</DropdownMenu.CheckboxItem>
</DropdownMenu.Content> </DropdownMenu.Content>
</DropdownMenu.Root> </DropdownMenu.Root>
@@ -6,8 +6,11 @@ export function SceneProps() {
const showGrid = useTankopediaPersistent( const showGrid = useTankopediaPersistent(
(state) => state.model.visual.showGrid, (state) => state.model.visual.showGrid,
); );
const showEnvironment = useTankopediaPersistent(
(state) => state.model.visual.showEnvironment,
);
if (!showGrid) return null; if (!showGrid || showEnvironment) return null;
return ( return (
<> <>
+2
View File
@@ -32,6 +32,7 @@ interface TankopediaPersistent {
controlsEnabled: boolean; controlsEnabled: boolean;
showGrid: boolean; showGrid: boolean;
greenPenetration: boolean; greenPenetration: boolean;
showEnvironment: boolean;
}; };
}; };
sort: { sort: {
@@ -76,6 +77,7 @@ export const useTankopediaPersistent = create<TankopediaPersistent>()(
controlsEnabled: true, controlsEnabled: true,
showGrid: true, showGrid: true,
greenPenetration: false, greenPenetration: false,
showEnvironment: false,
}, },
}, },
sort: { sort: {