Chore: r3f only uses Theatre's selections now
This commit is contained in:
parent
160448ec29
commit
d0e9d357e7
3 changed files with 16 additions and 6 deletions
|
@ -12,6 +12,7 @@ import {IconButton, Button, SettingsButton} from './elements'
|
||||||
import ViewportSettings from './ViewportSettings'
|
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'
|
||||||
|
|
||||||
const UI: VFC = () => {
|
const UI: VFC = () => {
|
||||||
const [
|
const [
|
||||||
|
@ -70,7 +71,8 @@ const UI: VFC = () => {
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const orbitControls =
|
const orbitControls =
|
||||||
useEditorStore.getState().orbitControlsRef?.current
|
useEditorStore.getState().orbitControlsRef?.current
|
||||||
const selected = useEditorStore.getState().selected
|
const selected = getSelected()
|
||||||
|
|
||||||
let focusObject
|
let focusObject
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
|
@ -97,7 +99,8 @@ const UI: VFC = () => {
|
||||||
useEditorStore.getState().orbitControlsRef
|
useEditorStore.getState().orbitControlsRef
|
||||||
?.current as $FixMe
|
?.current as $FixMe
|
||||||
)?.object
|
)?.object
|
||||||
const selected = useEditorStore.getState().selected
|
|
||||||
|
const selected = getSelected()
|
||||||
|
|
||||||
let proxyObject
|
let proxyObject
|
||||||
|
|
||||||
|
|
|
@ -25,3 +25,14 @@ export function useSelected(): undefined | string {
|
||||||
|
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getSelected(): undefined | string {
|
||||||
|
const sheet = useEditorStore.getState().sheet
|
||||||
|
if (!sheet) return undefined
|
||||||
|
const item = studio.selection.find((s) => s.sheet === sheet)
|
||||||
|
if (!item) {
|
||||||
|
return undefined
|
||||||
|
} else {
|
||||||
|
return item.address.objectKey
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -147,8 +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
|
||||||
initialState: EditableState | null
|
|
||||||
selected: string | null
|
|
||||||
transformControlsMode: TransformControlsMode
|
transformControlsMode: TransformControlsMode
|
||||||
transformControlsSpace: TransformControlsSpace
|
transformControlsSpace: TransformControlsSpace
|
||||||
viewportShading: ViewportShading
|
viewportShading: ViewportShading
|
||||||
|
@ -221,8 +219,6 @@ const config: StateCreator<EditorStore> = (set, get) => {
|
||||||
helpersRoot: new Group(),
|
helpersRoot: new Group(),
|
||||||
editables: {},
|
editables: {},
|
||||||
canvasName: 'default',
|
canvasName: 'default',
|
||||||
initialState: null,
|
|
||||||
selected: null,
|
|
||||||
transformControlsMode: 'translate',
|
transformControlsMode: 'translate',
|
||||||
transformControlsSpace: 'world',
|
transformControlsSpace: 'world',
|
||||||
viewportShading: 'rendered',
|
viewportShading: 'rendered',
|
||||||
|
|
Loading…
Reference in a new issue