Chore: Moved r3f's showGrid to Theatre
This commit is contained in:
parent
399c12f2d1
commit
8472cf259c
3 changed files with 12 additions and 19 deletions
|
@ -17,24 +17,25 @@ const EditorScene = () => {
|
||||||
const orbitControlsRef = useRef<typeof OrbitControls>()
|
const orbitControlsRef = useRef<typeof OrbitControls>()
|
||||||
|
|
||||||
const [
|
const [
|
||||||
|
editorObject,
|
||||||
selectedHdr,
|
selectedHdr,
|
||||||
useHdrAsBackground,
|
useHdrAsBackground,
|
||||||
showGrid,
|
|
||||||
showAxes,
|
|
||||||
helpersRoot,
|
helpersRoot,
|
||||||
setOrbitControlsRef,
|
setOrbitControlsRef,
|
||||||
] = useEditorStore(
|
] = useEditorStore(
|
||||||
(state) => [
|
(state) => [
|
||||||
|
state.editorObject,
|
||||||
state.selectedHdr,
|
state.selectedHdr,
|
||||||
state.useHdrAsBackground,
|
state.useHdrAsBackground,
|
||||||
state.showGrid,
|
|
||||||
state.showAxes,
|
|
||||||
state.helpersRoot,
|
state.helpersRoot,
|
||||||
state.setOrbitControlsRef,
|
state.setOrbitControlsRef,
|
||||||
],
|
],
|
||||||
shallow,
|
shallow,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const showGrid = useVal(editorObject?.props.showGrid) ?? true
|
||||||
|
const showAxes = useVal(editorObject?.props.showAxes) ?? true
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setOrbitControlsRef(orbitControlsRef)
|
setOrbitControlsRef(orbitControlsRef)
|
||||||
}, [setOrbitControlsRef])
|
}, [setOrbitControlsRef])
|
||||||
|
|
|
@ -11,29 +11,22 @@ const ViewportShadingSettings: VFC = () => {
|
||||||
const [
|
const [
|
||||||
editorObject,
|
editorObject,
|
||||||
showOverlayIcons,
|
showOverlayIcons,
|
||||||
showGrid,
|
|
||||||
_showAxes,
|
|
||||||
referenceWindowSize,
|
referenceWindowSize,
|
||||||
setShowOverlayIcons,
|
setShowOverlayIcons,
|
||||||
setShowGrid,
|
|
||||||
// setShowAxes,
|
|
||||||
setReferenceWindowSize,
|
setReferenceWindowSize,
|
||||||
] = useEditorStore(
|
] = useEditorStore(
|
||||||
(state) => [
|
(state) => [
|
||||||
state.editorObject,
|
state.editorObject,
|
||||||
state.showOverlayIcons,
|
state.showOverlayIcons,
|
||||||
state.showGrid,
|
|
||||||
state.showAxes,
|
|
||||||
state.referenceWindowSize,
|
state.referenceWindowSize,
|
||||||
state.setShowOverlayIcons,
|
state.setShowOverlayIcons,
|
||||||
state.setShowGrid,
|
|
||||||
// state.setShowAxes,
|
|
||||||
state.setReferenceWindowSize,
|
state.setReferenceWindowSize,
|
||||||
],
|
],
|
||||||
shallow,
|
shallow,
|
||||||
)
|
)
|
||||||
|
|
||||||
const showAxes = useVal(editorObject?.props.showAxes) ?? true
|
const showAxes = useVal(editorObject?.props.showAxes) ?? true
|
||||||
|
const showGrid = useVal(editorObject?.props.showGrid) ?? true
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
|
@ -50,7 +43,11 @@ const ViewportShadingSettings: VFC = () => {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
checked={showGrid}
|
checked={showGrid}
|
||||||
onChange={() => setShowGrid(!showGrid)}
|
onChange={() =>
|
||||||
|
studio.transaction(({set}) => {
|
||||||
|
set(editorObject!.props.showGrid, !showGrid)
|
||||||
|
})
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Show grid
|
Show grid
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
|
|
|
@ -156,7 +156,6 @@ export type EditorStore = {
|
||||||
selectedHdr: string | null
|
selectedHdr: string | null
|
||||||
showOverlayIcons: boolean
|
showOverlayIcons: boolean
|
||||||
useHdrAsBackground: boolean
|
useHdrAsBackground: boolean
|
||||||
showGrid: boolean
|
|
||||||
referenceWindowSize: number
|
referenceWindowSize: number
|
||||||
initialEditorCamera: ContainerProps['camera']
|
initialEditorCamera: ContainerProps['camera']
|
||||||
|
|
||||||
|
@ -180,7 +179,6 @@ export type EditorStore = {
|
||||||
setViewportShading: (mode: ViewportShading) => void
|
setViewportShading: (mode: ViewportShading) => void
|
||||||
setShowOverlayIcons: (show: boolean) => void
|
setShowOverlayIcons: (show: boolean) => void
|
||||||
setUseHdrAsBackground: (use: boolean) => void
|
setUseHdrAsBackground: (use: boolean) => void
|
||||||
setShowGrid: (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
|
||||||
|
@ -226,7 +224,6 @@ const config: StateCreator<EditorStore> = (set, get) => {
|
||||||
selectedHdr: null,
|
selectedHdr: null,
|
||||||
showOverlayIcons: false,
|
showOverlayIcons: false,
|
||||||
useHdrAsBackground: false,
|
useHdrAsBackground: false,
|
||||||
showGrid: true,
|
|
||||||
referenceWindowSize: 120,
|
referenceWindowSize: 120,
|
||||||
initialEditorCamera: {},
|
initialEditorCamera: {},
|
||||||
|
|
||||||
|
@ -322,9 +319,6 @@ const config: StateCreator<EditorStore> = (set, get) => {
|
||||||
setUseHdrAsBackground: (use) => {
|
setUseHdrAsBackground: (use) => {
|
||||||
set({useHdrAsBackground: use})
|
set({useHdrAsBackground: use})
|
||||||
},
|
},
|
||||||
setShowGrid: (show) => {
|
|
||||||
set({showGrid: show})
|
|
||||||
},
|
|
||||||
|
|
||||||
setReferenceWindowSize: (size) => set({referenceWindowSize: size}),
|
setReferenceWindowSize: (size) => set({referenceWindowSize: size}),
|
||||||
createSnapshot: () => {
|
createSnapshot: () => {
|
||||||
|
@ -359,6 +353,7 @@ const editorSheetObjectConfig = {
|
||||||
props: types.compound({
|
props: types.compound({
|
||||||
isOpen: types.boolean(false),
|
isOpen: types.boolean(false),
|
||||||
showAxes: types.boolean(true),
|
showAxes: types.boolean(true),
|
||||||
|
showGrid: types.boolean(true),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue