build-dxf 0.0.20-14 → 0.0.20-2
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/package.json +1 -1
- package/src/build.js +1915 -1194
- package/src/index.css +629 -1
- package/src/index.js +7 -7
- package/src/index2.js +528 -327
- package/src/index3.js +1714 -1660
- package/src/selectLocalFile.js +3145 -1955
- package/src/utils/CommandManager/CommandFlow.d.ts +0 -17
- package/src/utils/CommandManager/CommandManager.d.ts +0 -23
- package/src/utils/DxfSystem/components/Dxf.d.ts +0 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/CommandFlowComponent.d.ts +1 -4
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/Default.d.ts +20 -0
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawDoorLine.d.ts +4 -24
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawLine.d.ts +4 -20
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawWindow.d.ts +2 -25
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/PointDrag.d.ts +1 -14
- package/src/utils/DxfSystem/plugin/Editor/components/index.d.ts +0 -1
- package/src/utils/Quadtree/LineSegment.d.ts +0 -1
- package/src/utils/Quadtree/Point.d.ts +1 -2
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/ConnectionLine.d.ts +0 -33
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DeleteSelectLine.d.ts +0 -28
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DeleteSelectWindow.d.ts +0 -33
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/IntersectionConnectionLine.d.ts +0 -33
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/MergeLine.d.ts +0 -33
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/SelectAll.d.ts +0 -30
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/VerticalCorrection.d.ts +0 -76
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/ViewAngle.d.ts +0 -15
package/src/index3.js
CHANGED
|
@@ -1,73 +1,134 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { i as
|
|
3
|
-
import { C as
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { i as isString, n as noop, r as resolveUnref, t as tryOnScopeDispose, c as isClient, d as tryOnMounted, e as identity, f as buildProps, g as definePropType, _ as _export_sfc$1, u as useNamespace, h as isNumber, j as addUnit, w as withInstall, k as useEmptyValuesProps, l as useSizeProp, p as provideGlobalConfig, m as iconPropType, o as useGlobalComponentSettings, T as TypeComponentsMap, q as ElIcon, s as TypeComponents, v as useTimeoutFn, x as isString$1, y as isFunction, z as isBoolean, A as isElement, B as withInstallFunction, L as Lines, D as DomEventRegister, b as ElCheckbox, E as ElButton, S as SelectLocalFile } from "./selectLocalFile.js";
|
|
3
|
+
import { C as Component, L as LineSegment, P as Point, B as Box2, E as EventDispatcher, b as PointVirtualGrid, Q as Quadtree, W as WhiteModel } from "./build.js";
|
|
4
|
+
import { watch, ref, defineComponent, computed, createElementBlock, openBlock, normalizeClass, unref, renderSlot, createVNode, Transition, withCtx, withDirectives, createElementVNode, normalizeStyle, createTextVNode, toDisplayString, vShow, shallowReactive, onMounted, createBlock, createCommentVNode, resolveDynamicComponent, Fragment, withModifiers, nextTick, isVNode, render, toRaw, onUnmounted, renderList, createStaticVNode, createApp } from "vue";
|
|
4
5
|
import "clipper-lib";
|
|
5
6
|
import "dxf-writer";
|
|
6
7
|
import "three/addons/controls/OrbitControls.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return (e = t?.$el) != null ? e : t;
|
|
8
|
+
function unrefElement(elRef) {
|
|
9
|
+
var _a;
|
|
10
|
+
const plain = resolveUnref(elRef);
|
|
11
|
+
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
const defaultWindow = isClient ? window : void 0;
|
|
14
|
+
function useEventListener(...args) {
|
|
15
|
+
let target;
|
|
16
|
+
let events;
|
|
17
|
+
let listeners;
|
|
18
|
+
let options;
|
|
19
|
+
if (isString(args[0]) || Array.isArray(args[0])) {
|
|
20
|
+
[events, listeners, options] = args;
|
|
21
|
+
target = defaultWindow;
|
|
22
|
+
} else {
|
|
23
|
+
[target, events, listeners, options] = args;
|
|
24
|
+
}
|
|
25
|
+
if (!target)
|
|
26
|
+
return noop;
|
|
27
|
+
if (!Array.isArray(events))
|
|
28
|
+
events = [events];
|
|
29
|
+
if (!Array.isArray(listeners))
|
|
30
|
+
listeners = [listeners];
|
|
31
|
+
const cleanups = [];
|
|
32
|
+
const cleanup = () => {
|
|
33
|
+
cleanups.forEach((fn) => fn());
|
|
34
|
+
cleanups.length = 0;
|
|
25
35
|
};
|
|
26
|
-
|
|
36
|
+
const register = (el, event, listener, options2) => {
|
|
37
|
+
el.addEventListener(event, listener, options2);
|
|
38
|
+
return () => el.removeEventListener(event, listener, options2);
|
|
39
|
+
};
|
|
40
|
+
const stopWatch = watch(() => [unrefElement(target), resolveUnref(options)], ([el, options2]) => {
|
|
41
|
+
cleanup();
|
|
42
|
+
if (!el)
|
|
43
|
+
return;
|
|
44
|
+
cleanups.push(...events.flatMap((event) => {
|
|
45
|
+
return listeners.map((listener) => register(el, event, listener, options2));
|
|
46
|
+
}));
|
|
47
|
+
}, { immediate: true, flush: "post" });
|
|
48
|
+
const stop = () => {
|
|
49
|
+
stopWatch();
|
|
50
|
+
cleanup();
|
|
51
|
+
};
|
|
52
|
+
tryOnScopeDispose(stop);
|
|
53
|
+
return stop;
|
|
27
54
|
}
|
|
28
|
-
function
|
|
29
|
-
const
|
|
30
|
-
|
|
55
|
+
function useSupported(callback, sync = false) {
|
|
56
|
+
const isSupported = ref();
|
|
57
|
+
const update = () => isSupported.value = Boolean(callback());
|
|
58
|
+
update();
|
|
59
|
+
tryOnMounted(update, sync);
|
|
60
|
+
return isSupported;
|
|
31
61
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
63
|
+
const globalKey = "__vueuse_ssr_handlers__";
|
|
64
|
+
_global[globalKey] = _global[globalKey] || {};
|
|
65
|
+
var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
|
|
66
|
+
var __hasOwnProp$g = Object.prototype.hasOwnProperty;
|
|
67
|
+
var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
|
|
68
|
+
var __objRest$2 = (source, exclude) => {
|
|
69
|
+
var target = {};
|
|
70
|
+
for (var prop in source)
|
|
71
|
+
if (__hasOwnProp$g.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
72
|
+
target[prop] = source[prop];
|
|
73
|
+
if (source != null && __getOwnPropSymbols$g)
|
|
74
|
+
for (var prop of __getOwnPropSymbols$g(source)) {
|
|
75
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$g.call(source, prop))
|
|
76
|
+
target[prop] = source[prop];
|
|
77
|
+
}
|
|
78
|
+
return target;
|
|
42
79
|
};
|
|
43
|
-
function
|
|
44
|
-
const
|
|
45
|
-
let
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
80
|
+
function useResizeObserver(target, callback, options = {}) {
|
|
81
|
+
const _a = options, { window: window2 = defaultWindow } = _a, observerOptions = __objRest$2(_a, ["window"]);
|
|
82
|
+
let observer;
|
|
83
|
+
const isSupported = useSupported(() => window2 && "ResizeObserver" in window2);
|
|
84
|
+
const cleanup = () => {
|
|
85
|
+
if (observer) {
|
|
86
|
+
observer.disconnect();
|
|
87
|
+
observer = void 0;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const stopWatch = watch(() => unrefElement(target), (el) => {
|
|
91
|
+
cleanup();
|
|
92
|
+
if (isSupported.value && window2 && el) {
|
|
93
|
+
observer = new ResizeObserver(callback);
|
|
94
|
+
observer.observe(el, observerOptions);
|
|
95
|
+
}
|
|
96
|
+
}, { immediate: true, flush: "post" });
|
|
97
|
+
const stop = () => {
|
|
98
|
+
cleanup();
|
|
99
|
+
stopWatch();
|
|
52
100
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
101
|
+
tryOnScopeDispose(stop);
|
|
102
|
+
return {
|
|
103
|
+
isSupported,
|
|
104
|
+
stop
|
|
56
105
|
};
|
|
57
106
|
}
|
|
58
|
-
var
|
|
59
|
-
(function(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
107
|
+
var SwipeDirection;
|
|
108
|
+
(function(SwipeDirection2) {
|
|
109
|
+
SwipeDirection2["UP"] = "UP";
|
|
110
|
+
SwipeDirection2["RIGHT"] = "RIGHT";
|
|
111
|
+
SwipeDirection2["DOWN"] = "DOWN";
|
|
112
|
+
SwipeDirection2["LEFT"] = "LEFT";
|
|
113
|
+
SwipeDirection2["NONE"] = "NONE";
|
|
114
|
+
})(SwipeDirection || (SwipeDirection = {}));
|
|
115
|
+
var __defProp = Object.defineProperty;
|
|
116
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
117
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
118
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
119
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
120
|
+
var __spreadValues = (a, b) => {
|
|
121
|
+
for (var prop in b || (b = {}))
|
|
122
|
+
if (__hasOwnProp.call(b, prop))
|
|
123
|
+
__defNormalProp(a, prop, b[prop]);
|
|
124
|
+
if (__getOwnPropSymbols)
|
|
125
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
126
|
+
if (__propIsEnum.call(b, prop))
|
|
127
|
+
__defNormalProp(a, prop, b[prop]);
|
|
128
|
+
}
|
|
129
|
+
return a;
|
|
69
130
|
};
|
|
70
|
-
const
|
|
131
|
+
const _TransitionPresets = {
|
|
71
132
|
easeInSine: [0.12, 0, 0.39, 0],
|
|
72
133
|
easeOutSine: [0.61, 1, 0.88, 1],
|
|
73
134
|
easeInOutSine: [0.37, 0, 0.63, 1],
|
|
@@ -93,12 +154,14 @@ const qt = {
|
|
|
93
154
|
easeOutBack: [0.34, 1.56, 0.64, 1],
|
|
94
155
|
easeInOutBack: [0.68, -0.6, 0.32, 1.6]
|
|
95
156
|
};
|
|
96
|
-
|
|
97
|
-
linear:
|
|
98
|
-
},
|
|
99
|
-
const
|
|
157
|
+
__spreadValues({
|
|
158
|
+
linear: identity
|
|
159
|
+
}, _TransitionPresets);
|
|
160
|
+
const mutable = (val) => val;
|
|
161
|
+
const EVENT_CODE = {
|
|
100
162
|
esc: "Escape"
|
|
101
|
-
}
|
|
163
|
+
};
|
|
164
|
+
const badgeProps = buildProps({
|
|
102
165
|
value: {
|
|
103
166
|
type: [String, Number],
|
|
104
167
|
default: ""
|
|
@@ -116,440 +179,546 @@ const $t = (r) => r, Ht = {
|
|
|
116
179
|
},
|
|
117
180
|
showZero: {
|
|
118
181
|
type: Boolean,
|
|
119
|
-
default:
|
|
182
|
+
default: true
|
|
120
183
|
},
|
|
121
184
|
color: String,
|
|
122
185
|
badgeStyle: {
|
|
123
|
-
type:
|
|
186
|
+
type: definePropType([String, Object, Array])
|
|
124
187
|
},
|
|
125
188
|
offset: {
|
|
126
|
-
type:
|
|
189
|
+
type: definePropType(Array),
|
|
127
190
|
default: [0, 0]
|
|
128
191
|
},
|
|
129
192
|
badgeClass: {
|
|
130
193
|
type: String
|
|
131
194
|
}
|
|
132
|
-
})
|
|
195
|
+
});
|
|
196
|
+
const __default__$1 = defineComponent({
|
|
133
197
|
name: "ElBadge"
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
198
|
+
});
|
|
199
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
200
|
+
...__default__$1,
|
|
201
|
+
props: badgeProps,
|
|
202
|
+
setup(__props, { expose }) {
|
|
203
|
+
const props = __props;
|
|
204
|
+
const ns = useNamespace("badge");
|
|
205
|
+
const content = computed(() => {
|
|
206
|
+
if (props.isDot)
|
|
207
|
+
return "";
|
|
208
|
+
if (isNumber(props.value) && isNumber(props.max)) {
|
|
209
|
+
return props.max < props.value ? `${props.max}+` : `${props.value}`;
|
|
210
|
+
}
|
|
211
|
+
return `${props.value}`;
|
|
212
|
+
});
|
|
213
|
+
const style = computed(() => {
|
|
214
|
+
var _a, _b, _c, _d, _e;
|
|
140
215
|
return [
|
|
141
216
|
{
|
|
142
|
-
backgroundColor:
|
|
143
|
-
marginRight:
|
|
144
|
-
marginTop:
|
|
217
|
+
backgroundColor: props.color,
|
|
218
|
+
marginRight: addUnit(-((_b = (_a = props.offset) == null ? void 0 : _a[0]) != null ? _b : 0)),
|
|
219
|
+
marginTop: addUnit((_d = (_c = props.offset) == null ? void 0 : _c[1]) != null ? _d : 0)
|
|
145
220
|
},
|
|
146
|
-
(
|
|
221
|
+
(_e = props.badgeStyle) != null ? _e : {}
|
|
147
222
|
];
|
|
148
223
|
});
|
|
149
|
-
|
|
150
|
-
content
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
224
|
+
expose({
|
|
225
|
+
content
|
|
226
|
+
});
|
|
227
|
+
return (_ctx, _cache) => {
|
|
228
|
+
return openBlock(), createElementBlock("div", {
|
|
229
|
+
class: normalizeClass(unref(ns).b())
|
|
230
|
+
}, [
|
|
231
|
+
renderSlot(_ctx.$slots, "default"),
|
|
232
|
+
createVNode(Transition, {
|
|
233
|
+
name: `${unref(ns).namespace.value}-zoom-in-center`,
|
|
234
|
+
persisted: ""
|
|
235
|
+
}, {
|
|
236
|
+
default: withCtx(() => [
|
|
237
|
+
withDirectives(createElementVNode("sup", {
|
|
238
|
+
class: normalizeClass([
|
|
239
|
+
unref(ns).e("content"),
|
|
240
|
+
unref(ns).em("content", _ctx.type),
|
|
241
|
+
unref(ns).is("fixed", !!_ctx.$slots.default),
|
|
242
|
+
unref(ns).is("dot", _ctx.isDot),
|
|
243
|
+
unref(ns).is("hide-zero", !_ctx.showZero && props.value === 0),
|
|
244
|
+
_ctx.badgeClass
|
|
245
|
+
]),
|
|
246
|
+
style: normalizeStyle(unref(style))
|
|
247
|
+
}, [
|
|
248
|
+
renderSlot(_ctx.$slots, "content", { value: unref(content) }, () => [
|
|
249
|
+
createTextVNode(toDisplayString(unref(content)), 1)
|
|
250
|
+
])
|
|
251
|
+
], 6), [
|
|
252
|
+
[vShow, !_ctx.hidden && (unref(content) || _ctx.isDot || _ctx.$slots.content)]
|
|
173
253
|
])
|
|
174
|
-
]
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}, 8, ["name"])
|
|
180
|
-
], 2));
|
|
254
|
+
]),
|
|
255
|
+
_: 3
|
|
256
|
+
}, 8, ["name"])
|
|
257
|
+
], 2);
|
|
258
|
+
};
|
|
181
259
|
}
|
|
182
260
|
});
|
|
183
|
-
var
|
|
184
|
-
const
|
|
261
|
+
var Badge = /* @__PURE__ */ _export_sfc$1(_sfc_main$2, [["__file", "badge.vue"]]);
|
|
262
|
+
const ElBadge = withInstall(Badge);
|
|
263
|
+
const configProviderProps = buildProps({
|
|
185
264
|
a11y: {
|
|
186
265
|
type: Boolean,
|
|
187
|
-
default:
|
|
266
|
+
default: true
|
|
188
267
|
},
|
|
189
268
|
locale: {
|
|
190
|
-
type:
|
|
269
|
+
type: definePropType(Object)
|
|
191
270
|
},
|
|
192
|
-
size:
|
|
271
|
+
size: useSizeProp,
|
|
193
272
|
button: {
|
|
194
|
-
type:
|
|
273
|
+
type: definePropType(Object)
|
|
195
274
|
},
|
|
196
275
|
card: {
|
|
197
|
-
type:
|
|
276
|
+
type: definePropType(Object)
|
|
198
277
|
},
|
|
199
278
|
dialog: {
|
|
200
|
-
type:
|
|
279
|
+
type: definePropType(Object)
|
|
201
280
|
},
|
|
202
281
|
link: {
|
|
203
|
-
type:
|
|
282
|
+
type: definePropType(Object)
|
|
204
283
|
},
|
|
205
284
|
experimentalFeatures: {
|
|
206
|
-
type:
|
|
285
|
+
type: definePropType(Object)
|
|
207
286
|
},
|
|
208
287
|
keyboardNavigation: {
|
|
209
288
|
type: Boolean,
|
|
210
|
-
default:
|
|
289
|
+
default: true
|
|
211
290
|
},
|
|
212
291
|
message: {
|
|
213
|
-
type:
|
|
292
|
+
type: definePropType(Object)
|
|
214
293
|
},
|
|
215
294
|
zIndex: Number,
|
|
216
295
|
namespace: {
|
|
217
296
|
type: String,
|
|
218
297
|
default: "el"
|
|
219
298
|
},
|
|
220
|
-
...
|
|
221
|
-
})
|
|
222
|
-
|
|
299
|
+
...useEmptyValuesProps
|
|
300
|
+
});
|
|
301
|
+
const messageConfig = {};
|
|
302
|
+
defineComponent({
|
|
223
303
|
name: "ElConfigProvider",
|
|
224
|
-
props:
|
|
225
|
-
setup(
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
var
|
|
229
|
-
Object.assign(
|
|
230
|
-
}, { immediate:
|
|
304
|
+
props: configProviderProps,
|
|
305
|
+
setup(props, { slots }) {
|
|
306
|
+
const config = provideGlobalConfig(props);
|
|
307
|
+
watch(() => props.message, (val) => {
|
|
308
|
+
var _a, _b;
|
|
309
|
+
Object.assign(messageConfig, (_b = (_a = config == null ? void 0 : config.value) == null ? void 0 : _a.message) != null ? _b : {}, val != null ? val : {});
|
|
310
|
+
}, { immediate: true, deep: true });
|
|
311
|
+
return () => renderSlot(slots, "default", { config: config == null ? void 0 : config.value });
|
|
231
312
|
}
|
|
232
313
|
});
|
|
233
|
-
const
|
|
314
|
+
const messageTypes = [
|
|
234
315
|
"primary",
|
|
235
316
|
"success",
|
|
236
317
|
"info",
|
|
237
318
|
"warning",
|
|
238
319
|
"error"
|
|
239
|
-
]
|
|
320
|
+
];
|
|
321
|
+
const messageDefaults = mutable({
|
|
240
322
|
customClass: "",
|
|
241
|
-
dangerouslyUseHTMLString:
|
|
323
|
+
dangerouslyUseHTMLString: false,
|
|
242
324
|
duration: 3e3,
|
|
243
325
|
icon: void 0,
|
|
244
326
|
id: "",
|
|
245
327
|
message: "",
|
|
246
328
|
onClose: void 0,
|
|
247
|
-
showClose:
|
|
329
|
+
showClose: false,
|
|
248
330
|
type: "info",
|
|
249
|
-
plain:
|
|
331
|
+
plain: false,
|
|
250
332
|
offset: 16,
|
|
251
333
|
zIndex: 0,
|
|
252
|
-
grouping:
|
|
334
|
+
grouping: false,
|
|
253
335
|
repeatNum: 1,
|
|
254
|
-
appendTo:
|
|
255
|
-
})
|
|
336
|
+
appendTo: isClient ? document.body : void 0
|
|
337
|
+
});
|
|
338
|
+
const messageProps = buildProps({
|
|
256
339
|
customClass: {
|
|
257
340
|
type: String,
|
|
258
|
-
default:
|
|
341
|
+
default: messageDefaults.customClass
|
|
259
342
|
},
|
|
260
343
|
dangerouslyUseHTMLString: {
|
|
261
344
|
type: Boolean,
|
|
262
|
-
default:
|
|
345
|
+
default: messageDefaults.dangerouslyUseHTMLString
|
|
263
346
|
},
|
|
264
347
|
duration: {
|
|
265
348
|
type: Number,
|
|
266
|
-
default:
|
|
349
|
+
default: messageDefaults.duration
|
|
267
350
|
},
|
|
268
351
|
icon: {
|
|
269
|
-
type:
|
|
270
|
-
default:
|
|
352
|
+
type: iconPropType,
|
|
353
|
+
default: messageDefaults.icon
|
|
271
354
|
},
|
|
272
355
|
id: {
|
|
273
356
|
type: String,
|
|
274
|
-
default:
|
|
357
|
+
default: messageDefaults.id
|
|
275
358
|
},
|
|
276
359
|
message: {
|
|
277
|
-
type:
|
|
360
|
+
type: definePropType([
|
|
278
361
|
String,
|
|
279
362
|
Object,
|
|
280
363
|
Function
|
|
281
364
|
]),
|
|
282
|
-
default:
|
|
365
|
+
default: messageDefaults.message
|
|
283
366
|
},
|
|
284
367
|
onClose: {
|
|
285
|
-
type:
|
|
286
|
-
default:
|
|
368
|
+
type: definePropType(Function),
|
|
369
|
+
default: messageDefaults.onClose
|
|
287
370
|
},
|
|
288
371
|
showClose: {
|
|
289
372
|
type: Boolean,
|
|
290
|
-
default:
|
|
373
|
+
default: messageDefaults.showClose
|
|
291
374
|
},
|
|
292
375
|
type: {
|
|
293
376
|
type: String,
|
|
294
|
-
values:
|
|
295
|
-
default:
|
|
377
|
+
values: messageTypes,
|
|
378
|
+
default: messageDefaults.type
|
|
296
379
|
},
|
|
297
380
|
plain: {
|
|
298
381
|
type: Boolean,
|
|
299
|
-
default:
|
|
382
|
+
default: messageDefaults.plain
|
|
300
383
|
},
|
|
301
384
|
offset: {
|
|
302
385
|
type: Number,
|
|
303
|
-
default:
|
|
386
|
+
default: messageDefaults.offset
|
|
304
387
|
},
|
|
305
388
|
zIndex: {
|
|
306
389
|
type: Number,
|
|
307
|
-
default:
|
|
390
|
+
default: messageDefaults.zIndex
|
|
308
391
|
},
|
|
309
392
|
grouping: {
|
|
310
393
|
type: Boolean,
|
|
311
|
-
default:
|
|
394
|
+
default: messageDefaults.grouping
|
|
312
395
|
},
|
|
313
396
|
repeatNum: {
|
|
314
397
|
type: Number,
|
|
315
|
-
default:
|
|
316
|
-
}
|
|
317
|
-
})
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
398
|
+
default: messageDefaults.repeatNum
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
const messageEmits = {
|
|
402
|
+
destroy: () => true
|
|
403
|
+
};
|
|
404
|
+
const instances = shallowReactive([]);
|
|
405
|
+
const getInstance = (id) => {
|
|
406
|
+
const idx = instances.findIndex((instance) => instance.id === id);
|
|
407
|
+
const current = instances[idx];
|
|
408
|
+
let prev;
|
|
409
|
+
if (idx > 0) {
|
|
410
|
+
prev = instances[idx - 1];
|
|
411
|
+
}
|
|
412
|
+
return { current, prev };
|
|
413
|
+
};
|
|
414
|
+
const getLastOffset = (id) => {
|
|
415
|
+
const { prev } = getInstance(id);
|
|
416
|
+
if (!prev)
|
|
417
|
+
return 0;
|
|
418
|
+
return prev.vm.exposed.bottom.value;
|
|
419
|
+
};
|
|
420
|
+
const getOffsetOrSpace = (id, offset) => {
|
|
421
|
+
const idx = instances.findIndex((instance) => instance.id === id);
|
|
422
|
+
return idx > 0 ? 16 : offset;
|
|
423
|
+
};
|
|
424
|
+
const __default__ = defineComponent({
|
|
327
425
|
name: "ElMessage"
|
|
328
|
-
})
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
426
|
+
});
|
|
427
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
428
|
+
...__default__,
|
|
429
|
+
props: messageProps,
|
|
430
|
+
emits: messageEmits,
|
|
431
|
+
setup(__props, { expose, emit }) {
|
|
432
|
+
const props = __props;
|
|
433
|
+
const { Close } = TypeComponents;
|
|
434
|
+
const isStartTransition = ref(false);
|
|
435
|
+
const { ns, zIndex } = useGlobalComponentSettings("message");
|
|
436
|
+
const { currentZIndex, nextZIndex } = zIndex;
|
|
437
|
+
const messageRef = ref();
|
|
438
|
+
const visible = ref(false);
|
|
439
|
+
const height = ref(0);
|
|
440
|
+
let stopTimer = void 0;
|
|
441
|
+
const badgeType = computed(() => props.type ? props.type === "error" ? "danger" : props.type : "info");
|
|
442
|
+
const typeClass = computed(() => {
|
|
443
|
+
const type = props.type;
|
|
444
|
+
return { [ns.bm("icon", type)]: type && TypeComponentsMap[type] };
|
|
445
|
+
});
|
|
446
|
+
const iconComponent = computed(() => props.icon || TypeComponentsMap[props.type] || "");
|
|
447
|
+
const lastOffset = computed(() => getLastOffset(props.id));
|
|
448
|
+
const offset = computed(() => getOffsetOrSpace(props.id, props.offset) + lastOffset.value);
|
|
449
|
+
const bottom = computed(() => height.value + offset.value);
|
|
450
|
+
const customStyle = computed(() => ({
|
|
451
|
+
top: `${offset.value}px`,
|
|
452
|
+
zIndex: currentZIndex.value
|
|
341
453
|
}));
|
|
342
|
-
function
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
454
|
+
function startTimer() {
|
|
455
|
+
if (props.duration === 0)
|
|
456
|
+
return;
|
|
457
|
+
({ stop: stopTimer } = useTimeoutFn(() => {
|
|
458
|
+
close();
|
|
459
|
+
}, props.duration));
|
|
346
460
|
}
|
|
347
|
-
function
|
|
348
|
-
|
|
461
|
+
function clearTimer() {
|
|
462
|
+
stopTimer == null ? void 0 : stopTimer();
|
|
349
463
|
}
|
|
350
|
-
function
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
464
|
+
function close() {
|
|
465
|
+
visible.value = false;
|
|
466
|
+
nextTick(() => {
|
|
467
|
+
var _a;
|
|
468
|
+
if (!isStartTransition.value) {
|
|
469
|
+
(_a = props.onClose) == null ? void 0 : _a.call(props);
|
|
470
|
+
emit("destroy");
|
|
471
|
+
}
|
|
354
472
|
});
|
|
355
473
|
}
|
|
356
|
-
function
|
|
357
|
-
|
|
474
|
+
function keydown({ code }) {
|
|
475
|
+
if (code === EVENT_CODE.esc) {
|
|
476
|
+
close();
|
|
477
|
+
}
|
|
358
478
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
})
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
type: v(C),
|
|
397
|
-
class: O(v(a).e("badge"))
|
|
398
|
-
}, null, 8, ["value", "type", "class"])) : q("v-if", !0),
|
|
399
|
-
v(P) ? (M(), de(v(Se), {
|
|
400
|
-
key: 1,
|
|
401
|
-
class: O([v(a).e("icon"), v(b)])
|
|
402
|
-
}, {
|
|
403
|
-
default: F(() => [
|
|
404
|
-
(M(), de(_t(v(P))))
|
|
479
|
+
onMounted(() => {
|
|
480
|
+
startTimer();
|
|
481
|
+
nextZIndex();
|
|
482
|
+
visible.value = true;
|
|
483
|
+
});
|
|
484
|
+
watch(() => props.repeatNum, () => {
|
|
485
|
+
clearTimer();
|
|
486
|
+
startTimer();
|
|
487
|
+
});
|
|
488
|
+
useEventListener(document, "keydown", keydown);
|
|
489
|
+
useResizeObserver(messageRef, () => {
|
|
490
|
+
height.value = messageRef.value.getBoundingClientRect().height;
|
|
491
|
+
});
|
|
492
|
+
expose({
|
|
493
|
+
visible,
|
|
494
|
+
bottom,
|
|
495
|
+
close
|
|
496
|
+
});
|
|
497
|
+
return (_ctx, _cache) => {
|
|
498
|
+
return openBlock(), createBlock(Transition, {
|
|
499
|
+
name: unref(ns).b("fade"),
|
|
500
|
+
onBeforeEnter: ($event) => isStartTransition.value = true,
|
|
501
|
+
onBeforeLeave: _ctx.onClose,
|
|
502
|
+
onAfterLeave: ($event) => _ctx.$emit("destroy"),
|
|
503
|
+
persisted: ""
|
|
504
|
+
}, {
|
|
505
|
+
default: withCtx(() => [
|
|
506
|
+
withDirectives(createElementVNode("div", {
|
|
507
|
+
id: _ctx.id,
|
|
508
|
+
ref_key: "messageRef",
|
|
509
|
+
ref: messageRef,
|
|
510
|
+
class: normalizeClass([
|
|
511
|
+
unref(ns).b(),
|
|
512
|
+
{ [unref(ns).m(_ctx.type)]: _ctx.type },
|
|
513
|
+
unref(ns).is("closable", _ctx.showClose),
|
|
514
|
+
unref(ns).is("plain", _ctx.plain),
|
|
515
|
+
_ctx.customClass
|
|
405
516
|
]),
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
class: O(v(a).e("content")),
|
|
413
|
-
innerHTML: w.message
|
|
414
|
-
}, null, 10, ["innerHTML"])
|
|
415
|
-
], 2112)) : (M(), S("p", {
|
|
517
|
+
style: normalizeStyle(unref(customStyle)),
|
|
518
|
+
role: "alert",
|
|
519
|
+
onMouseenter: clearTimer,
|
|
520
|
+
onMouseleave: startTimer
|
|
521
|
+
}, [
|
|
522
|
+
_ctx.repeatNum > 1 ? (openBlock(), createBlock(unref(ElBadge), {
|
|
416
523
|
key: 0,
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
524
|
+
value: _ctx.repeatNum,
|
|
525
|
+
type: unref(badgeType),
|
|
526
|
+
class: normalizeClass(unref(ns).e("badge"))
|
|
527
|
+
}, null, 8, ["value", "type", "class"])) : createCommentVNode("v-if", true),
|
|
528
|
+
unref(iconComponent) ? (openBlock(), createBlock(unref(ElIcon), {
|
|
529
|
+
key: 1,
|
|
530
|
+
class: normalizeClass([unref(ns).e("icon"), unref(typeClass)])
|
|
531
|
+
}, {
|
|
532
|
+
default: withCtx(() => [
|
|
533
|
+
(openBlock(), createBlock(resolveDynamicComponent(unref(iconComponent))))
|
|
534
|
+
]),
|
|
535
|
+
_: 1
|
|
536
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true),
|
|
537
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
538
|
+
!_ctx.dangerouslyUseHTMLString ? (openBlock(), createElementBlock("p", {
|
|
539
|
+
key: 0,
|
|
540
|
+
class: normalizeClass(unref(ns).e("content"))
|
|
541
|
+
}, toDisplayString(_ctx.message), 3)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
542
|
+
createCommentVNode(" Caution here, message could've been compromised, never use user's input as message "),
|
|
543
|
+
createElementVNode("p", {
|
|
544
|
+
class: normalizeClass(unref(ns).e("content")),
|
|
545
|
+
innerHTML: _ctx.message
|
|
546
|
+
}, null, 10, ["innerHTML"])
|
|
547
|
+
], 2112))
|
|
427
548
|
]),
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
549
|
+
_ctx.showClose ? (openBlock(), createBlock(unref(ElIcon), {
|
|
550
|
+
key: 2,
|
|
551
|
+
class: normalizeClass(unref(ns).e("closeBtn")),
|
|
552
|
+
onClick: withModifiers(close, ["stop"])
|
|
553
|
+
}, {
|
|
554
|
+
default: withCtx(() => [
|
|
555
|
+
createVNode(unref(Close))
|
|
556
|
+
]),
|
|
557
|
+
_: 1
|
|
558
|
+
}, 8, ["class", "onClick"])) : createCommentVNode("v-if", true)
|
|
559
|
+
], 46, ["id"]), [
|
|
560
|
+
[vShow, visible.value]
|
|
561
|
+
])
|
|
562
|
+
]),
|
|
563
|
+
_: 3
|
|
564
|
+
}, 8, ["name", "onBeforeEnter", "onBeforeLeave", "onAfterLeave"]);
|
|
565
|
+
};
|
|
436
566
|
}
|
|
437
567
|
});
|
|
438
|
-
var
|
|
439
|
-
let
|
|
440
|
-
const
|
|
441
|
-
const
|
|
442
|
-
|
|
443
|
-
...
|
|
568
|
+
var MessageConstructor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1, [["__file", "message.vue"]]);
|
|
569
|
+
let seed = 1;
|
|
570
|
+
const normalizeOptions = (params) => {
|
|
571
|
+
const options = !params || isString$1(params) || isVNode(params) || isFunction(params) ? { message: params } : params;
|
|
572
|
+
const normalized = {
|
|
573
|
+
...messageDefaults,
|
|
574
|
+
...options
|
|
444
575
|
};
|
|
445
|
-
if (!
|
|
446
|
-
|
|
447
|
-
else if (
|
|
448
|
-
let
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
if (
|
|
576
|
+
if (!normalized.appendTo) {
|
|
577
|
+
normalized.appendTo = document.body;
|
|
578
|
+
} else if (isString$1(normalized.appendTo)) {
|
|
579
|
+
let appendTo = document.querySelector(normalized.appendTo);
|
|
580
|
+
if (!isElement(appendTo)) {
|
|
581
|
+
appendTo = document.body;
|
|
582
|
+
}
|
|
583
|
+
normalized.appendTo = appendTo;
|
|
584
|
+
}
|
|
585
|
+
if (isBoolean(messageConfig.grouping) && !normalized.grouping) {
|
|
586
|
+
normalized.grouping = messageConfig.grouping;
|
|
587
|
+
}
|
|
588
|
+
if (isNumber(messageConfig.duration) && normalized.duration === 3e3) {
|
|
589
|
+
normalized.duration = messageConfig.duration;
|
|
590
|
+
}
|
|
591
|
+
if (isNumber(messageConfig.offset) && normalized.offset === 16) {
|
|
592
|
+
normalized.offset = messageConfig.offset;
|
|
593
|
+
}
|
|
594
|
+
if (isBoolean(messageConfig.showClose) && !normalized.showClose) {
|
|
595
|
+
normalized.showClose = messageConfig.showClose;
|
|
596
|
+
}
|
|
597
|
+
if (isBoolean(messageConfig.plain) && !normalized.plain) {
|
|
598
|
+
normalized.plain = messageConfig.plain;
|
|
599
|
+
}
|
|
600
|
+
return normalized;
|
|
601
|
+
};
|
|
602
|
+
const closeMessage = (instance) => {
|
|
603
|
+
const idx = instances.indexOf(instance);
|
|
604
|
+
if (idx === -1)
|
|
455
605
|
return;
|
|
456
|
-
|
|
457
|
-
const { handler
|
|
458
|
-
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
606
|
+
instances.splice(idx, 1);
|
|
607
|
+
const { handler } = instance;
|
|
608
|
+
handler.close();
|
|
609
|
+
};
|
|
610
|
+
const createMessage = ({ appendTo, ...options }, context) => {
|
|
611
|
+
const id = `message_${seed++}`;
|
|
612
|
+
const userOnClose = options.onClose;
|
|
613
|
+
const container = document.createElement("div");
|
|
614
|
+
const props = {
|
|
615
|
+
...options,
|
|
616
|
+
id,
|
|
463
617
|
onClose: () => {
|
|
464
|
-
|
|
618
|
+
userOnClose == null ? void 0 : userOnClose();
|
|
619
|
+
closeMessage(instance);
|
|
465
620
|
},
|
|
466
621
|
onDestroy: () => {
|
|
467
|
-
|
|
622
|
+
render(null, container);
|
|
468
623
|
}
|
|
469
|
-
}
|
|
470
|
-
|
|
624
|
+
};
|
|
625
|
+
const vnode = createVNode(MessageConstructor, props, isFunction(props.message) || isVNode(props.message) ? {
|
|
626
|
+
default: isFunction(props.message) ? props.message : () => props.message
|
|
471
627
|
} : null);
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
close
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
628
|
+
vnode.appContext = context || message._context;
|
|
629
|
+
render(vnode, container);
|
|
630
|
+
appendTo.appendChild(container.firstElementChild);
|
|
631
|
+
const vm = vnode.component;
|
|
632
|
+
const handler = {
|
|
633
|
+
close: () => {
|
|
634
|
+
vm.exposed.close();
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
const instance = {
|
|
638
|
+
id,
|
|
639
|
+
vnode,
|
|
640
|
+
vm,
|
|
641
|
+
handler,
|
|
642
|
+
props: vnode.component.props
|
|
483
643
|
};
|
|
484
|
-
return
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
const
|
|
490
|
-
if (
|
|
491
|
-
const
|
|
492
|
-
var
|
|
493
|
-
return ((
|
|
644
|
+
return instance;
|
|
645
|
+
};
|
|
646
|
+
const message = (options = {}, context) => {
|
|
647
|
+
if (!isClient)
|
|
648
|
+
return { close: () => void 0 };
|
|
649
|
+
const normalized = normalizeOptions(options);
|
|
650
|
+
if (normalized.grouping && instances.length) {
|
|
651
|
+
const instance2 = instances.find(({ vnode: vm }) => {
|
|
652
|
+
var _a;
|
|
653
|
+
return ((_a = vm.props) == null ? void 0 : _a.message) === normalized.message;
|
|
494
654
|
});
|
|
495
|
-
if (
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
655
|
+
if (instance2) {
|
|
656
|
+
instance2.props.repeatNum += 1;
|
|
657
|
+
instance2.props.type = normalized.type;
|
|
658
|
+
return instance2.handler;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (isNumber(messageConfig.max) && instances.length >= messageConfig.max) {
|
|
662
|
+
return { close: () => void 0 };
|
|
663
|
+
}
|
|
664
|
+
const instance = createMessage(normalized, context);
|
|
665
|
+
instances.push(instance);
|
|
666
|
+
return instance.handler;
|
|
503
667
|
};
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
const
|
|
507
|
-
return
|
|
668
|
+
messageTypes.forEach((type) => {
|
|
669
|
+
message[type] = (options = {}, appContext) => {
|
|
670
|
+
const normalized = normalizeOptions(options);
|
|
671
|
+
return message({ ...normalized, type }, appContext);
|
|
508
672
|
};
|
|
509
673
|
});
|
|
510
|
-
function
|
|
511
|
-
const
|
|
512
|
-
for (const
|
|
513
|
-
(!
|
|
674
|
+
function closeAll(type) {
|
|
675
|
+
const instancesToClose = [...instances];
|
|
676
|
+
for (const instance of instancesToClose) {
|
|
677
|
+
if (!type || type === instance.props.type) {
|
|
678
|
+
instance.handler.close();
|
|
679
|
+
}
|
|
680
|
+
}
|
|
514
681
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
const
|
|
518
|
-
class
|
|
682
|
+
message.closeAll = closeAll;
|
|
683
|
+
message._context = null;
|
|
684
|
+
const ElMessage = withInstallFunction(message, "$message");
|
|
685
|
+
class CommandFlowComponent extends Component {
|
|
519
686
|
_renderer;
|
|
520
687
|
get renderer() {
|
|
521
|
-
|
|
688
|
+
if (!this._renderer) this._renderer = this.parent?.findComponentByName("Renderer");
|
|
689
|
+
return this._renderer;
|
|
522
690
|
}
|
|
523
691
|
_domElement;
|
|
524
692
|
get domElement() {
|
|
525
|
-
|
|
693
|
+
if (!this._domElement) this._domElement = this.editor?.domContainer?.domElement;
|
|
694
|
+
return this._domElement;
|
|
526
695
|
}
|
|
527
696
|
_editor;
|
|
528
697
|
get editor() {
|
|
529
|
-
|
|
698
|
+
if (!this._editor) this._editor = this.parent?.findComponentByName("Editor");
|
|
699
|
+
return this._editor;
|
|
530
700
|
}
|
|
531
701
|
_eventInput;
|
|
532
702
|
get eventInput() {
|
|
533
|
-
|
|
703
|
+
if (!this._eventInput) this._eventInput = this.parent?.findComponentByName("EventInput");
|
|
704
|
+
return this._eventInput;
|
|
534
705
|
}
|
|
535
706
|
_renderManager;
|
|
536
707
|
get renderManager() {
|
|
537
|
-
|
|
708
|
+
if (!this._renderManager) this._renderManager = this.parent?.findComponentByName("RenderManager");
|
|
709
|
+
return this._renderManager;
|
|
538
710
|
}
|
|
539
711
|
_commandManager;
|
|
540
712
|
get commandManager() {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
_default;
|
|
544
|
-
get default() {
|
|
545
|
-
return this._default || (this._default = this.parent?.findComponentByName("Default")), this._default;
|
|
713
|
+
if (!this._commandManager) this._commandManager = this.editor?.commandManager;
|
|
714
|
+
return this._commandManager;
|
|
546
715
|
}
|
|
547
716
|
interruptKeys = ["escape"];
|
|
548
717
|
commandName = "";
|
|
549
718
|
constructor() {
|
|
550
719
|
super();
|
|
551
720
|
}
|
|
552
|
-
onAddFromParent(
|
|
721
|
+
onAddFromParent(parent) {
|
|
553
722
|
this.editor.addEventListener("cancelCommand", () => {
|
|
554
723
|
this.cancel();
|
|
555
724
|
});
|
|
@@ -558,21 +727,22 @@ class T extends ye {
|
|
|
558
727
|
* 取消
|
|
559
728
|
*/
|
|
560
729
|
cancel() {
|
|
561
|
-
|
|
562
|
-
this.
|
|
730
|
+
if (this.editor.commandManager.currentName !== this.commandName) return;
|
|
731
|
+
this.editor.commandManager.cancel();
|
|
563
732
|
}
|
|
564
733
|
/**
|
|
565
|
-
*
|
|
734
|
+
* 创建中断
|
|
566
735
|
* @returns
|
|
567
736
|
*/
|
|
568
737
|
createInterrupt() {
|
|
569
|
-
return (
|
|
738
|
+
return (next, data) => {
|
|
570
739
|
this.addEventRecord(
|
|
571
740
|
"clear",
|
|
572
|
-
this.eventInput.addEventListener("codeChange", async () => {
|
|
573
|
-
this.eventInput.isKeyDowns(this.interruptKeys)
|
|
741
|
+
this.editor?.eventInput.addEventListener("codeChange", async () => {
|
|
742
|
+
if (this.editor.eventInput.isKeyDowns(this.interruptKeys)) this.cancel();
|
|
574
743
|
})
|
|
575
|
-
)
|
|
744
|
+
);
|
|
745
|
+
next(data);
|
|
576
746
|
};
|
|
577
747
|
}
|
|
578
748
|
/**
|
|
@@ -580,166 +750,305 @@ class T extends ye {
|
|
|
580
750
|
* @param cursor
|
|
581
751
|
* @returns
|
|
582
752
|
*/
|
|
583
|
-
createCursor(
|
|
584
|
-
return (
|
|
585
|
-
const
|
|
586
|
-
this.domElement.style.cursor =
|
|
587
|
-
|
|
588
|
-
|
|
753
|
+
createCursor(cursor) {
|
|
754
|
+
return (next, data) => {
|
|
755
|
+
const defaultCursor = this.domElement.style.cursor;
|
|
756
|
+
this.domElement.style.cursor = cursor;
|
|
757
|
+
this.addEventRecord("clear", () => {
|
|
758
|
+
this.domElement.style.cursor = defaultCursor ?? "default";
|
|
759
|
+
});
|
|
760
|
+
next(data);
|
|
589
761
|
};
|
|
590
762
|
}
|
|
591
763
|
/**
|
|
592
764
|
* 创建清理
|
|
593
765
|
* @returns
|
|
594
766
|
*/
|
|
595
|
-
createFinally(
|
|
767
|
+
createFinally(keys = []) {
|
|
596
768
|
return () => {
|
|
597
|
-
this.canceEventRecord("clear")
|
|
769
|
+
this.canceEventRecord("clear");
|
|
770
|
+
keys.forEach((k) => this.canceEventRecord(k));
|
|
598
771
|
};
|
|
599
772
|
}
|
|
600
773
|
}
|
|
601
|
-
class
|
|
774
|
+
class DrawLine extends CommandFlowComponent {
|
|
602
775
|
static name = "DrawLine";
|
|
603
|
-
container = new
|
|
776
|
+
container = new THREE.Group();
|
|
604
777
|
interruptKeys = ["escape"];
|
|
605
778
|
withdrawalKeys = ["control", "z"];
|
|
606
779
|
shortcutKeys = ["control", "l"];
|
|
607
780
|
confirmKeys = ["enter"];
|
|
608
781
|
commandName = "draw-line";
|
|
609
|
-
onAddFromParent(
|
|
610
|
-
super.onAddFromParent(
|
|
611
|
-
|
|
612
|
-
|
|
782
|
+
onAddFromParent(parent) {
|
|
783
|
+
super.onAddFromParent(parent);
|
|
784
|
+
this.editor.container.add(this.container);
|
|
785
|
+
const commandFlow = this.commandManager.addCommandFlow(this.commandName).add(this.createInterrupt()).add(this.createCursor("crosshair")).add(this.selectPoint.bind(this));
|
|
786
|
+
commandFlow.addEventListener("finally", this.createFinally());
|
|
787
|
+
commandFlow.addEventListener("completed", (e) => this.completed(e.data));
|
|
788
|
+
this.eventInput.addKeyCombination(this.commandName, this.shortcutKeys);
|
|
789
|
+
this.eventInput.addEventListener("codeChange", async () => this.eventInput.isKeyCombination(this.commandName) && await this.commandManager.start(this.commandName));
|
|
790
|
+
this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
|
|
613
791
|
}
|
|
614
792
|
/** 选择点
|
|
615
793
|
* @param next
|
|
616
794
|
*/
|
|
617
|
-
selectPoint(
|
|
618
|
-
let
|
|
619
|
-
new
|
|
620
|
-
new
|
|
621
|
-
new
|
|
622
|
-
new
|
|
795
|
+
selectPoint(next) {
|
|
796
|
+
let editor = this.parent?.findComponentByName("Editor"), start = null, end = null, points = [], circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 65280 })), dom = editor.domContainer.domElement, line2 = new Lines([], 16711935), auxiliaryLine = new Lines([
|
|
797
|
+
new THREE.Vector3(-1e4, 0, 0),
|
|
798
|
+
new THREE.Vector3(1e4, 0, 0),
|
|
799
|
+
new THREE.Vector3(0, -1e4, 0),
|
|
800
|
+
new THREE.Vector3(0, 1e4, 0)
|
|
623
801
|
], 16711935);
|
|
624
|
-
|
|
802
|
+
auxiliaryLine.material = new THREE.LineDashedMaterial({
|
|
625
803
|
color: 4235007,
|
|
626
804
|
dashSize: 0.1,
|
|
627
805
|
gapSize: 0.1,
|
|
628
806
|
linewidth: 0.1
|
|
629
|
-
})
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
807
|
+
});
|
|
808
|
+
this.container.add(line2);
|
|
809
|
+
const updateLine = () => {
|
|
810
|
+
line2.setPoint(...points, start, end);
|
|
811
|
+
auxiliaryLine.position.copy(end);
|
|
812
|
+
this.container.add(auxiliaryLine);
|
|
813
|
+
auxiliaryLine.computeLineDistances();
|
|
814
|
+
};
|
|
815
|
+
const currentPoint = new THREE.Vector3();
|
|
633
816
|
this.addEventRecord(
|
|
634
817
|
"clear",
|
|
635
|
-
|
|
636
|
-
const { point
|
|
637
|
-
if (
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
818
|
+
editor.addEventListener("pointerPositionChange", () => {
|
|
819
|
+
const { point, find } = editor.renderManager.adsorption();
|
|
820
|
+
if (find) {
|
|
821
|
+
circle.position.set(point.x, point.y, 0);
|
|
822
|
+
this.container.add(circle);
|
|
823
|
+
dom.style.cursor = "none";
|
|
824
|
+
} else {
|
|
825
|
+
circle.removeFromParent();
|
|
826
|
+
dom.style.cursor = "crosshair";
|
|
644
827
|
}
|
|
828
|
+
currentPoint.copy(point);
|
|
829
|
+
if (!(start && end)) return;
|
|
830
|
+
if (editor.eventInput.isKeyDown("shift")) {
|
|
831
|
+
const x = Math.abs(editor.pointerPosition.x - start.x), y = Math.abs(editor.pointerPosition.y - start.y);
|
|
832
|
+
if (x > y) end.set(editor.pointerPosition.x, start.y, 0);
|
|
833
|
+
else end.set(start.x, editor.pointerPosition.y, 0);
|
|
834
|
+
updateLine();
|
|
835
|
+
currentPoint.copy(end);
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
end.set(editor.pointerPosition.x, editor.pointerPosition.y, 0);
|
|
839
|
+
updateLine();
|
|
645
840
|
}),
|
|
646
|
-
|
|
647
|
-
if (
|
|
648
|
-
if (!
|
|
649
|
-
|
|
841
|
+
editor.eventInput.addEventListener("codeChange", async () => {
|
|
842
|
+
if (editor.eventInput.isKeyDown("mouse_0")) {
|
|
843
|
+
if (!start) {
|
|
844
|
+
start = currentPoint.clone();
|
|
845
|
+
end = currentPoint.clone();
|
|
846
|
+
updateLine();
|
|
650
847
|
return;
|
|
651
848
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
849
|
+
end = currentPoint.clone();
|
|
850
|
+
points.push(start.clone(), end.clone());
|
|
851
|
+
start.copy(end);
|
|
852
|
+
updateLine();
|
|
853
|
+
} else if (editor.eventInput.isOnlyKeyDowns(this.withdrawalKeys)) {
|
|
854
|
+
if (points.length) {
|
|
855
|
+
const { point } = editor.renderManager.adsorption();
|
|
856
|
+
points.pop();
|
|
857
|
+
end?.copy(point);
|
|
858
|
+
start?.copy(points.pop());
|
|
859
|
+
updateLine();
|
|
657
860
|
}
|
|
658
|
-
} else
|
|
861
|
+
} else if (editor.eventInput.isKeyDowns(this.confirmKeys)) next(points);
|
|
659
862
|
}),
|
|
660
863
|
function() {
|
|
661
|
-
|
|
864
|
+
line2.removeFromParent();
|
|
865
|
+
circle.removeFromParent();
|
|
866
|
+
auxiliaryLine.removeFromParent();
|
|
662
867
|
}
|
|
663
868
|
);
|
|
664
869
|
}
|
|
665
|
-
/** 结束, 汇总结果
|
|
666
|
-
* @param points
|
|
667
|
-
*/
|
|
668
|
-
end(e, t) {
|
|
669
|
-
const n = [];
|
|
670
|
-
for (let o = 0; o < t.length; o += 2)
|
|
671
|
-
n.push(new ne(A.from(t[o]), A.from(t[o + 1])));
|
|
672
|
-
e(n);
|
|
673
|
-
}
|
|
674
870
|
/** 执行完成
|
|
675
871
|
*/
|
|
676
|
-
completed(
|
|
677
|
-
this.
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
return e.forEach((t) => this.renderManager.removeLine(t)), this.renderManager.draw(), e;
|
|
684
|
-
}
|
|
685
|
-
/** 撤回回滚
|
|
686
|
-
* @param lines
|
|
687
|
-
* @returns
|
|
688
|
-
*/
|
|
689
|
-
revokeRollback(e) {
|
|
690
|
-
return this.completed(e), e;
|
|
872
|
+
completed(points) {
|
|
873
|
+
const editor = this.editor, lines = [];
|
|
874
|
+
for (let i = 0; i < points.length; i += 2) {
|
|
875
|
+
lines.push(new LineSegment(Point.from(points[i]), Point.from(points[i + 1])));
|
|
876
|
+
}
|
|
877
|
+
editor.renderManager.addLines(lines);
|
|
878
|
+
editor.renderManager.draw();
|
|
691
879
|
}
|
|
692
880
|
}
|
|
693
|
-
class
|
|
881
|
+
class Default extends Component {
|
|
694
882
|
static name = "Default";
|
|
695
883
|
get editor() {
|
|
696
884
|
return this.parent?.findComponentByName("Editor");
|
|
697
885
|
}
|
|
698
886
|
renderer;
|
|
699
|
-
container = new
|
|
887
|
+
container = new THREE.Group();
|
|
700
888
|
onAddFromParent() {
|
|
701
|
-
const
|
|
702
|
-
this.renderer = this.parent?.findComponentByName("Renderer")
|
|
703
|
-
|
|
704
|
-
|
|
889
|
+
const editor = this.editor, commandManager = editor.commandManager;
|
|
890
|
+
this.renderer = this.parent?.findComponentByName("Renderer");
|
|
891
|
+
editor.container.add(this.container);
|
|
892
|
+
commandManager.addCommandFlow("default").add(this.start.bind(this)).addEventListener("finally", this.finally.bind(this));
|
|
893
|
+
commandManager.addEventListener("startedBefore", (e) => {
|
|
894
|
+
if (e.currentName === "default" && e.name !== "default") commandManager.cancel();
|
|
895
|
+
});
|
|
896
|
+
commandManager.addEventListener("finally", (e) => e.name !== "default" && commandManager.start("default"));
|
|
897
|
+
editor.eventInput.addCancelDefaultBehavior(() => editor.eventInput.isOnlyKeyDowns(["control", "g"]));
|
|
705
898
|
}
|
|
706
899
|
selectLines = [];
|
|
707
|
-
selectLineObject3D = new
|
|
900
|
+
selectLineObject3D = new THREE.Mesh();
|
|
708
901
|
/** 添加选择的线段
|
|
709
902
|
* @param lineSegment
|
|
710
903
|
*/
|
|
711
|
-
addSelectLine(
|
|
712
|
-
this.selectLines.indexOf(
|
|
904
|
+
addSelectLine(lineSegment) {
|
|
905
|
+
if (this.selectLines.indexOf(lineSegment) > -1) return;
|
|
906
|
+
this.selectLines.push(lineSegment);
|
|
907
|
+
this.updateSelectLinesGeometry();
|
|
908
|
+
this.dispatchEvent({
|
|
713
909
|
type: "selectLineChange"
|
|
714
|
-
})
|
|
910
|
+
});
|
|
715
911
|
}
|
|
716
912
|
/** 移除选择的线段
|
|
717
913
|
* @param lineSegment
|
|
718
914
|
*/
|
|
719
|
-
removeSelectLine(
|
|
720
|
-
const
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
915
|
+
removeSelectLine(lineSegment) {
|
|
916
|
+
const i = this.selectLines.indexOf(lineSegment);
|
|
917
|
+
if (i > -1) {
|
|
918
|
+
this.selectLines.splice(i, 1);
|
|
919
|
+
this.updateSelectLinesGeometry();
|
|
920
|
+
this.dispatchEvent({
|
|
921
|
+
type: "selectLineChange"
|
|
922
|
+
});
|
|
923
|
+
}
|
|
724
924
|
}
|
|
725
925
|
/**
|
|
726
926
|
* 移除所有选中线段
|
|
727
927
|
*/
|
|
728
928
|
removeSelectLineAll() {
|
|
729
|
-
this.selectLines.length = 0
|
|
929
|
+
this.selectLines.length = 0;
|
|
930
|
+
this.dispatchEvent({
|
|
730
931
|
type: "selectLineChange"
|
|
731
932
|
});
|
|
732
933
|
}
|
|
934
|
+
/**
|
|
935
|
+
* 删除选择的线段
|
|
936
|
+
*/
|
|
937
|
+
deleteSelectLine() {
|
|
938
|
+
const editor = this.editor;
|
|
939
|
+
this.selectLines.forEach((line2) => editor.renderManager.removeLine(line2));
|
|
940
|
+
this.removeSelectLineAll();
|
|
941
|
+
this.updateSelectLinesGeometry();
|
|
942
|
+
ElMessage({ message: "删除成功", type: "success" });
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* 删除选择线段上的窗户
|
|
946
|
+
*/
|
|
947
|
+
deleteSelectWindow() {
|
|
948
|
+
let is = false;
|
|
949
|
+
this.selectLines.forEach((line2) => {
|
|
950
|
+
if (!line2.userData.isWindow) return;
|
|
951
|
+
line2.userData = {};
|
|
952
|
+
is = true;
|
|
953
|
+
});
|
|
954
|
+
this.editor.renderManager.draw();
|
|
955
|
+
is && ElMessage({ message: "删除窗户成功", type: "success" });
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* 如果只选择两个线段,可为两个未链接的点创建连接
|
|
959
|
+
*/
|
|
960
|
+
connection() {
|
|
961
|
+
if (this.selectLines.length !== 2) {
|
|
962
|
+
ElMessage({ message: "连接失败,请选择两个线段", type: "warning" });
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
const editor = this.editor;
|
|
966
|
+
let start, end, diatance = Infinity;
|
|
967
|
+
for (let i = 0; i < 2; i++)
|
|
968
|
+
for (let j = 0; j < 2; j++) {
|
|
969
|
+
const point1 = this.selectLines[0].points[i];
|
|
970
|
+
const point2 = this.selectLines[1].points[j];
|
|
971
|
+
const d = point1.distance(point2);
|
|
972
|
+
if (d < diatance) {
|
|
973
|
+
start = point1;
|
|
974
|
+
end = point2;
|
|
975
|
+
diatance = d;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
if (start && end) {
|
|
979
|
+
const line2 = new LineSegment(start.clone(), end.clone());
|
|
980
|
+
editor.renderManager.addLine(line2);
|
|
981
|
+
editor.renderManager.draw();
|
|
982
|
+
ElMessage({ message: "连接成功", type: "success" });
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* 如果只选择两个线段,可为两个未链接的点创建连接, 通过计算交点,线段延长到交点
|
|
987
|
+
*/
|
|
988
|
+
intersectionConnection() {
|
|
989
|
+
if (this.selectLines.length !== 2) {
|
|
990
|
+
ElMessage({ message: "连接失败,请选择两个线段", type: "warning" });
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
const editor = this.editor, line1 = this.selectLines[0], line2 = this.selectLines[1], point = this.selectLines[0].getIntersection(this.selectLines[1]);
|
|
994
|
+
if (!point) return;
|
|
995
|
+
editor.renderManager.removeLine(line1);
|
|
996
|
+
editor.renderManager.removeLine(line2);
|
|
997
|
+
if (line1.start.distance(point) < line1.end.distance(point)) {
|
|
998
|
+
line1.start.copy(point);
|
|
999
|
+
} else {
|
|
1000
|
+
line1.end.copy(point);
|
|
1001
|
+
}
|
|
1002
|
+
if (line2.start.distance(point) < line2.end.distance(point)) {
|
|
1003
|
+
line2.start.copy(point);
|
|
1004
|
+
} else {
|
|
1005
|
+
line2.end.copy(point);
|
|
1006
|
+
}
|
|
1007
|
+
editor.renderManager.addLines([line1, line2]);
|
|
1008
|
+
editor.renderManager.draw();
|
|
1009
|
+
ElMessage({ message: "连接成功", type: "success" });
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* 如果只选择两个线段, 且两个线段在一条路径上,合并线段
|
|
1013
|
+
*/
|
|
1014
|
+
mergeLine() {
|
|
1015
|
+
if (this.selectLines.length !== 2) {
|
|
1016
|
+
ElMessage({ message: "未执行线段合并,请选择两条线段", type: "warning" });
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
const editor = this.editor, line1 = this.selectLines[0], line2 = this.selectLines[1];
|
|
1020
|
+
for (let i = 0; i < line1.points.length; i++) {
|
|
1021
|
+
const p1 = line1.points[i];
|
|
1022
|
+
for (let j = 0; j < line2.points.length; j++) {
|
|
1023
|
+
const p2 = line2.points[j];
|
|
1024
|
+
if (p1.equal(p2)) {
|
|
1025
|
+
const p1Next = line1.points[(i + 1) % 2];
|
|
1026
|
+
const p2Next = line2.points[(j + 1) % 2];
|
|
1027
|
+
editor.renderManager.removeLine(line1);
|
|
1028
|
+
editor.renderManager.removeLine(line2);
|
|
1029
|
+
const line3 = new LineSegment(p1Next, p2Next);
|
|
1030
|
+
editor.renderManager.addLine(line3);
|
|
1031
|
+
editor.renderManager.draw();
|
|
1032
|
+
ElMessage({ message: "已合并", type: "success" });
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
ElMessage({ message: "合并失败,两条线未找到共用点", type: "warning" });
|
|
1038
|
+
}
|
|
733
1039
|
_timer = null;
|
|
734
1040
|
/**
|
|
735
1041
|
* 更新选择的线段
|
|
736
1042
|
*/
|
|
737
1043
|
updateSelectLinesGeometry() {
|
|
738
|
-
|
|
1044
|
+
if (this._timer) clearTimeout(this._timer);
|
|
1045
|
+
this._timer = setTimeout(() => {
|
|
739
1046
|
if (this.destroyed) return;
|
|
740
|
-
this.selectLines.length
|
|
741
|
-
|
|
742
|
-
|
|
1047
|
+
if (this.selectLines.length) this.container.add(this.selectLineObject3D);
|
|
1048
|
+
else this.selectLineObject3D.removeFromParent();
|
|
1049
|
+
const editor = this.editor;
|
|
1050
|
+
const position = this.selectLines.flatMap((line2) => line2.expandToRectangle(0.04, "bothSides").createGeometry());
|
|
1051
|
+
this.selectLineObject3D.geometry = editor.renderManager.createGeometry({ position }, position.length / 3);
|
|
743
1052
|
}, 10);
|
|
744
1053
|
}
|
|
745
1054
|
/**
|
|
@@ -747,68 +1056,109 @@ class ke extends ye {
|
|
|
747
1056
|
* @param next
|
|
748
1057
|
*/
|
|
749
1058
|
start() {
|
|
750
|
-
const
|
|
751
|
-
let
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
1059
|
+
const editor = this.editor, eventInput = editor.eventInput, object3D = new THREE.Mesh(), dom = editor.domContainer.domElement;
|
|
1060
|
+
let currentSelectLine = null;
|
|
1061
|
+
object3D.position.z = 0.01;
|
|
1062
|
+
this.selectLineObject3D.position.z = object3D.position.z + 0.01;
|
|
1063
|
+
object3D.material = new THREE.MeshBasicMaterial({ color: 55561 });
|
|
1064
|
+
eventInput.addKeyCombination("intersectionConnection", ["control", "shift", "l"]);
|
|
1065
|
+
eventInput.addKeyCombination("connection", ["shift", "l"]);
|
|
1066
|
+
eventInput.addKeyCombination("mergeLine", ["control", "g"]);
|
|
1067
|
+
this.addEventRecord("clear", () => {
|
|
1068
|
+
eventInput.removeKeyCombination("intersectionConnection");
|
|
1069
|
+
eventInput.removeKeyCombination("connection");
|
|
1070
|
+
eventInput.removeKeyCombination("mergeLine");
|
|
1071
|
+
});
|
|
1072
|
+
const showSelectBox = () => {
|
|
1073
|
+
const startPoint = editor.pointerPosition.clone(), endPoint = editor.pointerPosition.clone(), mesh = new THREE.Mesh();
|
|
1074
|
+
this.container.add(mesh);
|
|
1075
|
+
mesh.position.z = 0.05;
|
|
1076
|
+
mesh.material = new THREE.MeshBasicMaterial({
|
|
756
1077
|
color: 16777215,
|
|
757
|
-
transparent:
|
|
1078
|
+
transparent: true,
|
|
758
1079
|
opacity: 0.5
|
|
759
1080
|
});
|
|
760
|
-
const
|
|
761
|
-
const
|
|
762
|
-
|
|
763
|
-
|
|
1081
|
+
const update = () => {
|
|
1082
|
+
const minX = Math.min(startPoint.x, endPoint.x), maxX = Math.max(startPoint.x, endPoint.x), minY = Math.min(startPoint.y, endPoint.y), maxY = Math.max(startPoint.y, endPoint.y);
|
|
1083
|
+
const position = [
|
|
1084
|
+
minX,
|
|
1085
|
+
maxY,
|
|
764
1086
|
0,
|
|
765
|
-
|
|
766
|
-
|
|
1087
|
+
maxX,
|
|
1088
|
+
minY,
|
|
767
1089
|
0,
|
|
768
|
-
|
|
769
|
-
|
|
1090
|
+
maxX,
|
|
1091
|
+
maxY,
|
|
770
1092
|
0,
|
|
771
|
-
|
|
772
|
-
|
|
1093
|
+
minX,
|
|
1094
|
+
maxY,
|
|
773
1095
|
0,
|
|
774
|
-
|
|
775
|
-
|
|
1096
|
+
minX,
|
|
1097
|
+
minY,
|
|
776
1098
|
0,
|
|
777
|
-
|
|
778
|
-
|
|
1099
|
+
maxX,
|
|
1100
|
+
minY,
|
|
779
1101
|
0
|
|
780
1102
|
];
|
|
781
|
-
|
|
782
|
-
}, h = () => {
|
|
783
|
-
d.copy(e.pointerPosition), c();
|
|
784
|
-
}, f = () => {
|
|
785
|
-
document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", f), l.removeFromParent();
|
|
786
|
-
const g = Math.min(i.x, d.x), C = Math.max(i.x, d.x), b = Math.min(i.y, d.y), P = Math.max(i.y, d.y), _ = new We(g, C, b, P), j = e.renderManager.quadtree.queryBox(_);
|
|
787
|
-
this.removeSelectLineAll(), j.forEach((se) => this.addSelectLine(se.line)), this.updateSelectLinesGeometry();
|
|
1103
|
+
mesh.geometry = editor.renderManager.createGeometry({ position }, position.length / 3);
|
|
788
1104
|
};
|
|
789
|
-
|
|
1105
|
+
const move = () => {
|
|
1106
|
+
endPoint.copy(editor.pointerPosition);
|
|
1107
|
+
update();
|
|
1108
|
+
};
|
|
1109
|
+
const end = () => {
|
|
1110
|
+
document.removeEventListener("mousemove", move);
|
|
1111
|
+
document.removeEventListener("mouseup", end);
|
|
1112
|
+
mesh.removeFromParent();
|
|
1113
|
+
const minX = Math.min(startPoint.x, endPoint.x), maxX = Math.max(startPoint.x, endPoint.x), minY = Math.min(startPoint.y, endPoint.y), maxY = Math.max(startPoint.y, endPoint.y);
|
|
1114
|
+
const box = new Box2(minX, maxX, minY, maxY);
|
|
1115
|
+
const resultList = editor.renderManager.quadtree.queryBox(box);
|
|
1116
|
+
this.removeSelectLineAll();
|
|
1117
|
+
resultList.forEach((result) => this.addSelectLine(result.line));
|
|
1118
|
+
this.updateSelectLinesGeometry();
|
|
1119
|
+
};
|
|
1120
|
+
document.addEventListener("mousemove", move);
|
|
1121
|
+
document.addEventListener("mouseup", end);
|
|
790
1122
|
};
|
|
791
1123
|
this.addEventRecord(
|
|
792
1124
|
"clear",
|
|
793
1125
|
// 注册鼠标指针位置变化事件
|
|
794
|
-
|
|
795
|
-
const { line:
|
|
796
|
-
if (
|
|
797
|
-
const
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
1126
|
+
editor.addEventListener("pointerPositionChange", () => {
|
|
1127
|
+
const { line: line2 } = editor.renderManager.adsorption(0.05);
|
|
1128
|
+
if (line2) {
|
|
1129
|
+
const rectangle = line2.expandToRectangle(0.02, "bothSides");
|
|
1130
|
+
object3D.geometry = editor.renderManager.createGeometry({ position: rectangle.createGeometry() }, 6);
|
|
1131
|
+
this.container.add(object3D);
|
|
1132
|
+
dom.style.cursor = "pointer";
|
|
1133
|
+
currentSelectLine = line2;
|
|
1134
|
+
} else {
|
|
1135
|
+
object3D.removeFromParent();
|
|
1136
|
+
dom.style.cursor = "default";
|
|
1137
|
+
currentSelectLine = null;
|
|
1138
|
+
}
|
|
801
1139
|
}),
|
|
802
|
-
|
|
803
|
-
if (
|
|
804
|
-
if (!
|
|
805
|
-
if (
|
|
806
|
-
return this.removeSelectLine(
|
|
807
|
-
|
|
808
|
-
|
|
1140
|
+
eventInput.addEventListener("codeChange", () => {
|
|
1141
|
+
if (eventInput.isKeyDown("mouse_0")) {
|
|
1142
|
+
if (!currentSelectLine) return showSelectBox();
|
|
1143
|
+
if (eventInput.isKeyDown("alt")) {
|
|
1144
|
+
return this.removeSelectLine(currentSelectLine);
|
|
1145
|
+
}
|
|
1146
|
+
if (!eventInput.isKeyDown("control")) this.removeSelectLineAll();
|
|
1147
|
+
this.addSelectLine(currentSelectLine);
|
|
1148
|
+
} else if (eventInput.isOnlyKeyDown("delete")) {
|
|
1149
|
+
this.deleteSelectLine();
|
|
1150
|
+
} else if (eventInput.isKeyDowns(["q", "delete"])) {
|
|
1151
|
+
this.deleteSelectWindow();
|
|
1152
|
+
} else if (eventInput.isKeyCombination("connection")) {
|
|
1153
|
+
this.connection();
|
|
1154
|
+
} else if (eventInput.isKeyCombination("intersectionConnection")) {
|
|
1155
|
+
this.intersectionConnection();
|
|
1156
|
+
} else if (eventInput.isKeyCombination("mergeLine")) {
|
|
1157
|
+
this.mergeLine();
|
|
1158
|
+
}
|
|
809
1159
|
}),
|
|
810
1160
|
function() {
|
|
811
|
-
|
|
1161
|
+
object3D.removeFromParent();
|
|
812
1162
|
}
|
|
813
1163
|
);
|
|
814
1164
|
}
|
|
@@ -816,55 +1166,32 @@ class ke extends ye {
|
|
|
816
1166
|
* 清理
|
|
817
1167
|
*/
|
|
818
1168
|
finally() {
|
|
819
|
-
this.canceEventRecord("clear")
|
|
1169
|
+
this.canceEventRecord("clear");
|
|
1170
|
+
this.removeSelectLineAll();
|
|
1171
|
+
this.updateSelectLinesGeometry();
|
|
820
1172
|
}
|
|
821
1173
|
}
|
|
822
|
-
class
|
|
1174
|
+
class CommandFlow extends EventDispatcher {
|
|
823
1175
|
list = [];
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
writeOperationList = !0;
|
|
828
|
-
/**
|
|
829
|
-
*
|
|
830
|
-
* @param operation
|
|
831
|
-
* @returns
|
|
832
|
-
*/
|
|
833
|
-
add(e) {
|
|
834
|
-
return this.list.push(e), this;
|
|
835
|
-
}
|
|
836
|
-
/** 添加回滚回调列表
|
|
837
|
-
* @param callBack
|
|
838
|
-
*/
|
|
839
|
-
addRollback(e) {
|
|
840
|
-
return this.rollbacklist.push(e), this;
|
|
841
|
-
}
|
|
842
|
-
/** 添加撤回回滚回调列表
|
|
843
|
-
* @param callBack
|
|
844
|
-
* @returns
|
|
845
|
-
*/
|
|
846
|
-
addRevokeRollback(e) {
|
|
847
|
-
return this.revokeRollbacklist.push(e), this;
|
|
1176
|
+
add(operation) {
|
|
1177
|
+
this.list.push(operation);
|
|
1178
|
+
return this;
|
|
848
1179
|
}
|
|
849
1180
|
}
|
|
850
|
-
class
|
|
1181
|
+
class CommandManager extends EventDispatcher {
|
|
851
1182
|
commandFlowMap = /* @__PURE__ */ new Map();
|
|
852
|
-
lock =
|
|
1183
|
+
lock = false;
|
|
853
1184
|
abortController = null;
|
|
854
1185
|
resolve = null;
|
|
855
1186
|
currentName = null;
|
|
856
|
-
_disabled =
|
|
857
|
-
set disabled(
|
|
858
|
-
this._disabled =
|
|
1187
|
+
_disabled = false;
|
|
1188
|
+
set disabled(disabled) {
|
|
1189
|
+
this._disabled = disabled;
|
|
1190
|
+
if (this._disabled) this.cancel();
|
|
859
1191
|
}
|
|
860
1192
|
get disabled() {
|
|
861
1193
|
return this._disabled;
|
|
862
1194
|
}
|
|
863
|
-
/**
|
|
864
|
-
* 操作记录
|
|
865
|
-
*/
|
|
866
|
-
operationList = [];
|
|
867
|
-
rollbackList = [];
|
|
868
1195
|
constructor() {
|
|
869
1196
|
super();
|
|
870
1197
|
}
|
|
@@ -872,10 +1199,11 @@ class pn extends Ue {
|
|
|
872
1199
|
* @param name
|
|
873
1200
|
* @returns
|
|
874
1201
|
*/
|
|
875
|
-
addCommandFlow(
|
|
876
|
-
if (this.commandFlowMap.has(
|
|
877
|
-
const
|
|
878
|
-
|
|
1202
|
+
addCommandFlow(name) {
|
|
1203
|
+
if (this.commandFlowMap.has(name)) throw new Error(`${name} 命令已经存在`);
|
|
1204
|
+
const commandFlow = new CommandFlow();
|
|
1205
|
+
this.commandFlowMap.set(name, commandFlow);
|
|
1206
|
+
return commandFlow;
|
|
879
1207
|
}
|
|
880
1208
|
executionPromise = null;
|
|
881
1209
|
executionResolve = null;
|
|
@@ -883,131 +1211,118 @@ class pn extends Ue {
|
|
|
883
1211
|
* @param name
|
|
884
1212
|
* @returns
|
|
885
1213
|
*/
|
|
886
|
-
async start(
|
|
1214
|
+
async start(name, data = null, step = 0) {
|
|
887
1215
|
if (this.disabled) throw new Error("命令管理器已禁用,无法启动新的命令流");
|
|
888
|
-
|
|
1216
|
+
this.dispatchEvent({
|
|
889
1217
|
type: "startedBefore",
|
|
890
|
-
name
|
|
1218
|
+
name,
|
|
891
1219
|
currentName: this.currentName
|
|
892
|
-
})
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
if (
|
|
896
|
-
throw new Error(
|
|
897
|
-
|
|
1220
|
+
});
|
|
1221
|
+
this.executionPromise && await this.executionPromise;
|
|
1222
|
+
this.executionPromise = null;
|
|
1223
|
+
if (this.lock) {
|
|
1224
|
+
throw new Error("命令管理器已被锁定,无法启动新的命令流");
|
|
1225
|
+
}
|
|
1226
|
+
const commandFlow = this.commandFlowMap.get(name);
|
|
1227
|
+
if (!commandFlow) {
|
|
1228
|
+
throw new Error(`命令流 ${name} 不存在`);
|
|
1229
|
+
}
|
|
1230
|
+
this.lock = true;
|
|
1231
|
+
this.abortController = new AbortController();
|
|
1232
|
+
this.currentName = name;
|
|
1233
|
+
commandFlow.dispatchEvent({ type: "started" });
|
|
1234
|
+
this.dispatchEvent({ type: "started", name });
|
|
898
1235
|
try {
|
|
899
|
-
for (let
|
|
900
|
-
const
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
1236
|
+
for (let i = step; i < commandFlow.list.length; i++) {
|
|
1237
|
+
const operation = commandFlow.list[i];
|
|
1238
|
+
commandFlow.dispatchEvent({ type: "executing", index: i });
|
|
1239
|
+
this.dispatchEvent({ type: "executing", name, index: i });
|
|
1240
|
+
data = await new Promise((resolve) => {
|
|
1241
|
+
this.resolve = resolve;
|
|
1242
|
+
operation(resolve, data);
|
|
1243
|
+
});
|
|
1244
|
+
if (this.abortController.signal.aborted) {
|
|
1245
|
+
commandFlow.dispatchEvent({ type: "executionInterrupt", index: i });
|
|
1246
|
+
this.dispatchEvent({ type: "executionInterrupt", name, index: i });
|
|
1247
|
+
this.dispatchEvent({ type: "cancel", name });
|
|
905
1248
|
break;
|
|
906
|
-
} else
|
|
907
|
-
|
|
1249
|
+
} else {
|
|
1250
|
+
commandFlow.dispatchEvent({ type: "executionCompleted", index: i, data });
|
|
1251
|
+
this.dispatchEvent({ type: "executionCompleted", name, index: i, data });
|
|
1252
|
+
}
|
|
908
1253
|
}
|
|
909
|
-
} catch (
|
|
910
|
-
console.error(
|
|
1254
|
+
} catch (error) {
|
|
1255
|
+
console.error(error);
|
|
911
1256
|
} finally {
|
|
912
|
-
this.abortController && !this.abortController.signal.aborted
|
|
1257
|
+
if (this.abortController && !this.abortController.signal.aborted) {
|
|
1258
|
+
commandFlow.dispatchEvent({ type: "completed", data });
|
|
1259
|
+
this.dispatchEvent({ type: "completed", name, data });
|
|
1260
|
+
}
|
|
1261
|
+
this.lock = false;
|
|
1262
|
+
this.abortController = null;
|
|
1263
|
+
this.currentName = null;
|
|
1264
|
+
commandFlow.dispatchEvent({ type: "finally" });
|
|
1265
|
+
this.dispatchEvent({ type: "finally", name });
|
|
1266
|
+
if (this.executionResolve) {
|
|
1267
|
+
this.executionResolve(null);
|
|
1268
|
+
this.executionResolve = null;
|
|
1269
|
+
}
|
|
913
1270
|
}
|
|
914
|
-
return
|
|
1271
|
+
return data;
|
|
915
1272
|
}
|
|
916
1273
|
/** 取消当前命令
|
|
917
1274
|
*/
|
|
918
1275
|
cancel() {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
*/
|
|
924
|
-
rollback() {
|
|
925
|
-
try {
|
|
926
|
-
const e = this.operationList.pop();
|
|
927
|
-
if (!e) return !1;
|
|
928
|
-
const t = this.commandFlowMap.get(e.name);
|
|
929
|
-
if (!t) return !1;
|
|
930
|
-
const n = t.rollbacklist.reduce((o, s) => s(o), e.data);
|
|
931
|
-
return this.dispatchEvent({ type: "rollback", name: e.name }), this.rollbackList.push({
|
|
932
|
-
data: n,
|
|
933
|
-
name: e.name
|
|
934
|
-
}), !0;
|
|
935
|
-
} catch (e) {
|
|
936
|
-
throw new Error(`回滚失败:${e}`);
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
/**
|
|
940
|
-
* 撤销回滚
|
|
941
|
-
*/
|
|
942
|
-
revokeRollback() {
|
|
943
|
-
try {
|
|
944
|
-
const e = this.rollbackList.pop();
|
|
945
|
-
if (!e) return !1;
|
|
946
|
-
const t = this.commandFlowMap.get(e.name);
|
|
947
|
-
if (!t) return !1;
|
|
948
|
-
const n = t.revokeRollbacklist.reduce((o, s) => s(o), e.data);
|
|
949
|
-
return this.dispatchEvent({ type: "revokeRollback", name: e.name }), this.operationList.push({ name: e.name, data: n }), !0;
|
|
950
|
-
} catch (e) {
|
|
951
|
-
throw new Error(`撤回回滚失败:${e}`);
|
|
1276
|
+
if (this.abortController) {
|
|
1277
|
+
this.abortController.abort();
|
|
1278
|
+
if (this.resolve) this.resolve();
|
|
1279
|
+
this.executionPromise = new Promise((resolve) => this.executionResolve = resolve);
|
|
952
1280
|
}
|
|
953
1281
|
}
|
|
954
1282
|
}
|
|
955
|
-
const
|
|
956
|
-
|
|
957
|
-
default: vn
|
|
958
|
-
}, Symbol.toStringTag, { value: "Module" })), gn = "data:image/svg+xml,%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20fill='%23555'%20width='16'%20height='16'%3e%3cpath%20d='M909.050991%20169.476903l-217.554898%200%200-31.346939c0-39.5866-32.205493-71.792093-71.793116-71.792093L408.15591%2066.337871c-39.5866%200-71.792093%2032.205493-71.792093%2071.792093l0%2031.346939L113.349581%20169.476903c-11.013845%200-19.942191%208.940626-19.942191%2019.954471s8.928347%2019.954471%2019.942191%2019.954471l84.264149%200%200%20640.687918c0%2060.479443%2049.203632%20109.683075%20109.683075%20109.683075l416.474366%200c60.479443%200%20109.683075-49.203632%20109.683075-109.683075L833.454246%20209.385844l75.595722%200c11.012821%200%2019.942191-8.940626%2019.942191-19.954471S920.063813%20169.476903%20909.050991%20169.476903zM376.2482%20138.130987c0-17.593703%2014.314007-31.907711%2031.907711-31.907711l211.547067%200c17.593703%200%2031.907711%2014.314007%2031.907711%2031.907711l0%2031.346939L376.2482%20169.477926%20376.2482%20138.130987zM793.569864%20850.074785c0%2038.486546-31.312146%2069.798692-69.798692%2069.798692L307.297828%20919.873478c-38.486546%200-69.798692-31.312146-69.798692-69.798692L237.499136%20211.042577l556.070728%200L793.569864%20850.074785zM510.662539%20861.276918c11.012821%200%2019.954471-8.92937%2019.954471-19.942191L530.61701%20294.912753c0-11.013845-8.94165-19.942191-19.954471-19.942191s-19.954471%208.928347-19.954471%2019.942191L490.708068%20841.334727C490.708068%20852.347548%20499.649717%20861.276918%20510.662539%20861.276918zM374.562814%20801.449321c11.012821%200%2019.954471-8.92937%2019.954471-19.942191L394.517285%20354.74035c0-11.013845-8.94165-19.942191-19.954471-19.942191s-19.954471%208.928347-19.954471%2019.942191l0%20426.76678C354.608344%20792.519951%20363.549993%20801.449321%20374.562814%20801.449321zM649.832182%20801.449321c11.012821%200%2019.954471-8.92937%2019.954471-19.942191L669.786653%20354.74035c0-11.013845-8.94165-19.942191-19.954471-19.942191s-19.954471%208.928347-19.954471%2019.942191l0%20426.76678C629.877711%20792.519951%20638.81936%20801.449321%20649.832182%20801.449321z'%20%3e%3c/path%3e%3c/svg%3e", yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
959
|
-
__proto__: null,
|
|
960
|
-
default: gn
|
|
961
|
-
}, Symbol.toStringTag, { value: "Module" })), wn = "data:image/svg+xml,%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20fill='%23555'%20width='16'%20height='16'%3e%3cpath%20d='M220.451548%20913.518482V318.145854c0-27.62038%2022.505495-50.125874%2050.125875-50.125874H865.95005c27.62038%200%2050.125874%2022.505495%2050.125874%2050.125874v218.917083h59.332667V318.145854c0-60.355644-49.102897-109.458541-109.458541-109.458541h-39.896104v-99.228772C826.053946%2049.102897%20776.951049%200%20716.595405%200H121.222777C60.867133%200%2011.764236%2049.102897%2011.764236%20109.458541V705.854146c0%2060.355644%2049.102897%20109.458541%20109.458541%20109.458541h39.896104v99.228772c0%2060.355644%2049.102897%20109.458541%20109.458542%20109.458541h257.790209v-59.332667H269.554446c-26.597403-1.022977-49.102897-23.528472-49.102898-51.148851z%20m-59.332667-595.372628v436.811189h-39.896104c-27.62038%200-50.125874-22.505495-50.125874-50.125874V109.458541c0-27.62038%2022.505495-50.125874%2050.125874-50.125874H716.595405c27.62038%200%2050.125874%2022.505495%2050.125874%2050.125874v99.228772H269.554446c-59.332667%200-108.435564%2049.102897-108.435565%20109.458541z'%20%3e%3c/path%3e%3cpath%20d='M902.777223%20854.185814l98.205794-98.205794c15.344655-15.344655%2015.344655-40.919081%200-56.263736s-40.919081-15.344655-56.263736%200L846.513487%20797.922078%20747.284715%20699.716284c-15.344655-15.344655-40.919081-15.344655-56.263736%200s-15.344655%2040.919081%200%2056.263736l98.205794%2098.205794-98.205794%2098.205794c-15.344655%2015.344655-15.344655%2040.919081%200%2056.263737s40.919081%2015.344655%2056.263736%200l98.205794-98.205795%2098.205795%2098.205795c15.344655%2015.344655%2040.919081%2015.344655%2056.263736%200s15.344655-40.919081%200-56.263737l-97.182817-98.205794z'%20%3e%3c/path%3e%3c/svg%3e", bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
962
|
-
__proto__: null,
|
|
963
|
-
default: wn
|
|
964
|
-
}, Symbol.toStringTag, { value: "Module" })), xn = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1757902601497'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='9801'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M761.344%20119.296H226.816c-18.944%200-39.424%2011.776-39.424%2030.72V921.6h614.4V148.48c0.512-18.944-22.016-29.184-40.448-29.184z%20m-537.6%20768c-2.048%200-2.048%200%200%200L221.696%20163.84c0-5.12%205.12-10.24%2010.24-10.24h522.24c8.704%200%2013.824%205.12%2013.824%2013.824v720.384s0%201.536-1.536%201.536h-15.36V194.56c0-16.896-8.704-24.064-29.184-24.064H266.24c-18.944%200-27.136%208.704-27.136%2024.064v692.736h-15.36z%20m49.152%200V204.8H716.8v682.496H272.896z'%20p-id='9802'%3e%3c/path%3e%3cpath%20d='M648.704%20508.416c-16.896%200-32.256%2013.824-32.256%2032.256%200%2016.896%2013.824%2032.256%2032.256%2032.256s32.256-13.824%2032.256-32.256c0-16.896-13.824-32.256-32.256-32.256z'%20p-id='9803'%3e%3c/path%3e%3c/svg%3e", Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
965
|
-
__proto__: null,
|
|
966
|
-
default: xn
|
|
967
|
-
}, Symbol.toStringTag, { value: "Module" })), Mn = "data:image/svg+xml,%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20fill='%23555'%20width='16'%20height='16'%3e%3cpath%20d='M491.80027198%20557.44938977c-10.0998647-15.14979706-20.19972802-25.24966037-35.34952507-35.34952507-15.14979706-10.0998647-30.29959271-15.14979706-50.49932211-15.14979704-55.54925309%200-100.99864286%2045.44938977-100.99864287%20100.99864285%200%2015.14979706%205.04993234%2035.34952507%2015.14979568%2050.49932212%2010.0998647%2015.14979706%2020.19972802%2030.29959271%2035.34952506%2035.34952508%2015.14979706%2010.0998647%2035.34952507%2015.14979706%2050.49932213%2015.14979567%2055.54925309%200%20100.99864286-45.44938977%20100.99864286-100.99864287%200-15.14979706-5.04993234-35.34952507-15.14979568-50.49932074z%20m-85.84884718%20100.99864286h-15.14979706c-20.19972802-5.04993234-30.29959271-20.19972802-35.34952507-35.34952507V612.99864286c0-30.29959271%2025.24966037-50.49932212%2050.49932213-50.49932074h10.09986469c15.14979706%205.04993234%2030.29959271%2015.14979706%2035.34952507%2035.34952507v15.14979567c5.04993234%2025.24966037-20.19972802%2045.44938977-45.44938976%2045.44938977z'%3e%3c/path%3e%3cpath%20d='M390.80162774%20658.44803263l-40.39945604%2040.39945743-227.24694747%20222.19701373-35.34952506-35.34952508%20227.24694745-227.24694608%2040.39945605-40.39945743c5.04993234%2020.19972802%2020.19972802%2035.34952507%2035.34952507%2040.39945743zM648.34816793%20405.9514248l-40.39945742%2040.3994574-116.14843853%20116.14843992-40.39945742%2035.34952507c-5.04993234-20.19972802-20.19972802-30.29959271-35.34952507-35.34952507l40.39945742-40.39945742%20116.14843853-111.09850756%2035.34952507-35.34952507c10.0998647%2015.14979706%2020.19972802%2025.24966037%2040.39945742%2030.29959273zM926.09443614%20133.25508894L749.34681078%20310.00271428l-40.3994574%2040.39945742c-5.04993234-20.19972802-15.14979706-35.34952507-30.29959272-40.39945742l35.34952506-40.39945742%20176.74762534-176.74762535%2035.34952508%2040.39945743z'%20%3e%3c/path%3e%3cpath%20d='M749.34681078%20310.00271428c-10.0998647-15.14979706-20.19972802-30.29959271-35.34952506-35.34952506-15.14979706-10.0998647-35.34952507-15.14979706-55.54925309-15.14979706-55.54925309%200-100.99864286%2045.44938977-100.99864286%20100.99864286%200%2020.19972802%205.04993234%2040.39945743%2015.14979567%2055.54925447%2010.0998647%2015.14979706%2020.19972802%2025.24966037%2035.34952507%2035.34952507%2015.14979706%2010.0998647%2030.29959271%2015.14979706%2050.49932212%2015.14979567%2055.54925309%200%20100.99864286-45.44938977%20100.99864286-100.99864286%200-25.24966037-5.04993234-40.39945743-10.09986471-55.54925309z%20m-90.89877815%2095.94871052h-10.0998647c-20.19972802-5.04993234-35.34952507-15.14979706-40.39945742-35.34952509%200-5.04993234-5.04993234-10.0998647-5.04993234-15.14979704%200-30.29959271%2025.24966037-50.49932212%2050.49932212-50.49932074%205.04993234%200%2010.0998647%200%2015.14979704%205.04993235%2015.14979706%205.04993234%2030.29959271%2020.19972802%2030.29959273%2040.39945742v10.09986332c10.0998647%2025.24966037-15.14979706%2045.44938977-40.39945743%2045.44938978z'%20%3e%3c/path%3e%3c/svg%3e", En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
968
|
-
__proto__: null,
|
|
969
|
-
default: Mn
|
|
970
|
-
}, Symbol.toStringTag, { value: "Module" })), Ln = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1757902422799'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='1735'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M843.2%20726.4c-20.2%200-39.2%205.2-55.8%2014.3L283.8%20237.2c9-16.5%2014.1-35.4%2014.1-55.5%200-64.2-52.3-116.5-116.5-116.5S65%20117.4%2065%20181.6s52.3%20116.5%20116.5%20116.5c20.2%200%2039.2-5.2%2055.8-14.2l503.5%20503.5c-9%2016.5-14.1%2035.4-14.1%2055.5%200%2064.2%2052.3%20116.5%20116.5%20116.5s116.5-52.3%20116.5-116.5-52.3-116.5-116.5-116.5zM181.4%20232.1c-27.8%200-50.5-22.6-50.5-50.5s22.6-50.5%2050.5-50.5%2050.5%2022.6%2050.5%2050.5-22.6%2050.5-50.5%2050.5z%20m661.8%20661.3c-27.8%200-50.5-22.6-50.5-50.5%200-27.8%2022.6-50.5%2050.5-50.5s50.5%2022.6%2050.5%2050.5c0%2027.8-22.7%2050.5-50.5%2050.5z'%20fill='%23231815'%20p-id='1736'%3e%3c/path%3e%3c/svg%3e", Dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1283
|
+
const door = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1757902601497'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='9801'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M761.344%20119.296H226.816c-18.944%200-39.424%2011.776-39.424%2030.72V921.6h614.4V148.48c0.512-18.944-22.016-29.184-40.448-29.184z%20m-537.6%20768c-2.048%200-2.048%200%200%200L221.696%20163.84c0-5.12%205.12-10.24%2010.24-10.24h522.24c8.704%200%2013.824%205.12%2013.824%2013.824v720.384s0%201.536-1.536%201.536h-15.36V194.56c0-16.896-8.704-24.064-29.184-24.064H266.24c-18.944%200-27.136%208.704-27.136%2024.064v692.736h-15.36z%20m49.152%200V204.8H716.8v682.496H272.896z'%20p-id='9802'%3e%3c/path%3e%3cpath%20d='M648.704%20508.416c-16.896%200-32.256%2013.824-32.256%2032.256%200%2016.896%2013.824%2032.256%2032.256%2032.256s32.256-13.824%2032.256-32.256c0-16.896-13.824-32.256-32.256-32.256z'%20p-id='9803'%3e%3c/path%3e%3c/svg%3e";
|
|
1284
|
+
const __vite_glob_0_0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
971
1285
|
__proto__: null,
|
|
972
|
-
default:
|
|
973
|
-
}, Symbol.toStringTag, { value: "Module" }))
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
}, Symbol.toStringTag, { value: "Module" })), Pn = "data:image/svg+xml,%3csvg%20viewBox='0%200%201029%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20fill='%23555'%20width='16'%20height='16'%3e%3cpath%20d='M788.17984%2016l-55.424%2060.672%20116.48%20106.56H418.13184a410.816%20410.816%200%201%200%200%20821.632h547.712v-82.176H418.13184a328.64%20328.64%200%200%201%200-657.28l441.792-0.128-124.8%2098.368%2050.752%2064.512%20243.328-191.488L788.17984%2016z'%3e%3c/path%3e%3c/svg%3e", In = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
977
|
-
__proto__: null,
|
|
978
|
-
default: Pn
|
|
979
|
-
}, Symbol.toStringTag, { value: "Module" })), Sn = "data:image/svg+xml,%3csvg%20viewBox='0%200%201048%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20fill='%23555'%20width='16'%20height='16'%3e%3cpath%20d='M310.04722%20451.334244A49.95122%2049.95122%200%200%201%20239.416195%20521.990244L27.473171%20310.04722a49.95122%2049.95122%200%200%201%200-70.631025L239.416195%2027.473171a49.95122%2049.95122%200%200%201%2070.631025%2070.631024l-126.651318%20126.626342L649.365854%20224.780488c220.709463%200%20399.609756%20178.900293%20399.609756%20399.609756s-178.900293%20399.609756-399.609756%20399.609756H124.878049a49.95122%2049.95122%200%201%201%200-99.902439h524.487805c165.513366%200%20299.707317-134.193951%20299.707317-299.707317s-134.193951-299.707317-299.707317-299.707317H183.395902l126.651318%20126.651317z'%3e%3c/path%3e%3c/svg%3e", Nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
980
|
-
__proto__: null,
|
|
981
|
-
default: Sn
|
|
982
|
-
}, Symbol.toStringTag, { value: "Module" })), On = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='11576'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='%23555'%20width='16'%20height='16'%3e%3cpath%20d='M102.4%20302.08c5.12%205.12%2015.36%2010.24%2025.6%2010.24s15.36-5.12%2025.6-10.24l174.08-174.08c5.12-5.12%2010.24-15.36%2010.24-25.6s-5.12-15.36-10.24-25.6c-20.48-5.12-40.96-5.12-51.2%2010.24l-148.48%20153.6-71.68-76.8C51.2%20158.72%2040.96%20158.72%2035.84%20158.72c-10.24%200-15.36%205.12-25.6%2010.24-5.12%205.12-10.24%2010.24-10.24%2020.48s5.12%2015.36%2010.24%2025.6L102.4%20302.08zM276.48%20409.6l-148.48%20153.6-71.68-71.68C51.2%20486.4%2040.96%20481.28%2035.84%20481.28c-10.24%200-15.36%205.12-25.6%2010.24-5.12%2010.24-10.24%2015.36-10.24%2025.6s5.12%2015.36%2010.24%2025.6L102.4%20629.76c5.12%205.12%2015.36%2010.24%2025.6%2010.24s15.36-5.12%2025.6-10.24L322.56%20460.8c5.12-5.12%2010.24-15.36%2010.24-25.6s-5.12-15.36-10.24-25.6c-10.24-10.24-30.72-10.24-46.08%200z%20m0%20327.68l-148.48%20153.6L56.32%20819.2c-5.12-5.12-15.36-10.24-25.6-10.24s-15.36%205.12-25.6%2010.24c0%205.12-5.12%2015.36-5.12%2025.6s5.12%2015.36%2010.24%2025.6L102.4%20957.44c5.12%205.12%2015.36%2010.24%2025.6%2010.24h5.12c10.24%200%2015.36-5.12%2025.6-10.24l174.08-174.08c5.12-5.12%2010.24-15.36%2010.24-25.6s-5.12-15.36-10.24-25.6c-25.6-5.12-40.96-5.12-56.32%205.12zM1024%20153.6c0%2030.72-25.6%2056.32-56.32%2056.32h-460.8c-30.72%200-61.44-25.6-61.44-56.32%200-30.72%2025.6-56.32%2056.32-56.32h455.68c35.84-5.12%2066.56%2020.48%2066.56%2056.32z%20m0%20358.4c0%2030.72-25.6%2056.32-56.32%2056.32h-460.8c-30.72%200-56.32-25.6-56.32-56.32s25.6-56.32%2056.32-56.32h455.68c35.84%200%2061.44%2025.6%2061.44%2056.32z%20m-5.12%20358.4c0%2030.72-25.6%2056.32-56.32%2056.32h-460.8c-30.72%200-56.32-25.6-56.32-56.32%200-30.72%2025.6-56.32%2056.32-56.32h455.68c35.84%200%2061.44%2025.6%2061.44%2056.32z%20m0%200'%20%3e%3c/path%3e%3c/svg%3e", Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
983
|
-
__proto__: null,
|
|
984
|
-
default: On
|
|
985
|
-
}, Symbol.toStringTag, { value: "Module" })), zn = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1757902488735'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='3957'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M520.416%20179.392c-12.384%200-22.4%204.672-22.4%2010.432l-0.032%20139.136c0%205.76%2010.016%2010.432%2022.368%2010.432%2012.352%200%2022.368-4.672%2022.368-10.432l0.064-139.136c0-5.76-10.016-10.432-22.4-10.432M520.32%20623.04c-12.352%200-22.368%204.64-22.368%2010.4l-0.032%20139.168c0%205.76%2010.016%2010.432%2022.368%2010.432%2012.352%200%2022.368-4.672%2022.368-10.432l0.064-139.168c0-5.76-10.016-10.4-22.4-10.4M800.256%20458.72l-139.168-0.064c-5.76%200-10.432%2010.016-10.432%2022.4%200%2012.352%204.672%2022.368%2010.432%2022.368l139.168%200.032c5.76%200%2010.4-10.016%2010.4-22.368%200-12.352-4.64-22.368-10.4-22.4zM352.256%20458.72l-139.168-0.064c-5.76%200-10.432%2010.016-10.432%2022.4%200%2012.352%204.672%2022.368%2010.432%2022.368l139.168%200.032c5.76%200%2010.4-10.016%2010.4-22.368%200-12.352-4.64-22.368-10.4-22.4M801.568%20748.672l-72.544-72.544%2073.792-23.2a4.416%204.416%200%200%200%200.096-8.384l-183.136-62.4a4.416%204.416%200%200%200-5.6%205.568l62.464%20183.168a4.416%204.416%200%200%200%208.352-0.064l23.36-73.6%2072.32%2072.32a14.752%2014.752%200%200%200%2020.896-20.864M510.688%20382.112c49.952%200%2092.8%2040.832%2092.8%2092.8%200%2051.968-42.848%2092.8-92.8%2092.8-49.984%200-92.8-40.832-92.8-92.8%200-51.968%2042.816-92.8%2092.8-92.8z'%20p-id='3958'%3e%3c/path%3e%3c/svg%3e", Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1286
|
+
default: door
|
|
1287
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1288
|
+
const line = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1757902422799'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='1735'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M843.2%20726.4c-20.2%200-39.2%205.2-55.8%2014.3L283.8%20237.2c9-16.5%2014.1-35.4%2014.1-55.5%200-64.2-52.3-116.5-116.5-116.5S65%20117.4%2065%20181.6s52.3%20116.5%20116.5%20116.5c20.2%200%2039.2-5.2%2055.8-14.2l503.5%20503.5c-9%2016.5-14.1%2035.4-14.1%2055.5%200%2064.2%2052.3%20116.5%20116.5%20116.5s116.5-52.3%20116.5-116.5-52.3-116.5-116.5-116.5zM181.4%20232.1c-27.8%200-50.5-22.6-50.5-50.5s22.6-50.5%2050.5-50.5%2050.5%2022.6%2050.5%2050.5-22.6%2050.5-50.5%2050.5z%20m661.8%20661.3c-27.8%200-50.5-22.6-50.5-50.5%200-27.8%2022.6-50.5%2050.5-50.5s50.5%2022.6%2050.5%2050.5c0%2027.8-22.7%2050.5-50.5%2050.5z'%20fill='%23231815'%20p-id='1736'%3e%3c/path%3e%3c/svg%3e";
|
|
1289
|
+
const __vite_glob_0_1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
986
1290
|
__proto__: null,
|
|
987
|
-
default:
|
|
988
|
-
}, Symbol.toStringTag, { value: "Module" }))
|
|
1291
|
+
default: line
|
|
1292
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1293
|
+
const selectPoint = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1757902488735'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='3957'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M520.416%20179.392c-12.384%200-22.4%204.672-22.4%2010.432l-0.032%20139.136c0%205.76%2010.016%2010.432%2022.368%2010.432%2012.352%200%2022.368-4.672%2022.368-10.432l0.064-139.136c0-5.76-10.016-10.432-22.4-10.432M520.32%20623.04c-12.352%200-22.368%204.64-22.368%2010.4l-0.032%20139.168c0%205.76%2010.016%2010.432%2022.368%2010.432%2012.352%200%2022.368-4.672%2022.368-10.432l0.064-139.168c0-5.76-10.016-10.4-22.4-10.4M800.256%20458.72l-139.168-0.064c-5.76%200-10.432%2010.016-10.432%2022.4%200%2012.352%204.672%2022.368%2010.432%2022.368l139.168%200.032c5.76%200%2010.4-10.016%2010.4-22.368%200-12.352-4.64-22.368-10.4-22.4zM352.256%20458.72l-139.168-0.064c-5.76%200-10.432%2010.016-10.432%2022.4%200%2012.352%204.672%2022.368%2010.432%2022.368l139.168%200.032c5.76%200%2010.4-10.016%2010.4-22.368%200-12.352-4.64-22.368-10.4-22.4M801.568%20748.672l-72.544-72.544%2073.792-23.2a4.416%204.416%200%200%200%200.096-8.384l-183.136-62.4a4.416%204.416%200%200%200-5.6%205.568l62.464%20183.168a4.416%204.416%200%200%200%208.352-0.064l23.36-73.6%2072.32%2072.32a14.752%2014.752%200%200%200%2020.896-20.864M510.688%20382.112c49.952%200%2092.8%2040.832%2092.8%2092.8%200%2051.968-42.848%2092.8-92.8%2092.8-49.984%200-92.8-40.832-92.8-92.8%200-51.968%2042.816-92.8%2092.8-92.8z'%20p-id='3958'%3e%3c/path%3e%3c/svg%3e";
|
|
1294
|
+
const __vite_glob_0_2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
989
1295
|
__proto__: null,
|
|
990
|
-
default:
|
|
991
|
-
}, Symbol.toStringTag, { value: "Module" }))
|
|
1296
|
+
default: selectPoint
|
|
1297
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1298
|
+
const window$1 = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1757902547951'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5129'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M59.355%2091.776v867.881h867.881V91.776H59.356zM897.31%20929.73H89.282V121.703h808.027V929.73z'%20fill=''%20p-id='5130'%3e%3c/path%3e%3cpath%20d='M833.964%20185.048H152.627v681.337h681.337V185.048z%20m-355.632%20651.41H182.554V532.2h295.778v304.257z%20m0-334.184H182.554V214.975h295.778v287.299z%20m325.705%20334.184H508.259V532.2h295.778v304.257z%20m0-334.184H508.259V214.975h295.778v287.299z'%20fill=''%20p-id='5131'%3e%3c/path%3e%3c/svg%3e";
|
|
1299
|
+
const __vite_glob_0_3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
992
1300
|
__proto__: null,
|
|
993
|
-
default:
|
|
1301
|
+
default: window$1
|
|
994
1302
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
995
|
-
class
|
|
1303
|
+
class RenderManager extends Component {
|
|
996
1304
|
static name = "RenderManager";
|
|
997
|
-
container = new
|
|
1305
|
+
container = new THREE.Group();
|
|
998
1306
|
lines = [];
|
|
999
|
-
pointVirtualGrid = new
|
|
1000
|
-
quadtree = new
|
|
1307
|
+
pointVirtualGrid = new PointVirtualGrid();
|
|
1308
|
+
quadtree = new Quadtree(new Box2());
|
|
1001
1309
|
actionHistory = /* @__PURE__ */ new Set();
|
|
1002
1310
|
onAddFromParent() {
|
|
1003
|
-
const
|
|
1004
|
-
this.editor.container.add(this.container)
|
|
1005
|
-
|
|
1311
|
+
const dxfLineModel = this.dxfLineModel;
|
|
1312
|
+
this.editor.container.add(this.container);
|
|
1313
|
+
this.editor.container.add(dxfLineModel.dxfModelGroup);
|
|
1314
|
+
dxfLineModel.dxfLineModel.material = new THREE.LineBasicMaterial({
|
|
1315
|
+
transparent: true,
|
|
1006
1316
|
opacity: 0.5,
|
|
1007
1317
|
color: 16777215
|
|
1008
|
-
})
|
|
1009
|
-
|
|
1010
|
-
|
|
1318
|
+
});
|
|
1319
|
+
dxfLineModel.addEventListener("modelUpdate", (e) => {
|
|
1320
|
+
e.model.position.z = 0;
|
|
1321
|
+
dxfLineModel.dxfDoorsLineModel.visible = false;
|
|
1322
|
+
});
|
|
1323
|
+
this.variable.addEventListener("dxfVisible", (e) => dxfLineModel.dxfModelGroup.visible = e.value);
|
|
1324
|
+
this.dxf.addEventListener("createGroup", () => this.reset());
|
|
1325
|
+
this.reset();
|
|
1011
1326
|
}
|
|
1012
1327
|
updatedMode = null;
|
|
1013
1328
|
/** 重新设置数据
|
|
@@ -1016,145 +1331,183 @@ class An extends ye {
|
|
|
1016
1331
|
if (this.updatedMode === "self") {
|
|
1017
1332
|
this.updatedMode = null;
|
|
1018
1333
|
return;
|
|
1019
|
-
} else
|
|
1334
|
+
} else {
|
|
1020
1335
|
this.updatedMode = "dxf";
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1336
|
+
}
|
|
1337
|
+
this.pointVirtualGrid = new PointVirtualGrid();
|
|
1338
|
+
const box = this.dxf.box.clone().expansion(Math.max(this.dxf.box.width, this.dxf.box.height) * 2);
|
|
1339
|
+
if (box.width === 0 || box.height === 0) box.set(-200, -200, 200, 200);
|
|
1340
|
+
this.quadtree = new Quadtree(box);
|
|
1341
|
+
this.lines.length = 0;
|
|
1342
|
+
this.dxf.lineSegments.forEach((line2) => {
|
|
1343
|
+
if (line2.userData.isDoor && !line2.userData.doorDirectConnection) return;
|
|
1344
|
+
this.addLine(line2.clone());
|
|
1345
|
+
});
|
|
1346
|
+
this.dxf.doorLineSegment.forEach((line2) => {
|
|
1347
|
+
const door2 = line2.clone();
|
|
1348
|
+
door2.userData = {
|
|
1349
|
+
isDoor: true,
|
|
1350
|
+
doorDirectConnection: true
|
|
1351
|
+
};
|
|
1352
|
+
this.addLine(door2);
|
|
1353
|
+
});
|
|
1354
|
+
this.draw();
|
|
1032
1355
|
}
|
|
1033
1356
|
/** 添加线段
|
|
1034
1357
|
* @param line
|
|
1035
1358
|
*/
|
|
1036
|
-
addLine(
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1359
|
+
addLine(line2) {
|
|
1360
|
+
if (!line2.userData) line2.userData = {};
|
|
1361
|
+
this.lines.push(line2);
|
|
1362
|
+
this.pointVirtualGrid.insert(line2.start, line2);
|
|
1363
|
+
this.pointVirtualGrid.insert(line2.end, line2);
|
|
1364
|
+
const quadtreeNode = {
|
|
1365
|
+
line: line2,
|
|
1040
1366
|
userData: void 0
|
|
1041
1367
|
};
|
|
1042
|
-
|
|
1368
|
+
line2.userData.quadtreeNode = quadtreeNode;
|
|
1369
|
+
this.quadtree.insert(quadtreeNode);
|
|
1370
|
+
this.actionHistory.add({
|
|
1043
1371
|
type: "addLine",
|
|
1044
|
-
data: [
|
|
1372
|
+
data: [line2]
|
|
1045
1373
|
});
|
|
1046
1374
|
}
|
|
1047
1375
|
/**
|
|
1048
1376
|
* 批量添加
|
|
1049
1377
|
* @param lines
|
|
1050
1378
|
*/
|
|
1051
|
-
addLines(
|
|
1052
|
-
for (let
|
|
1053
|
-
const
|
|
1054
|
-
this.lines.push(
|
|
1055
|
-
|
|
1056
|
-
|
|
1379
|
+
addLines(lines) {
|
|
1380
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1381
|
+
const line2 = lines[i];
|
|
1382
|
+
this.lines.push(line2);
|
|
1383
|
+
this.pointVirtualGrid.insert(line2.start, line2);
|
|
1384
|
+
this.pointVirtualGrid.insert(line2.end, line2);
|
|
1385
|
+
const quadtreeNode = {
|
|
1386
|
+
line: line2,
|
|
1057
1387
|
userData: void 0
|
|
1058
1388
|
};
|
|
1059
|
-
|
|
1389
|
+
line2.userData.quadtreeNode = quadtreeNode;
|
|
1390
|
+
this.quadtree.insert(quadtreeNode);
|
|
1060
1391
|
}
|
|
1061
1392
|
this.actionHistory.add({
|
|
1062
1393
|
type: "addLine",
|
|
1063
|
-
data: [...
|
|
1394
|
+
data: [...lines]
|
|
1064
1395
|
});
|
|
1065
1396
|
}
|
|
1066
1397
|
/** 移除线段
|
|
1067
1398
|
* @param line
|
|
1068
1399
|
*/
|
|
1069
|
-
removeLine(
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
this.
|
|
1400
|
+
removeLine(line2) {
|
|
1401
|
+
line2.userData.quadtreeNode && this.quadtree.remove(line2.userData.quadtreeNode);
|
|
1402
|
+
this.pointVirtualGrid.remove(line2.start);
|
|
1403
|
+
this.pointVirtualGrid.remove(line2.end);
|
|
1404
|
+
const index = this.lines.indexOf(line2);
|
|
1405
|
+
this.lines.splice(index, 1);
|
|
1406
|
+
this.draw();
|
|
1407
|
+
this.actionHistory.add({
|
|
1073
1408
|
type: "removeLine",
|
|
1074
|
-
data: [
|
|
1409
|
+
data: [line2]
|
|
1075
1410
|
});
|
|
1076
1411
|
}
|
|
1077
1412
|
/**
|
|
1078
1413
|
* 绘制
|
|
1079
1414
|
*/
|
|
1080
|
-
draw(
|
|
1415
|
+
draw(synchronize = true) {
|
|
1081
1416
|
this.container.clear();
|
|
1082
|
-
const
|
|
1083
|
-
this.lines.forEach((
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
const d = A.from(i), l = s.direction(), c = d.clone().add(l.clone().multiplyScalar(a * 0.5)), h = d.clone().add(l.clone().multiplyScalar(-a * 0.5));
|
|
1088
|
-
o.push(c.x, c.y, 1e-3), o.push(h.x, h.y, 1e-3);
|
|
1417
|
+
const position = [], doorPosition = [], windowPosition = [];
|
|
1418
|
+
this.lines.forEach((line2) => {
|
|
1419
|
+
line2.points.forEach((p) => {
|
|
1420
|
+
if (line2.userData.isDoor) doorPosition.push(p.x, p.y, 0);
|
|
1421
|
+
else position.push(p.x, p.y, 0);
|
|
1089
1422
|
});
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1423
|
+
if (line2.userData.isWindow && line2.userData.drawDoorData) {
|
|
1424
|
+
line2.userData.drawDoorData.forEach(({ width, p }) => {
|
|
1425
|
+
const center = Point.from(p), direction = line2.direction(), start = center.clone().add(direction.clone().multiplyScalar(width * 0.5)), end = center.clone().add(direction.clone().multiplyScalar(-width * 0.5));
|
|
1426
|
+
windowPosition.push(start.x, start.y, 1e-3);
|
|
1427
|
+
windowPosition.push(end.x, end.y, 1e-3);
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1431
|
+
position.length && this.renderer.createLineSegments({
|
|
1432
|
+
position
|
|
1433
|
+
}, position.length / 3, {
|
|
1093
1434
|
color: 5745151
|
|
1094
|
-
}, this.container)
|
|
1095
|
-
|
|
1096
|
-
|
|
1435
|
+
}, this.container);
|
|
1436
|
+
doorPosition.length && this.renderer.createLineSegments({
|
|
1437
|
+
position: doorPosition
|
|
1438
|
+
}, doorPosition.length / 3, {
|
|
1097
1439
|
color: 16776960
|
|
1098
|
-
}, this.container)
|
|
1099
|
-
|
|
1100
|
-
|
|
1440
|
+
}, this.container);
|
|
1441
|
+
windowPosition.length && this.renderer.createLineSegments({
|
|
1442
|
+
position: windowPosition
|
|
1443
|
+
}, windowPosition.length / 3, {
|
|
1101
1444
|
color: 16711935
|
|
1102
|
-
}, this.container)
|
|
1445
|
+
}, this.container);
|
|
1446
|
+
synchronize && this.synchronizeDxf();
|
|
1103
1447
|
}
|
|
1104
1448
|
/** 获取鼠标当前点, 吸附后的点
|
|
1105
1449
|
* @param point
|
|
1106
1450
|
* @returns
|
|
1107
1451
|
*/
|
|
1108
|
-
adsorption(
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1452
|
+
adsorption(radius = 0.1, pointVirtualGrid = this.pointVirtualGrid, quadtree = this.quadtree) {
|
|
1453
|
+
const editor = this.parent?.findComponentByName("Editor"), point = Point.from(editor.pointerPosition);
|
|
1454
|
+
const p = pointVirtualGrid.queryCircle(point, radius).sort((a, b) => a.point.distance(point) - b.point.distance(point));
|
|
1455
|
+
if (p.length) return {
|
|
1456
|
+
point: new THREE.Vector3(p[0].point.x, p[0].point.y, 0),
|
|
1457
|
+
find: true,
|
|
1113
1458
|
mode: "point",
|
|
1114
|
-
line:
|
|
1459
|
+
line: p[0].userData
|
|
1115
1460
|
};
|
|
1116
|
-
let
|
|
1117
|
-
if (
|
|
1118
|
-
let
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1461
|
+
let result = quadtree.queryCircle(point, radius);
|
|
1462
|
+
if (result.length) {
|
|
1463
|
+
let projectPoints = result.map((res) => res.line.projectPoint(point));
|
|
1464
|
+
projectPoints.sort((a, b) => {
|
|
1465
|
+
if (a && b) return a.distance(point) - b.distance(point);
|
|
1466
|
+
return 0;
|
|
1467
|
+
});
|
|
1468
|
+
result = result.filter((_, i) => !!projectPoints[i]);
|
|
1469
|
+
projectPoints = projectPoints.filter((_, i) => !!projectPoints[i]);
|
|
1470
|
+
return {
|
|
1471
|
+
point: new THREE.Vector3(projectPoints[0].x, projectPoints[0].y, 0),
|
|
1472
|
+
find: true,
|
|
1122
1473
|
mode: "line",
|
|
1123
|
-
line:
|
|
1474
|
+
line: result[0].line
|
|
1124
1475
|
};
|
|
1125
1476
|
}
|
|
1126
1477
|
return {
|
|
1127
|
-
point: new
|
|
1128
|
-
find:
|
|
1478
|
+
point: new THREE.Vector3(editor.pointerPosition.x, editor.pointerPosition.y, 0),
|
|
1479
|
+
find: false
|
|
1129
1480
|
};
|
|
1130
1481
|
}
|
|
1131
1482
|
/** 创建几何体
|
|
1132
1483
|
* @param rectangle
|
|
1133
1484
|
*/
|
|
1134
|
-
createGeometry(
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
})
|
|
1485
|
+
createGeometry(map, count) {
|
|
1486
|
+
const geometry = new THREE.BufferGeometry();
|
|
1487
|
+
Object.keys(map).forEach((k) => {
|
|
1488
|
+
geometry.setAttribute("position", new THREE.BufferAttribute(new Float32Array(map[k]), map[k].length / count));
|
|
1489
|
+
});
|
|
1490
|
+
return geometry;
|
|
1139
1491
|
}
|
|
1140
1492
|
/**
|
|
1141
1493
|
* 转为json
|
|
1142
1494
|
*/
|
|
1143
1495
|
toJson() {
|
|
1144
|
-
return this.lines.map((
|
|
1145
|
-
const
|
|
1496
|
+
return this.lines.map((line2) => {
|
|
1497
|
+
const userData = line2.userData;
|
|
1498
|
+
const drawDoorData = userData.drawDoorData;
|
|
1499
|
+
const insetionArr = this.quadtree.queryLineSegment(line2).filter((r) => r.line !== line2 && !r.userData?.isDoor).map((r) => ({ index: this.lines.indexOf(r.line) }));
|
|
1146
1500
|
return {
|
|
1147
|
-
start:
|
|
1148
|
-
end:
|
|
1149
|
-
insetionArr
|
|
1150
|
-
isDoor:
|
|
1151
|
-
doorDirectConnection:
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
full: s.full
|
|
1501
|
+
start: line2.start.toJson(),
|
|
1502
|
+
end: line2.end.toJson(),
|
|
1503
|
+
insetionArr,
|
|
1504
|
+
isDoor: userData.isDoor,
|
|
1505
|
+
doorDirectConnection: userData.isDoor,
|
|
1506
|
+
isWindow: userData.isWindow,
|
|
1507
|
+
drawDoorData: drawDoorData && drawDoorData.map((w) => ({
|
|
1508
|
+
p: { x: w.p.x, y: w.p.y, z: w.p.z },
|
|
1509
|
+
width: w.width,
|
|
1510
|
+
full: w.full
|
|
1158
1511
|
}))
|
|
1159
1512
|
};
|
|
1160
1513
|
});
|
|
@@ -1168,11 +1521,13 @@ class An extends ye {
|
|
|
1168
1521
|
this.updatedMode = null;
|
|
1169
1522
|
return;
|
|
1170
1523
|
}
|
|
1171
|
-
|
|
1524
|
+
if (this._timer) clearTimeout(this._timer);
|
|
1525
|
+
setTimeout(() => {
|
|
1172
1526
|
this.updatedMode = "self";
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1175
|
-
|
|
1527
|
+
const dxf = this.dxf;
|
|
1528
|
+
const json = this.toJson();
|
|
1529
|
+
dxf.set(json).then(() => {
|
|
1530
|
+
dxf.lineOffset();
|
|
1176
1531
|
});
|
|
1177
1532
|
}, 10);
|
|
1178
1533
|
}
|
|
@@ -1195,994 +1550,625 @@ class An extends ye {
|
|
|
1195
1550
|
return this.parent?.findComponentByName("DxfLineModel");
|
|
1196
1551
|
}
|
|
1197
1552
|
}
|
|
1198
|
-
class
|
|
1553
|
+
class DrawDoorLine extends CommandFlowComponent {
|
|
1199
1554
|
static name = "DrawDoorLine";
|
|
1200
|
-
container = new
|
|
1555
|
+
container = new THREE.Group();
|
|
1201
1556
|
interruptKeys = ["escape"];
|
|
1202
1557
|
shortcutKeys = ["control", "m"];
|
|
1203
1558
|
commandName = "draw-door-line";
|
|
1204
|
-
onAddFromParent(
|
|
1205
|
-
super.onAddFromParent(
|
|
1206
|
-
const
|
|
1559
|
+
onAddFromParent(parent) {
|
|
1560
|
+
super.onAddFromParent(parent);
|
|
1561
|
+
const editor = parent.findComponentByName("Editor"), eventInput = editor.eventInput, commandManager = editor.commandManager;
|
|
1207
1562
|
this.editor.container.add(this.container);
|
|
1208
|
-
const
|
|
1209
|
-
|
|
1210
|
-
|
|
1563
|
+
const commandFlow = this.commandManager.addCommandFlow("draw-door-line").add(this.createInterrupt()).add(this.createCursor("no-drop")).add(this.selectPoint.bind(this));
|
|
1564
|
+
eventInput.addKeyCombination(this.commandName, this.shortcutKeys);
|
|
1565
|
+
commandFlow.addEventListener("finally", this.createFinally());
|
|
1566
|
+
commandFlow.addEventListener("completed", (e) => this.completed(e.data));
|
|
1567
|
+
eventInput.addCancelDefaultBehavior(() => eventInput.isOnlyKeyDowns(this.shortcutKeys));
|
|
1568
|
+
eventInput.addEventListener("codeChange", async () => {
|
|
1569
|
+
eventInput.isKeyCombination(this.commandName) && await commandManager.start(this.commandName);
|
|
1211
1570
|
});
|
|
1212
1571
|
}
|
|
1213
1572
|
/** 选择点
|
|
1214
1573
|
* @param next
|
|
1215
1574
|
*/
|
|
1216
|
-
selectPoint(
|
|
1217
|
-
let
|
|
1218
|
-
new
|
|
1219
|
-
new
|
|
1220
|
-
new
|
|
1221
|
-
new
|
|
1575
|
+
selectPoint(next) {
|
|
1576
|
+
let editor = this.parent?.findComponentByName("Editor"), start = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 65280 })), line2 = new Lines([], 16711935), auxiliaryLine = new Lines([
|
|
1577
|
+
new THREE.Vector3(-1e4, 0, 0),
|
|
1578
|
+
new THREE.Vector3(1e4, 0, 0),
|
|
1579
|
+
new THREE.Vector3(0, -1e4, 0),
|
|
1580
|
+
new THREE.Vector3(0, 1e4, 0)
|
|
1222
1581
|
], 16711935);
|
|
1223
|
-
|
|
1582
|
+
auxiliaryLine.material = new THREE.LineDashedMaterial({
|
|
1224
1583
|
color: 4235007,
|
|
1225
1584
|
dashSize: 0.1,
|
|
1226
1585
|
gapSize: 0.1,
|
|
1227
1586
|
linewidth: 0.1
|
|
1228
|
-
})
|
|
1229
|
-
|
|
1587
|
+
});
|
|
1588
|
+
this.container.add(line2);
|
|
1589
|
+
let currentPoint = null;
|
|
1230
1590
|
this.addEventRecord(
|
|
1231
1591
|
"clear",
|
|
1232
|
-
|
|
1233
|
-
const { point
|
|
1234
|
-
|
|
1592
|
+
editor.addEventListener("pointerPositionChange", () => {
|
|
1593
|
+
const { point, find } = editor.renderManager.adsorption(0.05);
|
|
1594
|
+
start && line2.setPoint(start, point);
|
|
1595
|
+
if (find) {
|
|
1596
|
+
circle.position.set(point.x, point.y, 0);
|
|
1597
|
+
this.container.add(circle);
|
|
1598
|
+
this.domElement.style.cursor = "none";
|
|
1599
|
+
currentPoint = point.clone();
|
|
1600
|
+
} else {
|
|
1601
|
+
currentPoint = null;
|
|
1602
|
+
circle.removeFromParent();
|
|
1603
|
+
this.domElement.style.cursor = "no-drop";
|
|
1604
|
+
}
|
|
1235
1605
|
}),
|
|
1236
|
-
|
|
1237
|
-
if (
|
|
1238
|
-
if (!
|
|
1239
|
-
|
|
1606
|
+
editor.eventInput.addEventListener("codeChange", async () => {
|
|
1607
|
+
if (editor.eventInput.isKeyDown("mouse_0") && currentPoint) {
|
|
1608
|
+
if (!start) {
|
|
1609
|
+
start = currentPoint.clone();
|
|
1240
1610
|
return;
|
|
1241
1611
|
}
|
|
1242
|
-
|
|
1612
|
+
next([start.clone(), currentPoint.clone()]);
|
|
1243
1613
|
}
|
|
1244
1614
|
}),
|
|
1245
1615
|
function() {
|
|
1246
|
-
|
|
1616
|
+
line2.removeFromParent();
|
|
1617
|
+
circle.removeFromParent();
|
|
1618
|
+
auxiliaryLine.removeFromParent();
|
|
1247
1619
|
}
|
|
1248
1620
|
);
|
|
1249
1621
|
}
|
|
1250
|
-
/**
|
|
1251
|
-
* 结束处理
|
|
1252
|
-
* @param next
|
|
1253
|
-
* @param points
|
|
1254
|
-
*/
|
|
1255
|
-
end(e, t) {
|
|
1256
|
-
const n = [];
|
|
1257
|
-
for (let o = 0; o < t.length; o += 2) {
|
|
1258
|
-
const s = new ne(A.from(t[o]), A.from(t[o + 1]));
|
|
1259
|
-
s.userData.isDoor = !0, s.userData.doorDirectConnection = !0, n.push(s);
|
|
1260
|
-
}
|
|
1261
|
-
e(n);
|
|
1262
|
-
}
|
|
1263
1622
|
/** 执行完成
|
|
1264
1623
|
*/
|
|
1265
|
-
completed(
|
|
1266
|
-
this.
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
* @param lines
|
|
1276
|
-
* @returns
|
|
1277
|
-
*/
|
|
1278
|
-
revokeRollback(e) {
|
|
1279
|
-
return this.completed(e), e;
|
|
1624
|
+
completed(points) {
|
|
1625
|
+
const editor = this.editor, lines = [];
|
|
1626
|
+
for (let i = 0; i < points.length; i += 2) {
|
|
1627
|
+
const line2 = new LineSegment(Point.from(points[i]), Point.from(points[i + 1]));
|
|
1628
|
+
line2.userData.isDoor = true;
|
|
1629
|
+
line2.userData.doorDirectConnection = true;
|
|
1630
|
+
lines.push(line2);
|
|
1631
|
+
}
|
|
1632
|
+
editor.renderManager.addLines(lines);
|
|
1633
|
+
editor.renderManager.draw();
|
|
1280
1634
|
}
|
|
1281
1635
|
}
|
|
1282
|
-
class
|
|
1636
|
+
class DrawWindow extends CommandFlowComponent {
|
|
1283
1637
|
static name = "DrawWindow";
|
|
1284
|
-
container = new
|
|
1638
|
+
container = new THREE.Group();
|
|
1285
1639
|
interruptKeys = ["escape"];
|
|
1286
1640
|
shortcutKeys = ["control", "q"];
|
|
1287
1641
|
commandName = "draw-window-line";
|
|
1288
|
-
onAddFromParent(
|
|
1289
|
-
super.onAddFromParent(
|
|
1290
|
-
|
|
1291
|
-
|
|
1642
|
+
onAddFromParent(parent) {
|
|
1643
|
+
super.onAddFromParent(parent);
|
|
1644
|
+
this.editor.container.add(this.container);
|
|
1645
|
+
const commandFlow = this.commandManager.addCommandFlow(this.commandName).add(this.createInterrupt()).add(this.createCursor("no-drop")).add(this.selectPointStart.bind(this)).add(this.selectPointEnd.bind(this));
|
|
1646
|
+
commandFlow.addEventListener("finally", this.createFinally(["selectPointStart"]));
|
|
1647
|
+
commandFlow.addEventListener("completed", (e) => this.completed(e.data));
|
|
1648
|
+
this.eventInput.addKeyCombination(this.commandName, this.shortcutKeys);
|
|
1649
|
+
this.eventInput.addEventListener("codeChange", async () => this.eventInput.isKeyCombination(this.commandName) && await this.commandManager.start(this.commandName));
|
|
1650
|
+
this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
|
|
1292
1651
|
}
|
|
1293
1652
|
/** 选择开始点
|
|
1294
1653
|
* @param next
|
|
1295
1654
|
*/
|
|
1296
|
-
selectPointStart(
|
|
1297
|
-
let
|
|
1655
|
+
selectPointStart(next) {
|
|
1656
|
+
let currentPoint = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 16711935 })), currentLine = null;
|
|
1298
1657
|
this.addEventRecord("selectPointStart").add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
1299
|
-
const { point
|
|
1300
|
-
|
|
1658
|
+
const { point, line: line2, find } = this.editor.renderManager.adsorption();
|
|
1659
|
+
if (find) {
|
|
1660
|
+
this.domElement.style.cursor = "none";
|
|
1661
|
+
circle.position.copy(point);
|
|
1662
|
+
currentLine = line2;
|
|
1663
|
+
currentPoint = point.clone();
|
|
1664
|
+
this.container.add(circle);
|
|
1665
|
+
} else {
|
|
1666
|
+
this.domElement.style.cursor = "no-drop";
|
|
1667
|
+
currentPoint = null;
|
|
1668
|
+
circle.removeFromParent();
|
|
1669
|
+
}
|
|
1301
1670
|
})).add(this.eventInput.addEventListener("codeChange", () => {
|
|
1302
|
-
this.eventInput.isKeyDown("mouse_0") &&
|
|
1303
|
-
|
|
1671
|
+
if (this.eventInput.isKeyDown("mouse_0") && currentPoint) {
|
|
1672
|
+
this.canceEventRecord("selectPointStart");
|
|
1673
|
+
next({ point: currentPoint, line: currentLine });
|
|
1674
|
+
}
|
|
1675
|
+
}));
|
|
1676
|
+
this.addEventRecord("clear").add(() => circle.removeFromParent());
|
|
1304
1677
|
}
|
|
1305
1678
|
/** 选择结束点
|
|
1306
1679
|
* @param next
|
|
1307
1680
|
*/
|
|
1308
|
-
selectPointEnd(
|
|
1309
|
-
let
|
|
1310
|
-
this.addEventRecord("clear").add(() =>
|
|
1311
|
-
const { point:
|
|
1312
|
-
|
|
1681
|
+
selectPointEnd(next, { point, line: line2 }) {
|
|
1682
|
+
let currentPoint = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 16711935 }));
|
|
1683
|
+
this.addEventRecord("clear").add(() => circle.removeFromParent()).add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
1684
|
+
const { point: point2, find, line: l } = this.editor.renderManager.adsorption();
|
|
1685
|
+
if (find && l === line2) {
|
|
1686
|
+
this.domElement.style.cursor = "none";
|
|
1687
|
+
circle.position.copy(point2);
|
|
1688
|
+
currentPoint = point2.clone();
|
|
1689
|
+
this.container.add(circle);
|
|
1690
|
+
} else {
|
|
1691
|
+
this.domElement.style.cursor = "no-drop";
|
|
1692
|
+
currentPoint = null;
|
|
1693
|
+
circle.removeFromParent();
|
|
1694
|
+
}
|
|
1313
1695
|
})).add(this.eventInput.addEventListener("codeChange", () => {
|
|
1314
|
-
this.eventInput.isKeyDown("mouse_0") &&
|
|
1696
|
+
if (this.eventInput.isKeyDown("mouse_0") && currentPoint) next({ line: line2, start: point, end: currentPoint });
|
|
1315
1697
|
}));
|
|
1316
1698
|
}
|
|
1317
|
-
/**
|
|
1318
|
-
* 结束处理
|
|
1319
|
-
* @param next
|
|
1320
|
-
* @param points
|
|
1321
|
-
*/
|
|
1322
|
-
end(e, { start: t, end: n, line: o }) {
|
|
1323
|
-
const s = new ne(A.from(t), A.from(n)), a = s.center, i = s.length(), d = {
|
|
1324
|
-
p: new m.Vector3(a.x, a.y, 0),
|
|
1325
|
-
width: i,
|
|
1326
|
-
full: Math.abs(i - o.length()) < 0.01
|
|
1327
|
-
};
|
|
1328
|
-
e({ line: o, doorDataItem: d });
|
|
1329
|
-
}
|
|
1330
1699
|
/** 执行完成
|
|
1331
1700
|
*/
|
|
1332
|
-
completed(
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
if (n.userData.drawDoorData) {
|
|
1341
|
-
const o = n.userData.drawDoorData.indexOf(t);
|
|
1342
|
-
o !== -1 && (n.userData.drawDoorData.splice(o, 1), n.userData.drawDoorData.length === 0 && (delete n.userData.drawDoorData, delete n.userData.isWindow), this.renderManager.draw());
|
|
1343
|
-
}
|
|
1344
|
-
return e;
|
|
1345
|
-
}
|
|
1346
|
-
/** 撤回回滚
|
|
1347
|
-
* @param data
|
|
1348
|
-
* @returns
|
|
1349
|
-
*/
|
|
1350
|
-
revokeRollback(e) {
|
|
1351
|
-
return this.completed(e), e;
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
class ee extends T {
|
|
1355
|
-
static name = "VerticalCorrection";
|
|
1356
|
-
container = new m.Group();
|
|
1357
|
-
shortcutKeys = ["control", "c"];
|
|
1358
|
-
shortcutKeys2 = ["control", "shift", "c"];
|
|
1359
|
-
static commandName = "verticalCorrection";
|
|
1360
|
-
recursion = !1;
|
|
1361
|
-
onAddFromParent(e) {
|
|
1362
|
-
super.onAddFromParent(e), this.editor.container.add(this.container), this.container.position.z = 1e-3;
|
|
1363
|
-
const t = this.commandManager.addCommandFlow(ee.commandName).add(this.createInterrupt()).add(this.constraint.bind(this)).add(this.verticalCorrection.bind(this)).addRollback(this.rollback.bind(this)).addRevokeRollback(this.revokeRollback.bind(this));
|
|
1364
|
-
t.addEventListener("finally", this.createFinally()), t.addEventListener("completed", (n) => this.completed(n.data)), t.addEventListener("started", () => {
|
|
1365
|
-
!this.eventInput.isOnlyKeyDowns(this.shortcutKeys) && !this.eventInput.isOnlyKeyDowns(this.shortcutKeys2) && (this.recursion = !1);
|
|
1366
|
-
}), this.eventInput.addEventListener("codeChange", async () => {
|
|
1367
|
-
this.eventInput.isOnlyKeyDowns(this.shortcutKeys) ? (this.recursion = !1, this.commandManager.start(ee.commandName, [...this.default.selectLines])) : this.eventInput.isOnlyKeyDowns(this.shortcutKeys2) && (this.recursion = !0, this.commandManager.start(ee.commandName, [...this.default.selectLines]));
|
|
1368
|
-
}), this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys) || this.eventInput.isOnlyKeyDowns(this.shortcutKeys2));
|
|
1369
|
-
}
|
|
1370
|
-
/**
|
|
1371
|
-
* 进入命令约束
|
|
1372
|
-
*/
|
|
1373
|
-
constraint(e, t) {
|
|
1374
|
-
Array.isArray(t) ? t.length !== 1 ? (k({ message: "请选择一条线段", type: "warning" }), this.cancel()) : e(t) : (k({ message: "进入命令失败", type: "warning" }), this.cancel());
|
|
1375
|
-
}
|
|
1376
|
-
/**
|
|
1377
|
-
* 线段是否为结尾线段
|
|
1378
|
-
* @param line
|
|
1379
|
-
*/
|
|
1380
|
-
lineIsPathEnd(e) {
|
|
1381
|
-
for (let t = 0; t < e.points.length; t++) {
|
|
1382
|
-
const n = e.points[t];
|
|
1383
|
-
if (this.renderManager.pointVirtualGrid.queryPoint(n).filter((s) => !s.point.equal(n)).length === 0) return !0;
|
|
1384
|
-
}
|
|
1385
|
-
return !1;
|
|
1386
|
-
}
|
|
1387
|
-
/**
|
|
1388
|
-
*
|
|
1389
|
-
* @param line0
|
|
1390
|
-
* @param line1
|
|
1391
|
-
*/
|
|
1392
|
-
isTowLineSegmentConnect(e, t) {
|
|
1393
|
-
return !!(e.start.equal(t.start) || e.start.equal(t.end) || e.end.equal(t.start) || e.end.equal(t.end));
|
|
1394
|
-
}
|
|
1395
|
-
/**
|
|
1396
|
-
* 获取所有相同点的位置信息
|
|
1397
|
-
* @param point
|
|
1398
|
-
* @param point2
|
|
1399
|
-
*/
|
|
1400
|
-
getSamePointAll(e, t) {
|
|
1401
|
-
return this.renderManager.pointVirtualGrid.queryPoint(e).map((o) => {
|
|
1402
|
-
const s = {
|
|
1403
|
-
point: o.point,
|
|
1404
|
-
oldPoint: o.point.clone(),
|
|
1405
|
-
newPoint: t,
|
|
1406
|
-
line: o.userData
|
|
1407
|
-
};
|
|
1408
|
-
return o.point.copy(s.newPoint), s;
|
|
1701
|
+
completed(data) {
|
|
1702
|
+
const start = data.start, end = data.end, line2 = data.line, win = new LineSegment(Point.from(start), Point.from(end)), center = win.center, len = win.length();
|
|
1703
|
+
line2.userData.isWindow = true;
|
|
1704
|
+
if (!line2.userData.drawDoorData) line2.userData.drawDoorData = [];
|
|
1705
|
+
line2.userData.drawDoorData.push({
|
|
1706
|
+
p: new THREE.Vector3(center.x, center.y, 0),
|
|
1707
|
+
width: len,
|
|
1708
|
+
full: Math.abs(len - line2.length()) < 0.01
|
|
1409
1709
|
});
|
|
1410
|
-
|
|
1411
|
-
/** 修正
|
|
1412
|
-
* @param targettLine
|
|
1413
|
-
* @param vistedList
|
|
1414
|
-
*/
|
|
1415
|
-
correction0(e, t = [], n = /* @__PURE__ */ new Set()) {
|
|
1416
|
-
if (n.has(e)) return;
|
|
1417
|
-
n.add(e);
|
|
1418
|
-
const o = this.renderManager.quadtree.queryLineSegment(e).filter(({ line: a }) => !(a === e || a.userData.isDoor)).map((a) => a.line), s = e.direction();
|
|
1419
|
-
return o.forEach((a) => {
|
|
1420
|
-
if (n.has(a)) return !1;
|
|
1421
|
-
if (a.length() / e.length() > 1 && this.recursion) return;
|
|
1422
|
-
const i = a.direction(), d = s.angleBetween(i, "angle"), l = Math.abs(90 - d);
|
|
1423
|
-
if (!(l > 20 || l < 1))
|
|
1424
|
-
if (this.isTowLineSegmentConnect(e, a)) {
|
|
1425
|
-
const c = e.start.equal(a.start) || e.start.equal(a.end) ? e.start : e.end, h = a.start.equal(e.start) || a.start.equal(e.end) ? a.end : a.start, f = new ne(
|
|
1426
|
-
h.clone().add(s.clone().multiplyScalar(1)),
|
|
1427
|
-
h.clone().add(s.clone().multiplyScalar(-1))
|
|
1428
|
-
), g = f.projectPoint(c, !1);
|
|
1429
|
-
g && t.push(this.getSamePointAll(h, g));
|
|
1430
|
-
} else
|
|
1431
|
-
console.log("交点");
|
|
1432
|
-
}), this.recursion && o.forEach((a) => this.correction0(a, t, n)), t;
|
|
1433
|
-
}
|
|
1434
|
-
/** 修正2
|
|
1435
|
-
* 第一步:确定需要修复的线段
|
|
1436
|
-
* 第二步:查找与该线段相交的其他线段
|
|
1437
|
-
* 第三步:找出两端点相交的线段,其他为区间相交
|
|
1438
|
-
* 第四步:找出两端点相交的线段数量,大于2, 该点不能修
|
|
1439
|
-
* 第五步:修正
|
|
1440
|
-
* 第六步:修正同向线段
|
|
1441
|
-
* @param targettLine
|
|
1442
|
-
* @param vistedList
|
|
1443
|
-
*/
|
|
1444
|
-
correction(e, t = [], n = /* @__PURE__ */ new Set()) {
|
|
1445
|
-
if (n.has(e)) return;
|
|
1446
|
-
n.add(e);
|
|
1447
|
-
const o = this.renderManager.quadtree.queryLineSegment(e).filter(({ line: d }) => !(d === e || d.userData.isDoor)).map((d) => d.line);
|
|
1448
|
-
e.direction();
|
|
1449
|
-
const [s, a, i] = o.reduce((d, l) => {
|
|
1450
|
-
const [c, h, f] = d;
|
|
1451
|
-
return e.start.equal(l.start) || e.start.equal(l.end) ? c.push(l) : e.end.equal(l.start) || e.end.equal(l.end) ? h.push(l) : f.push(l), d;
|
|
1452
|
-
}, [[], [], []]);
|
|
1453
|
-
return s.length >= 2, console.log(s, a, i), t;
|
|
1454
|
-
}
|
|
1455
|
-
/** 开始
|
|
1456
|
-
* @param next
|
|
1457
|
-
*/
|
|
1458
|
-
verticalCorrection(e, t) {
|
|
1459
|
-
e(this.correction0(t[0]));
|
|
1460
|
-
}
|
|
1461
|
-
/** 执行完成
|
|
1462
|
-
* @param data
|
|
1463
|
-
*/
|
|
1464
|
-
completed(e) {
|
|
1465
|
-
e.forEach((t) => {
|
|
1466
|
-
t.forEach((n) => {
|
|
1467
|
-
const { line: o, newPoint: s, point: a } = n;
|
|
1468
|
-
a.copy(s), this.renderManager.removeLine(o), this.renderManager.addLine(o);
|
|
1469
|
-
});
|
|
1470
|
-
}), this.renderManager.draw();
|
|
1471
|
-
}
|
|
1472
|
-
/** 回滚操作
|
|
1473
|
-
* @param data
|
|
1474
|
-
*/
|
|
1475
|
-
rollback(e) {
|
|
1476
|
-
return e.forEach((t) => {
|
|
1477
|
-
t.forEach((n) => {
|
|
1478
|
-
const { line: o, oldPoint: s, point: a } = n;
|
|
1479
|
-
a.copy(s), this.renderManager.removeLine(o), this.renderManager.addLine(o);
|
|
1480
|
-
});
|
|
1481
|
-
}), this.renderManager.draw(), e;
|
|
1482
|
-
}
|
|
1483
|
-
/** 撤回回滚
|
|
1484
|
-
* @param lines
|
|
1485
|
-
* @returns
|
|
1486
|
-
*/
|
|
1487
|
-
revokeRollback(e) {
|
|
1488
|
-
return this.completed(e), e;
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
class H extends T {
|
|
1492
|
-
static name = "MergeLine";
|
|
1493
|
-
shortcutKeys = ["control", "g"];
|
|
1494
|
-
static commandName = "merge-line";
|
|
1495
|
-
onAddFromParent(e) {
|
|
1496
|
-
super.onAddFromParent(e);
|
|
1497
|
-
const t = e.findComponentByType(ke), n = this.commandManager.addCommandFlow(H.commandName).add(this.createInterrupt()).add(this.constraint.bind(this)).add(this.mergeLine.bind(this)).addRollback(this.rollback.bind(this)).addRevokeRollback(this.revokeRollback.bind(this));
|
|
1498
|
-
n.addEventListener("finally", this.createFinally()), n.addEventListener("completed", (o) => this.completed(o.data)), this.eventInput.addKeyCombination(H.commandName, this.shortcutKeys), this.eventInput.addEventListener("codeChange", async () => {
|
|
1499
|
-
t?.selectLines.length === 2 && this.eventInput.isKeyCombination(H.commandName) && await this.commandManager.start(H.commandName, [...this.default.selectLines]);
|
|
1500
|
-
}), this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
|
|
1501
|
-
}
|
|
1502
|
-
/**
|
|
1503
|
-
* 进入命令约束
|
|
1504
|
-
*/
|
|
1505
|
-
constraint(e, t) {
|
|
1506
|
-
Array.isArray(t) ? t.length !== 2 ? (k({ message: "未执行线段合并,请选择两条线段", type: "warning" }), this.cancel()) : e(t) : (k({ message: "进入命令失败", type: "warning" }), this.cancel());
|
|
1507
|
-
}
|
|
1508
|
-
/** 开始
|
|
1509
|
-
* @param next
|
|
1510
|
-
* @todo 合并所有
|
|
1511
|
-
*/
|
|
1512
|
-
mergeLine(e, t) {
|
|
1513
|
-
const n = t[0], o = t[1];
|
|
1514
|
-
for (let s = 0; s < n.points.length; s++) {
|
|
1515
|
-
const a = n.points[s];
|
|
1516
|
-
for (let i = 0; i < o.points.length; i++) {
|
|
1517
|
-
const d = o.points[i];
|
|
1518
|
-
if (a.equal(d)) {
|
|
1519
|
-
const l = n.points[(s + 1) % 2], c = o.points[(i + 1) % 2], h = new ne(l, c);
|
|
1520
|
-
return e({ line1: n, line2: o, newLine: h }), k({ message: "已合并", type: "success" });
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
k({ message: "合并失败,两条线未找到共用点", type: "warning" }), this.commandManager.cancel();
|
|
1525
|
-
}
|
|
1526
|
-
/** 执行完成
|
|
1527
|
-
* @param data
|
|
1528
|
-
*/
|
|
1529
|
-
completed(e) {
|
|
1530
|
-
this.renderManager.removeLine(e.line1), this.renderManager.removeLine(e.line2), this.renderManager.addLine(e.newLine), this.renderManager.draw();
|
|
1531
|
-
}
|
|
1532
|
-
/** 回滚操作
|
|
1533
|
-
* @param data
|
|
1534
|
-
*/
|
|
1535
|
-
rollback(e) {
|
|
1536
|
-
return this.renderManager.addLines([e.line1, e.line2]), this.renderManager.removeLine(e.newLine), this.renderManager.draw(), e;
|
|
1537
|
-
}
|
|
1538
|
-
/** 撤回回滚
|
|
1539
|
-
* @param lines
|
|
1540
|
-
* @returns
|
|
1541
|
-
*/
|
|
1542
|
-
revokeRollback(e) {
|
|
1543
|
-
return this.completed(e), e;
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
class W extends T {
|
|
1547
|
-
static name = "DeleteSelectLine";
|
|
1548
|
-
shortcutKeys = ["Delete"];
|
|
1549
|
-
static commandName = "deleteSelectLine";
|
|
1550
|
-
onAddFromParent(e) {
|
|
1551
|
-
super.onAddFromParent(e), this.commandManager.addCommandFlow(W.commandName).add(this.createInterrupt()).add(this.constraint.bind(this)).add(this.delete.bind(this)).addRollback(this.rollback.bind(this)).addRevokeRollback(this.revokeRollback.bind(this)).addEventListener("finally", this.createFinally()), this.eventInput.addKeyCombination(W.commandName, this.shortcutKeys), this.eventInput.addEventListener("codeChange", async () => {
|
|
1552
|
-
this.eventInput.isKeyCombination(W.commandName) && await this.commandManager.start(W.commandName, [...this.default.selectLines]);
|
|
1553
|
-
}), this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
|
|
1554
|
-
}
|
|
1555
|
-
/**
|
|
1556
|
-
* 进入命令约束
|
|
1557
|
-
*/
|
|
1558
|
-
constraint(e, t) {
|
|
1559
|
-
Array.isArray(t) ? e(t) : (k({ message: "请选择线段", type: "warning" }), this.cancel());
|
|
1560
|
-
}
|
|
1561
|
-
/** 开始
|
|
1562
|
-
* @param next
|
|
1563
|
-
*/
|
|
1564
|
-
delete(e, t) {
|
|
1565
|
-
t.forEach((n) => this.renderManager.removeLine(n)), k({ message: "删除成功", type: "success" }), e(t);
|
|
1566
|
-
}
|
|
1567
|
-
/** 回滚操作
|
|
1568
|
-
* @param data
|
|
1569
|
-
*/
|
|
1570
|
-
rollback(e) {
|
|
1571
|
-
return this.renderManager.addLines(e), this.renderManager.draw(), e;
|
|
1572
|
-
}
|
|
1573
|
-
/** 撤回回滚
|
|
1574
|
-
* @param lines
|
|
1575
|
-
* @returns
|
|
1576
|
-
*/
|
|
1577
|
-
revokeRollback(e) {
|
|
1578
|
-
return e.forEach((t) => this.renderManager.removeLine(t)), e;
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
class U extends T {
|
|
1582
|
-
static name = "ConnectionLine";
|
|
1583
|
-
shortcutKeys = ["Shift", "L"];
|
|
1584
|
-
static commandName = "connectionLine";
|
|
1585
|
-
onAddFromParent(e) {
|
|
1586
|
-
super.onAddFromParent(e);
|
|
1587
|
-
const t = this.commandManager.addCommandFlow(U.commandName).add(this.createInterrupt()).add(this.constraint.bind(this)).add(this.connection.bind(this)).addRollback(this.rollback.bind(this)).addRevokeRollback(this.revokeRollback.bind(this));
|
|
1588
|
-
t.addEventListener("finally", this.createFinally()), t.addEventListener("completed", (n) => this.completed(n.data)), this.eventInput.addKeyCombination(U.commandName, this.shortcutKeys), this.eventInput.addEventListener("codeChange", async () => {
|
|
1589
|
-
this.eventInput.isKeyCombination(U.commandName) && await this.commandManager.start(U.commandName, [...this.default.selectLines]);
|
|
1590
|
-
}), this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
|
|
1591
|
-
}
|
|
1592
|
-
/**
|
|
1593
|
-
* 进入命令约束
|
|
1594
|
-
*/
|
|
1595
|
-
constraint(e, t) {
|
|
1596
|
-
Array.isArray(t) ? t.length !== 2 ? (k({ message: "请选择2条线段", type: "warning" }), this.cancel()) : e(t) : (k({ message: "进入命令失败", type: "warning" }), this.cancel());
|
|
1597
|
-
}
|
|
1598
|
-
/** 连接
|
|
1599
|
-
* @param next
|
|
1600
|
-
*/
|
|
1601
|
-
connection(e, t) {
|
|
1602
|
-
let n, o, s = 1 / 0;
|
|
1603
|
-
for (let a = 0; a < 2; a++)
|
|
1604
|
-
for (let i = 0; i < 2; i++) {
|
|
1605
|
-
const d = t[0].points[a], l = t[1].points[i], c = d.distance(l);
|
|
1606
|
-
c < s && (n = d, o = l, s = c);
|
|
1607
|
-
}
|
|
1608
|
-
if (n && o) {
|
|
1609
|
-
const a = new ne(n.clone(), o.clone());
|
|
1610
|
-
e(a), k({ message: "连接成功", type: "success" });
|
|
1611
|
-
} else this.cancel();
|
|
1612
|
-
}
|
|
1613
|
-
/** 成功
|
|
1614
|
-
* @param next
|
|
1615
|
-
* @param selectLines
|
|
1616
|
-
*/
|
|
1617
|
-
completed(e) {
|
|
1618
|
-
this.renderManager.addLine(e), this.renderManager.draw();
|
|
1619
|
-
}
|
|
1620
|
-
/** 回滚操作
|
|
1621
|
-
* @param data
|
|
1622
|
-
*/
|
|
1623
|
-
rollback(e) {
|
|
1624
|
-
return this.renderManager.removeLine(e), e;
|
|
1625
|
-
}
|
|
1626
|
-
/** 撤回回滚
|
|
1627
|
-
* @param lines
|
|
1628
|
-
* @returns
|
|
1629
|
-
*/
|
|
1630
|
-
revokeRollback(e) {
|
|
1631
|
-
return this.completed(e), e;
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
class Q extends T {
|
|
1635
|
-
static name = "IntersectionConnectionLine";
|
|
1636
|
-
shortcutKeys = ["control", "Shift", "L"];
|
|
1637
|
-
static commandName = "intersectionConnectionLine";
|
|
1638
|
-
onAddFromParent(e) {
|
|
1639
|
-
super.onAddFromParent(e);
|
|
1640
|
-
const t = this.commandManager.addCommandFlow(Q.commandName).add(this.createInterrupt()).add(this.constraint.bind(this)).add(this.connection.bind(this)).addRollback(this.rollback.bind(this)).addRevokeRollback(this.revokeRollback.bind(this));
|
|
1641
|
-
t.addEventListener("finally", this.createFinally()), t.addEventListener("completed", (n) => this.completed(n.data)), this.eventInput.addKeyCombination(Q.commandName, this.shortcutKeys), this.eventInput.addEventListener("codeChange", async () => {
|
|
1642
|
-
this.eventInput.isKeyCombination(Q.commandName) && await this.commandManager.start(Q.commandName, [...this.default.selectLines]);
|
|
1643
|
-
}), this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
|
|
1644
|
-
}
|
|
1645
|
-
/**
|
|
1646
|
-
* 进入命令约束
|
|
1647
|
-
*/
|
|
1648
|
-
constraint(e, t) {
|
|
1649
|
-
Array.isArray(t) ? t.length !== 2 ? (k({ message: "请选择2条线段", type: "warning" }), this.cancel()) : e(t) : (k({ message: "进入命令失败", type: "warning" }), this.cancel());
|
|
1650
|
-
}
|
|
1651
|
-
/** 开始
|
|
1652
|
-
* @param next
|
|
1653
|
-
*/
|
|
1654
|
-
connection(e, t) {
|
|
1655
|
-
const n = t[0], o = t[1], s = t[0].getIntersection(t[1]);
|
|
1656
|
-
if (!s) return;
|
|
1657
|
-
const a = n.points.map((c) => c.clone()), i = o.points.map((c) => c.clone());
|
|
1658
|
-
n.start.distance(s) < n.end.distance(s) ? n.start.copy(s) : n.end.copy(s), o.start.distance(s) < o.end.distance(s) ? o.start.copy(s) : o.end.copy(s);
|
|
1659
|
-
const d = n.points.map((c) => c.clone()), l = o.points.map((c) => c.clone());
|
|
1660
|
-
e({ line1: n, line2: o, oldLine1: a, oldLine2: i, newLine1: d, newLine2: l }), k({ message: "连接成功", type: "success" });
|
|
1661
|
-
}
|
|
1662
|
-
/** 执行完成
|
|
1663
|
-
* @param next
|
|
1664
|
-
* @param selectLines
|
|
1665
|
-
*/
|
|
1666
|
-
completed({ line1: e, line2: t, newLine1: n, newLine2: o }) {
|
|
1667
|
-
this.renderManager.removeLine(e), this.renderManager.removeLine(t), e.set(...n), t.set(...o), this.renderManager.addLines([e, t]), this.renderManager.draw();
|
|
1668
|
-
}
|
|
1669
|
-
/** 回滚操作
|
|
1670
|
-
* @param data
|
|
1671
|
-
*/
|
|
1672
|
-
rollback(e) {
|
|
1673
|
-
const { line1: t, line2: n, oldLine1: o, oldLine2: s } = e;
|
|
1674
|
-
return this.renderManager.removeLine(t), this.renderManager.removeLine(n), t.set(...o), n.set(...s), this.renderManager.addLines([t, n]), this.renderManager.draw(), e;
|
|
1675
|
-
}
|
|
1676
|
-
/** 撤回回滚
|
|
1677
|
-
* @param lines
|
|
1678
|
-
* @returns
|
|
1679
|
-
*/
|
|
1680
|
-
revokeRollback(e) {
|
|
1681
|
-
return this.completed(e), e;
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
class Y extends T {
|
|
1685
|
-
static name = "DeleteSelectWindow";
|
|
1686
|
-
shortcutKeys = ["Q", "Delete"];
|
|
1687
|
-
static commandName = "deleteSelectWindow";
|
|
1688
|
-
onAddFromParent(e) {
|
|
1689
|
-
super.onAddFromParent(e);
|
|
1690
|
-
const t = this.commandManager.addCommandFlow(Y.commandName).add(this.createInterrupt()).add(this.constraint.bind(this)).add(this.end.bind(this)).addRollback(this.rollback.bind(this)).addRevokeRollback(this.revokeRollback.bind(this));
|
|
1691
|
-
t.addEventListener("finally", this.createFinally()), t.addEventListener("completed", (n) => this.completed(n.data)), this.eventInput.addKeyCombination(Y.commandName, this.shortcutKeys), this.eventInput.addEventListener("codeChange", async () => {
|
|
1692
|
-
this.eventInput.isKeyCombination(Y.commandName) && await this.commandManager.start(Y.commandName, [...this.default.selectLines]);
|
|
1693
|
-
}), this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
|
|
1694
|
-
}
|
|
1695
|
-
/**
|
|
1696
|
-
* 进入命令约束
|
|
1697
|
-
*/
|
|
1698
|
-
constraint(e, t) {
|
|
1699
|
-
Array.isArray(t) ? t.some((n) => n.userData.isWindow) ? e(t) : (k({ message: "请选择有窗户线段", type: "warning" }), this.cancel()) : (k({ message: "进入命令失败", type: "warning" }), this.cancel());
|
|
1700
|
-
}
|
|
1701
|
-
/** 开始
|
|
1702
|
-
* @param next
|
|
1703
|
-
*/
|
|
1704
|
-
end(e, t) {
|
|
1705
|
-
let n = !1, o = [];
|
|
1706
|
-
t.forEach((s) => {
|
|
1707
|
-
s.userData.isWindow && (o.push({
|
|
1708
|
-
line: s,
|
|
1709
|
-
drawDoorData: s.userData.drawDoorData
|
|
1710
|
-
}), n = !0);
|
|
1711
|
-
}), n && k({ message: "删除窗户成功", type: "success" }), e(o);
|
|
1712
|
-
}
|
|
1713
|
-
/**
|
|
1714
|
-
* 完成
|
|
1715
|
-
* @param list
|
|
1716
|
-
*/
|
|
1717
|
-
completed(e) {
|
|
1718
|
-
e.forEach((t) => {
|
|
1719
|
-
const n = t.line.userData;
|
|
1720
|
-
n && (delete n.isWindow, delete n.drawDoorData);
|
|
1721
|
-
}), this.renderManager.draw();
|
|
1722
|
-
}
|
|
1723
|
-
/** 回滚操作
|
|
1724
|
-
* @param data
|
|
1725
|
-
*/
|
|
1726
|
-
rollback(e) {
|
|
1727
|
-
return e.forEach((t) => {
|
|
1728
|
-
t.line.userData || (t.line.userData = {});
|
|
1729
|
-
const n = t.line.userData;
|
|
1730
|
-
n.isWindow = !0, n.drawDoorData = t.drawDoorData;
|
|
1731
|
-
}), this.renderManager.draw(), e;
|
|
1732
|
-
}
|
|
1733
|
-
/** 撤回回滚
|
|
1734
|
-
* @param lines
|
|
1735
|
-
* @returns
|
|
1736
|
-
*/
|
|
1737
|
-
revokeRollback(e) {
|
|
1738
|
-
return this.completed(e), e;
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
class Z extends T {
|
|
1742
|
-
static name = "SelectAll";
|
|
1743
|
-
container = new m.Group();
|
|
1744
|
-
shortcutKeys = ["control", "a"];
|
|
1745
|
-
static commandName = "selectAll";
|
|
1746
|
-
onAddFromParent(e) {
|
|
1747
|
-
super.onAddFromParent(e), this.editor.container.add(this.container), this.container.position.z = 1e-3;
|
|
1748
|
-
const t = this.commandManager.addCommandFlow(Z.commandName).add(this.createInterrupt()).add(this.selectAll.bind(this)).addRollback(this.rollback.bind(this)).addRevokeRollback(this.revokeRollback.bind(this));
|
|
1749
|
-
t.writeOperationList = !1, t.addEventListener("finally", this.createFinally()), t.addEventListener("completed", (n) => this.completed(n.data)), this.eventInput.addKeyCombination(Z.commandName, this.shortcutKeys), this.eventInput.addEventListener("codeChange", async () => {
|
|
1750
|
-
this.eventInput.isKeyCombination(Z.commandName) && await this.commandManager.start(Z.commandName);
|
|
1751
|
-
}), this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
|
|
1752
|
-
}
|
|
1753
|
-
/** 开始
|
|
1754
|
-
* @param next
|
|
1755
|
-
*/
|
|
1756
|
-
selectAll(e) {
|
|
1757
|
-
e([...this.renderManager.lines]);
|
|
1758
|
-
}
|
|
1759
|
-
/** 执行完成
|
|
1760
|
-
*/
|
|
1761
|
-
completed(e) {
|
|
1762
|
-
e.map((t) => this.default.addSelectLine(t));
|
|
1763
|
-
}
|
|
1764
|
-
/** 回滚操作
|
|
1765
|
-
* @param lines
|
|
1766
|
-
*/
|
|
1767
|
-
rollback(e) {
|
|
1768
|
-
return e.map((t) => this.default.removeSelectLine(t)), e;
|
|
1769
|
-
}
|
|
1770
|
-
/** 撤回回滚
|
|
1771
|
-
* @param lines
|
|
1772
|
-
* @returns
|
|
1773
|
-
*/
|
|
1774
|
-
revokeRollback(e) {
|
|
1775
|
-
return this.completed(e), e;
|
|
1710
|
+
this.renderManager.draw();
|
|
1776
1711
|
}
|
|
1777
1712
|
}
|
|
1778
|
-
const
|
|
1713
|
+
const _hoisted_1 = {
|
|
1779
1714
|
key: 0,
|
|
1780
1715
|
class: "mt-[5px] text-[#ccc] text-[11px] absolute left-[10px] bottom-[10px] rounded-[8px] min-w-[150px] bg-black/15 p-[10px]"
|
|
1781
|
-
}
|
|
1716
|
+
};
|
|
1717
|
+
const _hoisted_2 = { class: "text-start max-w-[150px]" };
|
|
1718
|
+
const _hoisted_3 = { class: "inline-block ml-[10px] text-[var(--color-primary)]" };
|
|
1719
|
+
const _hoisted_4 = {
|
|
1782
1720
|
key: 0,
|
|
1783
|
-
class: "p-[5px]
|
|
1784
|
-
}
|
|
1721
|
+
class: "p-[5px] min-w-[140px]"
|
|
1722
|
+
};
|
|
1723
|
+
const _hoisted_5 = { class: "text-[14px] flex flex-col" };
|
|
1724
|
+
const _hoisted_6 = ["onClick"];
|
|
1725
|
+
const _hoisted_7 = { class: "flex flex-row items-center" };
|
|
1726
|
+
const _hoisted_8 = { class: "flex justify-center items-center size-[20px] bg-[#f0f0f0] rounded-[2px] mr-[10px]" };
|
|
1727
|
+
const _hoisted_9 = ["src"];
|
|
1728
|
+
const _hoisted_10 = {
|
|
1785
1729
|
key: 1,
|
|
1786
1730
|
class: "text-[#999]"
|
|
1787
|
-
}
|
|
1731
|
+
};
|
|
1732
|
+
const _hoisted_11 = {
|
|
1788
1733
|
style: { "--el-color-primary": "var(--primary-color)" },
|
|
1789
1734
|
class: "flex flex-row items-center justify-between gap-[10px] mt-[10px] text-[10px]"
|
|
1790
|
-
}
|
|
1735
|
+
};
|
|
1736
|
+
const _hoisted_12 = {
|
|
1791
1737
|
key: 0,
|
|
1792
1738
|
class: "flex flex-row items-center flex-wrap justify-between gap-[10px] mt-[10px] text-[10px]"
|
|
1793
|
-
}
|
|
1739
|
+
};
|
|
1740
|
+
const _hoisted_13 = { class: "border-t-1 border-t-[#eee] mt-[5px] pt-[5px] h-[20px] flex items-center gap-[10px]" };
|
|
1741
|
+
const _hoisted_14 = {
|
|
1742
|
+
key: 1,
|
|
1743
|
+
class: "select-none flex-1 flex justify-center text-[12px] text-[#999]"
|
|
1744
|
+
};
|
|
1745
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1794
1746
|
__name: "EditorTool",
|
|
1795
1747
|
props: {
|
|
1796
1748
|
dxfSystem: {},
|
|
1797
1749
|
permission: {}
|
|
1798
1750
|
},
|
|
1799
|
-
setup(
|
|
1800
|
-
function
|
|
1801
|
-
const
|
|
1802
|
-
|
|
1751
|
+
setup(__props) {
|
|
1752
|
+
function setEditorToolPosition(left, top, rect = elRef.value.getBoundingClientRect(), toolBarRect = toolBarRef.value.getBoundingClientRect()) {
|
|
1753
|
+
const minX = 0, maxX = rect.width - toolBarRect.width, minY = 0, maxY = rect.height - toolBarRect.height;
|
|
1754
|
+
left = Math.max(minX, Math.min(left, maxX));
|
|
1755
|
+
top = Math.max(minY, Math.min(top, maxY));
|
|
1756
|
+
toolBarPosition.value = { left, top };
|
|
1803
1757
|
}
|
|
1804
|
-
function
|
|
1805
|
-
|
|
1758
|
+
function startCurrentCommandItem(item) {
|
|
1759
|
+
if (currentCommand.value === item.command) return;
|
|
1760
|
+
editor.commandManager.start(item.command);
|
|
1806
1761
|
}
|
|
1807
|
-
function
|
|
1808
|
-
if (
|
|
1809
|
-
localStorage.setItem("lines", JSON.stringify(
|
|
1762
|
+
function setLines(lines) {
|
|
1763
|
+
if (lines) {
|
|
1764
|
+
localStorage.setItem("lines", JSON.stringify(lines));
|
|
1810
1765
|
try {
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1766
|
+
dxfSystem.Dxf.set(lines);
|
|
1767
|
+
dxfSystem.Dxf.lineOffset();
|
|
1768
|
+
} catch (error) {
|
|
1769
|
+
console.log(error);
|
|
1814
1770
|
}
|
|
1815
1771
|
}
|
|
1816
1772
|
}
|
|
1817
|
-
async function
|
|
1818
|
-
const
|
|
1819
|
-
Array.isArray(
|
|
1773
|
+
async function selectLocalFile() {
|
|
1774
|
+
const data = await SelectLocalFile.json();
|
|
1775
|
+
if (Array.isArray(data)) {
|
|
1776
|
+
localStorage.removeItem("orbitControls");
|
|
1777
|
+
setLines(data);
|
|
1778
|
+
}
|
|
1820
1779
|
}
|
|
1821
|
-
function
|
|
1822
|
-
|
|
1823
|
-
const
|
|
1780
|
+
function dragMoveHelper({ offsetX, offsetY }) {
|
|
1781
|
+
domEventRegister.mouseMoveEventProxylock = true;
|
|
1782
|
+
const cusor = document.body.style.cursor;
|
|
1824
1783
|
document.body.style.cursor = "move";
|
|
1825
|
-
const
|
|
1826
|
-
const
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
)
|
|
1833
|
-
|
|
1834
|
-
document.body.
|
|
1784
|
+
const move = (e) => {
|
|
1785
|
+
const rect = elRef.value.getBoundingClientRect(), toolBarRect = toolBarRef.value.getBoundingClientRect();
|
|
1786
|
+
setEditorToolPosition(
|
|
1787
|
+
e.pageX - rect.left - offsetX,
|
|
1788
|
+
e.pageY - rect.top - offsetY,
|
|
1789
|
+
rect,
|
|
1790
|
+
toolBarRect
|
|
1791
|
+
);
|
|
1792
|
+
e.stopPropagation();
|
|
1793
|
+
document.body.style.cursor = "move";
|
|
1835
1794
|
};
|
|
1836
|
-
|
|
1795
|
+
const end = () => {
|
|
1796
|
+
document.body.removeEventListener("mousemove", move);
|
|
1797
|
+
document.removeEventListener("mouseup", end);
|
|
1798
|
+
document.body.style.cursor = cusor;
|
|
1799
|
+
domEventRegister.mouseMoveEventProxylock = false;
|
|
1800
|
+
};
|
|
1801
|
+
document.body.addEventListener("mousemove", move);
|
|
1802
|
+
document.addEventListener("mouseup", end);
|
|
1837
1803
|
}
|
|
1838
|
-
const
|
|
1839
|
-
|
|
1840
|
-
{ name: "
|
|
1841
|
-
{ name: "
|
|
1842
|
-
{ name: "
|
|
1843
|
-
{ name: "
|
|
1844
|
-
{ name: "
|
|
1845
|
-
{ name: "
|
|
1846
|
-
{ name: "
|
|
1847
|
-
{ name: "
|
|
1848
|
-
{ name: "
|
|
1849
|
-
{ name: "
|
|
1850
|
-
{ name: "
|
|
1851
|
-
{ name: "
|
|
1852
|
-
{ name: "
|
|
1853
|
-
{ name: "
|
|
1854
|
-
{ name: "命令确认", shortcut: "Enter" },
|
|
1855
|
-
{ name: "取消命令", shortcut: "Esc" }
|
|
1856
|
-
|
|
1857
|
-
{ name: "取消回滚操作", shortcut: "Ctrl + Y" }
|
|
1858
|
-
], at = [
|
|
1804
|
+
const props = __props;
|
|
1805
|
+
const originalLineVisible = ref(true), dxfVisible = ref(true), whiteModelVisible = ref(true), isLook = ref(false), elRef = ref(), toolBarRef = ref(), toolBarExpand = ref(true), currentCommand = ref(""), dxfSystem = toRaw(props.dxfSystem), domEventRegister = dxfSystem.findComponentByType(DomEventRegister), editor = dxfSystem.findComponentByType(Editor$1), defaultComponent = dxfSystem.findComponentByType(Default), whiteModel = dxfSystem.findComponentByType(WhiteModel), toolBarPosition = ref({ left: 10, top: 10 }), images = /* @__PURE__ */ Object.assign({ "./assets/images/door.svg": __vite_glob_0_0, "./assets/images/line.svg": __vite_glob_0_1, "./assets/images/selectPoint.svg": __vite_glob_0_2, "./assets/images/window.svg": __vite_glob_0_3 }), showShortcutKey = ref(false), selectLineCount = ref(0), hasWindowLine = ref(false), resizeObserver = new ResizeObserver(() => setEditorToolPosition(toolBarPosition.value.left, toolBarPosition.value.top)), shortcutKeys = [
|
|
1806
|
+
{ "name": "开启绘制线段命令", "shortcut": "Ctrl + L" },
|
|
1807
|
+
{ "name": "开启绘制门线命令", "shortcut": "Ctrl + M" },
|
|
1808
|
+
{ "name": "开启绘制窗户线命令", "shortcut": "Ctrl + Q" },
|
|
1809
|
+
{ "name": "开启点修改命令", "shortcut": "Ctrl + P" },
|
|
1810
|
+
{ "name": "线段方向移动线段点(点修改命令下)", "shortcut": "Shift + 移动" },
|
|
1811
|
+
{ "name": "删除线段", "shortcut": "选中 + Delete" },
|
|
1812
|
+
{ "name": "删除窗户线", "shortcut": "选中 + Q + Delete" },
|
|
1813
|
+
{ "name": "选中", "shortcut": "鼠标左键" },
|
|
1814
|
+
{ "name": "多选", "shortcut": "鼠标左键 + Ctrl" },
|
|
1815
|
+
{ "name": "取消选中", "shortcut": "鼠标左键 + Alt" },
|
|
1816
|
+
{ "name": "框选", "shortcut": "鼠标左键 + 移动" },
|
|
1817
|
+
{ "name": "线段同方向合并", "shortcut": "Ctrl + G" },
|
|
1818
|
+
{ "name": "线段连接", "shortcut": "选中 + Shift + L" },
|
|
1819
|
+
{ "name": "线段交点连接", "shortcut": "选中 + Ctrl + Shift + L" },
|
|
1820
|
+
{ "name": "命令确认", "shortcut": "Enter" },
|
|
1821
|
+
{ "name": "取消命令", "shortcut": "Esc" }
|
|
1822
|
+
], commandList = [
|
|
1859
1823
|
{
|
|
1860
1824
|
command: "default",
|
|
1861
1825
|
name: "默认",
|
|
1862
|
-
show:
|
|
1826
|
+
show: false,
|
|
1863
1827
|
shortcut: ""
|
|
1864
1828
|
},
|
|
1865
1829
|
{
|
|
1866
1830
|
command: "draw-line",
|
|
1867
1831
|
name: "绘制线段",
|
|
1868
|
-
src:
|
|
1869
|
-
show:
|
|
1832
|
+
src: images["./assets/images/line.svg"].default,
|
|
1833
|
+
show: true,
|
|
1870
1834
|
shortcut: "Ctrl + L"
|
|
1871
1835
|
},
|
|
1872
1836
|
{
|
|
1873
1837
|
command: "draw-door-line",
|
|
1874
1838
|
name: "绘制门线",
|
|
1875
|
-
show:
|
|
1876
|
-
src:
|
|
1839
|
+
show: true,
|
|
1840
|
+
src: images["./assets/images/door.svg"].default,
|
|
1877
1841
|
shortcut: "Ctrl + M"
|
|
1878
1842
|
},
|
|
1879
1843
|
{
|
|
1880
1844
|
command: "draw-window-line",
|
|
1881
1845
|
name: "绘制窗户线",
|
|
1882
|
-
show:
|
|
1883
|
-
src:
|
|
1846
|
+
show: true,
|
|
1847
|
+
src: images["./assets/images/window.svg"].default,
|
|
1884
1848
|
shortcut: "Ctrl + Q"
|
|
1885
1849
|
},
|
|
1886
1850
|
{
|
|
1887
1851
|
command: "point",
|
|
1888
1852
|
name: "点修改",
|
|
1889
|
-
show:
|
|
1890
|
-
src:
|
|
1853
|
+
show: true,
|
|
1854
|
+
src: images["./assets/images/selectPoint.svg"].default,
|
|
1891
1855
|
shortcut: "Ctrl + P"
|
|
1892
1856
|
}
|
|
1893
|
-
], rt = [
|
|
1894
|
-
{
|
|
1895
|
-
command: "",
|
|
1896
|
-
name: "操作回滚",
|
|
1897
|
-
src: L["./assets/images/rollback.svg"].default,
|
|
1898
|
-
show: D(() => ue.value !== 0),
|
|
1899
|
-
shortcut: "Ctrl + Z",
|
|
1900
|
-
action() {
|
|
1901
|
-
_.commandManager.rollback();
|
|
1902
|
-
}
|
|
1903
|
-
},
|
|
1904
|
-
{
|
|
1905
|
-
command: "",
|
|
1906
|
-
name: "撤销操作回滚",
|
|
1907
|
-
src: L["./assets/images/revokeRollback.svg"].default,
|
|
1908
|
-
show: D(() => X.value !== 0),
|
|
1909
|
-
shortcut: "Ctrl + Y",
|
|
1910
|
-
class: "rotateY-[180deg]",
|
|
1911
|
-
action() {
|
|
1912
|
-
_.commandManager.revokeRollback();
|
|
1913
|
-
}
|
|
1914
|
-
},
|
|
1915
|
-
{
|
|
1916
|
-
command: H.commandName,
|
|
1917
|
-
name: "合并",
|
|
1918
|
-
src: L["./assets/images/mergeLine.svg"].default,
|
|
1919
|
-
show: D(() => w.value === 2),
|
|
1920
|
-
shortcut: "Ctrl + G"
|
|
1921
|
-
},
|
|
1922
|
-
{
|
|
1923
|
-
command: U.commandName,
|
|
1924
|
-
name: "两点连接",
|
|
1925
|
-
show: D(() => w.value === 2),
|
|
1926
|
-
src: L["./assets/images/connection.svg"].default,
|
|
1927
|
-
shortcut: "Shift + L"
|
|
1928
|
-
},
|
|
1929
|
-
{
|
|
1930
|
-
command: Q.commandName,
|
|
1931
|
-
name: "延长线交点连接",
|
|
1932
|
-
show: D(() => w.value === 2),
|
|
1933
|
-
src: L["./assets/images/intersectionConnection.svg"].default,
|
|
1934
|
-
shortcut: "Ctrl + Shift + L"
|
|
1935
|
-
},
|
|
1936
|
-
{
|
|
1937
|
-
command: ee.commandName,
|
|
1938
|
-
name: "线段垂直纠正",
|
|
1939
|
-
show: D(() => w.value === 1),
|
|
1940
|
-
src: L["./assets/images/verticalCorrection.svg"].default,
|
|
1941
|
-
shortcut: "Ctrl + C 或 Ctrl + Shift + C"
|
|
1942
|
-
},
|
|
1943
|
-
{
|
|
1944
|
-
command: Z.commandName,
|
|
1945
|
-
name: "全选",
|
|
1946
|
-
show: D(() => w.value !== _.renderManager.lines.length),
|
|
1947
|
-
src: L["./assets/images/selectAll.svg"].default,
|
|
1948
|
-
shortcut: "Ctrl + A"
|
|
1949
|
-
},
|
|
1950
|
-
{
|
|
1951
|
-
command: Y.commandName,
|
|
1952
|
-
name: "清除窗户",
|
|
1953
|
-
show: D(() => we.value),
|
|
1954
|
-
src: L["./assets/images/deleteSelectWindow.svg"].default,
|
|
1955
|
-
shortcut: "Q + Delete"
|
|
1956
|
-
},
|
|
1957
|
-
{
|
|
1958
|
-
command: W.commandName,
|
|
1959
|
-
name: "删除",
|
|
1960
|
-
show: D(() => w.value > 0),
|
|
1961
|
-
src: L["./assets/images/deleteSelectLine.svg"].default,
|
|
1962
|
-
shortcut: "Delete"
|
|
1963
|
-
}
|
|
1964
1857
|
];
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1858
|
+
watch(toolBarPosition, () => localStorage.setItem("editorToolPosition", JSON.stringify(toolBarPosition.value)));
|
|
1859
|
+
watch(showShortcutKey, () => localStorage.setItem("showShortcutKey", showShortcutKey.value + ""));
|
|
1860
|
+
watch(toolBarExpand, () => localStorage.setItem("toolBarExpand", toolBarExpand.value + ""));
|
|
1861
|
+
watch(originalLineVisible, () => dxfSystem.Variable.set("originalLineVisible", originalLineVisible.value));
|
|
1862
|
+
watch(dxfVisible, () => dxfSystem.Variable.set("dxfVisible", dxfVisible.value));
|
|
1863
|
+
watch(whiteModelVisible, () => dxfSystem.Variable.set("whiteModelVisible", whiteModelVisible.value));
|
|
1864
|
+
dxfSystem.Variable.addEventListener("isLook", (e) => isLook.value = e.value);
|
|
1865
|
+
dxfSystem.Variable.addEventListener("originalLineVisible", (e) => originalLineVisible.value = e.value);
|
|
1866
|
+
dxfSystem.Variable.addEventListener("dxfVisible", (e) => dxfVisible.value = e.value);
|
|
1867
|
+
dxfSystem.Variable.addEventListener("whiteModelVisible", (e) => whiteModelVisible.value = e.value);
|
|
1868
|
+
const startedEventCancel = editor.commandManager.addEventListener("started", (e) => {
|
|
1869
|
+
currentCommand.value = e.name;
|
|
1970
1870
|
});
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
}
|
|
1871
|
+
if (localStorage.getItem("showShortcutKey")) {
|
|
1872
|
+
showShortcutKey.value = localStorage.getItem("showShortcutKey") === "true";
|
|
1873
|
+
}
|
|
1874
|
+
if (localStorage.getItem("toolBarExpand")) {
|
|
1875
|
+
toolBarExpand.value = localStorage.getItem("toolBarExpand") === "true";
|
|
1876
|
+
}
|
|
1877
|
+
onMounted(() => {
|
|
1878
|
+
toolBarRef.value.style.display = "none";
|
|
1879
|
+
setTimeout(() => {
|
|
1880
|
+
toolBarRef.value.style.display = "block";
|
|
1881
|
+
if (localStorage.getItem("editorToolPosition")) {
|
|
1882
|
+
const { left, top } = JSON.parse(localStorage.getItem("editorToolPosition") ?? "{}");
|
|
1883
|
+
setEditorToolPosition(left, top);
|
|
1884
|
+
nextTick(() => resizeObserver.observe(elRef.value));
|
|
1885
|
+
} else {
|
|
1886
|
+
nextTick(() => resizeObserver.observe(elRef.value));
|
|
1887
|
+
}
|
|
1888
|
+
}, 20);
|
|
1889
|
+
defaultComponent.addEventListener("selectLineChange", () => {
|
|
1890
|
+
selectLineCount.value = defaultComponent.selectLines.length;
|
|
1891
|
+
hasWindowLine.value = defaultComponent.selectLines.some((l) => l.userData.isWindow);
|
|
1986
1892
|
});
|
|
1987
|
-
})
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
class: "p-[4px_0px] flex justify-between text-right border-b-1 border-b-[rgba(255,255,255,0.1)] last-of-type:border-b-0",
|
|
1999
|
-
key: p.name
|
|
2000
|
-
}, [
|
|
2001
|
-
x("p", $n, J(p.name), 1),
|
|
2002
|
-
x("span", Hn, J(p.shortcut), 1)
|
|
2003
|
-
])), 64))
|
|
2004
|
-
])) : q("", !0)
|
|
2005
|
-
]),
|
|
2006
|
-
_: 1
|
|
2007
|
-
}),
|
|
2008
|
-
x("div", {
|
|
2009
|
-
ref_key: "toolBarRef",
|
|
2010
|
-
ref: f,
|
|
2011
|
-
style: _e({ left: R.value.left + "px", top: R.value.top + "px" }),
|
|
2012
|
-
class: O(["overflow-hidden pointer-events-auto w-fit max-w-[260px] transition-[border-radius] text-[#333] absolute z-[11] bg-white select-none", { "rounded-[8px] ": g.value }]),
|
|
2013
|
-
onMousedown: u[8] || (u[8] = (p) => p.stopPropagation())
|
|
1893
|
+
});
|
|
1894
|
+
onUnmounted(() => {
|
|
1895
|
+
domEventRegister.mouseMoveEventProxylock = false;
|
|
1896
|
+
startedEventCancel();
|
|
1897
|
+
resizeObserver.disconnect();
|
|
1898
|
+
});
|
|
1899
|
+
return (_ctx, _cache) => {
|
|
1900
|
+
return openBlock(), createElementBlock("div", {
|
|
1901
|
+
ref_key: "elRef",
|
|
1902
|
+
ref: elRef,
|
|
1903
|
+
class: "editorTool pointer-events-none overflow-hidden absolute left-0 top-0 w-full h-full z-[10000] flex flex-row justify-between p-[5px] box-border select-none pointer-events-[all]"
|
|
2014
1904
|
}, [
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
1905
|
+
createVNode(Transition, null, {
|
|
1906
|
+
default: withCtx(() => [
|
|
1907
|
+
showShortcutKey.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
1908
|
+
(openBlock(), createElementBlock(Fragment, null, renderList(shortcutKeys, (item) => {
|
|
1909
|
+
return createElementVNode("p", {
|
|
1910
|
+
class: "p-[4px_0px] flex justify-between text-right border-b-1 border-b-[rgba(255,255,255,0.1)] last-of-type:border-b-0",
|
|
1911
|
+
key: item.name
|
|
1912
|
+
}, [
|
|
1913
|
+
createElementVNode("p", _hoisted_2, toDisplayString(item.name), 1),
|
|
1914
|
+
createElementVNode("span", _hoisted_3, toDisplayString(item.shortcut), 1)
|
|
1915
|
+
]);
|
|
1916
|
+
}), 64))
|
|
1917
|
+
])) : createCommentVNode("", true)
|
|
1918
|
+
]),
|
|
1919
|
+
_: 1
|
|
1920
|
+
}),
|
|
1921
|
+
createElementVNode("div", {
|
|
1922
|
+
ref_key: "toolBarRef",
|
|
1923
|
+
ref: toolBarRef,
|
|
1924
|
+
style: normalizeStyle({ left: toolBarPosition.value.left + "px", top: toolBarPosition.value.top + "px" }),
|
|
1925
|
+
class: normalizeClass(["pointer-events-auto max-w-[260px] transition-[border-radius] text-[#333] absolute z-[11] bg-white select-none", { "rounded-[8px] ": toolBarExpand.value }]),
|
|
1926
|
+
onMousedown: _cache[13] || (_cache[13] = (e) => e.stopPropagation())
|
|
2018
1927
|
}, [
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
onClick: u[1] || (u[1] = (p) => g.value = !g.value),
|
|
2023
|
-
class: "cursor-pointer flex items-center p-[0px_5px]"
|
|
1928
|
+
createElementVNode("div", {
|
|
1929
|
+
onMousedown: dragMoveHelper,
|
|
1930
|
+
class: normalizeClass([{ "border-b-[#eee]": toolBarExpand.value }, "flex flex-row justify-between header text-[14px] font-bold p-[10px 0px] border-b-1"])
|
|
2024
1931
|
}, [
|
|
2025
|
-
(
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2031
|
-
width: "12",
|
|
2032
|
-
height: "12"
|
|
2033
|
-
}, u[9] || (u[9] = [
|
|
2034
|
-
x("path", { d: "M315.050667 938.666667a60.757333 60.757333 0 0 0 41.813333-16.298667L750.933333 551.338667a53.418667 53.418667 0 0 0 0-78.677334L356.864 101.632a61.696 61.696 0 0 0-83.541333 0 53.418667 53.418667 0 0 0-0.256 78.677333L625.408 512 273.066667 843.690667a53.418667 53.418667 0 0 0 0 78.677333 60.757333 60.757333 0 0 0 41.984 16.298667z" }, null, -1)
|
|
2035
|
-
]), 2))
|
|
2036
|
-
], 32)
|
|
2037
|
-
], 34),
|
|
2038
|
-
g.value ? (M(), S("div", Wn, [
|
|
2039
|
-
x("ul", Un, [
|
|
2040
|
-
(M(), S(ce, null, Me(at, (p) => (M(), S(ce, {
|
|
2041
|
-
key: p.command
|
|
1932
|
+
_cache[15] || (_cache[15] = createStaticVNode('<div class="flex flex-row" data-v-26d57fb7><div class="p-[2px_5px] flex items-center pointer-events-none" data-v-26d57fb7><svg fill="#aaa" width="20" height="20" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" data-v-26d57fb7><path d="M341.333333 298.666667a85.333333 85.333333 0 1 0 0-170.666667 85.333333 85.333333 0 0 0 0 170.666667z m0 298.666666a85.333333 85.333333 0 1 0 0-170.666666 85.333333 85.333333 0 0 0 0 170.666666z m85.333334 213.333334a85.333333 85.333333 0 1 1-170.666667 0 85.333333 85.333333 0 0 1 170.666667 0z m256-512a85.333333 85.333333 0 1 0 0-170.666667 85.333333 85.333333 0 0 0 0 170.666667z m85.333333 213.333333a85.333333 85.333333 0 1 1-170.666667 0 85.333333 85.333333 0 0 1 170.666667 0z m-85.333333 384a85.333333 85.333333 0 1 0 0-170.666667 85.333333 85.333333 0 0 0 0 170.666667z" data-v-26d57fb7></path></svg></div><h5 class="flex text-[12px] items-center pointer-events-none" data-v-26d57fb7>绘制工具</h5></div>', 1)),
|
|
1933
|
+
createElementVNode("div", {
|
|
1934
|
+
onMousedown: _cache[0] || (_cache[0] = (e) => e.stopPropagation()),
|
|
1935
|
+
onClick: _cache[1] || (_cache[1] = ($event) => toolBarExpand.value = !toolBarExpand.value),
|
|
1936
|
+
class: "cursor-pointer flex items-center p-[0px_5px]"
|
|
2042
1937
|
}, [
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
onClick: u[2] || (u[2] = (G) => (v(_).cancelCommand(), G.stopPropagation()))
|
|
2067
|
-
}, u[11] || (u[11] = [
|
|
2068
|
-
x("svg", {
|
|
2069
|
-
fill: "#fff",
|
|
2070
|
-
width: "16",
|
|
2071
|
-
height: "16",
|
|
2072
|
-
viewBox: "0 0 1024 1024",
|
|
2073
|
-
version: "1.1",
|
|
2074
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
1938
|
+
(openBlock(), createElementBlock("svg", {
|
|
1939
|
+
fill: "#666",
|
|
1940
|
+
class: normalizeClass([{ "rotate-90": toolBarExpand.value }, "transition-all"]),
|
|
1941
|
+
viewBox: "0 0 1024 1024",
|
|
1942
|
+
version: "1.1",
|
|
1943
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1944
|
+
width: "12",
|
|
1945
|
+
height: "12"
|
|
1946
|
+
}, _cache[14] || (_cache[14] = [
|
|
1947
|
+
createElementVNode("path", { d: "M315.050667 938.666667a60.757333 60.757333 0 0 0 41.813333-16.298667L750.933333 551.338667a53.418667 53.418667 0 0 0 0-78.677334L356.864 101.632a61.696 61.696 0 0 0-83.541333 0 53.418667 53.418667 0 0 0-0.256 78.677333L625.408 512 273.066667 843.690667a53.418667 53.418667 0 0 0 0 78.677333 60.757333 60.757333 0 0 0 41.984 16.298667z" }, null, -1)
|
|
1948
|
+
]), 2))
|
|
1949
|
+
], 32)
|
|
1950
|
+
], 34),
|
|
1951
|
+
toolBarExpand.value ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
1952
|
+
createElementVNode("ul", _hoisted_5, [
|
|
1953
|
+
(openBlock(), createElementBlock(Fragment, null, renderList(commandList, (item) => {
|
|
1954
|
+
return openBlock(), createElementBlock(Fragment, {
|
|
1955
|
+
key: item.command
|
|
1956
|
+
}, [
|
|
1957
|
+
item.show ? (openBlock(), createElementBlock("li", {
|
|
1958
|
+
key: 0,
|
|
1959
|
+
onClick: ($event) => startCurrentCommandItem(item),
|
|
1960
|
+
class: normalizeClass([{ "!bg-[var(--primary-color)] text-[#fff]": currentCommand.value === item.command }, "gap-[20px] text-[12px] hover:bg-[#ddd] transition-all rounded-[6px] p-[5px] flex flex-row items-center justify-between cursor-pointer"])
|
|
2075
1961
|
}, [
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
__: [12]
|
|
2109
|
-
}),
|
|
2110
|
-
z(v(pe), {
|
|
2111
|
-
style: { padding: "5px", "font-size": "10px" },
|
|
2112
|
-
size: "small",
|
|
2113
|
-
type: "primary",
|
|
2114
|
-
onClick: u[5] || (u[5] = (p) => console.log(v(b).Dxf.originalData))
|
|
2115
|
-
}, {
|
|
2116
|
-
default: F(() => u[13] || (u[13] = [
|
|
2117
|
-
le(" 打印Json ", -1)
|
|
2118
|
-
])),
|
|
2119
|
-
_: 1,
|
|
2120
|
-
__: [13]
|
|
2121
|
-
}),
|
|
2122
|
-
z(v(pe), {
|
|
2123
|
-
style: { padding: "5px", "font-size": "10px" },
|
|
2124
|
-
size: "small",
|
|
2125
|
-
type: "primary",
|
|
2126
|
-
onClick: u[6] || (u[6] = (p) => v(b).Dxf.download("test.dxf"))
|
|
2127
|
-
}, {
|
|
2128
|
-
default: F(() => u[14] || (u[14] = [
|
|
2129
|
-
le(" 下载DXF ", -1)
|
|
2130
|
-
])),
|
|
2131
|
-
_: 1,
|
|
2132
|
-
__: [14]
|
|
2133
|
-
}),
|
|
2134
|
-
z(v(pe), {
|
|
2135
|
-
style: { padding: "5px", "font-size": "10px" },
|
|
2136
|
-
size: "small",
|
|
2137
|
-
type: "primary",
|
|
2138
|
-
onClick: u[7] || (u[7] = (p) => v(se).downloadGltf("test.glb", !0))
|
|
2139
|
-
}, {
|
|
2140
|
-
default: F(() => u[15] || (u[15] = [
|
|
2141
|
-
le(" 下载白膜 ", -1)
|
|
2142
|
-
])),
|
|
2143
|
-
_: 1,
|
|
2144
|
-
__: [15]
|
|
2145
|
-
})
|
|
2146
|
-
])) : q("", !0),
|
|
2147
|
-
z(ge, null, {
|
|
2148
|
-
default: F(() => [
|
|
2149
|
-
x("div", oo, [
|
|
2150
|
-
z(Nt, null, {
|
|
2151
|
-
default: F(() => [
|
|
2152
|
-
(M(), S(ce, null, Me(rt, (p) => x("div", {
|
|
2153
|
-
onClick: (G) => p.show.value && C.value === "default" && (p.action ? p.action() : v(_).commandManager.start(p.command, [...v(j).selectLines])),
|
|
2154
|
-
title: `${p.name}(${p.shortcut})`,
|
|
2155
|
-
class: O(["size-[20px] flex justify-center items-center relative overflow-hidden active:scale-[0.8] border-1 border-[#ccc] rounded-[4px] transition-all cursor-pointer", {
|
|
2156
|
-
"opacity-30 bg-[#ccc] !cursor-no-drop active:!scale-[1]": !p.show.value || C.value !== "default",
|
|
2157
|
-
[p.class ?? ""]: !0
|
|
2158
|
-
}]),
|
|
2159
|
-
key: p.command
|
|
2160
|
-
}, [
|
|
2161
|
-
x("img", {
|
|
2162
|
-
class: "size-[14px]",
|
|
2163
|
-
src: p.src
|
|
2164
|
-
}, null, 8, ao)
|
|
2165
|
-
], 10, so)), 64))
|
|
2166
|
-
]),
|
|
2167
|
-
_: 1
|
|
2168
|
-
})
|
|
2169
|
-
])
|
|
1962
|
+
createElementVNode("div", _hoisted_7, [
|
|
1963
|
+
createElementVNode("div", _hoisted_8, [
|
|
1964
|
+
createElementVNode("img", {
|
|
1965
|
+
class: "size-[14px]",
|
|
1966
|
+
src: item.src,
|
|
1967
|
+
alt: "",
|
|
1968
|
+
srcset: ""
|
|
1969
|
+
}, null, 8, _hoisted_9)
|
|
1970
|
+
]),
|
|
1971
|
+
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
1972
|
+
]),
|
|
1973
|
+
currentCommand.value === item.command ? (openBlock(), createElementBlock("div", {
|
|
1974
|
+
key: 0,
|
|
1975
|
+
title: "取消命令(Esc)",
|
|
1976
|
+
class: "active:scale-[0.7] transition-all",
|
|
1977
|
+
onClick: _cache[2] || (_cache[2] = (e) => (unref(editor).cancelCommand(), e.stopPropagation()))
|
|
1978
|
+
}, _cache[16] || (_cache[16] = [
|
|
1979
|
+
createElementVNode("svg", {
|
|
1980
|
+
fill: "#fff",
|
|
1981
|
+
width: "16",
|
|
1982
|
+
height: "16",
|
|
1983
|
+
viewBox: "0 0 1024 1024",
|
|
1984
|
+
version: "1.1",
|
|
1985
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1986
|
+
}, [
|
|
1987
|
+
createElementVNode("path", { d: "M511.104 0C228.821333 0 0 228.821333 0 511.104c0 282.282667 228.821333 511.104 511.104 511.104 282.282667 0 511.104-228.842667 511.104-511.104C1022.208 228.821333 793.386667 0 511.104 0zM511.104 898.496c-213.973333 0-387.434667-173.44-387.434667-387.413333 0-213.952 173.44-387.413333 387.434667-387.413333 213.952 0 387.392 173.44 387.392 387.413333C898.496 725.056 725.056 898.496 511.104 898.496z" }),
|
|
1988
|
+
createElementVNode("path", { d: "M236.437333 463.914667l549.333333 0 0 96.874667-549.333333 0 0-96.874667Z" })
|
|
1989
|
+
], -1)
|
|
1990
|
+
]))) : item.shortcut ? (openBlock(), createElementBlock("div", _hoisted_10, toDisplayString(item.shortcut), 1)) : createCommentVNode("", true)
|
|
1991
|
+
], 10, _hoisted_6)) : createCommentVNode("", true)
|
|
1992
|
+
], 64);
|
|
1993
|
+
}), 64))
|
|
2170
1994
|
]),
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
}
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
1995
|
+
createElementVNode("div", _hoisted_11, [
|
|
1996
|
+
createVNode(unref(ElCheckbox), {
|
|
1997
|
+
size: "small",
|
|
1998
|
+
modelValue: showShortcutKey.value,
|
|
1999
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => showShortcutKey.value = $event),
|
|
2000
|
+
label: "快捷键提示"
|
|
2001
|
+
}, null, 8, ["modelValue"]),
|
|
2002
|
+
createVNode(unref(ElCheckbox), {
|
|
2003
|
+
size: "small",
|
|
2004
|
+
modelValue: dxfVisible.value,
|
|
2005
|
+
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => dxfVisible.value = $event),
|
|
2006
|
+
label: "dxf"
|
|
2007
|
+
}, null, 8, ["modelValue"])
|
|
2008
|
+
]),
|
|
2009
|
+
_ctx.permission === "admin" ? (openBlock(), createElementBlock("div", _hoisted_12, [
|
|
2010
|
+
createVNode(unref(ElButton), {
|
|
2011
|
+
style: { "padding": "5px", "font-size": "10px" },
|
|
2012
|
+
size: "small",
|
|
2013
|
+
type: "success",
|
|
2014
|
+
onClick: selectLocalFile
|
|
2015
|
+
}, {
|
|
2016
|
+
default: withCtx(() => _cache[17] || (_cache[17] = [
|
|
2017
|
+
createTextVNode(" 选择文件 ", -1)
|
|
2018
|
+
])),
|
|
2019
|
+
_: 1,
|
|
2020
|
+
__: [17]
|
|
2021
|
+
}),
|
|
2022
|
+
createVNode(unref(ElButton), {
|
|
2023
|
+
style: { "padding": "5px", "font-size": "10px" },
|
|
2024
|
+
size: "small",
|
|
2025
|
+
type: "primary",
|
|
2026
|
+
onClick: _cache[5] || (_cache[5] = ($event) => unref(dxfSystem).Dxf.download("test.dxf"))
|
|
2027
|
+
}, {
|
|
2028
|
+
default: withCtx(() => _cache[18] || (_cache[18] = [
|
|
2029
|
+
createTextVNode(" 下载 DXF ", -1)
|
|
2030
|
+
])),
|
|
2031
|
+
_: 1,
|
|
2032
|
+
__: [18]
|
|
2033
|
+
}),
|
|
2034
|
+
createVNode(unref(ElButton), {
|
|
2035
|
+
style: { "padding": "5px", "font-size": "10px" },
|
|
2036
|
+
size: "small",
|
|
2037
|
+
type: "primary",
|
|
2038
|
+
onClick: _cache[6] || (_cache[6] = ($event) => unref(whiteModel).downloadGltf("test.glb", true))
|
|
2039
|
+
}, {
|
|
2040
|
+
default: withCtx(() => _cache[19] || (_cache[19] = [
|
|
2041
|
+
createTextVNode(" 下载 白膜 ", -1)
|
|
2042
|
+
])),
|
|
2043
|
+
_: 1,
|
|
2044
|
+
__: [19]
|
|
2045
|
+
}),
|
|
2046
|
+
createVNode(unref(ElButton), {
|
|
2047
|
+
style: { "padding": "5px", "font-size": "10px" },
|
|
2048
|
+
size: "small",
|
|
2049
|
+
type: "primary",
|
|
2050
|
+
onClick: _cache[7] || (_cache[7] = ($event) => console.log(unref(dxfSystem).Dxf.originalData))
|
|
2051
|
+
}, {
|
|
2052
|
+
default: withCtx(() => _cache[20] || (_cache[20] = [
|
|
2053
|
+
createTextVNode(" 打印Json ", -1)
|
|
2054
|
+
])),
|
|
2055
|
+
_: 1,
|
|
2056
|
+
__: [20]
|
|
2057
|
+
})
|
|
2058
|
+
])) : createCommentVNode("", true),
|
|
2059
|
+
createVNode(Transition, null, {
|
|
2060
|
+
default: withCtx(() => [
|
|
2061
|
+
createElementVNode("div", _hoisted_13, [
|
|
2062
|
+
selectLineCount.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2063
|
+
selectLineCount.value == 2 ? (openBlock(), createElementBlock("div", {
|
|
2064
|
+
key: 0,
|
|
2065
|
+
onClick: _cache[8] || (_cache[8] = ($event) => unref(defaultComponent).mergeLine()),
|
|
2066
|
+
title: "合并(Ctrl + G)",
|
|
2067
|
+
class: "active:scale-[0.8] transition-all cursor-pointer"
|
|
2068
|
+
}, _cache[21] || (_cache[21] = [
|
|
2069
|
+
createElementVNode("svg", {
|
|
2070
|
+
viewBox: "0 0 1024 1024",
|
|
2071
|
+
version: "1.1",
|
|
2072
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2073
|
+
fill: "#555",
|
|
2074
|
+
width: "16",
|
|
2075
|
+
height: "16"
|
|
2076
|
+
}, [
|
|
2077
|
+
createElementVNode("path", { d: "M114.176 46.528h618.496c37.312 0.064 67.584 30.336 67.648 67.648v618.56c0 37.248-30.336 67.584-67.648 67.584H114.176A67.776 67.776 0 0 1 46.528 732.8V114.176c0-37.312 30.336-67.648 67.648-67.648z m2.176 686.208l616.32-2.24-2.176-616.32-614.144 2.176v616.32zM907.648 291.2l2.176 616.32H291.264a34.88 34.88 0 1 0 0 69.888h618.56c37.312 0 67.648-30.336 67.648-67.648V291.264a34.88 34.88 0 1 0-69.824 0z" })
|
|
2078
|
+
], -1)
|
|
2079
|
+
]))) : createCommentVNode("", true),
|
|
2080
|
+
selectLineCount.value == 2 ? (openBlock(), createElementBlock("div", {
|
|
2081
|
+
key: 1,
|
|
2082
|
+
onClick: _cache[9] || (_cache[9] = ($event) => unref(defaultComponent).connection()),
|
|
2083
|
+
title: "两点连接(Shift + L)",
|
|
2084
|
+
class: "active:scale-[0.8] transition-all cursor-pointer"
|
|
2085
|
+
}, _cache[22] || (_cache[22] = [
|
|
2086
|
+
createElementVNode("svg", {
|
|
2087
|
+
viewBox: "0 0 1024 1024",
|
|
2088
|
+
version: "1.1",
|
|
2089
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2090
|
+
fill: "#555",
|
|
2091
|
+
width: "16",
|
|
2092
|
+
height: "16"
|
|
2093
|
+
}, [
|
|
2094
|
+
createElementVNode("path", { d: "M639.999191 893.597594c-0.999994-54.699654-36.39977-101.099361-85.39946-118.399252-6.39996-2.199986-10.599933-8.299948-10.599933-14.999905V263.801573c0-6.699958 4.199973-12.799919 10.599933-14.999905 49.09969-17.299891 84.399467-63.599598 85.39946-118.399252C641.299183 59.902862 583.399549 0.503237 512.899994 0.00324 441.800444-0.496757 384.000809 57.00288 384.000809 128.002431c0 55.699648 35.599775 103.099349 85.299461 120.699238 6.39996 2.299985 10.699932 8.299948 10.699932 15.099904v496.396864c0 6.799957-4.299973 12.799919-10.699932 15.099904-49.699686 17.599889-85.299461 64.999589-85.299461 120.699238 0 70.999551 57.799635 128.499188 128.899185 127.999191 70.499555-0.499997 128.399189-59.899622 127.099197-130.399176zM448.000404 128.002431c0-35.299777 28.699819-63.999596 63.999596-63.999595s63.999596 28.699819 63.999596 63.999595-28.699819 63.999596-63.999596 63.999596-63.999596-28.699819-63.999596-63.999596z m0 767.995148c0-35.299777 28.699819-63.999596 63.999596-63.999596s63.999596 28.699819 63.999596 63.999596-28.699819 63.999596-63.999596 63.999595-63.999596-28.699819-63.999596-63.999595z" })
|
|
2095
|
+
], -1)
|
|
2096
|
+
]))) : createCommentVNode("", true),
|
|
2097
|
+
selectLineCount.value == 2 ? (openBlock(), createElementBlock("div", {
|
|
2098
|
+
key: 2,
|
|
2099
|
+
onClick: _cache[10] || (_cache[10] = ($event) => unref(defaultComponent).intersectionConnection()),
|
|
2100
|
+
title: "延长线交点连接(Ctrl + Shift + L)",
|
|
2101
|
+
class: "active:scale-[0.8] transition-all cursor-pointer"
|
|
2102
|
+
}, _cache[23] || (_cache[23] = [
|
|
2103
|
+
createElementVNode("svg", {
|
|
2104
|
+
viewBox: "0 0 1024 1024",
|
|
2105
|
+
version: "1.1",
|
|
2106
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2107
|
+
fill: "#555",
|
|
2108
|
+
width: "16",
|
|
2109
|
+
height: "16"
|
|
2110
|
+
}, [
|
|
2111
|
+
createElementVNode("path", { d: "M491.80027198 557.44938977c-10.0998647-15.14979706-20.19972802-25.24966037-35.34952507-35.34952507-15.14979706-10.0998647-30.29959271-15.14979706-50.49932211-15.14979704-55.54925309 0-100.99864286 45.44938977-100.99864287 100.99864285 0 15.14979706 5.04993234 35.34952507 15.14979568 50.49932212 10.0998647 15.14979706 20.19972802 30.29959271 35.34952506 35.34952508 15.14979706 10.0998647 35.34952507 15.14979706 50.49932213 15.14979567 55.54925309 0 100.99864286-45.44938977 100.99864286-100.99864287 0-15.14979706-5.04993234-35.34952507-15.14979568-50.49932074z m-85.84884718 100.99864286h-15.14979706c-20.19972802-5.04993234-30.29959271-20.19972802-35.34952507-35.34952507V612.99864286c0-30.29959271 25.24966037-50.49932212 50.49932213-50.49932074h10.09986469c15.14979706 5.04993234 30.29959271 15.14979706 35.34952507 35.34952507v15.14979567c5.04993234 25.24966037-20.19972802 45.44938977-45.44938976 45.44938977z" }),
|
|
2112
|
+
createElementVNode("path", { d: "M390.80162774 658.44803263l-40.39945604 40.39945743-227.24694747 222.19701373-35.34952506-35.34952508 227.24694745-227.24694608 40.39945605-40.39945743c5.04993234 20.19972802 20.19972802 35.34952507 35.34952507 40.39945743zM648.34816793 405.9514248l-40.39945742 40.3994574-116.14843853 116.14843992-40.39945742 35.34952507c-5.04993234-20.19972802-20.19972802-30.29959271-35.34952507-35.34952507l40.39945742-40.39945742 116.14843853-111.09850756 35.34952507-35.34952507c10.0998647 15.14979706 20.19972802 25.24966037 40.39945742 30.29959273zM926.09443614 133.25508894L749.34681078 310.00271428l-40.3994574 40.39945742c-5.04993234-20.19972802-15.14979706-35.34952507-30.29959272-40.39945742l35.34952506-40.39945742 176.74762534-176.74762535 35.34952508 40.39945743z" }),
|
|
2113
|
+
createElementVNode("path", { d: "M749.34681078 310.00271428c-10.0998647-15.14979706-20.19972802-30.29959271-35.34952506-35.34952506-15.14979706-10.0998647-35.34952507-15.14979706-55.54925309-15.14979706-55.54925309 0-100.99864286 45.44938977-100.99864286 100.99864286 0 20.19972802 5.04993234 40.39945743 15.14979567 55.54925447 10.0998647 15.14979706 20.19972802 25.24966037 35.34952507 35.34952507 15.14979706 10.0998647 30.29959271 15.14979706 50.49932212 15.14979567 55.54925309 0 100.99864286-45.44938977 100.99864286-100.99864286 0-25.24966037-5.04993234-40.39945743-10.09986471-55.54925309z m-90.89877815 95.94871052h-10.0998647c-20.19972802-5.04993234-35.34952507-15.14979706-40.39945742-35.34952509 0-5.04993234-5.04993234-10.0998647-5.04993234-15.14979704 0-30.29959271 25.24966037-50.49932212 50.49932212-50.49932074 5.04993234 0 10.0998647 0 15.14979704 5.04993235 15.14979706 5.04993234 30.29959271 20.19972802 30.29959273 40.39945742v10.09986332c10.0998647 25.24966037-15.14979706 45.44938977-40.39945743 45.44938978z" })
|
|
2114
|
+
], -1)
|
|
2115
|
+
]))) : createCommentVNode("", true),
|
|
2116
|
+
hasWindowLine.value ? (openBlock(), createElementBlock("div", {
|
|
2117
|
+
key: 3,
|
|
2118
|
+
onClick: _cache[11] || (_cache[11] = ($event) => unref(defaultComponent).deleteSelectWindow()),
|
|
2119
|
+
title: "清除窗户(Q + Delete)",
|
|
2120
|
+
class: "active:scale-[0.8] transition-all cursor-pointer"
|
|
2121
|
+
}, _cache[24] || (_cache[24] = [
|
|
2122
|
+
createElementVNode("svg", {
|
|
2123
|
+
viewBox: "0 0 1024 1024",
|
|
2124
|
+
version: "1.1",
|
|
2125
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2126
|
+
fill: "#555",
|
|
2127
|
+
width: "16",
|
|
2128
|
+
height: "16"
|
|
2129
|
+
}, [
|
|
2130
|
+
createElementVNode("path", { d: "M220.451548 913.518482V318.145854c0-27.62038 22.505495-50.125874 50.125875-50.125874H865.95005c27.62038 0 50.125874 22.505495 50.125874 50.125874v218.917083h59.332667V318.145854c0-60.355644-49.102897-109.458541-109.458541-109.458541h-39.896104v-99.228772C826.053946 49.102897 776.951049 0 716.595405 0H121.222777C60.867133 0 11.764236 49.102897 11.764236 109.458541V705.854146c0 60.355644 49.102897 109.458541 109.458541 109.458541h39.896104v99.228772c0 60.355644 49.102897 109.458541 109.458542 109.458541h257.790209v-59.332667H269.554446c-26.597403-1.022977-49.102897-23.528472-49.102898-51.148851z m-59.332667-595.372628v436.811189h-39.896104c-27.62038 0-50.125874-22.505495-50.125874-50.125874V109.458541c0-27.62038 22.505495-50.125874 50.125874-50.125874H716.595405c27.62038 0 50.125874 22.505495 50.125874 50.125874v99.228772H269.554446c-59.332667 0-108.435564 49.102897-108.435565 109.458541z" }),
|
|
2131
|
+
createElementVNode("path", { d: "M902.777223 854.185814l98.205794-98.205794c15.344655-15.344655 15.344655-40.919081 0-56.263736s-40.919081-15.344655-56.263736 0L846.513487 797.922078 747.284715 699.716284c-15.344655-15.344655-40.919081-15.344655-56.263736 0s-15.344655 40.919081 0 56.263736l98.205794 98.205794-98.205794 98.205794c-15.344655 15.344655-15.344655 40.919081 0 56.263737s40.919081 15.344655 56.263736 0l98.205794-98.205795 98.205795 98.205795c15.344655 15.344655 40.919081 15.344655 56.263736 0s15.344655-40.919081 0-56.263737l-97.182817-98.205794z" })
|
|
2132
|
+
], -1)
|
|
2133
|
+
]))) : createCommentVNode("", true),
|
|
2134
|
+
createElementVNode("div", {
|
|
2135
|
+
onClick: _cache[12] || (_cache[12] = ($event) => unref(defaultComponent).deleteSelectLine()),
|
|
2136
|
+
title: "删除(Delete)",
|
|
2137
|
+
class: "active:scale-[0.8] transition-all cursor-pointer"
|
|
2138
|
+
}, _cache[25] || (_cache[25] = [
|
|
2139
|
+
createElementVNode("svg", {
|
|
2140
|
+
viewBox: "0 0 1024 1024",
|
|
2141
|
+
version: "1.1",
|
|
2142
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2143
|
+
fill: "#555",
|
|
2144
|
+
width: "16",
|
|
2145
|
+
height: "16"
|
|
2146
|
+
}, [
|
|
2147
|
+
createElementVNode("path", { d: "M909.050991 169.476903l-217.554898 0 0-31.346939c0-39.5866-32.205493-71.792093-71.793116-71.792093L408.15591 66.337871c-39.5866 0-71.792093 32.205493-71.792093 71.792093l0 31.346939L113.349581 169.476903c-11.013845 0-19.942191 8.940626-19.942191 19.954471s8.928347 19.954471 19.942191 19.954471l84.264149 0 0 640.687918c0 60.479443 49.203632 109.683075 109.683075 109.683075l416.474366 0c60.479443 0 109.683075-49.203632 109.683075-109.683075L833.454246 209.385844l75.595722 0c11.012821 0 19.942191-8.940626 19.942191-19.954471S920.063813 169.476903 909.050991 169.476903zM376.2482 138.130987c0-17.593703 14.314007-31.907711 31.907711-31.907711l211.547067 0c17.593703 0 31.907711 14.314007 31.907711 31.907711l0 31.346939L376.2482 169.477926 376.2482 138.130987zM793.569864 850.074785c0 38.486546-31.312146 69.798692-69.798692 69.798692L307.297828 919.873478c-38.486546 0-69.798692-31.312146-69.798692-69.798692L237.499136 211.042577l556.070728 0L793.569864 850.074785zM510.662539 861.276918c11.012821 0 19.954471-8.92937 19.954471-19.942191L530.61701 294.912753c0-11.013845-8.94165-19.942191-19.954471-19.942191s-19.954471 8.928347-19.954471 19.942191L490.708068 841.334727C490.708068 852.347548 499.649717 861.276918 510.662539 861.276918zM374.562814 801.449321c11.012821 0 19.954471-8.92937 19.954471-19.942191L394.517285 354.74035c0-11.013845-8.94165-19.942191-19.954471-19.942191s-19.954471 8.928347-19.954471 19.942191l0 426.76678C354.608344 792.519951 363.549993 801.449321 374.562814 801.449321zM649.832182 801.449321c11.012821 0 19.954471-8.92937 19.954471-19.942191L669.786653 354.74035c0-11.013845-8.94165-19.942191-19.954471-19.942191s-19.954471 8.928347-19.954471 19.942191l0 426.76678C629.877711 792.519951 638.81936 801.449321 649.832182 801.449321z" })
|
|
2148
|
+
], -1)
|
|
2149
|
+
]))
|
|
2150
|
+
], 64)) : (openBlock(), createElementBlock("div", _hoisted_14, " 无可用操作 "))
|
|
2151
|
+
])
|
|
2152
|
+
]),
|
|
2153
|
+
_: 1
|
|
2154
|
+
})
|
|
2155
|
+
])) : createCommentVNode("", true)
|
|
2156
|
+
], 38)
|
|
2157
|
+
], 512);
|
|
2158
|
+
};
|
|
2159
|
+
}
|
|
2160
|
+
});
|
|
2161
|
+
const _export_sfc = (sfc, props) => {
|
|
2162
|
+
const target = sfc.__vccOpts || sfc;
|
|
2163
|
+
for (const [key, val] of props) {
|
|
2164
|
+
target[key] = val;
|
|
2165
|
+
}
|
|
2166
|
+
return target;
|
|
2167
|
+
};
|
|
2168
|
+
const EditorTool = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-26d57fb7"]]);
|
|
2169
|
+
let Editor$1 = class Editor extends Component {
|
|
2184
2170
|
static name = "Editor";
|
|
2185
|
-
container = new
|
|
2171
|
+
container = new THREE.Group();
|
|
2186
2172
|
get renderer() {
|
|
2187
2173
|
return this.parent?.findComponentByName("Renderer");
|
|
2188
2174
|
}
|
|
@@ -2204,23 +2190,32 @@ let ot = class extends ye {
|
|
|
2204
2190
|
get domContainer() {
|
|
2205
2191
|
return this.parent?.findComponentByName("DomContainer");
|
|
2206
2192
|
}
|
|
2207
|
-
commandManager = new
|
|
2208
|
-
plane = new
|
|
2193
|
+
commandManager = new CommandManager();
|
|
2194
|
+
plane = new THREE.Mesh(new THREE.PlaneGeometry(2e3, 2e3, 2, 2));
|
|
2209
2195
|
app;
|
|
2210
2196
|
domElement = document.createElement("div");
|
|
2211
2197
|
viewPermission;
|
|
2212
|
-
constructor(
|
|
2213
|
-
super()
|
|
2198
|
+
constructor(viewPermission) {
|
|
2199
|
+
super();
|
|
2200
|
+
this.viewPermission = viewPermission;
|
|
2214
2201
|
}
|
|
2215
2202
|
onAddFromParent() {
|
|
2216
2203
|
setTimeout(() => this.openEdit(), 10);
|
|
2217
|
-
const
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2204
|
+
const grid = new THREE.GridHelper(200, 100, 6710886, 4473924);
|
|
2205
|
+
grid.rotation.x = Math.PI * 0.5;
|
|
2206
|
+
grid.position.z = -0.01;
|
|
2207
|
+
this.container.add(grid);
|
|
2208
|
+
this.container.add(this.plane);
|
|
2209
|
+
this.plane.visible = false;
|
|
2210
|
+
const cancelEvent = this.addEventListener("update", () => {
|
|
2211
|
+
if (this.domContainer.domElement.parentElement) {
|
|
2212
|
+
this.domContainer.domElement.parentElement.appendChild(this.domElement);
|
|
2213
|
+
cancelEvent();
|
|
2214
|
+
}
|
|
2221
2215
|
});
|
|
2222
2216
|
setTimeout(() => {
|
|
2223
|
-
this.app =
|
|
2217
|
+
this.app = createApp(EditorTool, { dxfSystem: this.parent, permission: this.viewPermission });
|
|
2218
|
+
this.app.mount(this.domElement);
|
|
2224
2219
|
});
|
|
2225
2220
|
}
|
|
2226
2221
|
/**
|
|
@@ -2231,113 +2226,172 @@ let ot = class extends ye {
|
|
|
2231
2226
|
type: "cancelCommand"
|
|
2232
2227
|
});
|
|
2233
2228
|
}
|
|
2234
|
-
coords = new
|
|
2235
|
-
pointerPosition = new
|
|
2229
|
+
coords = new THREE.Vector2();
|
|
2230
|
+
pointerPosition = new THREE.Vector2();
|
|
2236
2231
|
_exitEditCallBack;
|
|
2237
2232
|
/**
|
|
2238
2233
|
* 打开编辑器
|
|
2239
2234
|
*/
|
|
2240
2235
|
openEdit() {
|
|
2241
|
-
const
|
|
2242
|
-
this.container.position.z =
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2236
|
+
const renderer = this.renderer, domEventRegister = this.domEventRegister, dxf = this.dxf, orbitControls = renderer.orbitControls, camera = renderer.camera, center = dxf.box.center, cameraPosition = renderer.camera.position.clone(), target = orbitControls?.target?.clone(), size = new THREE.Vector2(), raycaster = new THREE.Raycaster(), coords = this.coords, pointerPosition = this.pointerPosition;
|
|
2237
|
+
this.container.position.z = dxf.originalZAverage;
|
|
2238
|
+
renderer.scene.add(this.container);
|
|
2239
|
+
camera.position.set(center.x, center.y, 5);
|
|
2240
|
+
if (orbitControls) {
|
|
2241
|
+
orbitControls.target.set(center.x, center.y, 0);
|
|
2242
|
+
orbitControls.enableRotate = false;
|
|
2243
|
+
}
|
|
2244
|
+
const mousemoveFun = () => {
|
|
2245
|
+
renderer.renderer.getSize(size);
|
|
2246
|
+
const x = domEventRegister.pointer.x / size.x * 2 - 1;
|
|
2247
|
+
const y = -(domEventRegister.pointer.y / size.y * 2 - 1);
|
|
2248
|
+
coords.set(x, y);
|
|
2249
|
+
raycaster.setFromCamera(coords, renderer.camera);
|
|
2250
|
+
const intersections = raycaster.intersectObject(this.plane);
|
|
2251
|
+
if (intersections.length) {
|
|
2252
|
+
pointerPosition.copy(intersections[0].point);
|
|
2253
|
+
this.dispatchEvent({
|
|
2254
|
+
type: "pointerPositionChange",
|
|
2255
|
+
position: pointerPosition
|
|
2256
|
+
});
|
|
2257
|
+
}
|
|
2252
2258
|
};
|
|
2253
|
-
|
|
2254
|
-
|
|
2259
|
+
domEventRegister.addEventListener("mousemove", mousemoveFun);
|
|
2260
|
+
this.commandManager.disabled = false;
|
|
2261
|
+
this.commandManager.start("default");
|
|
2262
|
+
this._exitEditCallBack = () => {
|
|
2263
|
+
domEventRegister.removeEventListener("mousemove", mousemoveFun);
|
|
2264
|
+
camera.position.copy(cameraPosition);
|
|
2265
|
+
if (orbitControls) {
|
|
2266
|
+
orbitControls.enableRotate = true;
|
|
2267
|
+
orbitControls.target.copy(target);
|
|
2268
|
+
}
|
|
2255
2269
|
};
|
|
2256
2270
|
}
|
|
2257
2271
|
/**
|
|
2258
2272
|
* 退出编辑
|
|
2259
2273
|
*/
|
|
2260
2274
|
exitEdit() {
|
|
2261
|
-
typeof this._exitEditCallBack
|
|
2275
|
+
if (typeof this._exitEditCallBack === "function") {
|
|
2276
|
+
this._exitEditCallBack();
|
|
2277
|
+
this._exitEditCallBack = void 0;
|
|
2278
|
+
this.commandManager.disabled = true;
|
|
2279
|
+
}
|
|
2262
2280
|
}
|
|
2263
2281
|
destroy() {
|
|
2264
|
-
super.destroy()
|
|
2282
|
+
super.destroy();
|
|
2283
|
+
this.exitEdit();
|
|
2284
|
+
this.renderer.scene.remove(this.container);
|
|
2285
|
+
this.domElement.remove();
|
|
2286
|
+
this.app?.unmount();
|
|
2265
2287
|
}
|
|
2266
2288
|
};
|
|
2267
|
-
class
|
|
2289
|
+
class PointDrag extends CommandFlowComponent {
|
|
2268
2290
|
static name = "PointDrag";
|
|
2269
|
-
container = new
|
|
2291
|
+
container = new THREE.Group();
|
|
2270
2292
|
interruptKeys = ["escape"];
|
|
2271
2293
|
shortcutKeys = ["control", "p"];
|
|
2272
2294
|
commandName = "point";
|
|
2273
|
-
onAddFromParent(
|
|
2274
|
-
super.onAddFromParent(
|
|
2275
|
-
|
|
2276
|
-
|
|
2295
|
+
onAddFromParent(parent) {
|
|
2296
|
+
super.onAddFromParent(parent);
|
|
2297
|
+
this.editor.container.add(this.container);
|
|
2298
|
+
this.container.position.z = 1e-3;
|
|
2299
|
+
const commandFlow = this.commandManager.addCommandFlow(this.commandName).add(this.createInterrupt()).add(this.createCursor("crosshair")).add(this.selectPoint.bind(this)).add(this.drag.bind(this));
|
|
2300
|
+
commandFlow.addEventListener("finally", this.createFinally());
|
|
2301
|
+
commandFlow.addEventListener("completed", (e) => this.completed(e.data));
|
|
2302
|
+
this.eventInput.addKeyCombination(this.commandName, this.shortcutKeys);
|
|
2303
|
+
this.eventInput.addEventListener("codeChange", async () => this.eventInput.isKeyCombination(this.commandName) && await this.commandManager.start(this.commandName));
|
|
2304
|
+
this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
|
|
2277
2305
|
}
|
|
2278
2306
|
/** 选择开始点
|
|
2279
2307
|
* @param next
|
|
2280
2308
|
*/
|
|
2281
|
-
selectPoint(
|
|
2282
|
-
let
|
|
2309
|
+
selectPoint(next) {
|
|
2310
|
+
let currentPoint = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 16711935 })), currentLine = null;
|
|
2283
2311
|
this.addEventRecord("selectPointStart").add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
2284
|
-
const { point
|
|
2285
|
-
|
|
2312
|
+
const { point, line: line2, find, mode } = this.editor.renderManager.adsorption();
|
|
2313
|
+
if (find && mode === "point") {
|
|
2314
|
+
this.domElement.style.cursor = "none";
|
|
2315
|
+
circle.position.copy(point);
|
|
2316
|
+
currentLine = line2;
|
|
2317
|
+
currentPoint = point.clone();
|
|
2318
|
+
this.container.add(circle);
|
|
2319
|
+
} else {
|
|
2320
|
+
this.domElement.style.cursor = "no-drop";
|
|
2321
|
+
currentPoint = null;
|
|
2322
|
+
circle.removeFromParent();
|
|
2323
|
+
}
|
|
2286
2324
|
})).add(this.eventInput.addEventListener("codeChange", () => {
|
|
2287
|
-
this.eventInput.isKeyDown("mouse_0") &&
|
|
2288
|
-
|
|
2325
|
+
if (this.eventInput.isKeyDown("mouse_0") && currentPoint) {
|
|
2326
|
+
this.canceEventRecord("selectPointStart");
|
|
2327
|
+
circle.material.color.set(65280);
|
|
2328
|
+
next({ point: currentPoint, line: currentLine });
|
|
2329
|
+
}
|
|
2330
|
+
}));
|
|
2331
|
+
this.addEventRecord("clear").add(() => circle.removeFromParent());
|
|
2289
2332
|
}
|
|
2290
2333
|
/** 拖拽点
|
|
2291
2334
|
* @description 拖拽点到指定位置
|
|
2292
2335
|
* @param next
|
|
2293
2336
|
* @param param1
|
|
2294
2337
|
*/
|
|
2295
|
-
drag(
|
|
2338
|
+
drag(next, { point, line: line2 }) {
|
|
2296
2339
|
this.domElement.style.cursor = "crosshair";
|
|
2297
|
-
const
|
|
2298
|
-
this.container.add(
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2340
|
+
const mode = line2.start.equal(Point.from(point)) ? "start" : "end", start = mode == "start" ? new THREE.Vector3(line2.end.x, line2.end.y, 0) : new THREE.Vector3(line2.start.x, line2.start.y, 0), end = point.clone(), lines = new Lines([start, end], 16711935), circle = new THREE.Mesh(new THREE.SphereGeometry(0.03), new THREE.MeshBasicMaterial({ color: 16711935 }));
|
|
2341
|
+
this.container.add(lines);
|
|
2342
|
+
this.addEventRecord("clear").add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
2343
|
+
let { point: point2, find } = this.editor.renderManager.adsorption(), cursor = "none";
|
|
2344
|
+
if (point2) {
|
|
2345
|
+
if (this.eventInput.isKeyDown("shift")) {
|
|
2346
|
+
const p = line2.projectPoint(Point.from(point2), false);
|
|
2347
|
+
point2.set(p?.x ?? point2.x, p?.y ?? point2.y, 0);
|
|
2348
|
+
find = true;
|
|
2349
|
+
cursor = "crosshair";
|
|
2350
|
+
}
|
|
2351
|
+
if (find) {
|
|
2352
|
+
circle.position.copy(point2);
|
|
2353
|
+
this.container.add(circle);
|
|
2354
|
+
} else {
|
|
2355
|
+
circle.removeFromParent();
|
|
2356
|
+
cursor = "crosshair";
|
|
2304
2357
|
}
|
|
2305
|
-
|
|
2358
|
+
end.copy(point2);
|
|
2359
|
+
lines.setPoint(start, end);
|
|
2360
|
+
this.domElement.style.cursor = cursor;
|
|
2306
2361
|
}
|
|
2307
2362
|
})).add(this.eventInput.addEventListener("codeChange", () => {
|
|
2308
|
-
this.eventInput.isKeyDown("mouse_0")
|
|
2309
|
-
|
|
2363
|
+
if (this.eventInput.isKeyDown("mouse_0")) {
|
|
2364
|
+
this.canceEventRecord("selectPointStart");
|
|
2365
|
+
next({ point: end, line: line2, mode });
|
|
2366
|
+
}
|
|
2367
|
+
})).add(() => circle.removeFromParent()).add(() => lines.removeFromParent());
|
|
2310
2368
|
}
|
|
2311
2369
|
/** 执行完成
|
|
2312
2370
|
*/
|
|
2313
|
-
completed(
|
|
2314
|
-
const { line:
|
|
2315
|
-
this.renderManager.removeLine(
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
rollback(e) {
|
|
2321
|
-
const { line: t, oldPoint: n, mode: o } = e;
|
|
2322
|
-
return o === "end" ? t.end.set(n.x, n.y) : o === "start" && t.start.set(n.x, n.y), this.renderManager.addLine(t), this.renderManager.draw(), e;
|
|
2323
|
-
}
|
|
2324
|
-
/** 撤回回滚
|
|
2325
|
-
* @param lines
|
|
2326
|
-
* @returns
|
|
2327
|
-
*/
|
|
2328
|
-
revokeRollback(e) {
|
|
2329
|
-
return this.completed(e), e;
|
|
2371
|
+
completed(data) {
|
|
2372
|
+
const { line: line2, point, mode } = data;
|
|
2373
|
+
this.renderManager.removeLine(line2);
|
|
2374
|
+
if (mode === "end") line2.end.set(point.x, point.y);
|
|
2375
|
+
else if (mode === "start") line2.start.set(point.x, point.y);
|
|
2376
|
+
this.renderManager.addLine(line2);
|
|
2377
|
+
this.renderManager.draw();
|
|
2330
2378
|
}
|
|
2331
2379
|
}
|
|
2332
|
-
function
|
|
2333
|
-
|
|
2380
|
+
function Editor_(dxfSystem, option = {}) {
|
|
2381
|
+
dxfSystem.addComponent(new Editor$1(option.viewPermission));
|
|
2382
|
+
dxfSystem.addComponent(new RenderManager());
|
|
2383
|
+
dxfSystem.addComponent(new Default());
|
|
2384
|
+
dxfSystem.addComponent(new DrawLine());
|
|
2385
|
+
dxfSystem.addComponent(new DrawDoorLine());
|
|
2386
|
+
dxfSystem.addComponent(new DrawWindow());
|
|
2387
|
+
dxfSystem.addComponent(new PointDrag());
|
|
2334
2388
|
}
|
|
2335
|
-
const
|
|
2336
|
-
create(
|
|
2337
|
-
return (
|
|
2389
|
+
const Editor2 = Object.assign(Editor_, {
|
|
2390
|
+
create(option = {}) {
|
|
2391
|
+
return (dxfSystem) => Editor_(dxfSystem, option);
|
|
2338
2392
|
}
|
|
2339
2393
|
});
|
|
2340
2394
|
export {
|
|
2341
|
-
|
|
2342
|
-
|
|
2395
|
+
Editor2 as Editor,
|
|
2396
|
+
Editor_
|
|
2343
2397
|
};
|