mylingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
29 lines (25 loc) • 867 B
text/typescript
import store, { createEffect } from "@lincode/reactivity"
import { isPositionedItem } from "../api/core/PositionedItem"
import SimpleObjectManager from "../display/core/SimpleObjectManager"
import { getSelectionTarget } from "./useSelectionTarget"
import { getEditorMode } from "./useEditorMode"
export const [setEditorModeComputed, getEditorModeComputed] = store(
getEditorMode()
)
createEffect(() => {
const target = getSelectionTarget()
const mode = getEditorMode()
if (!target || mode === "select") {
setEditorModeComputed(mode)
return
}
if (!isPositionedItem(target)) {
setEditorModeComputed("select")
return
}
if (!(target instanceof SimpleObjectManager)) {
setEditorModeComputed("translate")
return
}
setEditorModeComputed(mode)
}, [getEditorMode, getSelectionTarget])