UNPKG

lingo3d

Version:

Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor

45 lines 1.79 kB
import { event } from "@lincode/events"; import updateSelectionManagersPhysics from "../display/utils/updateSelectionManagersPhysics"; import getAllSelectionTargets from "../throttle/getAllSelectionTargets"; import { pushUndoStack } from "../api/undoStack"; import { flushMultipleSelectionTargets } from "../states/useMultipleSelectionTargets"; import MeshAppendable from "../display/core/MeshAppendable"; import { emitTransformEdit } from "./onTransformEdit"; export const [emitEditorEdit, onEditorEdit] = event(); onEditorEdit(({ phase, key }) => { let payload; if (key === "x" || key === "y" || key === "z") payload = { phase, mode: "translate" }; else if (key.startsWith("rotation")) payload = { phase, mode: "rotate" }; else if (key.startsWith("scale")) payload = { phase, mode: "scale" }; if (!payload) return; for (const target of getAllSelectionTargets()) target instanceof MeshAppendable && emitTransformEdit({ target, phase, mode: payload.mode }); updateSelectionManagersPhysics(payload); }); let commandRecord = {}; onEditorEdit(({ phase, key, value }) => { if (phase === "start") { flushMultipleSelectionTargets(() => { for (const target of getAllSelectionTargets()) commandRecord[target.uuid] = { command: "update", commandPrev: { [key]: value } }; }); return; } flushMultipleSelectionTargets(() => { for (const target of getAllSelectionTargets()) commandRecord[target.uuid].commandNext = { [key]: value }; pushUndoStack(commandRecord); commandRecord = {}; }); }); //# sourceMappingURL=onEditorEdit.js.map