@loafacto/ui 0.23.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LfSegmented-D2zAGi24.js +182 -0
- package/dist/LfSegmented-D2zAGi24.js.map +1 -0
- package/dist/{LfSegmented-CvGl-0vv.js → LfSelect-BrK4QbUk.js} +137 -116
- package/dist/LfSelect-BrK4QbUk.js.map +1 -0
- package/dist/LfSwitch-BD05yyB3.js +119 -0
- package/dist/LfSwitch-BD05yyB3.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +166 -472
- package/dist/index.js.map +1 -1
- package/dist/loafacto-ui.css +971 -414
- package/dist/map-editor/LfMapEditor.vue.d.ts +126 -0
- package/dist/map-editor/MapEditorCanvas.vue.d.ts +19 -0
- package/dist/map-editor/doc.d.ts +134 -0
- package/dist/map-editor/editor.d.ts +149 -0
- package/dist/map-editor.d.ts +19 -0
- package/dist/map-editor.js +2096 -0
- package/dist/map-editor.js.map +1 -0
- package/dist/map3d/LfModelEditor.vue.d.ts +19 -0
- package/dist/map3d/LfModelViewer.vue.d.ts +28 -0
- package/dist/map3d/MapScene.d.ts +9 -0
- package/dist/map3d/ModelScene.d.ts +43 -0
- package/dist/map3d/model.d.ts +54 -0
- package/dist/map3d/types.d.ts +81 -1
- package/dist/map3d.d.ts +5 -1
- package/dist/map3d.js +1208 -31
- package/dist/map3d.js.map +1 -1
- package/package.json +5 -1
- package/dist/LfSegmented-CvGl-0vv.js.map +0 -1
|
@@ -0,0 +1,2096 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { defineComponent, ref, computed, reactive, watch, onMounted, onBeforeUnmount, openBlock, createElementBlock, withModifiers, normalizeClass, createElementVNode, Fragment, createCommentVNode, renderList, normalizeStyle, toDisplayString, shallowRef, unref, createBlock, createVNode, withCtx, createTextVNode } from "vue";
|
|
5
|
+
import { L as LfButton, a as LfSwitch } from "./LfSwitch-BD05yyB3.js";
|
|
6
|
+
import { _ as _export_sfc, L as LfIcon, e as LfSelect, b as LfIconButton, f as LfTextField } from "./LfSelect-BrK4QbUk.js";
|
|
7
|
+
const COLLECTIONS = ["nodes", "edges", "zones", "walls", "objects", "extras"];
|
|
8
|
+
const targetKey = (t) => `${t.c}:${t.id}`;
|
|
9
|
+
const clone = (v) => v === void 0 ? v : JSON.parse(JSON.stringify(v));
|
|
10
|
+
function round(v, digits = 3) {
|
|
11
|
+
const k = 10 ** digits;
|
|
12
|
+
return Math.round(v * k) / k;
|
|
13
|
+
}
|
|
14
|
+
function normDeg(deg) {
|
|
15
|
+
let d = deg % 360;
|
|
16
|
+
if (d > 180) d -= 360;
|
|
17
|
+
if (d <= -180) d += 360;
|
|
18
|
+
return round(d, 1);
|
|
19
|
+
}
|
|
20
|
+
function normalizeDoc(doc) {
|
|
21
|
+
const d = clone(doc);
|
|
22
|
+
d.floors ?? (d.floors = []);
|
|
23
|
+
const used = /* @__PURE__ */ new Set();
|
|
24
|
+
for (const f of d.floors) for (const c of COLLECTIONS) for (const it of f[c] ?? []) if (it.id) used.add(it.id);
|
|
25
|
+
const fresh = (prefix) => {
|
|
26
|
+
for (let i = 1; ; i++) {
|
|
27
|
+
const id = `${prefix}${String(i).padStart(3, "0")}`;
|
|
28
|
+
if (!used.has(id)) {
|
|
29
|
+
used.add(id);
|
|
30
|
+
return id;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
for (const f of d.floors) {
|
|
35
|
+
for (const c of COLLECTIONS) f[c] ?? (f[c] = []);
|
|
36
|
+
for (const e of f.edges) e.id ?? (e.id = fresh("E-"));
|
|
37
|
+
for (const w of f.walls) w.id ?? (w.id = fresh("W-"));
|
|
38
|
+
}
|
|
39
|
+
return d;
|
|
40
|
+
}
|
|
41
|
+
function floorOf(doc, floorId) {
|
|
42
|
+
const f = doc.floors.find((x) => x.id === floorId);
|
|
43
|
+
if (!f) throw new Error(`층 ${floorId} 이(가) 없습니다`);
|
|
44
|
+
return f;
|
|
45
|
+
}
|
|
46
|
+
function list(doc, floorId, c) {
|
|
47
|
+
const f = floorOf(doc, floorId);
|
|
48
|
+
return f[c] ?? (f[c] = []);
|
|
49
|
+
}
|
|
50
|
+
function find(doc, floorId, c, id) {
|
|
51
|
+
return list(doc, floorId, c).find((x) => x.id === id) ?? null;
|
|
52
|
+
}
|
|
53
|
+
function put(doc, ch, item) {
|
|
54
|
+
const l = list(doc, ch.floorId, ch.c);
|
|
55
|
+
const i = l.findIndex((x) => x.id === ch.id);
|
|
56
|
+
if (item === null) {
|
|
57
|
+
if (i >= 0) l.splice(i, 1);
|
|
58
|
+
} else if (i >= 0) l[i] = clone(item);
|
|
59
|
+
else l.push(clone(item));
|
|
60
|
+
}
|
|
61
|
+
function putFloor(doc, fc, floor) {
|
|
62
|
+
const i = doc.floors.findIndex((f) => f.id === fc.floorId);
|
|
63
|
+
if (floor === null) {
|
|
64
|
+
if (i >= 0) doc.floors.splice(i, 1);
|
|
65
|
+
} else if (i >= 0) doc.floors[i] = clone(floor);
|
|
66
|
+
else doc.floors.splice(fc.at ?? doc.floors.length, 0, clone(floor));
|
|
67
|
+
}
|
|
68
|
+
function apply(doc, c) {
|
|
69
|
+
for (const f of c.floors ?? []) putFloor(doc, f, f.after);
|
|
70
|
+
for (const ch of c.changes) put(doc, ch, ch.after);
|
|
71
|
+
}
|
|
72
|
+
function revert(doc, c) {
|
|
73
|
+
for (const ch of [...c.changes].reverse()) put(doc, ch, ch.before);
|
|
74
|
+
for (const f of [...c.floors ?? []].reverse()) putFloor(doc, f, f.before);
|
|
75
|
+
}
|
|
76
|
+
function mergeCommands(a, b) {
|
|
77
|
+
const changes = /* @__PURE__ */ new Map();
|
|
78
|
+
for (const ch of [...a.changes, ...b.changes]) {
|
|
79
|
+
const k = `${ch.floorId}/${ch.c}/${ch.id}`;
|
|
80
|
+
const prev = changes.get(k);
|
|
81
|
+
changes.set(k, prev ? { ...ch, before: prev.before } : ch);
|
|
82
|
+
}
|
|
83
|
+
const floors = /* @__PURE__ */ new Map();
|
|
84
|
+
for (const fc of [...a.floors ?? [], ...b.floors ?? []]) {
|
|
85
|
+
const prev = floors.get(fc.floorId);
|
|
86
|
+
floors.set(fc.floorId, prev ? { ...fc, before: prev.before, at: prev.at } : fc);
|
|
87
|
+
}
|
|
88
|
+
return { label: b.label, changes: [...changes.values()], floors: [...floors.values()], mergeKey: b.mergeKey };
|
|
89
|
+
}
|
|
90
|
+
class History {
|
|
91
|
+
constructor(doc, limit = 300) {
|
|
92
|
+
__publicField(this, "done", []);
|
|
93
|
+
__publicField(this, "undone", []);
|
|
94
|
+
this.doc = doc;
|
|
95
|
+
this.limit = limit;
|
|
96
|
+
}
|
|
97
|
+
get canUndo() {
|
|
98
|
+
return this.done.length > 0;
|
|
99
|
+
}
|
|
100
|
+
get canRedo() {
|
|
101
|
+
return this.undone.length > 0;
|
|
102
|
+
}
|
|
103
|
+
/** 실행한다. 바뀐 것이 없으면 false. */
|
|
104
|
+
run(c) {
|
|
105
|
+
var _a;
|
|
106
|
+
if (!c.changes.length && !((_a = c.floors) == null ? void 0 : _a.length)) return false;
|
|
107
|
+
const last = this.done[this.done.length - 1];
|
|
108
|
+
if (c.mergeKey && last && last.mergeKey === c.mergeKey) {
|
|
109
|
+
revert(this.doc, last);
|
|
110
|
+
const merged = mergeCommands(last, c);
|
|
111
|
+
apply(this.doc, merged);
|
|
112
|
+
this.done[this.done.length - 1] = merged;
|
|
113
|
+
} else {
|
|
114
|
+
apply(this.doc, c);
|
|
115
|
+
this.done.push(c);
|
|
116
|
+
if (this.done.length > this.limit) this.done.shift();
|
|
117
|
+
}
|
|
118
|
+
this.undone = [];
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
/** 합치기를 끝낸다(마우스를 뗐다) — 다음 명령은 새 걸음이다. */
|
|
122
|
+
seal() {
|
|
123
|
+
const last = this.done[this.done.length - 1];
|
|
124
|
+
if (last) last.mergeKey = void 0;
|
|
125
|
+
}
|
|
126
|
+
undo() {
|
|
127
|
+
const c = this.done.pop();
|
|
128
|
+
if (!c) return null;
|
|
129
|
+
revert(this.doc, c);
|
|
130
|
+
this.undone.push(c);
|
|
131
|
+
return c;
|
|
132
|
+
}
|
|
133
|
+
redo() {
|
|
134
|
+
const c = this.undone.pop();
|
|
135
|
+
if (!c) return null;
|
|
136
|
+
apply(this.doc, c);
|
|
137
|
+
this.done.push(c);
|
|
138
|
+
return c;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function nextId(doc, prefix, reserved) {
|
|
142
|
+
const used = /* @__PURE__ */ new Set();
|
|
143
|
+
for (const f of doc.floors) for (const c of COLLECTIONS) for (const it of f[c] ?? []) if (it.id) used.add(it.id);
|
|
144
|
+
for (const f of doc.floors) used.add(f.id);
|
|
145
|
+
reserved == null ? void 0 : reserved.forEach((r) => used.add(r));
|
|
146
|
+
for (let i = 1; ; i++) {
|
|
147
|
+
const id = `${prefix}${String(i).padStart(3, "0")}`;
|
|
148
|
+
if (!used.has(id)) return id;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function addItems(floorId, c, items, label = "더하기") {
|
|
152
|
+
return { label, changes: items.map((it) => ({ floorId, c, id: it.id, before: null, after: clone(it) })) };
|
|
153
|
+
}
|
|
154
|
+
function updateItems(doc, floorId, c, updates, label = "고치기", mergeKey) {
|
|
155
|
+
const changes = [];
|
|
156
|
+
for (const u of updates) {
|
|
157
|
+
const before = find(doc, floorId, c, u.id);
|
|
158
|
+
if (!before) continue;
|
|
159
|
+
const after = { ...clone(before), ...clone(u.patch) };
|
|
160
|
+
for (const [k, v] of Object.entries(u.patch)) if (v === void 0) delete after[k];
|
|
161
|
+
changes.push({ floorId, c, id: u.id, before: clone(before), after });
|
|
162
|
+
}
|
|
163
|
+
return { label, changes, mergeKey };
|
|
164
|
+
}
|
|
165
|
+
function removeItems(doc, floorId, targets, label = "지우기") {
|
|
166
|
+
const changes = [];
|
|
167
|
+
const seen = /* @__PURE__ */ new Set();
|
|
168
|
+
const drop = (c, id) => {
|
|
169
|
+
const k = `${c}:${id}`;
|
|
170
|
+
if (seen.has(k)) return;
|
|
171
|
+
const before = find(doc, floorId, c, id);
|
|
172
|
+
if (!before) return;
|
|
173
|
+
seen.add(k);
|
|
174
|
+
changes.push({ floorId, c, id, before: clone(before), after: null });
|
|
175
|
+
};
|
|
176
|
+
const f = floorOf(doc, floorId);
|
|
177
|
+
for (const t of targets) {
|
|
178
|
+
if (t.c === "nodes") {
|
|
179
|
+
for (const e of f.edges ?? []) if (e.from === t.id || e.to === t.id) drop("edges", e.id);
|
|
180
|
+
}
|
|
181
|
+
drop(t.c, t.id);
|
|
182
|
+
}
|
|
183
|
+
return { label, changes };
|
|
184
|
+
}
|
|
185
|
+
function mapPoints(it, f) {
|
|
186
|
+
const after = clone(it);
|
|
187
|
+
if (typeof after.x === "number" && typeof after.y === "number") {
|
|
188
|
+
const [x, y] = f([after.x, after.y]);
|
|
189
|
+
after.x = round(x);
|
|
190
|
+
after.y = round(y);
|
|
191
|
+
}
|
|
192
|
+
for (const key of ["polygon", "points"]) {
|
|
193
|
+
const pts = after[key];
|
|
194
|
+
if (Array.isArray(pts)) after[key] = pts.map((p) => f(p).map((v) => round(v)));
|
|
195
|
+
}
|
|
196
|
+
return after;
|
|
197
|
+
}
|
|
198
|
+
function moveItems(doc, floorId, sel, dx, dy, mergeKey) {
|
|
199
|
+
const changes = [];
|
|
200
|
+
for (const s of sel) {
|
|
201
|
+
if (s.c === "edges") continue;
|
|
202
|
+
const it = find(doc, floorId, s.c, s.id);
|
|
203
|
+
if (!it) continue;
|
|
204
|
+
changes.push({ floorId, c: s.c, id: s.id, before: clone(it), after: mapPoints(it, ([x, y]) => [x + dx, y + dy]) });
|
|
205
|
+
}
|
|
206
|
+
return { label: "옮기기", changes, mergeKey };
|
|
207
|
+
}
|
|
208
|
+
function movePoint(doc, floorId, t, index, to, mergeKey) {
|
|
209
|
+
const it = find(doc, floorId, t.c, t.id);
|
|
210
|
+
const key = t.c === "zones" ? "polygon" : "points";
|
|
211
|
+
const pts = it == null ? void 0 : it[key];
|
|
212
|
+
if (!it || !pts || !pts[index]) return { label: "꼭짓점", changes: [] };
|
|
213
|
+
const after = clone(it);
|
|
214
|
+
after[key][index] = [round(to[0]), round(to[1])];
|
|
215
|
+
return { label: "꼭짓점 옮기기", changes: [{ floorId, c: t.c, id: t.id, before: clone(it), after }], mergeKey };
|
|
216
|
+
}
|
|
217
|
+
function sizeOf(it) {
|
|
218
|
+
return typeof it.w === "number" && typeof it.h === "number" ? { w: it.w, h: it.h } : void 0;
|
|
219
|
+
}
|
|
220
|
+
function bounds(it) {
|
|
221
|
+
const pts = it.polygon ?? it.points;
|
|
222
|
+
if (Array.isArray(pts) && pts.length) {
|
|
223
|
+
const xs = pts.map((p) => p[0]);
|
|
224
|
+
const ys = pts.map((p) => p[1]);
|
|
225
|
+
return { x0: Math.min(...xs), y0: Math.min(...ys), x1: Math.max(...xs), y1: Math.max(...ys) };
|
|
226
|
+
}
|
|
227
|
+
if (typeof it.x !== "number" || typeof it.y !== "number") return null;
|
|
228
|
+
const size = sizeOf(it);
|
|
229
|
+
if (!size) return { x0: it.x, y0: it.y, x1: it.x, y1: it.y };
|
|
230
|
+
const a = (it.rotation ?? 0) * Math.PI / 180;
|
|
231
|
+
const hw = (Math.abs(Math.cos(a)) * size.w + Math.abs(Math.sin(a)) * size.h) / 2;
|
|
232
|
+
const hh = (Math.abs(Math.sin(a)) * size.w + Math.abs(Math.cos(a)) * size.h) / 2;
|
|
233
|
+
return { x0: it.x - hw, y0: it.y - hh, x1: it.x + hw, y1: it.y + hh };
|
|
234
|
+
}
|
|
235
|
+
function rotateItems(doc, floorId, sel, deg, pivot, mergeKey) {
|
|
236
|
+
const a = deg * Math.PI / 180;
|
|
237
|
+
const ca = Math.cos(a);
|
|
238
|
+
const sa = Math.sin(a);
|
|
239
|
+
const turn = ([x, y]) => [pivot[0] + (x - pivot[0]) * ca - (y - pivot[1]) * sa, pivot[1] + (x - pivot[0]) * sa + (y - pivot[1]) * ca];
|
|
240
|
+
const changes = [];
|
|
241
|
+
for (const s of sel) {
|
|
242
|
+
if (s.c === "edges") continue;
|
|
243
|
+
const it = find(doc, floorId, s.c, s.id);
|
|
244
|
+
if (!it) continue;
|
|
245
|
+
const after = mapPoints(it, turn);
|
|
246
|
+
if (s.c === "objects" || s.c === "extras") after.rotation = normDeg((it.rotation ?? 0) + deg);
|
|
247
|
+
changes.push({ floorId, c: s.c, id: s.id, before: clone(it), after });
|
|
248
|
+
}
|
|
249
|
+
return { label: "돌리기", changes, mergeKey };
|
|
250
|
+
}
|
|
251
|
+
function alignItems(doc, floorId, sel, how) {
|
|
252
|
+
const rows = sel.flatMap((s) => {
|
|
253
|
+
if (s.c === "edges") return [];
|
|
254
|
+
const it = find(doc, floorId, s.c, s.id);
|
|
255
|
+
const b = it ? bounds(it) : null;
|
|
256
|
+
return it && b ? [{ s, it, b, cx: (b.x0 + b.x1) / 2, cy: (b.y0 + b.y1) / 2 }] : [];
|
|
257
|
+
});
|
|
258
|
+
const changes = [];
|
|
259
|
+
if (rows.length < 2) return { label: "맞추기", changes };
|
|
260
|
+
const x0 = Math.min(...rows.map((r) => r.b.x0));
|
|
261
|
+
const x1 = Math.max(...rows.map((r) => r.b.x1));
|
|
262
|
+
const y0 = Math.min(...rows.map((r) => r.b.y0));
|
|
263
|
+
const y1 = Math.max(...rows.map((r) => r.b.y1));
|
|
264
|
+
const shift = /* @__PURE__ */ new Map();
|
|
265
|
+
for (const r of rows) {
|
|
266
|
+
const d = [0, 0];
|
|
267
|
+
if (how === "left") d[0] = x0 - r.b.x0;
|
|
268
|
+
else if (how === "right") d[0] = x1 - r.b.x1;
|
|
269
|
+
else if (how === "hcenter") d[0] = (x0 + x1) / 2 - r.cx;
|
|
270
|
+
else if (how === "bottom") d[1] = y0 - r.b.y0;
|
|
271
|
+
else if (how === "top") d[1] = y1 - r.b.y1;
|
|
272
|
+
else if (how === "vcenter") d[1] = (y0 + y1) / 2 - r.cy;
|
|
273
|
+
shift.set(targetKey(r.s), d);
|
|
274
|
+
}
|
|
275
|
+
if ((how === "hspread" || how === "vspread") && rows.length >= 3) {
|
|
276
|
+
const axis = how === "hspread" ? "cx" : "cy";
|
|
277
|
+
const sorted = [...rows].sort((a, b) => a[axis] - b[axis]);
|
|
278
|
+
const first = sorted[0][axis];
|
|
279
|
+
const step = (sorted[sorted.length - 1][axis] - first) / (sorted.length - 1);
|
|
280
|
+
sorted.forEach((r, i) => shift.set(targetKey(r.s), how === "hspread" ? [first + i * step - r.cx, 0] : [0, first + i * step - r.cy]));
|
|
281
|
+
}
|
|
282
|
+
for (const r of rows) {
|
|
283
|
+
const [dx, dy] = shift.get(targetKey(r.s)) ?? [0, 0];
|
|
284
|
+
if (Math.abs(dx) < 1e-9 && Math.abs(dy) < 1e-9) continue;
|
|
285
|
+
changes.push({ floorId, c: r.s.c, id: r.s.id, before: clone(r.it), after: mapPoints(r.it, ([x, y]) => [x + dx, y + dy]) });
|
|
286
|
+
}
|
|
287
|
+
return { label: "맞추기", changes };
|
|
288
|
+
}
|
|
289
|
+
function pasteItems(doc, floorId, clip, dx, dy) {
|
|
290
|
+
const reserved = /* @__PURE__ */ new Set();
|
|
291
|
+
const remap = /* @__PURE__ */ new Map();
|
|
292
|
+
const PREFIX2 = { nodes: "N-", edges: "E-", zones: "Z-", walls: "W-", objects: "O-", extras: "X-" };
|
|
293
|
+
const out = [];
|
|
294
|
+
for (const { c, item } of clip) {
|
|
295
|
+
if (c === "edges") continue;
|
|
296
|
+
const id = nextId(doc, PREFIX2[c], reserved);
|
|
297
|
+
reserved.add(id);
|
|
298
|
+
remap.set(`${c}:${item.id}`, id);
|
|
299
|
+
out.push({ c, item: { ...mapPoints(item, ([x, y]) => [x + dx, y + dy]), id } });
|
|
300
|
+
}
|
|
301
|
+
for (const { c, item } of clip) {
|
|
302
|
+
if (c !== "edges") continue;
|
|
303
|
+
const from = remap.get(`nodes:${item.from}`);
|
|
304
|
+
const to = remap.get(`nodes:${item.to}`);
|
|
305
|
+
if (!from || !to) continue;
|
|
306
|
+
const id = nextId(doc, PREFIX2.edges, reserved);
|
|
307
|
+
reserved.add(id);
|
|
308
|
+
out.push({ c, item: { ...clone(item), id, from, to } });
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
command: { label: "붙여넣기", changes: out.map(({ c, item }) => ({ floorId, c, id: item.id, before: null, after: item })) },
|
|
312
|
+
targets: out.map(({ c, item }) => ({ c, id: item.id }))
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function setFloor(doc, floorId, patch, label = "층", mergeKey) {
|
|
316
|
+
const before = floorOf(doc, floorId);
|
|
317
|
+
const after = { ...clone(before), ...clone(patch) };
|
|
318
|
+
for (const [k, v] of Object.entries(patch)) if (v === void 0) delete after[k];
|
|
319
|
+
return { label, changes: [], floors: [{ floorId, before: clone(before), after }], mergeKey };
|
|
320
|
+
}
|
|
321
|
+
function addFloor(doc, floor) {
|
|
322
|
+
return { label: "층 더하기", changes: [], floors: [{ floorId: floor.id, before: null, after: clone(floor), at: doc.floors.length }] };
|
|
323
|
+
}
|
|
324
|
+
function removeFloor(doc, floorId) {
|
|
325
|
+
const at = doc.floors.findIndex((f) => f.id === floorId);
|
|
326
|
+
return { label: "층 빼기", changes: [], floors: [{ floorId, before: clone(floorOf(doc, floorId)), after: null, at }] };
|
|
327
|
+
}
|
|
328
|
+
function edgeLength(f, e) {
|
|
329
|
+
var _a, _b;
|
|
330
|
+
const a = (_a = f.nodes) == null ? void 0 : _a.find((n) => n.id === e.from);
|
|
331
|
+
const b = (_b = f.nodes) == null ? void 0 : _b.find((n) => n.id === e.to);
|
|
332
|
+
return a && b ? round(Math.hypot(b.x - a.x, b.y - a.y), 2) : null;
|
|
333
|
+
}
|
|
334
|
+
function itemsIn(f, box) {
|
|
335
|
+
const out = [];
|
|
336
|
+
const inside = (b) => b.x0 >= box.x0 && b.x1 <= box.x1 && b.y0 >= box.y0 && b.y1 <= box.y1;
|
|
337
|
+
for (const c of COLLECTIONS) {
|
|
338
|
+
if (c === "edges") continue;
|
|
339
|
+
for (const it of f[c] ?? []) {
|
|
340
|
+
const b = bounds(it);
|
|
341
|
+
if (b && inside(b)) out.push({ c, id: it.id });
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
const nodes = new Set(out.filter((t) => t.c === "nodes").map((t) => t.id));
|
|
345
|
+
for (const e of f.edges ?? []) if (e.id && nodes.has(e.from) && nodes.has(e.to)) out.push({ c: "edges", id: e.id });
|
|
346
|
+
return out;
|
|
347
|
+
}
|
|
348
|
+
const _hoisted_1$1 = ["transform"];
|
|
349
|
+
const _hoisted_2$1 = ["width", "height"];
|
|
350
|
+
const _hoisted_3$1 = ["href", "x", "y", "width", "height", "opacity"];
|
|
351
|
+
const _hoisted_4$1 = ["d"];
|
|
352
|
+
const _hoisted_5$1 = ["width", "height"];
|
|
353
|
+
const _hoisted_6$1 = ["points", "data-id"];
|
|
354
|
+
const _hoisted_7$1 = ["data-id"];
|
|
355
|
+
const _hoisted_8$1 = ["points", "stroke-width"];
|
|
356
|
+
const _hoisted_9$1 = ["points"];
|
|
357
|
+
const _hoisted_10$1 = ["data-id"];
|
|
358
|
+
const _hoisted_11$1 = ["x1", "y1", "x2", "y2", "stroke-width"];
|
|
359
|
+
const _hoisted_12$1 = ["x1", "y1", "x2", "y2"];
|
|
360
|
+
const _hoisted_13$1 = ["d"];
|
|
361
|
+
const _hoisted_14$1 = ["x1", "y1", "x2", "y2"];
|
|
362
|
+
const _hoisted_15$1 = ["transform", "data-id"];
|
|
363
|
+
const _hoisted_16$1 = ["x", "y", "width", "height"];
|
|
364
|
+
const _hoisted_17$1 = ["x1", "x2"];
|
|
365
|
+
const _hoisted_18$1 = ["transform", "data-id"];
|
|
366
|
+
const _hoisted_19$1 = ["x", "y", "width", "height"];
|
|
367
|
+
const _hoisted_20$1 = ["d"];
|
|
368
|
+
const _hoisted_21$1 = ["cx", "cy", "r", "data-id"];
|
|
369
|
+
const _hoisted_22$1 = ["x", "y", "width", "height", "data-vertex"];
|
|
370
|
+
const _hoisted_23$1 = ["points"];
|
|
371
|
+
const _hoisted_24$1 = ["x1", "y1", "x2", "y2"];
|
|
372
|
+
const _hoisted_25$1 = ["x", "y", "width", "height"];
|
|
373
|
+
const _hoisted_26$1 = {
|
|
374
|
+
class: "lf-mec__labels",
|
|
375
|
+
"aria-hidden": "true"
|
|
376
|
+
};
|
|
377
|
+
const _hoisted_27$1 = { class: "lf-mec__status" };
|
|
378
|
+
const _hoisted_28$1 = { key: 0 };
|
|
379
|
+
const _hoisted_29$1 = { class: "lf-mec__hint" };
|
|
380
|
+
const _hoisted_30$1 = {
|
|
381
|
+
key: 0,
|
|
382
|
+
class: "lf-mec__empty"
|
|
383
|
+
};
|
|
384
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
385
|
+
__name: "MapEditorCanvas",
|
|
386
|
+
props: {
|
|
387
|
+
editor: {}
|
|
388
|
+
},
|
|
389
|
+
setup(__props, { expose: __expose }) {
|
|
390
|
+
const props = __props;
|
|
391
|
+
const ed = props.editor;
|
|
392
|
+
const root = ref(null);
|
|
393
|
+
const svg = ref(null);
|
|
394
|
+
const floor = computed(() => ed.floor.value);
|
|
395
|
+
const view = reactive({ k: 20, tx: 40, ty: 400 });
|
|
396
|
+
const size = reactive({ w: 600, h: 400 });
|
|
397
|
+
function fit() {
|
|
398
|
+
const f = floor.value;
|
|
399
|
+
if (!f) return;
|
|
400
|
+
const pad = 32;
|
|
401
|
+
const k = Math.max(0.5, Math.min((size.w - pad * 2) / f.size.w, (size.h - pad * 2) / f.size.h));
|
|
402
|
+
view.k = k;
|
|
403
|
+
view.tx = (size.w - f.size.w * k) / 2;
|
|
404
|
+
view.ty = (size.h + f.size.h * k) / 2;
|
|
405
|
+
}
|
|
406
|
+
const toWorld = (sx, sy) => [(sx - view.tx) / view.k, -(sy - view.ty) / view.k];
|
|
407
|
+
const toScreen = (x, y) => ({ x: x * view.k + view.tx, y: -y * view.k + view.ty });
|
|
408
|
+
function local(e) {
|
|
409
|
+
const r = svg.value.getBoundingClientRect();
|
|
410
|
+
return { sx: e.clientX - r.left, sy: e.clientY - r.top };
|
|
411
|
+
}
|
|
412
|
+
function onWheel(e) {
|
|
413
|
+
const { sx, sy } = local(e);
|
|
414
|
+
const [wx, wy] = toWorld(sx, sy);
|
|
415
|
+
const k = Math.max(0.5, Math.min(400, view.k * Math.exp(-e.deltaY * 15e-4)));
|
|
416
|
+
view.k = k;
|
|
417
|
+
view.tx = sx - wx * k;
|
|
418
|
+
view.ty = sy + wy * k;
|
|
419
|
+
}
|
|
420
|
+
const gridPath = computed(() => {
|
|
421
|
+
const f = floor.value;
|
|
422
|
+
if (!f) return "";
|
|
423
|
+
const steps = [0.25, 0.5, 1, 2, 5, 10, 20, 50, 100];
|
|
424
|
+
const step = steps.find((s) => s * view.k >= 10) ?? 100;
|
|
425
|
+
let d = "";
|
|
426
|
+
for (let x = 0; x <= f.size.w + 1e-6; x += step) d += `M${x} 0V${f.size.h}`;
|
|
427
|
+
for (let y = 0; y <= f.size.h + 1e-6; y += step) d += `M0 ${y}H${f.size.w}`;
|
|
428
|
+
return d;
|
|
429
|
+
});
|
|
430
|
+
const bg = computed(() => {
|
|
431
|
+
const f = floor.value;
|
|
432
|
+
const b = f.background;
|
|
433
|
+
return { x: b.x ?? 0, y: b.y ?? 0, w: b.w ?? f.size.w, h: b.h ?? f.size.h };
|
|
434
|
+
});
|
|
435
|
+
const nodeById = computed(() => {
|
|
436
|
+
var _a;
|
|
437
|
+
return new Map((((_a = floor.value) == null ? void 0 : _a.nodes) ?? []).map((n) => [n.id, n]));
|
|
438
|
+
});
|
|
439
|
+
const edgesDrawn = computed(
|
|
440
|
+
() => {
|
|
441
|
+
var _a;
|
|
442
|
+
return (((_a = floor.value) == null ? void 0 : _a.edges) ?? []).flatMap((e) => {
|
|
443
|
+
const a = nodeById.value.get(e.from);
|
|
444
|
+
const b = nodeById.value.get(e.to);
|
|
445
|
+
if (!a || !b || !e.id) return [];
|
|
446
|
+
const len = Math.hypot(b.x - a.x, b.y - a.y) || 1;
|
|
447
|
+
const ux = (b.x - a.x) / len;
|
|
448
|
+
const uy = (b.y - a.y) / len;
|
|
449
|
+
const s = 9 / view.k;
|
|
450
|
+
const mx = (a.x + b.x) / 2 + ux * s * 0.5;
|
|
451
|
+
const my = (a.y + b.y) / 2 + uy * s * 0.5;
|
|
452
|
+
const arrow = `M${mx} ${my}L${mx - ux * s - uy * s * 0.6} ${my - uy * s + ux * s * 0.6}L${mx - ux * s + uy * s * 0.6} ${my - uy * s - ux * s * 0.6}Z`;
|
|
453
|
+
return [{ id: e.id, a, b, width: (e.width ?? 0) >= 0.3 ? e.width : 0, oneWay: e.oneWay, arrow }];
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
);
|
|
457
|
+
const nodeR = computed(() => Math.max(0.12, 5 / view.k));
|
|
458
|
+
const handle = computed(() => 9 / view.k);
|
|
459
|
+
const diamond = computed(() => {
|
|
460
|
+
const r = Math.max(0.25, 7 / view.k);
|
|
461
|
+
return `M0 ${r}L${r} 0L0 ${-r}L${-r} 0Z`;
|
|
462
|
+
});
|
|
463
|
+
const wallPoints = (w) => {
|
|
464
|
+
const pts = w.closed && w.points.length > 2 ? [...w.points, w.points[0]] : w.points;
|
|
465
|
+
return pts.map((p) => p.join(",")).join(" ");
|
|
466
|
+
};
|
|
467
|
+
const TONE_VAR = {
|
|
468
|
+
neutral: "var(--admin-status-neutral)",
|
|
469
|
+
info: "var(--admin-status-info)",
|
|
470
|
+
success: "var(--admin-status-success)",
|
|
471
|
+
warning: "var(--admin-status-warning)",
|
|
472
|
+
error: "var(--admin-status-error)",
|
|
473
|
+
accent: "var(--admin-accent)",
|
|
474
|
+
purple: "var(--admin-status-purple)",
|
|
475
|
+
teal: "var(--admin-status-teal)"
|
|
476
|
+
};
|
|
477
|
+
const toneVar = (it, fallback = "info") => it.color || TONE_VAR[it.tone ?? fallback];
|
|
478
|
+
const on = (c, id) => {
|
|
479
|
+
void ed.rev.value;
|
|
480
|
+
return ed.selection.value.some((s) => s.c === c && s.id === id);
|
|
481
|
+
};
|
|
482
|
+
const vertexOwner = computed(() => {
|
|
483
|
+
const s = ed.single.value;
|
|
484
|
+
if (!s || ed.tool.value !== "select") return null;
|
|
485
|
+
if (s.t.c === "zones") return { t: s.t, points: s.item.polygon };
|
|
486
|
+
if (s.t.c === "walls") return { t: s.t, points: s.item.points };
|
|
487
|
+
return null;
|
|
488
|
+
});
|
|
489
|
+
const labels = computed(() => {
|
|
490
|
+
const f = floor.value;
|
|
491
|
+
if (!f) return [];
|
|
492
|
+
const out = [];
|
|
493
|
+
for (const z of f.zones ?? []) {
|
|
494
|
+
if (!z.name || z.polygon.length < 3) continue;
|
|
495
|
+
const cx = z.polygon.reduce((s, p2) => s + p2[0], 0) / z.polygon.length;
|
|
496
|
+
const cy = z.polygon.reduce((s, p2) => s + p2[1], 0) / z.polygon.length;
|
|
497
|
+
const p = toScreen(cx, cy);
|
|
498
|
+
out.push({ key: "z" + z.id, ...p, text: z.name, cls: "is-zone" });
|
|
499
|
+
}
|
|
500
|
+
if (view.k >= 14) {
|
|
501
|
+
for (const o of f.objects ?? []) {
|
|
502
|
+
const p = toScreen(o.x, o.y);
|
|
503
|
+
out.push({ key: "o" + o.id, ...p, text: o.name || o.id, cls: "is-obj" });
|
|
504
|
+
}
|
|
505
|
+
for (const x of f.extras ?? []) {
|
|
506
|
+
const p = toScreen(x.x, x.y - Math.max(0.3, (x.h ?? 0) / 2) - 8 / view.k);
|
|
507
|
+
out.push({ key: "x" + x.id, ...p, text: x.name || x.id, cls: "is-extra" });
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return out.filter((l) => l.x > -100 && l.x < size.w + 100 && l.y > -40 && l.y < size.h + 40);
|
|
511
|
+
});
|
|
512
|
+
const cursor = ref(null);
|
|
513
|
+
const draft = ref([]);
|
|
514
|
+
const chain = ref(null);
|
|
515
|
+
const chainFrom = computed(() => chain.value ? nodeById.value.get(chain.value) ?? null : null);
|
|
516
|
+
const draftLine = computed(() => {
|
|
517
|
+
if (!draft.value.length) return "";
|
|
518
|
+
const pts = cursor.value ? [...draft.value, ed.snapP(cursor.value)] : draft.value;
|
|
519
|
+
const closing = ed.tool.value === "zone" && pts.length > 2 ? [...pts, pts[0]] : pts;
|
|
520
|
+
return closing.map((p) => p.join(",")).join(" ");
|
|
521
|
+
});
|
|
522
|
+
const toolClass = computed(() => ed.tool.value.startsWith("extra:") ? "extra" : ed.tool.value);
|
|
523
|
+
const hint = computed(() => {
|
|
524
|
+
switch (ed.tool.value) {
|
|
525
|
+
case "select":
|
|
526
|
+
return "누르기 고르기 · Shift 더하기 · 빈 곳(또는 Alt) 끌기 상자 고르기 · 가운데/오른쪽 끌기 화면 이동";
|
|
527
|
+
case "pan":
|
|
528
|
+
return "끌어서 화면 이동 · 휠 확대";
|
|
529
|
+
case "wall":
|
|
530
|
+
return "눌러 점 찍기 · 두 번 누르기/Enter 끝 · 첫 점을 누르면 닫힌 벽 · Esc 취소";
|
|
531
|
+
case "zone":
|
|
532
|
+
return "눌러 꼭짓점 찍기 · 두 번 누르기/Enter 끝(셋 이상) · Esc 취소";
|
|
533
|
+
case "node":
|
|
534
|
+
return "눌러 마디 놓기";
|
|
535
|
+
case "edge":
|
|
536
|
+
return "마디(또는 빈 곳)를 차례로 누르면 길이 이어집니다 · Esc 끊기";
|
|
537
|
+
case "object":
|
|
538
|
+
return "눌러 설비 놓기 — 모양은 위 막대에서";
|
|
539
|
+
default:
|
|
540
|
+
return "눌러 놓기";
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
watch(
|
|
544
|
+
() => ed.tool.value,
|
|
545
|
+
() => {
|
|
546
|
+
draft.value = [];
|
|
547
|
+
chain.value = null;
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
watch(
|
|
551
|
+
() => ed.floorId.value,
|
|
552
|
+
() => {
|
|
553
|
+
draft.value = [];
|
|
554
|
+
chain.value = null;
|
|
555
|
+
fit();
|
|
556
|
+
}
|
|
557
|
+
);
|
|
558
|
+
const drag = ref(null);
|
|
559
|
+
const band = ref(null);
|
|
560
|
+
const panning = computed(() => {
|
|
561
|
+
var _a;
|
|
562
|
+
return ((_a = drag.value) == null ? void 0 : _a.kind) === "pan";
|
|
563
|
+
});
|
|
564
|
+
let spaceDown = false;
|
|
565
|
+
let downAt = null;
|
|
566
|
+
function hitOf(e) {
|
|
567
|
+
var _a;
|
|
568
|
+
const el = (_a = e.target) == null ? void 0 : _a.closest("[data-vertex],[data-id]");
|
|
569
|
+
if (!el) return null;
|
|
570
|
+
if (el.dataset.vertex !== void 0) return { vertex: Number(el.dataset.vertex) };
|
|
571
|
+
const c = el.dataset.c;
|
|
572
|
+
const id = el.dataset.id;
|
|
573
|
+
return c && id ? { t: { c, id } } : null;
|
|
574
|
+
}
|
|
575
|
+
function nodeNear(p) {
|
|
576
|
+
var _a;
|
|
577
|
+
let best = null;
|
|
578
|
+
let bestD = 10 / view.k;
|
|
579
|
+
for (const n of ((_a = floor.value) == null ? void 0 : _a.nodes) ?? []) {
|
|
580
|
+
const d = Math.hypot(n.x - p[0], n.y - p[1]);
|
|
581
|
+
if (d <= bestD) {
|
|
582
|
+
best = n.id;
|
|
583
|
+
bestD = d;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return best;
|
|
587
|
+
}
|
|
588
|
+
function capture(e) {
|
|
589
|
+
var _a;
|
|
590
|
+
try {
|
|
591
|
+
(_a = svg.value) == null ? void 0 : _a.setPointerCapture(e.pointerId);
|
|
592
|
+
} catch {
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function onDown(e) {
|
|
596
|
+
var _a;
|
|
597
|
+
(_a = root.value) == null ? void 0 : _a.focus({ preventScroll: true });
|
|
598
|
+
const { sx, sy } = local(e);
|
|
599
|
+
downAt = { sx, sy };
|
|
600
|
+
const p = toWorld(sx, sy);
|
|
601
|
+
if (e.button === 1 || e.button === 2 || spaceDown || ed.tool.value === "pan") {
|
|
602
|
+
drag.value = { kind: "pan", sx, sy, tx: view.tx, ty: view.ty };
|
|
603
|
+
capture(e);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (e.button !== 0 || !floor.value) return;
|
|
607
|
+
const tool = ed.tool.value;
|
|
608
|
+
if (tool === "select") {
|
|
609
|
+
const hit = e.altKey ? null : hitOf(e);
|
|
610
|
+
if (hit && "vertex" in hit && vertexOwner.value) {
|
|
611
|
+
drag.value = { kind: "vertex", t: vertexOwner.value.t, index: hit.vertex };
|
|
612
|
+
} else if (hit && "t" in hit) {
|
|
613
|
+
if (e.shiftKey) ed.select(hit.t, true);
|
|
614
|
+
else if (!ed.isSelected(hit.t)) ed.select(hit.t);
|
|
615
|
+
drag.value = { kind: "move", start: p, applied: [0, 0], moved: false };
|
|
616
|
+
} else {
|
|
617
|
+
drag.value = { kind: "band", sx, sy, add: e.shiftKey };
|
|
618
|
+
}
|
|
619
|
+
capture(e);
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
if (tool === "wall" || tool === "zone") {
|
|
623
|
+
const first = draft.value[0];
|
|
624
|
+
if (tool === "wall" && first && draft.value.length >= 3 && Math.hypot(first[0] - p[0], first[1] - p[1]) * view.k <= 10) {
|
|
625
|
+
ed.addWall(draft.value, true);
|
|
626
|
+
draft.value = [];
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
draft.value = [...draft.value, ed.snapP(p)];
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
if (tool === "node") {
|
|
633
|
+
if (!nodeNear(p)) {
|
|
634
|
+
const id = ed.addNode(p);
|
|
635
|
+
if (id) ed.select({ c: "nodes", id });
|
|
636
|
+
}
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if (tool === "edge") {
|
|
640
|
+
const near = nodeNear(p);
|
|
641
|
+
if (!chain.value) chain.value = near ?? ed.addNode(p);
|
|
642
|
+
else chain.value = ed.addEdge(chain.value, near ?? p);
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
if (tool === "object") return ed.addObject(p);
|
|
646
|
+
if (tool.startsWith("extra:")) return ed.addExtra(tool.slice(6), p);
|
|
647
|
+
}
|
|
648
|
+
function onMove(e) {
|
|
649
|
+
const { sx, sy } = local(e);
|
|
650
|
+
const p = toWorld(sx, sy);
|
|
651
|
+
cursor.value = p;
|
|
652
|
+
const d = drag.value;
|
|
653
|
+
if (!d) return;
|
|
654
|
+
if (d.kind === "pan") {
|
|
655
|
+
view.tx = d.tx + (sx - d.sx);
|
|
656
|
+
view.ty = d.ty + (sy - d.sy);
|
|
657
|
+
} else if (d.kind === "move") {
|
|
658
|
+
if (!d.moved && downAt && Math.hypot(sx - downAt.sx, sy - downAt.sy) < 3) return;
|
|
659
|
+
d.moved = true;
|
|
660
|
+
const tx = ed.snapV(p[0] - d.start[0]);
|
|
661
|
+
const ty = ed.snapV(p[1] - d.start[1]);
|
|
662
|
+
const dx = tx - d.applied[0];
|
|
663
|
+
const dy = ty - d.applied[1];
|
|
664
|
+
if (dx || dy) {
|
|
665
|
+
ed.move(dx, dy, "drag");
|
|
666
|
+
d.applied = [tx, ty];
|
|
667
|
+
}
|
|
668
|
+
} else if (d.kind === "vertex") {
|
|
669
|
+
ed.moveVertex(d.t, d.index, p, "vertex");
|
|
670
|
+
} else if (d.kind === "band") {
|
|
671
|
+
band.value = { x0: d.sx, y0: d.sy, x1: sx, y1: sy };
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function onUp(e) {
|
|
675
|
+
var _a;
|
|
676
|
+
const d = drag.value;
|
|
677
|
+
drag.value = null;
|
|
678
|
+
if ((_a = svg.value) == null ? void 0 : _a.hasPointerCapture(e.pointerId)) svg.value.releasePointerCapture(e.pointerId);
|
|
679
|
+
if (!d) return;
|
|
680
|
+
if (d.kind === "move" || d.kind === "vertex") ed.seal();
|
|
681
|
+
if (d.kind === "band") {
|
|
682
|
+
const b = band.value;
|
|
683
|
+
band.value = null;
|
|
684
|
+
const f = floor.value;
|
|
685
|
+
if (!f) return;
|
|
686
|
+
if (!b || Math.hypot(b.x1 - b.x0, b.y1 - b.y0) < 4) {
|
|
687
|
+
if (!d.add) ed.select(null);
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
const [ax, ay] = toWorld(b.x0, b.y0);
|
|
691
|
+
const [bx, by] = toWorld(b.x1, b.y1);
|
|
692
|
+
ed.select(itemsIn(f, { x0: Math.min(ax, bx), y0: Math.min(ay, by), x1: Math.max(ax, bx), y1: Math.max(ay, by) }), d.add);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
function onDbl() {
|
|
696
|
+
finishDraft();
|
|
697
|
+
}
|
|
698
|
+
function finishDraft() {
|
|
699
|
+
if (ed.tool.value === "wall" && draft.value.length >= 2) ed.addWall(draft.value, false);
|
|
700
|
+
else if (ed.tool.value === "zone" && draft.value.length >= 3) ed.addZone(draft.value);
|
|
701
|
+
else return;
|
|
702
|
+
draft.value = [];
|
|
703
|
+
}
|
|
704
|
+
function onKey(e) {
|
|
705
|
+
const mod = e.ctrlKey || e.metaKey;
|
|
706
|
+
const k = e.key;
|
|
707
|
+
if (e.type === "keyup") {
|
|
708
|
+
if (k === " ") spaceDown = false;
|
|
709
|
+
if (k.startsWith("Arrow")) ed.seal();
|
|
710
|
+
return false;
|
|
711
|
+
}
|
|
712
|
+
if (k === " ") {
|
|
713
|
+
spaceDown = true;
|
|
714
|
+
return true;
|
|
715
|
+
}
|
|
716
|
+
if (k === "Escape") {
|
|
717
|
+
if (draft.value.length || chain.value) {
|
|
718
|
+
draft.value = [];
|
|
719
|
+
chain.value = null;
|
|
720
|
+
} else if (ed.selection.value.length) ed.select(null);
|
|
721
|
+
else ed.tool.value = "select";
|
|
722
|
+
return true;
|
|
723
|
+
}
|
|
724
|
+
if (k === "Enter") {
|
|
725
|
+
finishDraft();
|
|
726
|
+
return true;
|
|
727
|
+
}
|
|
728
|
+
if (k === "Backspace" && draft.value.length) {
|
|
729
|
+
draft.value = draft.value.slice(0, -1);
|
|
730
|
+
return true;
|
|
731
|
+
}
|
|
732
|
+
if (mod && k.toLowerCase() === "z") {
|
|
733
|
+
if (e.shiftKey) ed.redo();
|
|
734
|
+
else ed.undo();
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
if (mod && k.toLowerCase() === "y") return ed.redo(), true;
|
|
738
|
+
if (mod && k.toLowerCase() === "c") return ed.copy(), true;
|
|
739
|
+
if (mod && k.toLowerCase() === "v") return ed.paste(ed.snap.value || 1), true;
|
|
740
|
+
if (mod && k.toLowerCase() === "d") return ed.duplicate(), true;
|
|
741
|
+
if (mod && k.toLowerCase() === "a") return ed.selectAll(), true;
|
|
742
|
+
if (k === "Delete" || k === "Backspace") return ed.remove(), true;
|
|
743
|
+
if (k.startsWith("Arrow") && ed.selection.value.length) {
|
|
744
|
+
const step = (ed.snap.value || 0.1) * (e.shiftKey ? 10 : 1);
|
|
745
|
+
const [dx, dy] = k === "ArrowLeft" ? [-step, 0] : k === "ArrowRight" ? [step, 0] : k === "ArrowUp" ? [0, step] : [0, -step];
|
|
746
|
+
ed.move(dx, dy, "nudge");
|
|
747
|
+
return true;
|
|
748
|
+
}
|
|
749
|
+
if (mod) return false;
|
|
750
|
+
const TOOL_KEYS = { v: "select", h: "pan", w: "wall", z: "zone", n: "node", e: "edge", o: "object" };
|
|
751
|
+
const t = TOOL_KEYS[k.toLowerCase()];
|
|
752
|
+
if (t) {
|
|
753
|
+
ed.tool.value = t;
|
|
754
|
+
return true;
|
|
755
|
+
}
|
|
756
|
+
if (k.toLowerCase() === "r" && ed.selection.value.length) {
|
|
757
|
+
ed.rotate(e.shiftKey ? -90 : 90);
|
|
758
|
+
return true;
|
|
759
|
+
}
|
|
760
|
+
if (k.toLowerCase() === "f") {
|
|
761
|
+
fit();
|
|
762
|
+
return true;
|
|
763
|
+
}
|
|
764
|
+
return false;
|
|
765
|
+
}
|
|
766
|
+
function reveal(t) {
|
|
767
|
+
const f = floor.value;
|
|
768
|
+
const it = f ? (f[t.c] ?? []).find((x) => x.id === t.id) : null;
|
|
769
|
+
const b = it ? bounds(it) : null;
|
|
770
|
+
if (!b) return;
|
|
771
|
+
const p = toScreen((b.x0 + b.x1) / 2, (b.y0 + b.y1) / 2);
|
|
772
|
+
if (p.x < 0 || p.y < 0 || p.x > size.w || p.y > size.h) {
|
|
773
|
+
view.tx += size.w / 2 - p.x;
|
|
774
|
+
view.ty += size.h / 2 - p.y;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
let resizeObs = null;
|
|
778
|
+
let fitted = false;
|
|
779
|
+
onMounted(() => {
|
|
780
|
+
resizeObs = new ResizeObserver(() => {
|
|
781
|
+
const r = svg.value.getBoundingClientRect();
|
|
782
|
+
size.w = r.width || 600;
|
|
783
|
+
size.h = r.height || 400;
|
|
784
|
+
if (!fitted && floor.value) {
|
|
785
|
+
fit();
|
|
786
|
+
fitted = true;
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
resizeObs.observe(svg.value);
|
|
790
|
+
});
|
|
791
|
+
onBeforeUnmount(() => resizeObs == null ? void 0 : resizeObs.disconnect());
|
|
792
|
+
__expose({ fit, onKey, reveal, finishDraft });
|
|
793
|
+
return (_ctx, _cache) => {
|
|
794
|
+
var _a;
|
|
795
|
+
return openBlock(), createElementBlock("div", {
|
|
796
|
+
ref_key: "root",
|
|
797
|
+
ref: root,
|
|
798
|
+
class: normalizeClass(["lf-mec", [`lf-mec--${toolClass.value}`, { "lf-mec--panning": panning.value }]]),
|
|
799
|
+
onContextmenu: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
800
|
+
}, ["prevent"]))
|
|
801
|
+
}, [
|
|
802
|
+
(openBlock(), createElementBlock("svg", {
|
|
803
|
+
ref_key: "svg",
|
|
804
|
+
ref: svg,
|
|
805
|
+
class: "lf-mec__svg",
|
|
806
|
+
onPointerdown: onDown,
|
|
807
|
+
onPointermove: onMove,
|
|
808
|
+
onPointerup: onUp,
|
|
809
|
+
onPointercancel: onUp,
|
|
810
|
+
onWheel: withModifiers(onWheel, ["prevent"]),
|
|
811
|
+
onDblclick: onDbl
|
|
812
|
+
}, [
|
|
813
|
+
createElementVNode("g", {
|
|
814
|
+
transform: `matrix(${view.k},0,0,${-view.k},${view.tx},${view.ty})`
|
|
815
|
+
}, [
|
|
816
|
+
floor.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
817
|
+
createElementVNode("rect", {
|
|
818
|
+
class: "lf-mec__floor",
|
|
819
|
+
x: "0",
|
|
820
|
+
y: "0",
|
|
821
|
+
width: floor.value.size.w,
|
|
822
|
+
height: floor.value.size.h
|
|
823
|
+
}, null, 8, _hoisted_2$1),
|
|
824
|
+
((_a = floor.value.background) == null ? void 0 : _a.url) ? (openBlock(), createElementBlock("image", {
|
|
825
|
+
key: 0,
|
|
826
|
+
href: floor.value.background.url,
|
|
827
|
+
x: bg.value.x,
|
|
828
|
+
y: -(bg.value.y + bg.value.h),
|
|
829
|
+
width: bg.value.w,
|
|
830
|
+
height: bg.value.h,
|
|
831
|
+
opacity: floor.value.background.opacity ?? 0.5,
|
|
832
|
+
transform: "scale(1,-1)",
|
|
833
|
+
preserveAspectRatio: "none",
|
|
834
|
+
"pointer-events": "none"
|
|
835
|
+
}, null, 8, _hoisted_3$1)) : createCommentVNode("", true),
|
|
836
|
+
createElementVNode("path", {
|
|
837
|
+
class: "lf-mec__grid",
|
|
838
|
+
d: gridPath.value,
|
|
839
|
+
"vector-effect": "non-scaling-stroke"
|
|
840
|
+
}, null, 8, _hoisted_4$1),
|
|
841
|
+
createElementVNode("rect", {
|
|
842
|
+
class: "lf-mec__edge-line",
|
|
843
|
+
x: "0",
|
|
844
|
+
y: "0",
|
|
845
|
+
width: floor.value.size.w,
|
|
846
|
+
height: floor.value.size.h,
|
|
847
|
+
fill: "none",
|
|
848
|
+
"vector-effect": "non-scaling-stroke"
|
|
849
|
+
}, null, 8, _hoisted_5$1),
|
|
850
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(floor.value.zones ?? [], (z) => {
|
|
851
|
+
return openBlock(), createElementBlock("polygon", {
|
|
852
|
+
key: "z" + z.id,
|
|
853
|
+
class: normalizeClass(["lf-mec__zone", { "is-on": on("zones", z.id) }]),
|
|
854
|
+
points: z.polygon.map((p) => p.join(",")).join(" "),
|
|
855
|
+
style: normalizeStyle({ "--tone": toneVar(z) }),
|
|
856
|
+
"data-c": "zones",
|
|
857
|
+
"data-id": z.id,
|
|
858
|
+
"vector-effect": "non-scaling-stroke"
|
|
859
|
+
}, null, 14, _hoisted_6$1);
|
|
860
|
+
}), 128)),
|
|
861
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(floor.value.walls ?? [], (w) => {
|
|
862
|
+
return openBlock(), createElementBlock("g", {
|
|
863
|
+
key: "w" + w.id,
|
|
864
|
+
"data-c": "walls",
|
|
865
|
+
"data-id": w.id
|
|
866
|
+
}, [
|
|
867
|
+
createElementVNode("polyline", {
|
|
868
|
+
class: normalizeClass(["lf-mec__wall", { "is-on": on("walls", w.id) }]),
|
|
869
|
+
points: wallPoints(w),
|
|
870
|
+
"stroke-width": Math.max(0.12, w.thickness ?? 0.2)
|
|
871
|
+
}, null, 10, _hoisted_8$1),
|
|
872
|
+
createElementVNode("polyline", {
|
|
873
|
+
class: "lf-mec__hit",
|
|
874
|
+
points: wallPoints(w),
|
|
875
|
+
"stroke-width": "12",
|
|
876
|
+
"vector-effect": "non-scaling-stroke"
|
|
877
|
+
}, null, 8, _hoisted_9$1)
|
|
878
|
+
], 8, _hoisted_7$1);
|
|
879
|
+
}), 128)),
|
|
880
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(edgesDrawn.value, (e) => {
|
|
881
|
+
return openBlock(), createElementBlock("g", {
|
|
882
|
+
key: "e" + e.id,
|
|
883
|
+
"data-c": "edges",
|
|
884
|
+
"data-id": e.id
|
|
885
|
+
}, [
|
|
886
|
+
e.width ? (openBlock(), createElementBlock("line", {
|
|
887
|
+
key: 0,
|
|
888
|
+
class: "lf-mec__lane",
|
|
889
|
+
x1: e.a.x,
|
|
890
|
+
y1: e.a.y,
|
|
891
|
+
x2: e.b.x,
|
|
892
|
+
y2: e.b.y,
|
|
893
|
+
"stroke-width": e.width
|
|
894
|
+
}, null, 8, _hoisted_11$1)) : createCommentVNode("", true),
|
|
895
|
+
createElementVNode("line", {
|
|
896
|
+
class: normalizeClass(["lf-mec__edge", { "is-on": on("edges", e.id) }]),
|
|
897
|
+
x1: e.a.x,
|
|
898
|
+
y1: e.a.y,
|
|
899
|
+
x2: e.b.x,
|
|
900
|
+
y2: e.b.y,
|
|
901
|
+
"vector-effect": "non-scaling-stroke"
|
|
902
|
+
}, null, 10, _hoisted_12$1),
|
|
903
|
+
e.oneWay ? (openBlock(), createElementBlock("path", {
|
|
904
|
+
key: 1,
|
|
905
|
+
class: "lf-mec__arrow",
|
|
906
|
+
d: e.arrow
|
|
907
|
+
}, null, 8, _hoisted_13$1)) : createCommentVNode("", true),
|
|
908
|
+
createElementVNode("line", {
|
|
909
|
+
class: "lf-mec__hit",
|
|
910
|
+
x1: e.a.x,
|
|
911
|
+
y1: e.a.y,
|
|
912
|
+
x2: e.b.x,
|
|
913
|
+
y2: e.b.y,
|
|
914
|
+
"stroke-width": "10",
|
|
915
|
+
"vector-effect": "non-scaling-stroke"
|
|
916
|
+
}, null, 8, _hoisted_14$1)
|
|
917
|
+
], 8, _hoisted_10$1);
|
|
918
|
+
}), 128)),
|
|
919
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(floor.value.objects ?? [], (o) => {
|
|
920
|
+
return openBlock(), createElementBlock("g", {
|
|
921
|
+
key: "o" + o.id,
|
|
922
|
+
transform: `translate(${o.x},${o.y}) rotate(${o.rotation ?? 0})`,
|
|
923
|
+
"data-c": "objects",
|
|
924
|
+
"data-id": o.id
|
|
925
|
+
}, [
|
|
926
|
+
createElementVNode("rect", {
|
|
927
|
+
class: normalizeClass(["lf-mec__obj", { "is-on": on("objects", o.id), "has-model": !!o.model }]),
|
|
928
|
+
x: -o.w / 2,
|
|
929
|
+
y: -o.h / 2,
|
|
930
|
+
width: o.w,
|
|
931
|
+
height: o.h,
|
|
932
|
+
style: normalizeStyle({ "--tone": toneVar(o, "neutral") }),
|
|
933
|
+
"vector-effect": "non-scaling-stroke"
|
|
934
|
+
}, null, 14, _hoisted_16$1),
|
|
935
|
+
createElementVNode("line", {
|
|
936
|
+
class: "lf-mec__front",
|
|
937
|
+
x1: o.w / 2 - Math.min(o.w, o.h) * 0.25,
|
|
938
|
+
y1: "0",
|
|
939
|
+
x2: o.w / 2,
|
|
940
|
+
y2: "0",
|
|
941
|
+
"vector-effect": "non-scaling-stroke"
|
|
942
|
+
}, null, 8, _hoisted_17$1)
|
|
943
|
+
], 8, _hoisted_15$1);
|
|
944
|
+
}), 128)),
|
|
945
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(floor.value.extras ?? [], (x) => {
|
|
946
|
+
return openBlock(), createElementBlock("g", {
|
|
947
|
+
key: "x" + x.id,
|
|
948
|
+
transform: `translate(${x.x},${x.y}) rotate(${x.rotation ?? 0})`,
|
|
949
|
+
"data-c": "extras",
|
|
950
|
+
"data-id": x.id
|
|
951
|
+
}, [
|
|
952
|
+
x.w && x.h ? (openBlock(), createElementBlock("rect", {
|
|
953
|
+
key: 0,
|
|
954
|
+
class: normalizeClass(["lf-mec__extra", { "is-on": on("extras", x.id) }]),
|
|
955
|
+
x: -x.w / 2,
|
|
956
|
+
y: -x.h / 2,
|
|
957
|
+
width: x.w,
|
|
958
|
+
height: x.h,
|
|
959
|
+
style: normalizeStyle({ "--tone": toneVar(x, "info") }),
|
|
960
|
+
"vector-effect": "non-scaling-stroke"
|
|
961
|
+
}, null, 14, _hoisted_19$1)) : (openBlock(), createElementBlock("path", {
|
|
962
|
+
key: 1,
|
|
963
|
+
class: normalizeClass(["lf-mec__extra", { "is-on": on("extras", x.id) }]),
|
|
964
|
+
d: diamond.value,
|
|
965
|
+
style: normalizeStyle({ "--tone": toneVar(x, "info") }),
|
|
966
|
+
"vector-effect": "non-scaling-stroke"
|
|
967
|
+
}, null, 14, _hoisted_20$1))
|
|
968
|
+
], 8, _hoisted_18$1);
|
|
969
|
+
}), 128)),
|
|
970
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(floor.value.nodes ?? [], (n) => {
|
|
971
|
+
return openBlock(), createElementBlock("circle", {
|
|
972
|
+
key: "n" + n.id,
|
|
973
|
+
class: normalizeClass(["lf-mec__node", { "is-on": on("nodes", n.id), "is-chain": chain.value === n.id }]),
|
|
974
|
+
cx: n.x,
|
|
975
|
+
cy: n.y,
|
|
976
|
+
r: nodeR.value,
|
|
977
|
+
"data-c": "nodes",
|
|
978
|
+
"data-id": n.id,
|
|
979
|
+
"vector-effect": "non-scaling-stroke"
|
|
980
|
+
}, null, 10, _hoisted_21$1);
|
|
981
|
+
}), 128)),
|
|
982
|
+
vertexOwner.value ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(vertexOwner.value.points, (p, i) => {
|
|
983
|
+
return openBlock(), createElementBlock("rect", {
|
|
984
|
+
key: "v" + i,
|
|
985
|
+
class: "lf-mec__vertex",
|
|
986
|
+
x: p[0] - handle.value / 2,
|
|
987
|
+
y: p[1] - handle.value / 2,
|
|
988
|
+
width: handle.value,
|
|
989
|
+
height: handle.value,
|
|
990
|
+
"data-vertex": i,
|
|
991
|
+
"vector-effect": "non-scaling-stroke"
|
|
992
|
+
}, null, 8, _hoisted_22$1);
|
|
993
|
+
}), 128)) : createCommentVNode("", true),
|
|
994
|
+
draftLine.value ? (openBlock(), createElementBlock("polyline", {
|
|
995
|
+
key: 2,
|
|
996
|
+
class: "lf-mec__draft",
|
|
997
|
+
points: draftLine.value,
|
|
998
|
+
"vector-effect": "non-scaling-stroke"
|
|
999
|
+
}, null, 8, _hoisted_23$1)) : createCommentVNode("", true),
|
|
1000
|
+
chainFrom.value && cursor.value ? (openBlock(), createElementBlock("line", {
|
|
1001
|
+
key: 3,
|
|
1002
|
+
class: "lf-mec__draft",
|
|
1003
|
+
x1: chainFrom.value.x,
|
|
1004
|
+
y1: chainFrom.value.y,
|
|
1005
|
+
x2: cursor.value[0],
|
|
1006
|
+
y2: cursor.value[1],
|
|
1007
|
+
"vector-effect": "non-scaling-stroke"
|
|
1008
|
+
}, null, 8, _hoisted_24$1)) : createCommentVNode("", true)
|
|
1009
|
+
], 64)) : createCommentVNode("", true)
|
|
1010
|
+
], 8, _hoisted_1$1),
|
|
1011
|
+
band.value ? (openBlock(), createElementBlock("rect", {
|
|
1012
|
+
key: 0,
|
|
1013
|
+
class: "lf-mec__band",
|
|
1014
|
+
x: Math.min(band.value.x0, band.value.x1),
|
|
1015
|
+
y: Math.min(band.value.y0, band.value.y1),
|
|
1016
|
+
width: Math.abs(band.value.x1 - band.value.x0),
|
|
1017
|
+
height: Math.abs(band.value.y1 - band.value.y0)
|
|
1018
|
+
}, null, 8, _hoisted_25$1)) : createCommentVNode("", true)
|
|
1019
|
+
], 544)),
|
|
1020
|
+
createElementVNode("div", _hoisted_26$1, [
|
|
1021
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(labels.value, (l) => {
|
|
1022
|
+
return openBlock(), createElementBlock("span", {
|
|
1023
|
+
key: l.key,
|
|
1024
|
+
class: normalizeClass(["lf-mec__label", l.cls]),
|
|
1025
|
+
style: normalizeStyle({ transform: `translate(${l.x}px, ${l.y}px)` })
|
|
1026
|
+
}, toDisplayString(l.text), 7);
|
|
1027
|
+
}), 128))
|
|
1028
|
+
]),
|
|
1029
|
+
createElementVNode("div", _hoisted_27$1, [
|
|
1030
|
+
cursor.value ? (openBlock(), createElementBlock("span", _hoisted_28$1, "x " + toDisplayString(cursor.value[0].toFixed(2)) + " · y " + toDisplayString(cursor.value[1].toFixed(2)) + " m", 1)) : createCommentVNode("", true),
|
|
1031
|
+
createElementVNode("span", null, toDisplayString(Math.round(view.k * 10) / 10) + " px/m", 1),
|
|
1032
|
+
createElementVNode("span", _hoisted_29$1, toDisplayString(hint.value), 1)
|
|
1033
|
+
]),
|
|
1034
|
+
!floor.value ? (openBlock(), createElementBlock("p", _hoisted_30$1, "층이 없습니다 — 오른쪽에서 층을 더하세요.")) : createCommentVNode("", true)
|
|
1035
|
+
], 34);
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
const MapEditorCanvas = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-e6e45535"]]);
|
|
1040
|
+
const PREFIX = { nodes: "N-", edges: "E-", zones: "Z-", walls: "W-", objects: "O-", extras: "X-" };
|
|
1041
|
+
function createMapEditor(initial, opts = {}) {
|
|
1042
|
+
var _a;
|
|
1043
|
+
const doc = ref(normalizeDoc(initial));
|
|
1044
|
+
const history = shallowRef(new History(doc.value));
|
|
1045
|
+
const rev = ref(0);
|
|
1046
|
+
const kinds = ref(opts.kinds ?? []);
|
|
1047
|
+
const floorId = ref(((_a = doc.value.floors[0]) == null ? void 0 : _a.id) ?? "");
|
|
1048
|
+
const floor = computed(() => {
|
|
1049
|
+
void rev.value;
|
|
1050
|
+
return doc.value.floors.find((f) => f.id === floorId.value) ?? null;
|
|
1051
|
+
});
|
|
1052
|
+
const tool = ref("select");
|
|
1053
|
+
const selection = ref([]);
|
|
1054
|
+
const snap = ref(0.5);
|
|
1055
|
+
const objectModel = ref("");
|
|
1056
|
+
const clipboard = shallowRef([]);
|
|
1057
|
+
const canUndo = computed(() => (void rev.value, history.value.canUndo));
|
|
1058
|
+
const canRedo = computed(() => (void rev.value, history.value.canRedo));
|
|
1059
|
+
function changed() {
|
|
1060
|
+
var _a2;
|
|
1061
|
+
rev.value++;
|
|
1062
|
+
const f = floor.value;
|
|
1063
|
+
if (f) selection.value = selection.value.filter((t) => !!find(doc.value, f.id, t.c, t.id));
|
|
1064
|
+
(_a2 = opts.onChange) == null ? void 0 : _a2.call(opts, clone(doc.value));
|
|
1065
|
+
}
|
|
1066
|
+
function run(c) {
|
|
1067
|
+
const ok = history.value.run(c);
|
|
1068
|
+
if (ok) changed();
|
|
1069
|
+
return ok;
|
|
1070
|
+
}
|
|
1071
|
+
function seal() {
|
|
1072
|
+
history.value.seal();
|
|
1073
|
+
}
|
|
1074
|
+
function undo() {
|
|
1075
|
+
if (history.value.undo()) changed();
|
|
1076
|
+
}
|
|
1077
|
+
function redo() {
|
|
1078
|
+
if (history.value.redo()) changed();
|
|
1079
|
+
}
|
|
1080
|
+
function load(next) {
|
|
1081
|
+
var _a2;
|
|
1082
|
+
doc.value = normalizeDoc(next);
|
|
1083
|
+
history.value = new History(doc.value);
|
|
1084
|
+
if (!doc.value.floors.some((f) => f.id === floorId.value)) floorId.value = ((_a2 = doc.value.floors[0]) == null ? void 0 : _a2.id) ?? "";
|
|
1085
|
+
selection.value = [];
|
|
1086
|
+
rev.value++;
|
|
1087
|
+
}
|
|
1088
|
+
const snapV = (v) => snap.value > 0 ? round(Math.round(v / snap.value) * snap.value) : round(v);
|
|
1089
|
+
const snapP = (p) => [snapV(p[0]), snapV(p[1])];
|
|
1090
|
+
function isSelected(t) {
|
|
1091
|
+
return selection.value.some((s) => s.c === t.c && s.id === t.id);
|
|
1092
|
+
}
|
|
1093
|
+
function select(t, add = false) {
|
|
1094
|
+
const list2 = t === null ? [] : Array.isArray(t) ? t : [t];
|
|
1095
|
+
if (!add) selection.value = list2;
|
|
1096
|
+
else {
|
|
1097
|
+
const keys = new Set(selection.value.map(targetKey));
|
|
1098
|
+
const next = [...selection.value];
|
|
1099
|
+
for (const x of list2) {
|
|
1100
|
+
if (keys.has(targetKey(x))) next.splice(next.findIndex((s) => targetKey(s) === targetKey(x)), 1);
|
|
1101
|
+
else next.push(x);
|
|
1102
|
+
}
|
|
1103
|
+
selection.value = next;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function selectAll() {
|
|
1107
|
+
const f = floor.value;
|
|
1108
|
+
if (!f) return;
|
|
1109
|
+
selection.value = COLLECTIONS.flatMap((c) => (f[c] ?? []).map((it) => ({ c, id: it.id })));
|
|
1110
|
+
}
|
|
1111
|
+
const single = computed(() => {
|
|
1112
|
+
void rev.value;
|
|
1113
|
+
const f = floor.value;
|
|
1114
|
+
if (!f || selection.value.length !== 1) return null;
|
|
1115
|
+
const t = selection.value[0];
|
|
1116
|
+
const item = find(doc.value, f.id, t.c, t.id);
|
|
1117
|
+
return item ? { t, item } : null;
|
|
1118
|
+
});
|
|
1119
|
+
function selectionCentre() {
|
|
1120
|
+
const f = floor.value;
|
|
1121
|
+
if (!f) return null;
|
|
1122
|
+
const bs = selection.value.flatMap((t) => {
|
|
1123
|
+
const it = find(doc.value, f.id, t.c, t.id);
|
|
1124
|
+
const b = it ? bounds(it) : null;
|
|
1125
|
+
return b ? [b] : [];
|
|
1126
|
+
});
|
|
1127
|
+
if (!bs.length) return null;
|
|
1128
|
+
return [(Math.min(...bs.map((b) => b.x0)) + Math.max(...bs.map((b) => b.x1))) / 2, (Math.min(...bs.map((b) => b.y0)) + Math.max(...bs.map((b) => b.y1))) / 2];
|
|
1129
|
+
}
|
|
1130
|
+
function update(t, patch, mergeKey) {
|
|
1131
|
+
if (!floor.value) return;
|
|
1132
|
+
run(updateItems(doc.value, floor.value.id, t.c, [{ id: t.id, patch }], "고치기", mergeKey));
|
|
1133
|
+
}
|
|
1134
|
+
function move(dx, dy, mergeKey) {
|
|
1135
|
+
if (!floor.value || !selection.value.length) return;
|
|
1136
|
+
run(moveItems(doc.value, floor.value.id, selection.value, dx, dy, mergeKey));
|
|
1137
|
+
}
|
|
1138
|
+
function moveVertex(t, index, to, mergeKey) {
|
|
1139
|
+
if (!floor.value) return;
|
|
1140
|
+
run(movePoint(doc.value, floor.value.id, t, index, snapP(to), mergeKey));
|
|
1141
|
+
}
|
|
1142
|
+
function rotate(deg) {
|
|
1143
|
+
const c = selectionCentre();
|
|
1144
|
+
if (!floor.value || !c) return;
|
|
1145
|
+
run(rotateItems(doc.value, floor.value.id, selection.value, deg, c));
|
|
1146
|
+
}
|
|
1147
|
+
function align(how) {
|
|
1148
|
+
if (!floor.value) return;
|
|
1149
|
+
run(alignItems(doc.value, floor.value.id, selection.value, how));
|
|
1150
|
+
}
|
|
1151
|
+
function remove() {
|
|
1152
|
+
if (!floor.value || !selection.value.length) return;
|
|
1153
|
+
run(removeItems(doc.value, floor.value.id, selection.value));
|
|
1154
|
+
selection.value = [];
|
|
1155
|
+
}
|
|
1156
|
+
let pasteCount = 0;
|
|
1157
|
+
function copy() {
|
|
1158
|
+
const f = floor.value;
|
|
1159
|
+
if (!f) return;
|
|
1160
|
+
clipboard.value = selection.value.flatMap((t) => {
|
|
1161
|
+
const it = find(doc.value, f.id, t.c, t.id);
|
|
1162
|
+
return it ? [{ c: t.c, item: clone(it) }] : [];
|
|
1163
|
+
});
|
|
1164
|
+
pasteCount = 0;
|
|
1165
|
+
}
|
|
1166
|
+
function paste(step = 1) {
|
|
1167
|
+
const f = floor.value;
|
|
1168
|
+
if (!f || !clipboard.value.length) return;
|
|
1169
|
+
pasteCount++;
|
|
1170
|
+
const d = step * pasteCount;
|
|
1171
|
+
const { command, targets } = pasteItems(doc.value, f.id, clipboard.value, d, -d);
|
|
1172
|
+
if (run(command)) selection.value = targets;
|
|
1173
|
+
}
|
|
1174
|
+
function duplicate() {
|
|
1175
|
+
copy();
|
|
1176
|
+
paste(snap.value || 1);
|
|
1177
|
+
}
|
|
1178
|
+
function newId(c, prefix) {
|
|
1179
|
+
return nextId(doc.value, prefix ?? PREFIX[c]);
|
|
1180
|
+
}
|
|
1181
|
+
function addNode(p) {
|
|
1182
|
+
const f = floor.value;
|
|
1183
|
+
if (!f) return null;
|
|
1184
|
+
const id = newId("nodes");
|
|
1185
|
+
const [x, y] = snapP(p);
|
|
1186
|
+
run(addItems(f.id, "nodes", [{ id, x, y }], "마디 더하기"));
|
|
1187
|
+
return id;
|
|
1188
|
+
}
|
|
1189
|
+
function addEdge(from, to) {
|
|
1190
|
+
const f = floor.value;
|
|
1191
|
+
if (!f) return null;
|
|
1192
|
+
const items = [];
|
|
1193
|
+
let toId;
|
|
1194
|
+
if (typeof to === "string") toId = to;
|
|
1195
|
+
else {
|
|
1196
|
+
toId = newId("nodes");
|
|
1197
|
+
const [x, y] = snapP(to);
|
|
1198
|
+
items.push({ c: "nodes", it: { id: toId, x, y } });
|
|
1199
|
+
}
|
|
1200
|
+
if (toId === from) return toId;
|
|
1201
|
+
const exists = (f.edges ?? []).some((e) => e.from === from && e.to === toId || e.from === toId && e.to === from);
|
|
1202
|
+
if (!exists) {
|
|
1203
|
+
const reserved = /* @__PURE__ */ new Set([toId]);
|
|
1204
|
+
items.push({ c: "edges", it: { id: nextId(doc.value, PREFIX.edges, reserved), from, to: toId } });
|
|
1205
|
+
}
|
|
1206
|
+
if (items.length)
|
|
1207
|
+
run({ label: "길 더하기", changes: items.map(({ c, it }) => ({ floorId: f.id, c, id: it.id, before: null, after: it })) });
|
|
1208
|
+
return toId;
|
|
1209
|
+
}
|
|
1210
|
+
function addWall(points, closed) {
|
|
1211
|
+
const f = floor.value;
|
|
1212
|
+
if (!f || points.length < 2) return;
|
|
1213
|
+
const id = newId("walls");
|
|
1214
|
+
run(addItems(f.id, "walls", [{ id, points: points.map(snapP), closed, thickness: 0.2 }], "벽 더하기"));
|
|
1215
|
+
selection.value = [{ c: "walls", id }];
|
|
1216
|
+
}
|
|
1217
|
+
function addZone(points) {
|
|
1218
|
+
const f = floor.value;
|
|
1219
|
+
if (!f || points.length < 3) return;
|
|
1220
|
+
const id = newId("zones");
|
|
1221
|
+
run(addItems(f.id, "zones", [{ id, name: `구역 ${id}`, polygon: points.map(snapP), tone: "info" }], "구역 더하기"));
|
|
1222
|
+
selection.value = [{ c: "zones", id }];
|
|
1223
|
+
}
|
|
1224
|
+
function addObject(p) {
|
|
1225
|
+
var _a2;
|
|
1226
|
+
const f = floor.value;
|
|
1227
|
+
if (!f) return;
|
|
1228
|
+
const id = newId("objects");
|
|
1229
|
+
const key = objectModel.value;
|
|
1230
|
+
const m = key ? (_a2 = doc.value.models) == null ? void 0 : _a2[key] : void 0;
|
|
1231
|
+
const [x, y] = snapP(p);
|
|
1232
|
+
const o = { id, name: id, x, y, w: (m == null ? void 0 : m.footprint.w) ?? 1.2, h: (m == null ? void 0 : m.footprint.h) ?? 1.2, height: (m == null ? void 0 : m.height) ?? 1 };
|
|
1233
|
+
if (key && m) o.model = key;
|
|
1234
|
+
run(addItems(f.id, "objects", [o], "설비 더하기"));
|
|
1235
|
+
selection.value = [{ c: "objects", id }];
|
|
1236
|
+
}
|
|
1237
|
+
function addExtra(kindKey, p) {
|
|
1238
|
+
const f = floor.value;
|
|
1239
|
+
if (!f) return;
|
|
1240
|
+
const k = kinds.value.find((x2) => x2.key === kindKey);
|
|
1241
|
+
const id = newId("extras", k == null ? void 0 : k.idPrefix);
|
|
1242
|
+
const [x, y] = snapP(p);
|
|
1243
|
+
const e = { id, kind: kindKey, x, y, name: id };
|
|
1244
|
+
if (k == null ? void 0 : k.tone) e.tone = k.tone;
|
|
1245
|
+
if (k == null ? void 0 : k.size) {
|
|
1246
|
+
e.w = k.size.w;
|
|
1247
|
+
e.h = k.size.h;
|
|
1248
|
+
}
|
|
1249
|
+
const props = {};
|
|
1250
|
+
for (const fd of (k == null ? void 0 : k.fields) ?? []) if (fd.default !== void 0) props[fd.key] = fd.default;
|
|
1251
|
+
if (Object.keys(props).length) e.props = props;
|
|
1252
|
+
run(addItems(f.id, "extras", [e], `${(k == null ? void 0 : k.label) ?? kindKey} 더하기`));
|
|
1253
|
+
selection.value = [{ c: "extras", id }];
|
|
1254
|
+
}
|
|
1255
|
+
function setFloorProps(patch, mergeKey) {
|
|
1256
|
+
if (!floor.value) return;
|
|
1257
|
+
run(setFloor(doc.value, floor.value.id, patch, "층 고치기", mergeKey));
|
|
1258
|
+
}
|
|
1259
|
+
function newFloor() {
|
|
1260
|
+
const cur = floor.value;
|
|
1261
|
+
const id = nextId(doc.value, "F");
|
|
1262
|
+
const top = Math.max(0, ...doc.value.floors.map((f2) => f2.elevation ?? 0));
|
|
1263
|
+
const f = {
|
|
1264
|
+
id,
|
|
1265
|
+
name: `${doc.value.floors.length + 1}층`,
|
|
1266
|
+
elevation: doc.value.floors.length ? top + 5 : 0,
|
|
1267
|
+
size: cur ? { ...cur.size } : { w: 40, h: 25 },
|
|
1268
|
+
nodes: [],
|
|
1269
|
+
edges: [],
|
|
1270
|
+
zones: [],
|
|
1271
|
+
walls: [],
|
|
1272
|
+
objects: [],
|
|
1273
|
+
extras: []
|
|
1274
|
+
};
|
|
1275
|
+
if (run(addFloor(doc.value, f))) {
|
|
1276
|
+
floorId.value = id;
|
|
1277
|
+
selection.value = [];
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
function dropFloor() {
|
|
1281
|
+
var _a2;
|
|
1282
|
+
const f = floor.value;
|
|
1283
|
+
if (!f || doc.value.floors.length < 2) return;
|
|
1284
|
+
const i = doc.value.floors.findIndex((x) => x.id === f.id);
|
|
1285
|
+
if (run(removeFloor(doc.value, f.id))) {
|
|
1286
|
+
floorId.value = ((_a2 = doc.value.floors[Math.max(0, i - 1)]) == null ? void 0 : _a2.id) ?? "";
|
|
1287
|
+
selection.value = [];
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
function showFloor(id) {
|
|
1291
|
+
if (id === floorId.value) return;
|
|
1292
|
+
floorId.value = id;
|
|
1293
|
+
selection.value = [];
|
|
1294
|
+
}
|
|
1295
|
+
return {
|
|
1296
|
+
doc,
|
|
1297
|
+
rev,
|
|
1298
|
+
kinds,
|
|
1299
|
+
floorId,
|
|
1300
|
+
floor,
|
|
1301
|
+
tool,
|
|
1302
|
+
selection,
|
|
1303
|
+
snap,
|
|
1304
|
+
objectModel,
|
|
1305
|
+
clipboard,
|
|
1306
|
+
canUndo,
|
|
1307
|
+
canRedo,
|
|
1308
|
+
single,
|
|
1309
|
+
run,
|
|
1310
|
+
seal,
|
|
1311
|
+
undo,
|
|
1312
|
+
redo,
|
|
1313
|
+
load,
|
|
1314
|
+
snapV,
|
|
1315
|
+
snapP,
|
|
1316
|
+
isSelected,
|
|
1317
|
+
select,
|
|
1318
|
+
selectAll,
|
|
1319
|
+
selectionCentre,
|
|
1320
|
+
update,
|
|
1321
|
+
move,
|
|
1322
|
+
moveVertex,
|
|
1323
|
+
rotate,
|
|
1324
|
+
align,
|
|
1325
|
+
remove,
|
|
1326
|
+
copy,
|
|
1327
|
+
paste,
|
|
1328
|
+
duplicate,
|
|
1329
|
+
addNode,
|
|
1330
|
+
addEdge,
|
|
1331
|
+
addWall,
|
|
1332
|
+
addZone,
|
|
1333
|
+
addObject,
|
|
1334
|
+
addExtra,
|
|
1335
|
+
setFloorProps,
|
|
1336
|
+
newFloor,
|
|
1337
|
+
dropFloor,
|
|
1338
|
+
showFloor,
|
|
1339
|
+
/** 층 하나 찾기(없으면 던진다) */
|
|
1340
|
+
floorOf: (id) => floorOf(doc.value, id)
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
const _hoisted_1 = {
|
|
1344
|
+
class: "lf-mae__bar",
|
|
1345
|
+
role: "toolbar",
|
|
1346
|
+
"aria-label": "맵 편집 도구"
|
|
1347
|
+
};
|
|
1348
|
+
const _hoisted_2 = { class: "lf-mae__tools" };
|
|
1349
|
+
const _hoisted_3 = ["aria-pressed", "title", "disabled", "onClick"];
|
|
1350
|
+
const _hoisted_4 = {
|
|
1351
|
+
key: 1,
|
|
1352
|
+
viewBox: "0 0 24 24",
|
|
1353
|
+
width: "16",
|
|
1354
|
+
height: "16",
|
|
1355
|
+
"aria-hidden": "true"
|
|
1356
|
+
};
|
|
1357
|
+
const _hoisted_5 = ["d"];
|
|
1358
|
+
const _hoisted_6 = { class: "lf-mae__opts" };
|
|
1359
|
+
const _hoisted_7 = { class: "lf-mae__body" };
|
|
1360
|
+
const _hoisted_8 = { class: "lf-mae__canvas" };
|
|
1361
|
+
const _hoisted_9 = { class: "lf-mae__side" };
|
|
1362
|
+
const _hoisted_10 = { class: "lf-mae__sec" };
|
|
1363
|
+
const _hoisted_11 = { class: "lf-mae__head" };
|
|
1364
|
+
const _hoisted_12 = {
|
|
1365
|
+
key: 0,
|
|
1366
|
+
class: "lf-mae__row-tools"
|
|
1367
|
+
};
|
|
1368
|
+
const _hoisted_13 = { class: "lf-mae__grid2" };
|
|
1369
|
+
const _hoisted_14 = {
|
|
1370
|
+
key: 0,
|
|
1371
|
+
class: "lf-mae__grid2"
|
|
1372
|
+
};
|
|
1373
|
+
const _hoisted_15 = {
|
|
1374
|
+
key: 0,
|
|
1375
|
+
class: "lf-mae__sec"
|
|
1376
|
+
};
|
|
1377
|
+
const _hoisted_16 = { class: "lf-mae__head" };
|
|
1378
|
+
const _hoisted_17 = { class: "lf-mae__id" };
|
|
1379
|
+
const _hoisted_18 = {
|
|
1380
|
+
key: 0,
|
|
1381
|
+
class: "lf-mae__grid2"
|
|
1382
|
+
};
|
|
1383
|
+
const _hoisted_19 = { class: "lf-mae__meta" };
|
|
1384
|
+
const _hoisted_20 = { class: "lf-mae__grid2" };
|
|
1385
|
+
const _hoisted_21 = { class: "lf-mae__grid2" };
|
|
1386
|
+
const _hoisted_22 = { class: "lf-mae__grid3" };
|
|
1387
|
+
const _hoisted_23 = { class: "lf-mae__grid3" };
|
|
1388
|
+
const _hoisted_24 = { class: "lf-mae__meta" };
|
|
1389
|
+
const _hoisted_25 = { class: "lf-mae__grid3" };
|
|
1390
|
+
const _hoisted_26 = {
|
|
1391
|
+
key: 1,
|
|
1392
|
+
class: "lf-mae__sec"
|
|
1393
|
+
};
|
|
1394
|
+
const _hoisted_27 = { class: "lf-mae__head" };
|
|
1395
|
+
const _hoisted_28 = { class: "lf-mae__aligns" };
|
|
1396
|
+
const _hoisted_29 = { class: "lf-mae__aligns" };
|
|
1397
|
+
const _hoisted_30 = {
|
|
1398
|
+
key: 2,
|
|
1399
|
+
class: "lf-mae__hint"
|
|
1400
|
+
};
|
|
1401
|
+
const _hoisted_31 = {
|
|
1402
|
+
key: 3,
|
|
1403
|
+
class: "lf-mae__hint lf-mae__keys"
|
|
1404
|
+
};
|
|
1405
|
+
const ICON_FIT = "M5,5H10V7H7V10H5V5M14,5H19V10H17V7H14V5M17,14H19V19H14V17H17V14M10,17V19H5V14H7V17H10Z";
|
|
1406
|
+
const ICON_WALL = "M3 5h18v4H3V5zm0 5h8v4H3v-4zm10 0h8v4h-8v-4zM3 15h18v4H3v-4z";
|
|
1407
|
+
const ICON_ZONE = "M4 4h7v2H6v5H4V4zm16 0v7h-2V6h-5V4h7zM4 20v-7h2v5h5v2H4zm16 0h-7v-2h5v-5h2v7z";
|
|
1408
|
+
const ICON_EDGE = "M5 17a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm14-14a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM6.4 17.2 17.2 6.4l1.4 1.4L7.8 18.6z";
|
|
1409
|
+
const ICON_NODE = "M12 7a5 5 0 1 0 0 10 5 5 0 0 0 0-10zm0 2a3 3 0 1 1 0 6 3 3 0 0 1 0-6z";
|
|
1410
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1411
|
+
__name: "LfMapEditor",
|
|
1412
|
+
props: {
|
|
1413
|
+
modelValue: {},
|
|
1414
|
+
kinds: { default: () => [] },
|
|
1415
|
+
floor: { default: null },
|
|
1416
|
+
readonly: { type: Boolean, default: false }
|
|
1417
|
+
},
|
|
1418
|
+
emits: ["update:modelValue", "update:floor"],
|
|
1419
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1420
|
+
const props = __props;
|
|
1421
|
+
const emit = __emit;
|
|
1422
|
+
let lastEmitted = null;
|
|
1423
|
+
const ed = createMapEditor(props.modelValue, {
|
|
1424
|
+
kinds: props.kinds,
|
|
1425
|
+
onChange: (d) => {
|
|
1426
|
+
lastEmitted = d;
|
|
1427
|
+
emit("update:modelValue", d);
|
|
1428
|
+
}
|
|
1429
|
+
});
|
|
1430
|
+
if (props.floor && props.modelValue.floors.some((f) => f.id === props.floor)) ed.floorId.value = props.floor;
|
|
1431
|
+
watch(
|
|
1432
|
+
() => props.modelValue,
|
|
1433
|
+
(v) => {
|
|
1434
|
+
if (v !== lastEmitted) ed.load(v);
|
|
1435
|
+
}
|
|
1436
|
+
);
|
|
1437
|
+
watch(
|
|
1438
|
+
() => props.kinds,
|
|
1439
|
+
(k) => ed.kinds.value = k
|
|
1440
|
+
);
|
|
1441
|
+
watch(
|
|
1442
|
+
() => props.floor,
|
|
1443
|
+
(f) => f && ed.showFloor(f)
|
|
1444
|
+
);
|
|
1445
|
+
watch(
|
|
1446
|
+
() => ed.floorId.value,
|
|
1447
|
+
(f) => emit("update:floor", f)
|
|
1448
|
+
);
|
|
1449
|
+
watch(
|
|
1450
|
+
() => props.readonly,
|
|
1451
|
+
(r) => r && (ed.tool.value = "select"),
|
|
1452
|
+
{ immediate: true }
|
|
1453
|
+
);
|
|
1454
|
+
const canvas = ref(null);
|
|
1455
|
+
const doc = computed(() => (void ed.rev.value, ed.doc.value));
|
|
1456
|
+
const floor = computed(() => ed.floor.value);
|
|
1457
|
+
const sel = computed(() => ed.single.value);
|
|
1458
|
+
const toolList = computed(() => {
|
|
1459
|
+
const base = [
|
|
1460
|
+
{ value: "select", label: "고르기", title: "고르기 · 옮기기 (V)", icon: "near_me" },
|
|
1461
|
+
{ value: "pan", label: "손", title: "화면 이동 (H)", icon: "pan_tool" },
|
|
1462
|
+
{ value: "wall", label: "벽", title: "벽 그리기 (W)", path: ICON_WALL },
|
|
1463
|
+
{ value: "zone", label: "구역", title: "구역 그리기 (Z)", path: ICON_ZONE },
|
|
1464
|
+
{ value: "node", label: "마디", title: "마디 놓기 (N)", path: ICON_NODE },
|
|
1465
|
+
{ value: "edge", label: "길", title: "길 잇기 (E)", path: ICON_EDGE },
|
|
1466
|
+
{ value: "object", label: "설비", title: "설비 놓기 (O)", icon: "view_in_ar" }
|
|
1467
|
+
];
|
|
1468
|
+
for (const k of ed.kinds.value) base.push({ value: `extra:${k.key}`, label: k.label, title: `${k.label} 놓기`, icon: "place" });
|
|
1469
|
+
return base;
|
|
1470
|
+
});
|
|
1471
|
+
const modelOptions = computed(() => [
|
|
1472
|
+
{ value: "", label: "상자 (모양 없음)" },
|
|
1473
|
+
...Object.keys(doc.value.models ?? {}).map((k) => ({ value: k, label: k }))
|
|
1474
|
+
]);
|
|
1475
|
+
const SNAP_OPTIONS = [
|
|
1476
|
+
{ value: 0, label: "맞춤 끔" },
|
|
1477
|
+
{ value: 0.1, label: "0.1 m" },
|
|
1478
|
+
{ value: 0.25, label: "0.25 m" },
|
|
1479
|
+
{ value: 0.5, label: "0.5 m" },
|
|
1480
|
+
{ value: 1, label: "1 m" }
|
|
1481
|
+
];
|
|
1482
|
+
const TONE_OPTIONS = [
|
|
1483
|
+
{ value: "neutral", label: "회색" },
|
|
1484
|
+
{ value: "info", label: "파랑" },
|
|
1485
|
+
{ value: "success", label: "초록" },
|
|
1486
|
+
{ value: "warning", label: "노랑" },
|
|
1487
|
+
{ value: "error", label: "빨강" },
|
|
1488
|
+
{ value: "accent", label: "강조색" },
|
|
1489
|
+
{ value: "purple", label: "보라" },
|
|
1490
|
+
{ value: "teal", label: "청록" }
|
|
1491
|
+
];
|
|
1492
|
+
const TYPE_LABEL = { nodes: "마디", edges: "길", zones: "구역", walls: "벽", objects: "설비", extras: "" };
|
|
1493
|
+
const ALIGNS = [
|
|
1494
|
+
{ how: "left", label: "왼쪽" },
|
|
1495
|
+
{ how: "hcenter", label: "가로 가운데" },
|
|
1496
|
+
{ how: "right", label: "오른쪽" },
|
|
1497
|
+
{ how: "top", label: "위" },
|
|
1498
|
+
{ how: "vcenter", label: "세로 가운데" },
|
|
1499
|
+
{ how: "bottom", label: "아래" },
|
|
1500
|
+
{ how: "hspread", label: "가로 고르게" },
|
|
1501
|
+
{ how: "vspread", label: "세로 고르게" }
|
|
1502
|
+
];
|
|
1503
|
+
const num = (v, fallback) => {
|
|
1504
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
1505
|
+
return Number.isFinite(n) ? round(n) : fallback;
|
|
1506
|
+
};
|
|
1507
|
+
const edgeLen = computed(() => {
|
|
1508
|
+
var _a;
|
|
1509
|
+
const s = sel.value;
|
|
1510
|
+
const f = floor.value;
|
|
1511
|
+
if (!s || !f || s.t.c !== "edges") return null;
|
|
1512
|
+
const e = (_a = f.edges) == null ? void 0 : _a.find((x) => x.id === s.item.id);
|
|
1513
|
+
return e ? edgeLength(f, e) : null;
|
|
1514
|
+
});
|
|
1515
|
+
function set(patch, mergeKey) {
|
|
1516
|
+
const s = sel.value;
|
|
1517
|
+
if (!s || props.readonly) return;
|
|
1518
|
+
ed.update(s.t, patch, mergeKey ? `${s.t.id}:${mergeKey}` : void 0);
|
|
1519
|
+
}
|
|
1520
|
+
function setModel(v) {
|
|
1521
|
+
var _a;
|
|
1522
|
+
const key = String(v ?? "");
|
|
1523
|
+
const m = key ? (_a = doc.value.models) == null ? void 0 : _a[key] : void 0;
|
|
1524
|
+
set(m ? { model: key, w: m.footprint.w, h: m.footprint.h, height: m.height } : { model: void 0 });
|
|
1525
|
+
}
|
|
1526
|
+
const kindOf = (key) => ed.kinds.value.find((k) => k.key === key);
|
|
1527
|
+
const kindLabel = (key) => {
|
|
1528
|
+
var _a;
|
|
1529
|
+
return ((_a = kindOf(key)) == null ? void 0 : _a.label) ?? key;
|
|
1530
|
+
};
|
|
1531
|
+
const propOf = (k) => {
|
|
1532
|
+
var _a, _b;
|
|
1533
|
+
return (_b = (_a = sel.value) == null ? void 0 : _a.item.props) == null ? void 0 : _b[k];
|
|
1534
|
+
};
|
|
1535
|
+
function setProp(k, v, mergeKey) {
|
|
1536
|
+
const s = sel.value;
|
|
1537
|
+
if (!s) return;
|
|
1538
|
+
set({ props: { ...s.item.props ?? {}, [k]: v } }, mergeKey ? `prop:${mergeKey}` : void 0);
|
|
1539
|
+
}
|
|
1540
|
+
function setBackground(patch) {
|
|
1541
|
+
const f = floor.value;
|
|
1542
|
+
if (!f || props.readonly) return;
|
|
1543
|
+
const next = { ...f.background ?? { url: "" }, ...patch };
|
|
1544
|
+
ed.setFloorProps({ background: next.url ? next : void 0 }, "bg");
|
|
1545
|
+
}
|
|
1546
|
+
watch(canvas, (c) => c && requestAnimationFrame(() => c.fit()));
|
|
1547
|
+
function editable(e) {
|
|
1548
|
+
const t = e.target;
|
|
1549
|
+
return !!t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.tagName === "SELECT" || t.isContentEditable);
|
|
1550
|
+
}
|
|
1551
|
+
function onKey(e) {
|
|
1552
|
+
var _a;
|
|
1553
|
+
if (editable(e)) return;
|
|
1554
|
+
if (props.readonly && (e.ctrlKey || e.metaKey || !["escape", "f", "v", "h", " "].includes(e.key.toLowerCase()))) return;
|
|
1555
|
+
if ((_a = canvas.value) == null ? void 0 : _a.onKey(e)) e.preventDefault();
|
|
1556
|
+
}
|
|
1557
|
+
function onKeyUp(e) {
|
|
1558
|
+
var _a;
|
|
1559
|
+
if (!editable(e)) (_a = canvas.value) == null ? void 0 : _a.onKey(e);
|
|
1560
|
+
}
|
|
1561
|
+
__expose({
|
|
1562
|
+
/** 화면을 층에 맞춘다 */
|
|
1563
|
+
fit: () => {
|
|
1564
|
+
var _a;
|
|
1565
|
+
return (_a = canvas.value) == null ? void 0 : _a.fit();
|
|
1566
|
+
},
|
|
1567
|
+
/** 화면 없는 편집기 — 고르기 · 붙이기 같은 동작을 바깥에서 부를 때 */
|
|
1568
|
+
editor: ed
|
|
1569
|
+
});
|
|
1570
|
+
return (_ctx, _cache) => {
|
|
1571
|
+
var _a, _b, _c;
|
|
1572
|
+
return openBlock(), createElementBlock("div", {
|
|
1573
|
+
class: normalizeClass(["lf-mae", { "lf-mae--readonly": __props.readonly }]),
|
|
1574
|
+
onKeydown: onKey,
|
|
1575
|
+
onKeyup: onKeyUp
|
|
1576
|
+
}, [
|
|
1577
|
+
createElementVNode("div", _hoisted_1, [
|
|
1578
|
+
createElementVNode("div", _hoisted_2, [
|
|
1579
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(toolList.value, (t) => {
|
|
1580
|
+
return openBlock(), createElementBlock("button", {
|
|
1581
|
+
key: t.value,
|
|
1582
|
+
type: "button",
|
|
1583
|
+
class: "lf-mae__tool",
|
|
1584
|
+
"aria-pressed": unref(ed).tool.value === t.value,
|
|
1585
|
+
title: t.title,
|
|
1586
|
+
disabled: __props.readonly && t.value !== "select" && t.value !== "pan",
|
|
1587
|
+
onClick: ($event) => unref(ed).tool.value = t.value
|
|
1588
|
+
}, [
|
|
1589
|
+
t.icon ? (openBlock(), createBlock(LfIcon, {
|
|
1590
|
+
key: 0,
|
|
1591
|
+
name: t.icon,
|
|
1592
|
+
size: "16px"
|
|
1593
|
+
}, null, 8, ["name"])) : (openBlock(), createElementBlock("svg", _hoisted_4, [
|
|
1594
|
+
createElementVNode("path", {
|
|
1595
|
+
d: t.path,
|
|
1596
|
+
fill: "currentColor"
|
|
1597
|
+
}, null, 8, _hoisted_5)
|
|
1598
|
+
])),
|
|
1599
|
+
createElementVNode("span", null, toDisplayString(t.label), 1)
|
|
1600
|
+
], 8, _hoisted_3);
|
|
1601
|
+
}), 128))
|
|
1602
|
+
]),
|
|
1603
|
+
createElementVNode("div", _hoisted_6, [
|
|
1604
|
+
unref(ed).tool.value === "object" ? (openBlock(), createBlock(LfSelect, {
|
|
1605
|
+
key: 0,
|
|
1606
|
+
modelValue: unref(ed).objectModel.value,
|
|
1607
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(ed).objectModel.value = $event),
|
|
1608
|
+
options: modelOptions.value,
|
|
1609
|
+
size: "sm",
|
|
1610
|
+
"aria-label": "놓을 설비 모양",
|
|
1611
|
+
class: "lf-mae__model"
|
|
1612
|
+
}, null, 8, ["modelValue", "options"])) : createCommentVNode("", true),
|
|
1613
|
+
createVNode(LfSelect, {
|
|
1614
|
+
modelValue: unref(ed).snap.value,
|
|
1615
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(ed).snap.value = $event),
|
|
1616
|
+
options: SNAP_OPTIONS,
|
|
1617
|
+
size: "sm",
|
|
1618
|
+
"aria-label": "격자 맞춤",
|
|
1619
|
+
class: "lf-mae__snap"
|
|
1620
|
+
}, null, 8, ["modelValue"]),
|
|
1621
|
+
createVNode(LfIconButton, {
|
|
1622
|
+
icon: "undo",
|
|
1623
|
+
label: "실행 취소 (Ctrl+Z)",
|
|
1624
|
+
size: "sm",
|
|
1625
|
+
disabled: __props.readonly || !unref(ed).canUndo.value,
|
|
1626
|
+
onClick: _cache[2] || (_cache[2] = ($event) => unref(ed).undo())
|
|
1627
|
+
}, null, 8, ["disabled"]),
|
|
1628
|
+
createVNode(LfIconButton, {
|
|
1629
|
+
icon: "redo",
|
|
1630
|
+
label: "다시 실행 (Ctrl+Shift+Z)",
|
|
1631
|
+
size: "sm",
|
|
1632
|
+
disabled: __props.readonly || !unref(ed).canRedo.value,
|
|
1633
|
+
onClick: _cache[3] || (_cache[3] = ($event) => unref(ed).redo())
|
|
1634
|
+
}, null, 8, ["disabled"]),
|
|
1635
|
+
createVNode(LfIconButton, {
|
|
1636
|
+
"icon-path": ICON_FIT,
|
|
1637
|
+
label: "화면 맞추기 (F)",
|
|
1638
|
+
size: "sm",
|
|
1639
|
+
onClick: _cache[4] || (_cache[4] = ($event) => {
|
|
1640
|
+
var _a2;
|
|
1641
|
+
return (_a2 = canvas.value) == null ? void 0 : _a2.fit();
|
|
1642
|
+
})
|
|
1643
|
+
})
|
|
1644
|
+
])
|
|
1645
|
+
]),
|
|
1646
|
+
createElementVNode("div", _hoisted_7, [
|
|
1647
|
+
createElementVNode("div", _hoisted_8, [
|
|
1648
|
+
createVNode(MapEditorCanvas, {
|
|
1649
|
+
ref_key: "canvas",
|
|
1650
|
+
ref: canvas,
|
|
1651
|
+
editor: unref(ed),
|
|
1652
|
+
tabindex: "0"
|
|
1653
|
+
}, null, 8, ["editor"])
|
|
1654
|
+
]),
|
|
1655
|
+
createElementVNode("aside", _hoisted_9, [
|
|
1656
|
+
createElementVNode("section", _hoisted_10, [
|
|
1657
|
+
createElementVNode("div", _hoisted_11, [
|
|
1658
|
+
_cache[42] || (_cache[42] = createElementVNode("h4", null, "층", -1)),
|
|
1659
|
+
!__props.readonly ? (openBlock(), createElementBlock("div", _hoisted_12, [
|
|
1660
|
+
createVNode(LfIconButton, {
|
|
1661
|
+
icon: "add",
|
|
1662
|
+
label: "층 더하기",
|
|
1663
|
+
size: "sm",
|
|
1664
|
+
onClick: _cache[5] || (_cache[5] = ($event) => unref(ed).newFloor())
|
|
1665
|
+
}),
|
|
1666
|
+
createVNode(LfIconButton, {
|
|
1667
|
+
icon: "delete",
|
|
1668
|
+
label: "이 층 빼기",
|
|
1669
|
+
size: "sm",
|
|
1670
|
+
danger: "",
|
|
1671
|
+
disabled: doc.value.floors.length < 2,
|
|
1672
|
+
onClick: _cache[6] || (_cache[6] = ($event) => unref(ed).dropFloor())
|
|
1673
|
+
}, null, 8, ["disabled"])
|
|
1674
|
+
])) : createCommentVNode("", true)
|
|
1675
|
+
]),
|
|
1676
|
+
doc.value.floors.length ? (openBlock(), createBlock(LfSelect, {
|
|
1677
|
+
key: 0,
|
|
1678
|
+
"model-value": unref(ed).floorId.value,
|
|
1679
|
+
options: doc.value.floors.map((f) => ({ value: f.id, label: f.name || f.id })),
|
|
1680
|
+
size: "sm",
|
|
1681
|
+
"aria-label": "층 고르기",
|
|
1682
|
+
"onUpdate:modelValue": _cache[7] || (_cache[7] = (v) => unref(ed).showFloor(String(v)))
|
|
1683
|
+
}, null, 8, ["model-value", "options"])) : createCommentVNode("", true),
|
|
1684
|
+
floor.value && !unref(ed).selection.value.length ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
1685
|
+
createElementVNode("div", _hoisted_13, [
|
|
1686
|
+
createVNode(LfTextField, {
|
|
1687
|
+
"model-value": floor.value.name ?? "",
|
|
1688
|
+
size: "sm",
|
|
1689
|
+
label: "이름",
|
|
1690
|
+
readonly: __props.readonly,
|
|
1691
|
+
"onUpdate:modelValue": _cache[8] || (_cache[8] = (v) => unref(ed).setFloorProps({ name: String(v ?? "") }, "fname"))
|
|
1692
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1693
|
+
createVNode(LfTextField, {
|
|
1694
|
+
"model-value": floor.value.elevation ?? 0,
|
|
1695
|
+
type: "number",
|
|
1696
|
+
size: "sm",
|
|
1697
|
+
label: "높이 (m)",
|
|
1698
|
+
readonly: __props.readonly,
|
|
1699
|
+
"onUpdate:modelValue": _cache[9] || (_cache[9] = (v) => unref(ed).setFloorProps({ elevation: num(v, 0) }, "felev"))
|
|
1700
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1701
|
+
createVNode(LfTextField, {
|
|
1702
|
+
"model-value": floor.value.size.w,
|
|
1703
|
+
type: "number",
|
|
1704
|
+
size: "sm",
|
|
1705
|
+
label: "가로 (m)",
|
|
1706
|
+
readonly: __props.readonly,
|
|
1707
|
+
"onUpdate:modelValue": _cache[10] || (_cache[10] = (v) => unref(ed).setFloorProps({ size: { ...floor.value.size, w: Math.max(1, num(v, floor.value.size.w)) } }, "fw"))
|
|
1708
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1709
|
+
createVNode(LfTextField, {
|
|
1710
|
+
"model-value": floor.value.size.h,
|
|
1711
|
+
type: "number",
|
|
1712
|
+
size: "sm",
|
|
1713
|
+
label: "세로 (m)",
|
|
1714
|
+
readonly: __props.readonly,
|
|
1715
|
+
"onUpdate:modelValue": _cache[11] || (_cache[11] = (v) => unref(ed).setFloorProps({ size: { ...floor.value.size, h: Math.max(1, num(v, floor.value.size.h)) } }, "fh"))
|
|
1716
|
+
}, null, 8, ["model-value", "readonly"])
|
|
1717
|
+
]),
|
|
1718
|
+
createVNode(LfTextField, {
|
|
1719
|
+
"model-value": ((_a = floor.value.background) == null ? void 0 : _a.url) ?? "",
|
|
1720
|
+
size: "sm",
|
|
1721
|
+
label: "밑그림 주소 (이미지)",
|
|
1722
|
+
placeholder: "https://… 또는 data:image/…",
|
|
1723
|
+
readonly: __props.readonly,
|
|
1724
|
+
"onUpdate:modelValue": _cache[12] || (_cache[12] = (v) => setBackground({ url: String(v ?? "").trim() }))
|
|
1725
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1726
|
+
((_b = floor.value.background) == null ? void 0 : _b.url) ? (openBlock(), createElementBlock("div", _hoisted_14, [
|
|
1727
|
+
createVNode(LfTextField, {
|
|
1728
|
+
"model-value": floor.value.background.opacity ?? 0.5,
|
|
1729
|
+
type: "number",
|
|
1730
|
+
size: "sm",
|
|
1731
|
+
label: "밑그림 진하기 (0~1)",
|
|
1732
|
+
readonly: __props.readonly,
|
|
1733
|
+
"onUpdate:modelValue": _cache[13] || (_cache[13] = (v) => setBackground({ opacity: Math.min(1, Math.max(0, num(v, 0.5))) }))
|
|
1734
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1735
|
+
!__props.readonly ? (openBlock(), createBlock(LfButton, {
|
|
1736
|
+
key: 0,
|
|
1737
|
+
size: "sm",
|
|
1738
|
+
variant: "subtle",
|
|
1739
|
+
class: "lf-mae__align-end",
|
|
1740
|
+
onClick: _cache[14] || (_cache[14] = ($event) => unref(ed).setFloorProps({ background: void 0 }))
|
|
1741
|
+
}, {
|
|
1742
|
+
default: withCtx(() => [..._cache[43] || (_cache[43] = [
|
|
1743
|
+
createTextVNode("밑그림 빼기", -1)
|
|
1744
|
+
])]),
|
|
1745
|
+
_: 1
|
|
1746
|
+
})) : createCommentVNode("", true)
|
|
1747
|
+
])) : createCommentVNode("", true),
|
|
1748
|
+
_cache[44] || (_cache[44] = createElementVNode("p", { class: "lf-mae__hint" }, "PDF · DXF 도면은 이미지로 바꿔서 주소를 넣습니다. 밑그림은 이 층의 바닥 크기에 맞춰 깔립니다.", -1))
|
|
1749
|
+
], 64)) : createCommentVNode("", true)
|
|
1750
|
+
]),
|
|
1751
|
+
sel.value ? (openBlock(), createElementBlock("section", _hoisted_15, [
|
|
1752
|
+
createElementVNode("div", _hoisted_16, [
|
|
1753
|
+
createElementVNode("h4", null, [
|
|
1754
|
+
createTextVNode(toDisplayString(TYPE_LABEL[sel.value.t.c]) + " ", 1),
|
|
1755
|
+
createElementVNode("span", _hoisted_17, toDisplayString(sel.value.item.id), 1)
|
|
1756
|
+
]),
|
|
1757
|
+
!__props.readonly ? (openBlock(), createBlock(LfIconButton, {
|
|
1758
|
+
key: 0,
|
|
1759
|
+
icon: "delete",
|
|
1760
|
+
label: "지우기 (Delete)",
|
|
1761
|
+
size: "sm",
|
|
1762
|
+
danger: "",
|
|
1763
|
+
onClick: _cache[15] || (_cache[15] = ($event) => unref(ed).remove())
|
|
1764
|
+
})) : createCommentVNode("", true)
|
|
1765
|
+
]),
|
|
1766
|
+
sel.value.t.c === "nodes" ? (openBlock(), createElementBlock("div", _hoisted_18, [
|
|
1767
|
+
createVNode(LfTextField, {
|
|
1768
|
+
"model-value": sel.value.item.x,
|
|
1769
|
+
type: "number",
|
|
1770
|
+
size: "sm",
|
|
1771
|
+
label: "x (m)",
|
|
1772
|
+
readonly: __props.readonly,
|
|
1773
|
+
"onUpdate:modelValue": _cache[16] || (_cache[16] = (v) => set({ x: num(v, sel.value.item.x) }, "x"))
|
|
1774
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1775
|
+
createVNode(LfTextField, {
|
|
1776
|
+
"model-value": sel.value.item.y,
|
|
1777
|
+
type: "number",
|
|
1778
|
+
size: "sm",
|
|
1779
|
+
label: "y (m)",
|
|
1780
|
+
readonly: __props.readonly,
|
|
1781
|
+
"onUpdate:modelValue": _cache[17] || (_cache[17] = (v) => set({ y: num(v, sel.value.item.y) }, "y"))
|
|
1782
|
+
}, null, 8, ["model-value", "readonly"])
|
|
1783
|
+
])) : sel.value.t.c === "edges" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
1784
|
+
createElementVNode("p", _hoisted_19, [
|
|
1785
|
+
createTextVNode(toDisplayString(sel.value.item.from) + " → " + toDisplayString(sel.value.item.to), 1),
|
|
1786
|
+
edgeLen.value !== null ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
1787
|
+
createTextVNode(" · " + toDisplayString(edgeLen.value) + " m", 1)
|
|
1788
|
+
], 64)) : createCommentVNode("", true)
|
|
1789
|
+
]),
|
|
1790
|
+
createVNode(LfTextField, {
|
|
1791
|
+
"model-value": sel.value.item.width ?? 0,
|
|
1792
|
+
type: "number",
|
|
1793
|
+
size: "sm",
|
|
1794
|
+
label: "통로 폭 (m) — 1.5 이상이면 3D 에 경계선",
|
|
1795
|
+
readonly: __props.readonly,
|
|
1796
|
+
"onUpdate:modelValue": _cache[18] || (_cache[18] = (v) => set({ width: num(v, 0) || void 0 }, "width"))
|
|
1797
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1798
|
+
createVNode(LfSwitch, {
|
|
1799
|
+
"model-value": !!sel.value.item.oneWay,
|
|
1800
|
+
label: "한쪽으로만 (from → to)",
|
|
1801
|
+
disabled: __props.readonly,
|
|
1802
|
+
"onUpdate:modelValue": _cache[19] || (_cache[19] = (v) => set({ oneWay: v || void 0 }))
|
|
1803
|
+
}, null, 8, ["model-value", "disabled"])
|
|
1804
|
+
], 64)) : sel.value.t.c === "zones" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
1805
|
+
createVNode(LfTextField, {
|
|
1806
|
+
"model-value": sel.value.item.name ?? "",
|
|
1807
|
+
size: "sm",
|
|
1808
|
+
label: "이름",
|
|
1809
|
+
readonly: __props.readonly,
|
|
1810
|
+
"onUpdate:modelValue": _cache[20] || (_cache[20] = (v) => set({ name: String(v ?? "") || void 0 }, "name"))
|
|
1811
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1812
|
+
createVNode(LfSelect, {
|
|
1813
|
+
"model-value": sel.value.item.tone ?? "info",
|
|
1814
|
+
options: TONE_OPTIONS,
|
|
1815
|
+
size: "sm",
|
|
1816
|
+
label: "색",
|
|
1817
|
+
disabled: __props.readonly,
|
|
1818
|
+
"onUpdate:modelValue": _cache[21] || (_cache[21] = (v) => set({ tone: v }))
|
|
1819
|
+
}, null, 8, ["model-value", "disabled"]),
|
|
1820
|
+
_cache[45] || (_cache[45] = createElementVNode("p", { class: "lf-mae__hint" }, "꼭짓점(네모 손잡이)을 끌어 모양을 고칩니다.", -1))
|
|
1821
|
+
], 64)) : sel.value.t.c === "walls" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
1822
|
+
createElementVNode("div", _hoisted_20, [
|
|
1823
|
+
createVNode(LfTextField, {
|
|
1824
|
+
"model-value": sel.value.item.thickness ?? 0.2,
|
|
1825
|
+
type: "number",
|
|
1826
|
+
size: "sm",
|
|
1827
|
+
label: "두께 (m)",
|
|
1828
|
+
readonly: __props.readonly,
|
|
1829
|
+
"onUpdate:modelValue": _cache[22] || (_cache[22] = (v) => set({ thickness: Math.max(0.05, num(v, 0.2)) }, "thick"))
|
|
1830
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1831
|
+
createVNode(LfTextField, {
|
|
1832
|
+
"model-value": sel.value.item.height ?? 0.5,
|
|
1833
|
+
type: "number",
|
|
1834
|
+
size: "sm",
|
|
1835
|
+
label: "높이 (m)",
|
|
1836
|
+
readonly: __props.readonly,
|
|
1837
|
+
"onUpdate:modelValue": _cache[23] || (_cache[23] = (v) => set({ height: num(v, 0.5) }, "height"))
|
|
1838
|
+
}, null, 8, ["model-value", "readonly"])
|
|
1839
|
+
]),
|
|
1840
|
+
createVNode(LfSwitch, {
|
|
1841
|
+
"model-value": !!sel.value.item.closed,
|
|
1842
|
+
label: "닫힌 벽(끝이 처음과 이어짐)",
|
|
1843
|
+
disabled: __props.readonly,
|
|
1844
|
+
"onUpdate:modelValue": _cache[24] || (_cache[24] = (v) => set({ closed: v || void 0 }))
|
|
1845
|
+
}, null, 8, ["model-value", "disabled"])
|
|
1846
|
+
], 64)) : sel.value.t.c === "objects" ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
|
|
1847
|
+
createElementVNode("div", _hoisted_21, [
|
|
1848
|
+
createVNode(LfTextField, {
|
|
1849
|
+
"model-value": sel.value.item.name ?? "",
|
|
1850
|
+
size: "sm",
|
|
1851
|
+
label: "이름",
|
|
1852
|
+
readonly: __props.readonly,
|
|
1853
|
+
"onUpdate:modelValue": _cache[25] || (_cache[25] = (v) => set({ name: String(v ?? "") || void 0 }, "name"))
|
|
1854
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1855
|
+
createVNode(LfTextField, {
|
|
1856
|
+
"model-value": sel.value.item.kind ?? "",
|
|
1857
|
+
size: "sm",
|
|
1858
|
+
label: "종류",
|
|
1859
|
+
readonly: __props.readonly,
|
|
1860
|
+
"onUpdate:modelValue": _cache[26] || (_cache[26] = (v) => set({ kind: String(v ?? "") || void 0 }, "kind"))
|
|
1861
|
+
}, null, 8, ["model-value", "readonly"])
|
|
1862
|
+
]),
|
|
1863
|
+
createVNode(LfSelect, {
|
|
1864
|
+
"model-value": typeof sel.value.item.model === "string" ? sel.value.item.model : "",
|
|
1865
|
+
options: modelOptions.value,
|
|
1866
|
+
size: "sm",
|
|
1867
|
+
label: "모양",
|
|
1868
|
+
disabled: __props.readonly,
|
|
1869
|
+
"onUpdate:modelValue": setModel
|
|
1870
|
+
}, null, 8, ["model-value", "options", "disabled"]),
|
|
1871
|
+
createElementVNode("div", _hoisted_22, [
|
|
1872
|
+
createVNode(LfTextField, {
|
|
1873
|
+
"model-value": sel.value.item.w,
|
|
1874
|
+
type: "number",
|
|
1875
|
+
size: "sm",
|
|
1876
|
+
label: "가로 w",
|
|
1877
|
+
readonly: __props.readonly,
|
|
1878
|
+
"onUpdate:modelValue": _cache[27] || (_cache[27] = (v) => set({ w: Math.max(0.05, num(v, sel.value.item.w)) }, "w"))
|
|
1879
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1880
|
+
createVNode(LfTextField, {
|
|
1881
|
+
"model-value": sel.value.item.h,
|
|
1882
|
+
type: "number",
|
|
1883
|
+
size: "sm",
|
|
1884
|
+
label: "세로 h",
|
|
1885
|
+
readonly: __props.readonly,
|
|
1886
|
+
"onUpdate:modelValue": _cache[28] || (_cache[28] = (v) => set({ h: Math.max(0.05, num(v, sel.value.item.h)) }, "h"))
|
|
1887
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1888
|
+
createVNode(LfTextField, {
|
|
1889
|
+
"model-value": sel.value.item.height ?? 1,
|
|
1890
|
+
type: "number",
|
|
1891
|
+
size: "sm",
|
|
1892
|
+
label: "높이",
|
|
1893
|
+
readonly: __props.readonly,
|
|
1894
|
+
"onUpdate:modelValue": _cache[29] || (_cache[29] = (v) => set({ height: Math.max(0.01, num(v, 1)) }, "height"))
|
|
1895
|
+
}, null, 8, ["model-value", "readonly"])
|
|
1896
|
+
]),
|
|
1897
|
+
createElementVNode("div", _hoisted_23, [
|
|
1898
|
+
createVNode(LfTextField, {
|
|
1899
|
+
"model-value": sel.value.item.x,
|
|
1900
|
+
type: "number",
|
|
1901
|
+
size: "sm",
|
|
1902
|
+
label: "x",
|
|
1903
|
+
readonly: __props.readonly,
|
|
1904
|
+
"onUpdate:modelValue": _cache[30] || (_cache[30] = (v) => set({ x: num(v, sel.value.item.x) }, "x"))
|
|
1905
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1906
|
+
createVNode(LfTextField, {
|
|
1907
|
+
"model-value": sel.value.item.y,
|
|
1908
|
+
type: "number",
|
|
1909
|
+
size: "sm",
|
|
1910
|
+
label: "y",
|
|
1911
|
+
readonly: __props.readonly,
|
|
1912
|
+
"onUpdate:modelValue": _cache[31] || (_cache[31] = (v) => set({ y: num(v, sel.value.item.y) }, "y"))
|
|
1913
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1914
|
+
createVNode(LfTextField, {
|
|
1915
|
+
"model-value": sel.value.item.rotation ?? 0,
|
|
1916
|
+
type: "number",
|
|
1917
|
+
size: "sm",
|
|
1918
|
+
label: "회전 (도)",
|
|
1919
|
+
readonly: __props.readonly,
|
|
1920
|
+
"onUpdate:modelValue": _cache[32] || (_cache[32] = (v) => set({ rotation: num(v, 0) || void 0 }, "rot"))
|
|
1921
|
+
}, null, 8, ["model-value", "readonly"])
|
|
1922
|
+
]),
|
|
1923
|
+
!sel.value.item.model ? (openBlock(), createBlock(LfSelect, {
|
|
1924
|
+
key: 0,
|
|
1925
|
+
"model-value": sel.value.item.tone ?? "neutral",
|
|
1926
|
+
options: TONE_OPTIONS,
|
|
1927
|
+
size: "sm",
|
|
1928
|
+
label: "색 (모양이 없을 때)",
|
|
1929
|
+
disabled: __props.readonly,
|
|
1930
|
+
"onUpdate:modelValue": _cache[33] || (_cache[33] = (v) => set({ tone: v }))
|
|
1931
|
+
}, null, 8, ["model-value", "disabled"])) : createCommentVNode("", true)
|
|
1932
|
+
], 64)) : sel.value.t.c === "extras" ? (openBlock(), createElementBlock(Fragment, { key: 5 }, [
|
|
1933
|
+
createElementVNode("p", _hoisted_24, toDisplayString(kindLabel(sel.value.item.kind)), 1),
|
|
1934
|
+
createVNode(LfTextField, {
|
|
1935
|
+
"model-value": sel.value.item.name ?? "",
|
|
1936
|
+
size: "sm",
|
|
1937
|
+
label: "이름",
|
|
1938
|
+
readonly: __props.readonly,
|
|
1939
|
+
"onUpdate:modelValue": _cache[34] || (_cache[34] = (v) => set({ name: String(v ?? "") || void 0 }, "name"))
|
|
1940
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1941
|
+
createElementVNode("div", _hoisted_25, [
|
|
1942
|
+
createVNode(LfTextField, {
|
|
1943
|
+
"model-value": sel.value.item.x,
|
|
1944
|
+
type: "number",
|
|
1945
|
+
size: "sm",
|
|
1946
|
+
label: "x",
|
|
1947
|
+
readonly: __props.readonly,
|
|
1948
|
+
"onUpdate:modelValue": _cache[35] || (_cache[35] = (v) => set({ x: num(v, sel.value.item.x) }, "x"))
|
|
1949
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1950
|
+
createVNode(LfTextField, {
|
|
1951
|
+
"model-value": sel.value.item.y,
|
|
1952
|
+
type: "number",
|
|
1953
|
+
size: "sm",
|
|
1954
|
+
label: "y",
|
|
1955
|
+
readonly: __props.readonly,
|
|
1956
|
+
"onUpdate:modelValue": _cache[36] || (_cache[36] = (v) => set({ y: num(v, sel.value.item.y) }, "y"))
|
|
1957
|
+
}, null, 8, ["model-value", "readonly"]),
|
|
1958
|
+
createVNode(LfTextField, {
|
|
1959
|
+
"model-value": sel.value.item.rotation ?? 0,
|
|
1960
|
+
type: "number",
|
|
1961
|
+
size: "sm",
|
|
1962
|
+
label: "회전 (도)",
|
|
1963
|
+
readonly: __props.readonly,
|
|
1964
|
+
"onUpdate:modelValue": _cache[37] || (_cache[37] = (v) => set({ rotation: num(v, 0) || void 0 }, "rot"))
|
|
1965
|
+
}, null, 8, ["model-value", "readonly"])
|
|
1966
|
+
]),
|
|
1967
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(((_c = kindOf(sel.value.item.kind)) == null ? void 0 : _c.fields) ?? [], (fd) => {
|
|
1968
|
+
return openBlock(), createElementBlock(Fragment, {
|
|
1969
|
+
key: fd.key
|
|
1970
|
+
}, [
|
|
1971
|
+
fd.type === "switch" ? (openBlock(), createBlock(LfSwitch, {
|
|
1972
|
+
key: 0,
|
|
1973
|
+
"model-value": !!propOf(fd.key),
|
|
1974
|
+
label: fd.label,
|
|
1975
|
+
disabled: __props.readonly,
|
|
1976
|
+
"onUpdate:modelValue": (v) => setProp(fd.key, v)
|
|
1977
|
+
}, null, 8, ["model-value", "label", "disabled", "onUpdate:modelValue"])) : fd.type === "select" ? (openBlock(), createBlock(LfSelect, {
|
|
1978
|
+
key: 1,
|
|
1979
|
+
"model-value": propOf(fd.key) ?? null,
|
|
1980
|
+
options: fd.options ?? [],
|
|
1981
|
+
size: "sm",
|
|
1982
|
+
label: fd.label,
|
|
1983
|
+
disabled: __props.readonly,
|
|
1984
|
+
"onUpdate:modelValue": (v) => setProp(fd.key, v)
|
|
1985
|
+
}, null, 8, ["model-value", "options", "label", "disabled", "onUpdate:modelValue"])) : (openBlock(), createBlock(LfTextField, {
|
|
1986
|
+
key: 2,
|
|
1987
|
+
"model-value": propOf(fd.key) ?? "",
|
|
1988
|
+
type: fd.type === "number" ? "number" : "text",
|
|
1989
|
+
size: "sm",
|
|
1990
|
+
label: fd.label,
|
|
1991
|
+
readonly: __props.readonly,
|
|
1992
|
+
"onUpdate:modelValue": (v) => setProp(fd.key, fd.type === "number" ? num(v, 0) : String(v ?? ""), fd.key)
|
|
1993
|
+
}, null, 8, ["model-value", "type", "label", "readonly", "onUpdate:modelValue"]))
|
|
1994
|
+
], 64);
|
|
1995
|
+
}), 128))
|
|
1996
|
+
], 64)) : createCommentVNode("", true)
|
|
1997
|
+
])) : unref(ed).selection.value.length > 1 ? (openBlock(), createElementBlock("section", _hoisted_26, [
|
|
1998
|
+
createElementVNode("div", _hoisted_27, [
|
|
1999
|
+
createElementVNode("h4", null, toDisplayString(unref(ed).selection.value.length) + "개 고름", 1),
|
|
2000
|
+
!__props.readonly ? (openBlock(), createBlock(LfIconButton, {
|
|
2001
|
+
key: 0,
|
|
2002
|
+
icon: "delete",
|
|
2003
|
+
label: "모두 지우기 (Delete)",
|
|
2004
|
+
size: "sm",
|
|
2005
|
+
danger: "",
|
|
2006
|
+
onClick: _cache[38] || (_cache[38] = ($event) => unref(ed).remove())
|
|
2007
|
+
})) : createCommentVNode("", true)
|
|
2008
|
+
]),
|
|
2009
|
+
!__props.readonly ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2010
|
+
_cache[49] || (_cache[49] = createElementVNode("p", { class: "lf-mae__label" }, "줄 맞추기", -1)),
|
|
2011
|
+
createElementVNode("div", _hoisted_28, [
|
|
2012
|
+
(openBlock(), createElementBlock(Fragment, null, renderList(ALIGNS, (a) => {
|
|
2013
|
+
return createVNode(LfButton, {
|
|
2014
|
+
key: a.how,
|
|
2015
|
+
size: "sm",
|
|
2016
|
+
variant: "ghost",
|
|
2017
|
+
onClick: ($event) => unref(ed).align(a.how)
|
|
2018
|
+
}, {
|
|
2019
|
+
default: withCtx(() => [
|
|
2020
|
+
createTextVNode(toDisplayString(a.label), 1)
|
|
2021
|
+
]),
|
|
2022
|
+
_: 2
|
|
2023
|
+
}, 1032, ["onClick"]);
|
|
2024
|
+
}), 64))
|
|
2025
|
+
]),
|
|
2026
|
+
_cache[50] || (_cache[50] = createElementVNode("p", { class: "lf-mae__label" }, "돌리기 · 복제", -1)),
|
|
2027
|
+
createElementVNode("div", _hoisted_29, [
|
|
2028
|
+
createVNode(LfButton, {
|
|
2029
|
+
size: "sm",
|
|
2030
|
+
variant: "ghost",
|
|
2031
|
+
onClick: _cache[39] || (_cache[39] = ($event) => unref(ed).rotate(90))
|
|
2032
|
+
}, {
|
|
2033
|
+
default: withCtx(() => [..._cache[46] || (_cache[46] = [
|
|
2034
|
+
createTextVNode("왼쪽으로 90°", -1)
|
|
2035
|
+
])]),
|
|
2036
|
+
_: 1
|
|
2037
|
+
}),
|
|
2038
|
+
createVNode(LfButton, {
|
|
2039
|
+
size: "sm",
|
|
2040
|
+
variant: "ghost",
|
|
2041
|
+
onClick: _cache[40] || (_cache[40] = ($event) => unref(ed).rotate(-90))
|
|
2042
|
+
}, {
|
|
2043
|
+
default: withCtx(() => [..._cache[47] || (_cache[47] = [
|
|
2044
|
+
createTextVNode("오른쪽으로 90°", -1)
|
|
2045
|
+
])]),
|
|
2046
|
+
_: 1
|
|
2047
|
+
}),
|
|
2048
|
+
createVNode(LfButton, {
|
|
2049
|
+
size: "sm",
|
|
2050
|
+
variant: "ghost",
|
|
2051
|
+
onClick: _cache[41] || (_cache[41] = ($event) => unref(ed).duplicate())
|
|
2052
|
+
}, {
|
|
2053
|
+
default: withCtx(() => [..._cache[48] || (_cache[48] = [
|
|
2054
|
+
createTextVNode("복제", -1)
|
|
2055
|
+
])]),
|
|
2056
|
+
_: 1
|
|
2057
|
+
})
|
|
2058
|
+
])
|
|
2059
|
+
], 64)) : createCommentVNode("", true)
|
|
2060
|
+
])) : floor.value && unref(ed).selection.value.length ? (openBlock(), createElementBlock("p", _hoisted_30, "고른 것을 이 층에서 찾지 못했습니다.")) : (openBlock(), createElementBlock("p", _hoisted_31, [..._cache[51] || (_cache[51] = [
|
|
2061
|
+
createTextVNode(" V 고르기 · H 손 · W 벽 · Z 구역 · N 마디 · E 길 · O 설비 · F 화면 맞추기", -1),
|
|
2062
|
+
createElementVNode("br", null, null, -1),
|
|
2063
|
+
createTextVNode(" Ctrl+Z 실행 취소 · Ctrl+C / V 복사 · 붙이기 · Ctrl+D 복제 · Delete 지우기 · 화살표 옮기기 · R 돌리기 ", -1)
|
|
2064
|
+
])]))
|
|
2065
|
+
])
|
|
2066
|
+
])
|
|
2067
|
+
], 34);
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
});
|
|
2071
|
+
const LfMapEditor = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-32b3ea7c"]]);
|
|
2072
|
+
export {
|
|
2073
|
+
COLLECTIONS,
|
|
2074
|
+
History,
|
|
2075
|
+
LfMapEditor,
|
|
2076
|
+
addFloor,
|
|
2077
|
+
addItems,
|
|
2078
|
+
alignItems,
|
|
2079
|
+
apply,
|
|
2080
|
+
bounds,
|
|
2081
|
+
createMapEditor,
|
|
2082
|
+
edgeLength,
|
|
2083
|
+
itemsIn,
|
|
2084
|
+
moveItems,
|
|
2085
|
+
movePoint,
|
|
2086
|
+
nextId,
|
|
2087
|
+
normalizeDoc,
|
|
2088
|
+
pasteItems,
|
|
2089
|
+
removeFloor,
|
|
2090
|
+
removeItems,
|
|
2091
|
+
revert,
|
|
2092
|
+
rotateItems,
|
|
2093
|
+
setFloor,
|
|
2094
|
+
updateItems
|
|
2095
|
+
};
|
|
2096
|
+
//# sourceMappingURL=map-editor.js.map
|