Chore: Moved r3f's viewportShading to Theatre
This commit is contained in:
parent
89913ac51f
commit
ffb8a24f07
3 changed files with 22 additions and 23 deletions
|
@ -32,22 +32,19 @@ type IEditableProxy = {
|
||||||
|
|
||||||
const ProxyManager: VFC<ProxyManagerProps> = ({orbitControlsRef}) => {
|
const ProxyManager: VFC<ProxyManagerProps> = ({orbitControlsRef}) => {
|
||||||
const isBeingEdited = useRef(false)
|
const isBeingEdited = useRef(false)
|
||||||
const [editorObject, sceneSnapshot, viewportShading, sheetObjects] =
|
const [editorObject, sceneSnapshot, sheetObjects] = useEditorStore(
|
||||||
useEditorStore(
|
(state) => [state.editorObject, state.sceneSnapshot, state.sheetObjects],
|
||||||
(state) => [
|
shallow,
|
||||||
state.editorObject,
|
)
|
||||||
state.sceneSnapshot,
|
|
||||||
state.viewportShading,
|
|
||||||
state.sheetObjects,
|
|
||||||
],
|
|
||||||
shallow,
|
|
||||||
)
|
|
||||||
const transformControlsMode =
|
const transformControlsMode =
|
||||||
useVal(editorObject?.props.transformControlsMode) ?? 'translate'
|
useVal(editorObject?.props.transformControlsMode) ?? 'translate'
|
||||||
|
|
||||||
const transformControlsSpace =
|
const transformControlsSpace =
|
||||||
useVal(editorObject?.props.transformControlsSpace) ?? 'world'
|
useVal(editorObject?.props.transformControlsSpace) ?? 'world'
|
||||||
|
|
||||||
|
const viewportShading =
|
||||||
|
useVal(editorObject?.props.viewportShading) ?? 'rendered'
|
||||||
|
|
||||||
const sceneProxy = useMemo(() => sceneSnapshot?.clone(), [sceneSnapshot])
|
const sceneProxy = useMemo(() => sceneSnapshot?.clone(), [sceneSnapshot])
|
||||||
const [editableProxies, setEditableProxies] = useState<{
|
const [editableProxies, setEditableProxies] = useState<{
|
||||||
[name: string]: IEditableProxy
|
[name: string]: IEditableProxy
|
||||||
|
|
|
@ -16,12 +16,8 @@ import {getSelected} from './useSelected'
|
||||||
import {useVal} from '@theatre/dataverse-react'
|
import {useVal} from '@theatre/dataverse-react'
|
||||||
|
|
||||||
const UI: VFC = () => {
|
const UI: VFC = () => {
|
||||||
const [editorObject, viewportShading, setViewportShading] = useEditorStore(
|
const [editorObject] = useEditorStore(
|
||||||
(state) => [
|
(state) => [state.editorObject],
|
||||||
state.editorObject,
|
|
||||||
state.viewportShading,
|
|
||||||
state.setViewportShading,
|
|
||||||
],
|
|
||||||
shallow,
|
shallow,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,6 +27,8 @@ const UI: VFC = () => {
|
||||||
useVal(editorObject?.props.transformControlsMode) ?? 'translate'
|
useVal(editorObject?.props.transformControlsMode) ?? 'translate'
|
||||||
const transformControlsSpace =
|
const transformControlsSpace =
|
||||||
useVal(editorObject?.props.transformControlsSpace) ?? 'world'
|
useVal(editorObject?.props.transformControlsSpace) ?? 'world'
|
||||||
|
const viewportShading =
|
||||||
|
useVal(editorObject?.props.viewportShading) ?? 'rendered'
|
||||||
|
|
||||||
if (!editorObject) return <></>
|
if (!editorObject) return <></>
|
||||||
|
|
||||||
|
@ -63,7 +61,11 @@ const UI: VFC = () => {
|
||||||
<div className="pointer-events-auto">
|
<div className="pointer-events-auto">
|
||||||
<ViewportShadingSelect
|
<ViewportShadingSelect
|
||||||
value={viewportShading}
|
value={viewportShading}
|
||||||
onChange={setViewportShading}
|
onChange={(shading) => {
|
||||||
|
studio.transaction(({set}) => {
|
||||||
|
set(editorObject.props.viewportShading, shading)
|
||||||
|
})
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="pointer-events-auto">
|
<div className="pointer-events-auto">
|
||||||
|
|
|
@ -147,7 +147,6 @@ export type EditorStore = {
|
||||||
editables: Record<string, Editable>
|
editables: Record<string, Editable>
|
||||||
// this will come in handy when we start supporting multiple canvases
|
// this will come in handy when we start supporting multiple canvases
|
||||||
canvasName: string
|
canvasName: string
|
||||||
viewportShading: ViewportShading
|
|
||||||
sceneSnapshot: Scene | null
|
sceneSnapshot: Scene | null
|
||||||
editablesSnapshot: Record<string, EditableSnapshot> | null
|
editablesSnapshot: Record<string, EditableSnapshot> | null
|
||||||
hdrPaths: string[]
|
hdrPaths: string[]
|
||||||
|
@ -170,7 +169,6 @@ export type EditorStore = {
|
||||||
addEditable: <T extends EditableType>(type: T, uniqueName: string) => void
|
addEditable: <T extends EditableType>(type: T, uniqueName: string) => void
|
||||||
removeEditable: (uniqueName: string) => void
|
removeEditable: (uniqueName: string) => void
|
||||||
setSelectedHdr: (hdr: string | null) => void
|
setSelectedHdr: (hdr: string | null) => void
|
||||||
setViewportShading: (mode: ViewportShading) => void
|
|
||||||
setUseHdrAsBackground: (use: boolean) => void
|
setUseHdrAsBackground: (use: boolean) => void
|
||||||
createSnapshot: () => void
|
createSnapshot: () => void
|
||||||
setSheetObject: (uniqueName: string, sheetObject: BaseSheetObjectType) => void
|
setSheetObject: (uniqueName: string, sheetObject: BaseSheetObjectType) => void
|
||||||
|
@ -207,7 +205,6 @@ const config: StateCreator<EditorStore> = (set, get) => {
|
||||||
helpersRoot: new Group(),
|
helpersRoot: new Group(),
|
||||||
editables: {},
|
editables: {},
|
||||||
canvasName: 'default',
|
canvasName: 'default',
|
||||||
viewportShading: 'rendered',
|
|
||||||
sceneSnapshot: null,
|
sceneSnapshot: null,
|
||||||
editablesSnapshot: null,
|
editablesSnapshot: null,
|
||||||
hdrPaths: [],
|
hdrPaths: [],
|
||||||
|
@ -292,9 +289,6 @@ const config: StateCreator<EditorStore> = (set, get) => {
|
||||||
setSelectedHdr: (hdr) => {
|
setSelectedHdr: (hdr) => {
|
||||||
set({selectedHdr: hdr})
|
set({selectedHdr: hdr})
|
||||||
},
|
},
|
||||||
setViewportShading: (mode) => {
|
|
||||||
set({viewportShading: mode})
|
|
||||||
},
|
|
||||||
|
|
||||||
setUseHdrAsBackground: (use) => {
|
setUseHdrAsBackground: (use) => {
|
||||||
set({useHdrAsBackground: use})
|
set({useHdrAsBackground: use})
|
||||||
|
@ -343,6 +337,12 @@ const editorSheetObjectConfig = {
|
||||||
'world',
|
'world',
|
||||||
['local', 'world'],
|
['local', 'world'],
|
||||||
),
|
),
|
||||||
|
viewportShading: types.stringLiteral<ViewportShading>('rendered', [
|
||||||
|
'flat',
|
||||||
|
'rendered',
|
||||||
|
'solid',
|
||||||
|
'wireframe',
|
||||||
|
]),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue