Chore: Moved r3f's showOverlayGrid to Theatrte
This commit is contained in:
parent
8472cf259c
commit
20b57011c3
3 changed files with 21 additions and 25 deletions
|
@ -23,6 +23,7 @@ import {
|
||||||
import type {IconType} from 'react-icons'
|
import type {IconType} from 'react-icons'
|
||||||
import studio from '@theatre/studio'
|
import studio from '@theatre/studio'
|
||||||
import {useSelected} from './useSelected'
|
import {useSelected} from './useSelected'
|
||||||
|
import {useVal} from '@theatre/dataverse-react'
|
||||||
|
|
||||||
export interface EditableProxyProps {
|
export interface EditableProxyProps {
|
||||||
editableName: string
|
editableName: string
|
||||||
|
@ -36,12 +37,13 @@ const EditableProxy: VFC<EditableProxyProps> = ({
|
||||||
editableType,
|
editableType,
|
||||||
object,
|
object,
|
||||||
}) => {
|
}) => {
|
||||||
const [showOverlayIcons, setSnapshotProxyObject] = useEditorStore(
|
const [editorObject, setSnapshotProxyObject] = useEditorStore(
|
||||||
(state) => [state.showOverlayIcons, state.setSnapshotProxyObject],
|
(state) => [state.editorObject, state.setSnapshotProxyObject],
|
||||||
shallow,
|
shallow,
|
||||||
)
|
)
|
||||||
|
|
||||||
const selected = useSelected()
|
const selected = useSelected()
|
||||||
|
const showOverlayIcons = useVal(editorObject?.props.showOverlayIcons) ?? false
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSnapshotProxyObject(object, uniqueName)
|
setSnapshotProxyObject(object, uniqueName)
|
||||||
|
|
|
@ -8,18 +8,11 @@ import {useVal} from '@theatre/dataverse-react'
|
||||||
import studio from '@theatre/studio'
|
import studio from '@theatre/studio'
|
||||||
|
|
||||||
const ViewportShadingSettings: VFC = () => {
|
const ViewportShadingSettings: VFC = () => {
|
||||||
const [
|
const [editorObject, referenceWindowSize, setReferenceWindowSize] =
|
||||||
editorObject,
|
useEditorStore(
|
||||||
showOverlayIcons,
|
|
||||||
referenceWindowSize,
|
|
||||||
setShowOverlayIcons,
|
|
||||||
setReferenceWindowSize,
|
|
||||||
] = useEditorStore(
|
|
||||||
(state) => [
|
(state) => [
|
||||||
state.editorObject,
|
state.editorObject,
|
||||||
state.showOverlayIcons,
|
|
||||||
state.referenceWindowSize,
|
state.referenceWindowSize,
|
||||||
state.setShowOverlayIcons,
|
|
||||||
state.setReferenceWindowSize,
|
state.setReferenceWindowSize,
|
||||||
],
|
],
|
||||||
shallow,
|
shallow,
|
||||||
|
@ -27,6 +20,7 @@ const ViewportShadingSettings: VFC = () => {
|
||||||
|
|
||||||
const showAxes = useVal(editorObject?.props.showAxes) ?? true
|
const showAxes = useVal(editorObject?.props.showAxes) ?? true
|
||||||
const showGrid = useVal(editorObject?.props.showGrid) ?? true
|
const showGrid = useVal(editorObject?.props.showGrid) ?? true
|
||||||
|
const showOverlayIcons = useVal(editorObject?.props.showOverlayIcons) ?? false
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
|
@ -34,7 +28,11 @@ const ViewportShadingSettings: VFC = () => {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
checked={showOverlayIcons}
|
checked={showOverlayIcons}
|
||||||
onChange={() => setShowOverlayIcons(!showOverlayIcons)}
|
onChange={() =>
|
||||||
|
studio.transaction(({set}) => {
|
||||||
|
set(editorObject!.props.showOverlayIcons, !showOverlayIcons)
|
||||||
|
})
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Show overlay icons
|
Show overlay icons
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
|
|
|
@ -154,7 +154,6 @@ export type EditorStore = {
|
||||||
editablesSnapshot: Record<string, EditableSnapshot> | null
|
editablesSnapshot: Record<string, EditableSnapshot> | null
|
||||||
hdrPaths: string[]
|
hdrPaths: string[]
|
||||||
selectedHdr: string | null
|
selectedHdr: string | null
|
||||||
showOverlayIcons: boolean
|
|
||||||
useHdrAsBackground: boolean
|
useHdrAsBackground: boolean
|
||||||
referenceWindowSize: number
|
referenceWindowSize: number
|
||||||
initialEditorCamera: ContainerProps['camera']
|
initialEditorCamera: ContainerProps['camera']
|
||||||
|
@ -177,7 +176,6 @@ export type EditorStore = {
|
||||||
setTransformControlsMode: (mode: TransformControlsMode) => void
|
setTransformControlsMode: (mode: TransformControlsMode) => void
|
||||||
setTransformControlsSpace: (mode: TransformControlsSpace) => void
|
setTransformControlsSpace: (mode: TransformControlsSpace) => void
|
||||||
setViewportShading: (mode: ViewportShading) => void
|
setViewportShading: (mode: ViewportShading) => void
|
||||||
setShowOverlayIcons: (show: boolean) => void
|
|
||||||
setUseHdrAsBackground: (use: boolean) => void
|
setUseHdrAsBackground: (use: boolean) => void
|
||||||
setReferenceWindowSize: (size: number) => void
|
setReferenceWindowSize: (size: number) => void
|
||||||
createSnapshot: () => void
|
createSnapshot: () => void
|
||||||
|
@ -222,7 +220,6 @@ const config: StateCreator<EditorStore> = (set, get) => {
|
||||||
editablesSnapshot: null,
|
editablesSnapshot: null,
|
||||||
hdrPaths: [],
|
hdrPaths: [],
|
||||||
selectedHdr: null,
|
selectedHdr: null,
|
||||||
showOverlayIcons: false,
|
|
||||||
useHdrAsBackground: false,
|
useHdrAsBackground: false,
|
||||||
referenceWindowSize: 120,
|
referenceWindowSize: 120,
|
||||||
initialEditorCamera: {},
|
initialEditorCamera: {},
|
||||||
|
@ -313,9 +310,7 @@ const config: StateCreator<EditorStore> = (set, get) => {
|
||||||
setViewportShading: (mode) => {
|
setViewportShading: (mode) => {
|
||||||
set({viewportShading: mode})
|
set({viewportShading: mode})
|
||||||
},
|
},
|
||||||
setShowOverlayIcons: (show) => {
|
|
||||||
set({showOverlayIcons: show})
|
|
||||||
},
|
|
||||||
setUseHdrAsBackground: (use) => {
|
setUseHdrAsBackground: (use) => {
|
||||||
set({useHdrAsBackground: use})
|
set({useHdrAsBackground: use})
|
||||||
},
|
},
|
||||||
|
@ -354,6 +349,7 @@ const editorSheetObjectConfig = {
|
||||||
isOpen: types.boolean(false),
|
isOpen: types.boolean(false),
|
||||||
showAxes: types.boolean(true),
|
showAxes: types.boolean(true),
|
||||||
showGrid: types.boolean(true),
|
showGrid: types.boolean(true),
|
||||||
|
showOverlayIcons: types.boolean(false),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue