Chore: r3f only uses Theatre's selections now

This commit is contained in:
Aria Minaei 2021-07-03 13:14:47 +02:00
parent 160448ec29
commit d0e9d357e7
3 changed files with 16 additions and 6 deletions

View file

@ -12,6 +12,7 @@ import {IconButton, Button, SettingsButton} from './elements'
import ViewportSettings from './ViewportSettings'
import type {$FixMe} from '@theatre/shared/utils/types'
import studio from '@theatre/studio'
import {getSelected} from './useSelected'
const UI: VFC = () => {
const [
@ -70,7 +71,8 @@ const UI: VFC = () => {
onClick={() => {
const orbitControls =
useEditorStore.getState().orbitControlsRef?.current
const selected = useEditorStore.getState().selected
const selected = getSelected()
let focusObject
if (selected) {
@ -97,7 +99,8 @@ const UI: VFC = () => {
useEditorStore.getState().orbitControlsRef
?.current as $FixMe
)?.object
const selected = useEditorStore.getState().selected
const selected = getSelected()
let proxyObject

View file

@ -25,3 +25,14 @@ export function useSelected(): undefined | string {
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
}
}

View file

@ -147,8 +147,6 @@ export type EditorStore = {
editables: Record<string, Editable>
// this will come in handy when we start supporting multiple canvases
canvasName: string
initialState: EditableState | null
selected: string | null
transformControlsMode: TransformControlsMode
transformControlsSpace: TransformControlsSpace
viewportShading: ViewportShading
@ -221,8 +219,6 @@ const config: StateCreator<EditorStore> = (set, get) => {
helpersRoot: new Group(),
editables: {},
canvasName: 'default',
initialState: null,
selected: null,
transformControlsMode: 'translate',
transformControlsSpace: 'world',
viewportShading: 'rendered',