diff --git a/src/app/components/previews/DensityFunctionPreview.tsx b/src/app/components/previews/DensityFunctionPreview.tsx index 6f57af2c..4742e0dc 100644 --- a/src/app/components/previews/DensityFunctionPreview.tsx +++ b/src/app/components/previews/DensityFunctionPreview.tsx @@ -5,6 +5,7 @@ import type { mat3, mat4 } from 'gl-matrix' import { useCallback, useEffect, useRef, useState } from 'preact/hooks' import { getProjectData, useLocale, useProject, useVersion } from '../../contexts/index.js' import { useAsync } from '../../hooks/useAsync.js' +import { useLocalStorage } from '../../hooks/useLocalStorage.js' import { Store } from '../../Store.js' import { iterateWorld2D, randomSeed } from '../../Utils.js' import { Btn, BtnMenu, NumberInput } from '../index.js' @@ -17,13 +18,12 @@ import { InteractiveCanvas2D } from './InteractiveCanvas2D.jsx' import { InteractiveCanvas3D } from './InteractiveCanvas3D.jsx' const MODES = ['side', 'top', '3d'] as const -type Mode = typeof MODES[number] export const DensityFunctionPreview = ({ data, shown }: PreviewProps) => { const { locale } = useLocale() const { project } = useProject() const { version } = useVersion() - const [mode, setMode] = useState('side') + const [mode, setMode] = useLocalStorage('misode_density_function_mode', 'side') const voxelMode = mode === '3d' const topDown = mode === 'top' const [seed, setSeed] = useState(randomSeed()) @@ -130,7 +130,7 @@ export const DensityFunctionPreview = ({ data, shown }: PreviewProps) => { {locale(topDown ? 'y' : 'z')} } - + {MODES.map(m => setMode(m)} />)}