Chore: Moved r3f's showAxes to Theatre
This commit is contained in:
parent
d0e9d357e7
commit
399c12f2d1
2 changed files with 16 additions and 10 deletions
|
@ -4,31 +4,37 @@ import {useEditorStore} from '../store'
|
||||||
import shallow from 'zustand/shallow'
|
import shallow from 'zustand/shallow'
|
||||||
import {Checkbox, FormControl, Slider} from './elements'
|
import {Checkbox, FormControl, Slider} from './elements'
|
||||||
import UnstyledFormLabel from './elements/UnstyledFormLabel'
|
import UnstyledFormLabel from './elements/UnstyledFormLabel'
|
||||||
|
import {useVal} from '@theatre/dataverse-react'
|
||||||
|
import studio from '@theatre/studio'
|
||||||
|
|
||||||
const ViewportShadingSettings: VFC = () => {
|
const ViewportShadingSettings: VFC = () => {
|
||||||
const [
|
const [
|
||||||
|
editorObject,
|
||||||
showOverlayIcons,
|
showOverlayIcons,
|
||||||
showGrid,
|
showGrid,
|
||||||
showAxes,
|
_showAxes,
|
||||||
referenceWindowSize,
|
referenceWindowSize,
|
||||||
setShowOverlayIcons,
|
setShowOverlayIcons,
|
||||||
setShowGrid,
|
setShowGrid,
|
||||||
setShowAxes,
|
// setShowAxes,
|
||||||
setReferenceWindowSize,
|
setReferenceWindowSize,
|
||||||
] = useEditorStore(
|
] = useEditorStore(
|
||||||
(state) => [
|
(state) => [
|
||||||
|
state.editorObject,
|
||||||
state.showOverlayIcons,
|
state.showOverlayIcons,
|
||||||
state.showGrid,
|
state.showGrid,
|
||||||
state.showAxes,
|
state.showAxes,
|
||||||
state.referenceWindowSize,
|
state.referenceWindowSize,
|
||||||
state.setShowOverlayIcons,
|
state.setShowOverlayIcons,
|
||||||
state.setShowGrid,
|
state.setShowGrid,
|
||||||
state.setShowAxes,
|
// state.setShowAxes,
|
||||||
state.setReferenceWindowSize,
|
state.setReferenceWindowSize,
|
||||||
],
|
],
|
||||||
shallow,
|
shallow,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const showAxes = useVal(editorObject?.props.showAxes) ?? true
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
<FormControl>
|
<FormControl>
|
||||||
|
@ -53,7 +59,11 @@ const ViewportShadingSettings: VFC = () => {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
checked={showAxes}
|
checked={showAxes}
|
||||||
onChange={() => setShowAxes(!showAxes)}
|
onChange={() =>
|
||||||
|
studio.transaction(({set}) => {
|
||||||
|
set(editorObject!.props.showAxes, !showAxes)
|
||||||
|
})
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Show axes
|
Show axes
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
|
|
|
@ -157,7 +157,6 @@ export type EditorStore = {
|
||||||
showOverlayIcons: boolean
|
showOverlayIcons: boolean
|
||||||
useHdrAsBackground: boolean
|
useHdrAsBackground: boolean
|
||||||
showGrid: boolean
|
showGrid: boolean
|
||||||
showAxes: boolean
|
|
||||||
referenceWindowSize: number
|
referenceWindowSize: number
|
||||||
initialEditorCamera: ContainerProps['camera']
|
initialEditorCamera: ContainerProps['camera']
|
||||||
|
|
||||||
|
@ -182,7 +181,6 @@ export type EditorStore = {
|
||||||
setShowOverlayIcons: (show: boolean) => void
|
setShowOverlayIcons: (show: boolean) => void
|
||||||
setUseHdrAsBackground: (use: boolean) => void
|
setUseHdrAsBackground: (use: boolean) => void
|
||||||
setShowGrid: (show: boolean) => void
|
setShowGrid: (show: boolean) => void
|
||||||
setShowAxes: (show: boolean) => void
|
|
||||||
setReferenceWindowSize: (size: number) => void
|
setReferenceWindowSize: (size: number) => void
|
||||||
createSnapshot: () => void
|
createSnapshot: () => void
|
||||||
setSheetObject: (uniqueName: string, sheetObject: BaseSheetObjectType) => void
|
setSheetObject: (uniqueName: string, sheetObject: BaseSheetObjectType) => void
|
||||||
|
@ -229,7 +227,6 @@ const config: StateCreator<EditorStore> = (set, get) => {
|
||||||
showOverlayIcons: false,
|
showOverlayIcons: false,
|
||||||
useHdrAsBackground: false,
|
useHdrAsBackground: false,
|
||||||
showGrid: true,
|
showGrid: true,
|
||||||
showAxes: true,
|
|
||||||
referenceWindowSize: 120,
|
referenceWindowSize: 120,
|
||||||
initialEditorCamera: {},
|
initialEditorCamera: {},
|
||||||
|
|
||||||
|
@ -328,9 +325,7 @@ const config: StateCreator<EditorStore> = (set, get) => {
|
||||||
setShowGrid: (show) => {
|
setShowGrid: (show) => {
|
||||||
set({showGrid: show})
|
set({showGrid: show})
|
||||||
},
|
},
|
||||||
setShowAxes: (show) => {
|
|
||||||
set({showAxes: show})
|
|
||||||
},
|
|
||||||
setReferenceWindowSize: (size) => set({referenceWindowSize: size}),
|
setReferenceWindowSize: (size) => set({referenceWindowSize: size}),
|
||||||
createSnapshot: () => {
|
createSnapshot: () => {
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
|
@ -363,6 +358,7 @@ export type BindFunction = (options: {
|
||||||
const editorSheetObjectConfig = {
|
const editorSheetObjectConfig = {
|
||||||
props: types.compound({
|
props: types.compound({
|
||||||
isOpen: types.boolean(false),
|
isOpen: types.boolean(false),
|
||||||
|
showAxes: types.boolean(true),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue