UNPKG

lingo3d

Version:

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

44 lines 1.61 kB
import { serializeAppendable } from "../../api/serializer/serialize"; import spawn from "../../api/spawn"; import { pushUndoStack } from "../../api/undoStack"; import { multipleSelectionTargets } from "../../collections/multipleSelectionTargets"; import { emitSelectionTarget } from "../../events/onSelectionTarget"; import { selectionTargetPtr } from "../../pointers/selectionTargetPtr"; import { flushMultipleSelectionTargets } from "../../states/useMultipleSelectionTargets"; const copy = (target) => { const item = spawn(target); target.parent?.append(item); return item; }; export default () => { if (multipleSelectionTargets.size) { flushMultipleSelectionTargets(() => { const commandRecord = {}; const newTargets = []; for (const target of multipleSelectionTargets) { const manager = copy(target); newTargets.push(manager); commandRecord[manager.uuid] = { command: "create", ...serializeAppendable(manager, false) }; } pushUndoStack(commandRecord); return newTargets; }); return; } if (!selectionTargetPtr[0]) return; const manager = copy(selectionTargetPtr[0]); flushMultipleSelectionTargets(() => { pushUndoStack({ [manager.uuid]: { command: "create", ...serializeAppendable(manager, false) } }); emitSelectionTarget(manager); }, true); }; //# sourceMappingURL=copySelected.js.map