Chore: Moved r3f's referenceWindowSize to Theatre
This commit is contained in:
parent
20b57011c3
commit
9809042762
3 changed files with 17 additions and 16 deletions
|
@ -13,6 +13,7 @@ import ViewportSettings from './ViewportSettings'
|
||||||
import type {$FixMe} from '@theatre/shared/utils/types'
|
import type {$FixMe} from '@theatre/shared/utils/types'
|
||||||
import studio from '@theatre/studio'
|
import studio from '@theatre/studio'
|
||||||
import {getSelected} from './useSelected'
|
import {getSelected} from './useSelected'
|
||||||
|
import {useVal} from '@theatre/dataverse-react'
|
||||||
|
|
||||||
const UI: VFC = () => {
|
const UI: VFC = () => {
|
||||||
const [
|
const [
|
||||||
|
@ -20,7 +21,6 @@ const UI: VFC = () => {
|
||||||
transformControlsMode,
|
transformControlsMode,
|
||||||
transformControlsSpace,
|
transformControlsSpace,
|
||||||
viewportShading,
|
viewportShading,
|
||||||
referenceWindowSize,
|
|
||||||
setTransformControlsMode,
|
setTransformControlsMode,
|
||||||
setTransformControlsSpace,
|
setTransformControlsSpace,
|
||||||
setViewportShading,
|
setViewportShading,
|
||||||
|
@ -30,7 +30,6 @@ const UI: VFC = () => {
|
||||||
state.transformControlsMode,
|
state.transformControlsMode,
|
||||||
state.transformControlsSpace,
|
state.transformControlsSpace,
|
||||||
state.viewportShading,
|
state.viewportShading,
|
||||||
state.referenceWindowSize,
|
|
||||||
state.setTransformControlsMode,
|
state.setTransformControlsMode,
|
||||||
state.setTransformControlsSpace,
|
state.setTransformControlsSpace,
|
||||||
state.setViewportShading,
|
state.setViewportShading,
|
||||||
|
@ -38,6 +37,9 @@ const UI: VFC = () => {
|
||||||
shallow,
|
shallow,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const referenceWindowSize =
|
||||||
|
useVal(editorObject?.props.referenceWindowSize) ?? 120
|
||||||
|
|
||||||
if (!editorObject) return <></>
|
if (!editorObject) return <></>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -8,19 +8,16 @@ import {useVal} from '@theatre/dataverse-react'
|
||||||
import studio from '@theatre/studio'
|
import studio from '@theatre/studio'
|
||||||
|
|
||||||
const ViewportShadingSettings: VFC = () => {
|
const ViewportShadingSettings: VFC = () => {
|
||||||
const [editorObject, referenceWindowSize, setReferenceWindowSize] =
|
const [editorObject] = useEditorStore(
|
||||||
useEditorStore(
|
(state) => [state.editorObject],
|
||||||
(state) => [
|
|
||||||
state.editorObject,
|
|
||||||
state.referenceWindowSize,
|
|
||||||
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
|
const showGrid = useVal(editorObject?.props.showGrid) ?? true
|
||||||
const showOverlayIcons = useVal(editorObject?.props.showOverlayIcons) ?? false
|
const showOverlayIcons = useVal(editorObject?.props.showOverlayIcons) ?? false
|
||||||
|
const referenceWindowSize =
|
||||||
|
useVal(editorObject?.props.referenceWindowSize) ?? 120
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
|
@ -76,7 +73,12 @@ const ViewportShadingSettings: VFC = () => {
|
||||||
min={120}
|
min={120}
|
||||||
max={400}
|
max={400}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setReferenceWindowSize(Number(event.target.value))
|
studio.transaction(({set}) => {
|
||||||
|
set(
|
||||||
|
editorObject!.props.referenceWindowSize,
|
||||||
|
Number(event.target.value),
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -155,7 +155,6 @@ export type EditorStore = {
|
||||||
hdrPaths: string[]
|
hdrPaths: string[]
|
||||||
selectedHdr: string | null
|
selectedHdr: string | null
|
||||||
useHdrAsBackground: boolean
|
useHdrAsBackground: boolean
|
||||||
referenceWindowSize: number
|
|
||||||
initialEditorCamera: ContainerProps['camera']
|
initialEditorCamera: ContainerProps['camera']
|
||||||
|
|
||||||
init: (
|
init: (
|
||||||
|
@ -177,7 +176,6 @@ export type EditorStore = {
|
||||||
setTransformControlsSpace: (mode: TransformControlsSpace) => void
|
setTransformControlsSpace: (mode: TransformControlsSpace) => void
|
||||||
setViewportShading: (mode: ViewportShading) => void
|
setViewportShading: (mode: ViewportShading) => void
|
||||||
setUseHdrAsBackground: (use: boolean) => void
|
setUseHdrAsBackground: (use: boolean) => void
|
||||||
setReferenceWindowSize: (size: number) => void
|
|
||||||
createSnapshot: () => void
|
createSnapshot: () => void
|
||||||
setSheetObject: (uniqueName: string, sheetObject: BaseSheetObjectType) => void
|
setSheetObject: (uniqueName: string, sheetObject: BaseSheetObjectType) => void
|
||||||
setSnapshotProxyObject: (
|
setSnapshotProxyObject: (
|
||||||
|
@ -221,7 +219,6 @@ const config: StateCreator<EditorStore> = (set, get) => {
|
||||||
hdrPaths: [],
|
hdrPaths: [],
|
||||||
selectedHdr: null,
|
selectedHdr: null,
|
||||||
useHdrAsBackground: false,
|
useHdrAsBackground: false,
|
||||||
referenceWindowSize: 120,
|
|
||||||
initialEditorCamera: {},
|
initialEditorCamera: {},
|
||||||
|
|
||||||
init: (
|
init: (
|
||||||
|
@ -315,7 +312,6 @@ const config: StateCreator<EditorStore> = (set, get) => {
|
||||||
set({useHdrAsBackground: use})
|
set({useHdrAsBackground: use})
|
||||||
},
|
},
|
||||||
|
|
||||||
setReferenceWindowSize: (size) => set({referenceWindowSize: size}),
|
|
||||||
createSnapshot: () => {
|
createSnapshot: () => {
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
sceneSnapshot: state.scene?.clone() ?? null,
|
sceneSnapshot: state.scene?.clone() ?? null,
|
||||||
|
@ -350,6 +346,7 @@ const editorSheetObjectConfig = {
|
||||||
showAxes: types.boolean(true),
|
showAxes: types.boolean(true),
|
||||||
showGrid: types.boolean(true),
|
showGrid: types.boolean(true),
|
||||||
showOverlayIcons: types.boolean(false),
|
showOverlayIcons: types.boolean(false),
|
||||||
|
referenceWindowSize: types.number(120, {min: 0, max: 800}),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue