build-dxf 0.0.19-14 → 0.0.19-15
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/index.css +65 -11
- package/src/index2.js +13 -2520
- package/src/index3.js +732 -485
- package/src/pages/Editor.vue.d.ts +3 -1
- package/src/selectLocalFile.js +2573 -91
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/CommandFlowComponent.d.ts +8 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/Default.d.ts +7 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawLine.d.ts +2 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawWindow.d.ts +2 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/PointDrag.d.ts +2 -1
- package/src/utils/DxfSystem/plugin/Editor/components/Editor.d.ts +5 -0
- package/src/components/Editor.vue.d.ts +0 -26
- package/src/pages/Editor02.vue.d.ts +0 -4
package/src/index3.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
|
-
import {
|
|
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
3
|
import { C as Component, L as LineSegment, P as Point, B as Box2, E as EventDispatcher, b as PointVirtualGrid, Q as Quadtree } 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, createApp } from "vue";
|
|
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";
|
|
5
5
|
import "clipper-lib";
|
|
6
6
|
import "dxf-writer";
|
|
7
7
|
import "three/addons/controls/OrbitControls.js";
|
|
@@ -714,6 +714,22 @@ class CommandFlowComponent extends Component {
|
|
|
714
714
|
return this._commandManager;
|
|
715
715
|
}
|
|
716
716
|
interruptKeys = ["escape"];
|
|
717
|
+
commandName = "";
|
|
718
|
+
constructor() {
|
|
719
|
+
super();
|
|
720
|
+
}
|
|
721
|
+
onAddFromParent(parent) {
|
|
722
|
+
this.editor.addEventListener("cancelCommand", () => {
|
|
723
|
+
this.cancel();
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* 取消
|
|
728
|
+
*/
|
|
729
|
+
cancel() {
|
|
730
|
+
if (this.editor.commandManager.currentName !== this.commandName) return;
|
|
731
|
+
this.editor.commandManager.cancel();
|
|
732
|
+
}
|
|
717
733
|
/**
|
|
718
734
|
* 创建中断
|
|
719
735
|
* @returns
|
|
@@ -723,9 +739,7 @@ class CommandFlowComponent extends Component {
|
|
|
723
739
|
this.addEventRecord(
|
|
724
740
|
"clear",
|
|
725
741
|
this.editor?.eventInput.addEventListener("codeChange", async () => {
|
|
726
|
-
if (this.editor.eventInput.isKeyDowns(this.interruptKeys))
|
|
727
|
-
this.editor.commandManager.cancel();
|
|
728
|
-
}
|
|
742
|
+
if (this.editor.eventInput.isKeyDowns(this.interruptKeys)) this.cancel();
|
|
729
743
|
})
|
|
730
744
|
);
|
|
731
745
|
next(data);
|
|
@@ -764,7 +778,8 @@ class DrawLine extends CommandFlowComponent {
|
|
|
764
778
|
shortcutKeys = ["control", "l"];
|
|
765
779
|
confirmKeys = ["enter"];
|
|
766
780
|
commandName = "draw-line";
|
|
767
|
-
onAddFromParent() {
|
|
781
|
+
onAddFromParent(parent) {
|
|
782
|
+
super.onAddFromParent(parent);
|
|
768
783
|
this.editor.container.add(this.container);
|
|
769
784
|
const commandFlow = this.commandManager.addCommandFlow(this.commandName).add(this.createInterrupt()).add(this.createCursor("crosshair")).add(this.selectPoint.bind(this));
|
|
770
785
|
commandFlow.addEventListener("finally", this.createFinally());
|
|
@@ -777,7 +792,7 @@ class DrawLine extends CommandFlowComponent {
|
|
|
777
792
|
* @param next
|
|
778
793
|
*/
|
|
779
794
|
selectPoint(next) {
|
|
780
|
-
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,
|
|
795
|
+
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([
|
|
781
796
|
new THREE.Vector3(-1e4, 0, 0),
|
|
782
797
|
new THREE.Vector3(1e4, 0, 0),
|
|
783
798
|
new THREE.Vector3(0, -1e4, 0),
|
|
@@ -789,9 +804,9 @@ class DrawLine extends CommandFlowComponent {
|
|
|
789
804
|
gapSize: 0.1,
|
|
790
805
|
linewidth: 0.1
|
|
791
806
|
});
|
|
792
|
-
this.container.add(
|
|
807
|
+
this.container.add(line2);
|
|
793
808
|
const updateLine = () => {
|
|
794
|
-
|
|
809
|
+
line2.setPoint(...points, start, end);
|
|
795
810
|
auxiliaryLine.position.copy(end);
|
|
796
811
|
this.container.add(auxiliaryLine);
|
|
797
812
|
auxiliaryLine.computeLineDistances();
|
|
@@ -845,7 +860,7 @@ class DrawLine extends CommandFlowComponent {
|
|
|
845
860
|
} else if (editor.eventInput.isKeyDowns(this.confirmKeys)) next(points);
|
|
846
861
|
}),
|
|
847
862
|
function() {
|
|
848
|
-
|
|
863
|
+
line2.removeFromParent();
|
|
849
864
|
circle.removeFromParent();
|
|
850
865
|
auxiliaryLine.removeFromParent();
|
|
851
866
|
}
|
|
@@ -889,6 +904,9 @@ class Default extends Component {
|
|
|
889
904
|
if (this.selectLines.indexOf(lineSegment) > -1) return;
|
|
890
905
|
this.selectLines.push(lineSegment);
|
|
891
906
|
this.updateSelectLinesGeometry();
|
|
907
|
+
this.dispatchEvent({
|
|
908
|
+
type: "selectLineChange"
|
|
909
|
+
});
|
|
892
910
|
}
|
|
893
911
|
/** 移除选择的线段
|
|
894
912
|
* @param lineSegment
|
|
@@ -898,15 +916,27 @@ class Default extends Component {
|
|
|
898
916
|
if (i > -1) {
|
|
899
917
|
this.selectLines.splice(i, 1);
|
|
900
918
|
this.updateSelectLinesGeometry();
|
|
919
|
+
this.dispatchEvent({
|
|
920
|
+
type: "selectLineChange"
|
|
921
|
+
});
|
|
901
922
|
}
|
|
902
923
|
}
|
|
924
|
+
/**
|
|
925
|
+
* 移除所有选中线段
|
|
926
|
+
*/
|
|
927
|
+
removeSelectLineAll() {
|
|
928
|
+
this.selectLines.length = 0;
|
|
929
|
+
this.dispatchEvent({
|
|
930
|
+
type: "selectLineChange"
|
|
931
|
+
});
|
|
932
|
+
}
|
|
903
933
|
/**
|
|
904
934
|
* 删除选择的线段
|
|
905
935
|
*/
|
|
906
936
|
deleteSelectLine() {
|
|
907
937
|
const editor = this.editor;
|
|
908
|
-
this.selectLines.forEach((
|
|
909
|
-
this.
|
|
938
|
+
this.selectLines.forEach((line2) => editor.renderManager.removeLine(line2));
|
|
939
|
+
this.removeSelectLineAll();
|
|
910
940
|
this.updateSelectLinesGeometry();
|
|
911
941
|
ElMessage({ message: "删除成功", type: "success" });
|
|
912
942
|
}
|
|
@@ -915,9 +945,9 @@ class Default extends Component {
|
|
|
915
945
|
*/
|
|
916
946
|
deleteSelectWindow() {
|
|
917
947
|
let is = false;
|
|
918
|
-
this.selectLines.forEach((
|
|
919
|
-
if (!
|
|
920
|
-
|
|
948
|
+
this.selectLines.forEach((line2) => {
|
|
949
|
+
if (!line2.userData.isWindow) return;
|
|
950
|
+
line2.userData = {};
|
|
921
951
|
is = true;
|
|
922
952
|
});
|
|
923
953
|
this.editor.renderManager.draw();
|
|
@@ -945,8 +975,8 @@ class Default extends Component {
|
|
|
945
975
|
}
|
|
946
976
|
}
|
|
947
977
|
if (start && end) {
|
|
948
|
-
const
|
|
949
|
-
editor.renderManager.addLine(
|
|
978
|
+
const line2 = new LineSegment(start.clone(), end.clone());
|
|
979
|
+
editor.renderManager.addLine(line2);
|
|
950
980
|
editor.renderManager.draw();
|
|
951
981
|
ElMessage({ message: "连接成功", type: "success" });
|
|
952
982
|
}
|
|
@@ -995,8 +1025,8 @@ class Default extends Component {
|
|
|
995
1025
|
const p2Next = line2.points[(j + 1) % 2];
|
|
996
1026
|
editor.renderManager.removeLine(line1);
|
|
997
1027
|
editor.renderManager.removeLine(line2);
|
|
998
|
-
const
|
|
999
|
-
editor.renderManager.addLine(
|
|
1028
|
+
const line3 = new LineSegment(p1Next, p2Next);
|
|
1029
|
+
editor.renderManager.addLine(line3);
|
|
1000
1030
|
editor.renderManager.draw();
|
|
1001
1031
|
ElMessage({ message: "已合并", type: "success" });
|
|
1002
1032
|
return;
|
|
@@ -1015,7 +1045,7 @@ class Default extends Component {
|
|
|
1015
1045
|
if (this.selectLines.length) this.container.add(this.selectLineObject3D);
|
|
1016
1046
|
else this.selectLineObject3D.removeFromParent();
|
|
1017
1047
|
const editor = this.editor;
|
|
1018
|
-
const position = this.selectLines.flatMap((
|
|
1048
|
+
const position = this.selectLines.flatMap((line2) => line2.expandToRectangle(0.04, "bothSides").createGeometry());
|
|
1019
1049
|
this.selectLineObject3D.geometry = editor.renderManager.createGeometry({ position }, position.length / 3);
|
|
1020
1050
|
}, 10);
|
|
1021
1051
|
}
|
|
@@ -1081,7 +1111,7 @@ class Default extends Component {
|
|
|
1081
1111
|
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);
|
|
1082
1112
|
const box = new Box2(minX, maxX, minY, maxY);
|
|
1083
1113
|
const resultList = editor.renderManager.quadtree.queryBox(box);
|
|
1084
|
-
this.
|
|
1114
|
+
this.removeSelectLineAll();
|
|
1085
1115
|
resultList.forEach((result) => this.addSelectLine(result.line));
|
|
1086
1116
|
this.updateSelectLinesGeometry();
|
|
1087
1117
|
};
|
|
@@ -1092,13 +1122,13 @@ class Default extends Component {
|
|
|
1092
1122
|
"clear",
|
|
1093
1123
|
// 注册鼠标指针位置变化事件
|
|
1094
1124
|
editor.addEventListener("pointerPositionChange", () => {
|
|
1095
|
-
const { line } = editor.renderManager.adsorption(0.05);
|
|
1096
|
-
if (
|
|
1097
|
-
const rectangle =
|
|
1125
|
+
const { line: line2 } = editor.renderManager.adsorption(0.05);
|
|
1126
|
+
if (line2) {
|
|
1127
|
+
const rectangle = line2.expandToRectangle(0.02, "bothSides");
|
|
1098
1128
|
object3D.geometry = editor.renderManager.createGeometry({ position: rectangle.createGeometry() }, 6);
|
|
1099
1129
|
this.container.add(object3D);
|
|
1100
1130
|
dom.style.cursor = "pointer";
|
|
1101
|
-
currentSelectLine =
|
|
1131
|
+
currentSelectLine = line2;
|
|
1102
1132
|
} else {
|
|
1103
1133
|
object3D.removeFromParent();
|
|
1104
1134
|
dom.style.cursor = "default";
|
|
@@ -1111,7 +1141,7 @@ class Default extends Component {
|
|
|
1111
1141
|
if (eventInput.isKeyDown("alt")) {
|
|
1112
1142
|
return this.removeSelectLine(currentSelectLine);
|
|
1113
1143
|
}
|
|
1114
|
-
if (!eventInput.isKeyDown("control")) this.
|
|
1144
|
+
if (!eventInput.isKeyDown("control")) this.removeSelectLineAll();
|
|
1115
1145
|
this.addSelectLine(currentSelectLine);
|
|
1116
1146
|
} else if (eventInput.isOnlyKeyDown("delete")) {
|
|
1117
1147
|
this.deleteSelectLine();
|
|
@@ -1135,7 +1165,7 @@ class Default extends Component {
|
|
|
1135
1165
|
*/
|
|
1136
1166
|
finally() {
|
|
1137
1167
|
this.canceEventRecord("clear");
|
|
1138
|
-
this.
|
|
1168
|
+
this.removeSelectLineAll();
|
|
1139
1169
|
this.updateSelectLinesGeometry();
|
|
1140
1170
|
}
|
|
1141
1171
|
}
|
|
@@ -1248,429 +1278,134 @@ class CommandManager extends EventDispatcher {
|
|
|
1248
1278
|
}
|
|
1249
1279
|
}
|
|
1250
1280
|
}
|
|
1251
|
-
const
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
];
|
|
1305
|
-
watch(toolBarPosition, () => localStorage.setItem("EditorToolPosition", JSON.stringify(toolBarPosition.value)));
|
|
1306
|
-
function setEditorToolPosition(left, top, rect = elRef.value.getBoundingClientRect(), toolBarRect = toolBarRef.value.getBoundingClientRect()) {
|
|
1307
|
-
const minX = 0, maxX = rect.width - toolBarRect.width, minY = 0, maxY = rect.height - toolBarRect.height;
|
|
1308
|
-
left = Math.max(minX, Math.min(left, maxX));
|
|
1309
|
-
top = Math.max(minY, Math.min(top, maxY));
|
|
1310
|
-
toolBarPosition.value = { left, top };
|
|
1311
|
-
}
|
|
1312
|
-
function startCurrentCommandItem(item) {
|
|
1313
|
-
if (currentCommand.value === item.command) return;
|
|
1314
|
-
editor.commandManager.start(item.command);
|
|
1281
|
+
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";
|
|
1282
|
+
const __vite_glob_0_0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1283
|
+
__proto__: null,
|
|
1284
|
+
default: door
|
|
1285
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1286
|
+
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";
|
|
1287
|
+
const __vite_glob_0_1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1288
|
+
__proto__: null,
|
|
1289
|
+
default: line
|
|
1290
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1291
|
+
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";
|
|
1292
|
+
const __vite_glob_0_2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1293
|
+
__proto__: null,
|
|
1294
|
+
default: selectPoint
|
|
1295
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1296
|
+
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";
|
|
1297
|
+
const __vite_glob_0_3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1298
|
+
__proto__: null,
|
|
1299
|
+
default: window$1
|
|
1300
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1301
|
+
class RenderManager extends Component {
|
|
1302
|
+
static name = "RenderManager";
|
|
1303
|
+
container = new THREE.Group();
|
|
1304
|
+
lines = [];
|
|
1305
|
+
pointVirtualGrid = new PointVirtualGrid();
|
|
1306
|
+
quadtree = new Quadtree(new Box2());
|
|
1307
|
+
actionHistory = /* @__PURE__ */ new Set();
|
|
1308
|
+
onAddFromParent() {
|
|
1309
|
+
const dxfLineModel = this.dxfLineModel;
|
|
1310
|
+
this.editor.container.add(this.container);
|
|
1311
|
+
this.editor.container.add(dxfLineModel.dxfModelGroup);
|
|
1312
|
+
dxfLineModel.dxfLineModel.material = new THREE.LineBasicMaterial({
|
|
1313
|
+
transparent: true,
|
|
1314
|
+
opacity: 0.5,
|
|
1315
|
+
color: 16777215
|
|
1316
|
+
});
|
|
1317
|
+
dxfLineModel.addEventListener("modelUpdate", (e) => {
|
|
1318
|
+
e.model.position.z = 0;
|
|
1319
|
+
dxfLineModel.dxfDoorsLineModel.visible = false;
|
|
1320
|
+
});
|
|
1321
|
+
this.variable.addEventListener("dxfVisible", (e) => dxfLineModel.dxfModelGroup.visible = e.value);
|
|
1322
|
+
this.dxf.addEventListener("createGroup", () => this.reset());
|
|
1323
|
+
this.reset();
|
|
1324
|
+
}
|
|
1325
|
+
updatedMode = null;
|
|
1326
|
+
/** 重新设置数据
|
|
1327
|
+
*/
|
|
1328
|
+
reset() {
|
|
1329
|
+
if (this.updatedMode === "self") {
|
|
1330
|
+
this.updatedMode = null;
|
|
1331
|
+
return;
|
|
1332
|
+
} else {
|
|
1333
|
+
this.updatedMode = "dxf";
|
|
1315
1334
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
};
|
|
1331
|
-
const end = () => {
|
|
1332
|
-
document.body.removeEventListener("mousemove", move);
|
|
1333
|
-
document.removeEventListener("mouseup", end);
|
|
1334
|
-
document.body.style.cursor = cusor;
|
|
1335
|
-
domEventRegister.mouseMoveEventProxylock = false;
|
|
1335
|
+
this.pointVirtualGrid = new PointVirtualGrid();
|
|
1336
|
+
const box = this.dxf.box.clone().expansion(Math.max(this.dxf.box.width, this.dxf.box.height) * 2);
|
|
1337
|
+
if (box.width === 0 || box.height === 0) box.set(-200, -200, 200, 200);
|
|
1338
|
+
this.quadtree = new Quadtree(box);
|
|
1339
|
+
this.lines.length = 0;
|
|
1340
|
+
this.dxf.lineSegments.forEach((line2) => {
|
|
1341
|
+
if (line2.userData.isDoor && !line2.userData.doorDirectConnection) return;
|
|
1342
|
+
this.addLine(line2.clone());
|
|
1343
|
+
});
|
|
1344
|
+
this.dxf.doorLineSegment.forEach((line2) => {
|
|
1345
|
+
const door2 = line2.clone();
|
|
1346
|
+
door2.userData = {
|
|
1347
|
+
isDoor: true,
|
|
1348
|
+
doorDirectConnection: true
|
|
1336
1349
|
};
|
|
1337
|
-
|
|
1338
|
-
document.addEventListener("mouseup", end);
|
|
1339
|
-
}
|
|
1340
|
-
watch(originalLineVisible, () => dxfSystem.Variable.set("originalLineVisible", originalLineVisible.value));
|
|
1341
|
-
watch(dxfVisible, () => dxfSystem.Variable.set("dxfVisible", dxfVisible.value));
|
|
1342
|
-
watch(whiteModelVisible, () => dxfSystem.Variable.set("whiteModelVisible", whiteModelVisible.value));
|
|
1343
|
-
dxfSystem.Variable.addEventListener("isLook", (e) => isLook.value = e.value);
|
|
1344
|
-
dxfSystem.Variable.addEventListener("originalLineVisible", (e) => originalLineVisible.value = e.value);
|
|
1345
|
-
dxfSystem.Variable.addEventListener("dxfVisible", (e) => dxfVisible.value = e.value);
|
|
1346
|
-
dxfSystem.Variable.addEventListener("whiteModelVisible", (e) => whiteModelVisible.value = e.value);
|
|
1347
|
-
const startedEventCancel = editor.commandManager.addEventListener("started", (e) => {
|
|
1348
|
-
currentCommand.value = e.name;
|
|
1350
|
+
this.addLine(door2);
|
|
1349
1351
|
});
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1352
|
+
this.draw();
|
|
1353
|
+
}
|
|
1354
|
+
/** 添加线段
|
|
1355
|
+
* @param line
|
|
1356
|
+
*/
|
|
1357
|
+
addLine(line2) {
|
|
1358
|
+
if (!line2.userData) line2.userData = {};
|
|
1359
|
+
this.lines.push(line2);
|
|
1360
|
+
this.pointVirtualGrid.insert(line2.start, line2);
|
|
1361
|
+
this.pointVirtualGrid.insert(line2.end, line2);
|
|
1362
|
+
const quadtreeNode = {
|
|
1363
|
+
line: line2,
|
|
1364
|
+
userData: void 0
|
|
1365
|
+
};
|
|
1366
|
+
line2.userData.quadtreeNode = quadtreeNode;
|
|
1367
|
+
this.quadtree.insert(quadtreeNode);
|
|
1368
|
+
this.actionHistory.add({
|
|
1369
|
+
type: "addLine",
|
|
1370
|
+
data: [line2]
|
|
1359
1371
|
});
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* 批量添加
|
|
1375
|
+
* @param lines
|
|
1376
|
+
*/
|
|
1377
|
+
addLines(lines) {
|
|
1378
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1379
|
+
const line2 = lines[i];
|
|
1380
|
+
this.lines.push(line2);
|
|
1381
|
+
this.pointVirtualGrid.insert(line2.start, line2);
|
|
1382
|
+
this.pointVirtualGrid.insert(line2.end, line2);
|
|
1383
|
+
const quadtreeNode = {
|
|
1384
|
+
line: line2,
|
|
1385
|
+
userData: void 0
|
|
1386
|
+
};
|
|
1387
|
+
line2.userData.quadtreeNode = quadtreeNode;
|
|
1388
|
+
this.quadtree.insert(quadtreeNode);
|
|
1389
|
+
}
|
|
1390
|
+
this.actionHistory.add({
|
|
1391
|
+
type: "addLine",
|
|
1392
|
+
data: [...lines]
|
|
1363
1393
|
});
|
|
1364
|
-
return (_ctx, _cache) => {
|
|
1365
|
-
return openBlock(), createElementBlock("div", {
|
|
1366
|
-
ref_key: "elRef",
|
|
1367
|
-
ref: elRef,
|
|
1368
|
-
class: "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]"
|
|
1369
|
-
}, [
|
|
1370
|
-
createElementVNode("div", _hoisted_1, [
|
|
1371
|
-
(openBlock(), createElementBlock(Fragment, null, renderList(shortcutKeys, (item) => {
|
|
1372
|
-
return createElementVNode("p", {
|
|
1373
|
-
class: "p-[2px_0px] flex justify-between text-right border-b-1 border-b-[rgba(255,255,255,0.1)] last-of-type:border-b-0",
|
|
1374
|
-
key: item.name
|
|
1375
|
-
}, [
|
|
1376
|
-
createTextVNode(toDisplayString(item.name) + ": ", 1),
|
|
1377
|
-
createElementVNode("span", _hoisted_2, toDisplayString(item.shortcut), 1)
|
|
1378
|
-
]);
|
|
1379
|
-
}), 64))
|
|
1380
|
-
]),
|
|
1381
|
-
createElementVNode("div", {
|
|
1382
|
-
ref_key: "toolBarRef",
|
|
1383
|
-
ref: toolBarRef,
|
|
1384
|
-
style: normalizeStyle({ left: toolBarPosition.value.left + "px", top: toolBarPosition.value.top + "px" }),
|
|
1385
|
-
class: "pointer-events-auto text-[#333] absolute rounded-[8px] z-[11] bg-white select-none"
|
|
1386
|
-
}, [
|
|
1387
|
-
createElementVNode("div", {
|
|
1388
|
-
class: normalizeClass([{ "border-b-[#eee]": toolBarExpand.value }, "flex flex-row justify-between header text-[14px] font-bold p-[10px 0px] border-b-1"])
|
|
1389
|
-
}, [
|
|
1390
|
-
createElementVNode("div", {
|
|
1391
|
-
class: "flex flex-row",
|
|
1392
|
-
onMousedown: dragMoveHelper
|
|
1393
|
-
}, _cache[3] || (_cache[3] = [
|
|
1394
|
-
createElementVNode("div", { class: "p-[2px_5px] flex items-center pointer-events-none" }, [
|
|
1395
|
-
createElementVNode("svg", {
|
|
1396
|
-
fill: "#aaa",
|
|
1397
|
-
width: "20",
|
|
1398
|
-
height: "20",
|
|
1399
|
-
viewBox: "0 0 1024 1024",
|
|
1400
|
-
version: "1.1",
|
|
1401
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
1402
|
-
}, [
|
|
1403
|
-
createElementVNode("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" })
|
|
1404
|
-
])
|
|
1405
|
-
], -1),
|
|
1406
|
-
createElementVNode("h5", { class: "flex items-center pointer-events-none" }, "绘制工具", -1)
|
|
1407
|
-
]), 32),
|
|
1408
|
-
createElementVNode("div", {
|
|
1409
|
-
onClick: _cache[0] || (_cache[0] = ($event) => toolBarExpand.value = !toolBarExpand.value),
|
|
1410
|
-
class: "cursor-pointer flex items-center p-[0px_5px]"
|
|
1411
|
-
}, [
|
|
1412
|
-
(openBlock(), createElementBlock("svg", {
|
|
1413
|
-
fill: "#666",
|
|
1414
|
-
class: normalizeClass([{ "rotate-90": toolBarExpand.value }, "transition-all"]),
|
|
1415
|
-
viewBox: "0 0 1024 1024",
|
|
1416
|
-
version: "1.1",
|
|
1417
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1418
|
-
width: "12",
|
|
1419
|
-
height: "12"
|
|
1420
|
-
}, _cache[4] || (_cache[4] = [
|
|
1421
|
-
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)
|
|
1422
|
-
]), 2))
|
|
1423
|
-
])
|
|
1424
|
-
], 2),
|
|
1425
|
-
toolBarExpand.value ? (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
1426
|
-
createElementVNode("ul", _hoisted_4, [
|
|
1427
|
-
(openBlock(), createElementBlock(Fragment, null, renderList(commandList, (item) => {
|
|
1428
|
-
return openBlock(), createElementBlock(Fragment, {
|
|
1429
|
-
key: item.command
|
|
1430
|
-
}, [
|
|
1431
|
-
item.show ? (openBlock(), createElementBlock("li", {
|
|
1432
|
-
key: 0,
|
|
1433
|
-
onClick: ($event) => startCurrentCommandItem(item),
|
|
1434
|
-
class: normalizeClass([{ "!bg-[#409eff] text-[#fff]": currentCommand.value === item.command }, "text-[12px] hover:bg-[#ddd] transition-all rounded-[6px] p-[5px] flex flex-row items-center cursor-pointer"])
|
|
1435
|
-
}, [
|
|
1436
|
-
_cache[5] || (_cache[5] = createElementVNode("div", { class: "p-[2px] h-fit bg-[#f0f0f0] rounded-[2px] mr-[10px]" }, [
|
|
1437
|
-
createElementVNode("img", {
|
|
1438
|
-
class: "w-[10px] h-[10px]",
|
|
1439
|
-
src: _imports_0,
|
|
1440
|
-
alt: "",
|
|
1441
|
-
srcset: ""
|
|
1442
|
-
})
|
|
1443
|
-
], -1)),
|
|
1444
|
-
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
1445
|
-
], 10, _hoisted_5)) : createCommentVNode("", true)
|
|
1446
|
-
], 64);
|
|
1447
|
-
}), 64))
|
|
1448
|
-
]),
|
|
1449
|
-
createCommentVNode("", true)
|
|
1450
|
-
])) : createCommentVNode("", true)
|
|
1451
|
-
], 4)
|
|
1452
|
-
], 512);
|
|
1453
|
-
};
|
|
1454
1394
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
}
|
|
1470
|
-
get dxf() {
|
|
1471
|
-
return this.parent?.findComponentByName("Dxf");
|
|
1472
|
-
}
|
|
1473
|
-
get variable() {
|
|
1474
|
-
return this.parent?.findComponentByName("Variable");
|
|
1475
|
-
}
|
|
1476
|
-
get eventInput() {
|
|
1477
|
-
return this.parent?.findComponentByName("EventInput");
|
|
1478
|
-
}
|
|
1479
|
-
get renderManager() {
|
|
1480
|
-
return this.parent?.findComponentByName("RenderManager");
|
|
1481
|
-
}
|
|
1482
|
-
get domEventRegister() {
|
|
1483
|
-
return this.parent?.findComponentByName("DomEventRegister");
|
|
1484
|
-
}
|
|
1485
|
-
get domContainer() {
|
|
1486
|
-
return this.parent?.findComponentByName("DomContainer");
|
|
1487
|
-
}
|
|
1488
|
-
commandManager = new CommandManager();
|
|
1489
|
-
plane = new THREE.Mesh(new THREE.PlaneGeometry(2e3, 2e3, 2, 2));
|
|
1490
|
-
app;
|
|
1491
|
-
domElement = document.createElement("div");
|
|
1492
|
-
onAddFromParent() {
|
|
1493
|
-
setTimeout(() => this.openEdit(), 10);
|
|
1494
|
-
const grid = new THREE.GridHelper(200, 100, 6710886, 4473924);
|
|
1495
|
-
grid.rotation.x = Math.PI * 0.5;
|
|
1496
|
-
grid.position.z = -0.01;
|
|
1497
|
-
this.container.add(grid);
|
|
1498
|
-
this.container.add(this.plane);
|
|
1499
|
-
this.plane.visible = false;
|
|
1500
|
-
this.app = createApp(EditorTool, { dxfSystem: this.parent });
|
|
1501
|
-
this.app.mount(this.domElement);
|
|
1502
|
-
const cancelEvent = this.addEventListener("update", () => {
|
|
1503
|
-
if (this.domContainer.domElement.parentElement) {
|
|
1504
|
-
this.domContainer.domElement.parentElement.appendChild(this.domElement);
|
|
1505
|
-
cancelEvent();
|
|
1506
|
-
}
|
|
1507
|
-
});
|
|
1508
|
-
}
|
|
1509
|
-
coords = new THREE.Vector2();
|
|
1510
|
-
pointerPosition = new THREE.Vector2();
|
|
1511
|
-
_exitEditCallBack;
|
|
1512
|
-
/**
|
|
1513
|
-
* 打开编辑器
|
|
1514
|
-
*/
|
|
1515
|
-
openEdit() {
|
|
1516
|
-
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;
|
|
1517
|
-
this.container.position.z = dxf.originalZAverage;
|
|
1518
|
-
renderer.scene.add(this.container);
|
|
1519
|
-
camera.position.set(center.x, center.y, 14);
|
|
1520
|
-
if (orbitControls) {
|
|
1521
|
-
orbitControls.target.set(center.x, center.y, 0);
|
|
1522
|
-
orbitControls.enableRotate = false;
|
|
1523
|
-
}
|
|
1524
|
-
const mousemoveFun = () => {
|
|
1525
|
-
renderer.renderer.getSize(size);
|
|
1526
|
-
const x = domEventRegister.pointer.x / size.x * 2 - 1;
|
|
1527
|
-
const y = -(domEventRegister.pointer.y / size.y * 2 - 1);
|
|
1528
|
-
coords.set(x, y);
|
|
1529
|
-
raycaster.setFromCamera(coords, renderer.camera);
|
|
1530
|
-
const intersections = raycaster.intersectObject(this.plane);
|
|
1531
|
-
if (intersections.length) {
|
|
1532
|
-
pointerPosition.copy(intersections[0].point);
|
|
1533
|
-
this.dispatchEvent({
|
|
1534
|
-
type: "pointerPositionChange",
|
|
1535
|
-
position: pointerPosition
|
|
1536
|
-
});
|
|
1537
|
-
}
|
|
1538
|
-
};
|
|
1539
|
-
domEventRegister.addEventListener("mousemove", mousemoveFun);
|
|
1540
|
-
this.commandManager.disabled = false;
|
|
1541
|
-
this.commandManager.start("default");
|
|
1542
|
-
this._exitEditCallBack = () => {
|
|
1543
|
-
domEventRegister.removeEventListener("mousemove", mousemoveFun);
|
|
1544
|
-
camera.position.copy(cameraPosition);
|
|
1545
|
-
orbitControls.enableRotate = true;
|
|
1546
|
-
orbitControls.target.copy(target);
|
|
1547
|
-
};
|
|
1548
|
-
}
|
|
1549
|
-
/**
|
|
1550
|
-
* 退出编辑
|
|
1551
|
-
*/
|
|
1552
|
-
exitEdit() {
|
|
1553
|
-
if (typeof this._exitEditCallBack === "function") {
|
|
1554
|
-
this._exitEditCallBack();
|
|
1555
|
-
this._exitEditCallBack = void 0;
|
|
1556
|
-
this.commandManager.disabled = true;
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
destroy() {
|
|
1560
|
-
this.exitEdit();
|
|
1561
|
-
this.renderer.scene.remove(this.container);
|
|
1562
|
-
this.domElement.remove();
|
|
1563
|
-
this.app?.unmount();
|
|
1564
|
-
}
|
|
1565
|
-
};
|
|
1566
|
-
class RenderManager extends Component {
|
|
1567
|
-
static name = "RenderManager";
|
|
1568
|
-
container = new THREE.Group();
|
|
1569
|
-
lines = [];
|
|
1570
|
-
pointVirtualGrid = new PointVirtualGrid();
|
|
1571
|
-
quadtree = new Quadtree(new Box2());
|
|
1572
|
-
actionHistory = /* @__PURE__ */ new Set();
|
|
1573
|
-
onAddFromParent() {
|
|
1574
|
-
const dxfLineModel = this.dxfLineModel;
|
|
1575
|
-
this.editor.container.add(this.container);
|
|
1576
|
-
this.editor.container.add(dxfLineModel.dxfModelGroup);
|
|
1577
|
-
dxfLineModel.dxfLineModel.material = new THREE.LineBasicMaterial({
|
|
1578
|
-
transparent: true,
|
|
1579
|
-
opacity: 0.5,
|
|
1580
|
-
color: 16777215
|
|
1581
|
-
});
|
|
1582
|
-
dxfLineModel.addEventListener("modelUpdate", (e) => {
|
|
1583
|
-
e.model.position.z = 0;
|
|
1584
|
-
dxfLineModel.dxfDoorsLineModel.visible = false;
|
|
1585
|
-
});
|
|
1586
|
-
this.variable.addEventListener("dxfVisible", (e) => dxfLineModel.dxfModelGroup.visible = e.value);
|
|
1587
|
-
this.dxf.addEventListener("createGroup", () => this.reset());
|
|
1588
|
-
this.reset();
|
|
1589
|
-
}
|
|
1590
|
-
updatedMode = null;
|
|
1591
|
-
/** 重新设置数据
|
|
1592
|
-
*/
|
|
1593
|
-
reset() {
|
|
1594
|
-
if (this.updatedMode === "self") {
|
|
1595
|
-
this.updatedMode = null;
|
|
1596
|
-
return;
|
|
1597
|
-
} else {
|
|
1598
|
-
this.updatedMode = "dxf";
|
|
1599
|
-
}
|
|
1600
|
-
this.pointVirtualGrid = new PointVirtualGrid();
|
|
1601
|
-
const box = this.dxf.box.clone().expansion(Math.max(this.dxf.box.width, this.dxf.box.height) * 2);
|
|
1602
|
-
if (box.width === 0 || box.height === 0) box.set(-200, -200, 200, 200);
|
|
1603
|
-
this.quadtree = new Quadtree(box);
|
|
1604
|
-
this.lines.length = 0;
|
|
1605
|
-
this.dxf.lineSegments.forEach((line) => {
|
|
1606
|
-
if (line.userData.isDoor && !line.userData.doorDirectConnection) return;
|
|
1607
|
-
this.addLine(line.clone());
|
|
1608
|
-
});
|
|
1609
|
-
this.dxf.doorLineSegment.forEach((line) => {
|
|
1610
|
-
const door = line.clone();
|
|
1611
|
-
door.userData = {
|
|
1612
|
-
isDoor: true,
|
|
1613
|
-
doorDirectConnection: true
|
|
1614
|
-
};
|
|
1615
|
-
this.addLine(door);
|
|
1616
|
-
});
|
|
1617
|
-
this.draw();
|
|
1618
|
-
}
|
|
1619
|
-
/** 添加线段
|
|
1620
|
-
* @param line
|
|
1621
|
-
*/
|
|
1622
|
-
addLine(line) {
|
|
1623
|
-
if (!line.userData) line.userData = {};
|
|
1624
|
-
this.lines.push(line);
|
|
1625
|
-
this.pointVirtualGrid.insert(line.start, line);
|
|
1626
|
-
this.pointVirtualGrid.insert(line.end, line);
|
|
1627
|
-
const quadtreeNode = {
|
|
1628
|
-
line,
|
|
1629
|
-
userData: void 0
|
|
1630
|
-
};
|
|
1631
|
-
line.userData.quadtreeNode = quadtreeNode;
|
|
1632
|
-
this.quadtree.insert(quadtreeNode);
|
|
1633
|
-
this.actionHistory.add({
|
|
1634
|
-
type: "addLine",
|
|
1635
|
-
data: [line]
|
|
1636
|
-
});
|
|
1637
|
-
}
|
|
1638
|
-
/**
|
|
1639
|
-
* 批量添加
|
|
1640
|
-
* @param lines
|
|
1641
|
-
*/
|
|
1642
|
-
addLines(lines) {
|
|
1643
|
-
for (let i = 0; i < lines.length; i++) {
|
|
1644
|
-
const line = lines[i];
|
|
1645
|
-
this.lines.push(line);
|
|
1646
|
-
this.pointVirtualGrid.insert(line.start, line);
|
|
1647
|
-
this.pointVirtualGrid.insert(line.end, line);
|
|
1648
|
-
const quadtreeNode = {
|
|
1649
|
-
line,
|
|
1650
|
-
userData: void 0
|
|
1651
|
-
};
|
|
1652
|
-
line.userData.quadtreeNode = quadtreeNode;
|
|
1653
|
-
this.quadtree.insert(quadtreeNode);
|
|
1654
|
-
}
|
|
1655
|
-
this.actionHistory.add({
|
|
1656
|
-
type: "addLine",
|
|
1657
|
-
data: [...lines]
|
|
1658
|
-
});
|
|
1659
|
-
}
|
|
1660
|
-
/** 移除线段
|
|
1661
|
-
* @param line
|
|
1662
|
-
*/
|
|
1663
|
-
removeLine(line) {
|
|
1664
|
-
line.userData.quadtreeNode && this.quadtree.remove(line.userData.quadtreeNode);
|
|
1665
|
-
this.pointVirtualGrid.remove(line.start);
|
|
1666
|
-
this.pointVirtualGrid.remove(line.end);
|
|
1667
|
-
const index = this.lines.indexOf(line);
|
|
1668
|
-
this.lines.splice(index, 1);
|
|
1669
|
-
this.draw();
|
|
1670
|
-
this.actionHistory.add({
|
|
1671
|
-
type: "removeLine",
|
|
1672
|
-
data: [line]
|
|
1673
|
-
});
|
|
1395
|
+
/** 移除线段
|
|
1396
|
+
* @param line
|
|
1397
|
+
*/
|
|
1398
|
+
removeLine(line2) {
|
|
1399
|
+
line2.userData.quadtreeNode && this.quadtree.remove(line2.userData.quadtreeNode);
|
|
1400
|
+
this.pointVirtualGrid.remove(line2.start);
|
|
1401
|
+
this.pointVirtualGrid.remove(line2.end);
|
|
1402
|
+
const index = this.lines.indexOf(line2);
|
|
1403
|
+
this.lines.splice(index, 1);
|
|
1404
|
+
this.draw();
|
|
1405
|
+
this.actionHistory.add({
|
|
1406
|
+
type: "removeLine",
|
|
1407
|
+
data: [line2]
|
|
1408
|
+
});
|
|
1674
1409
|
}
|
|
1675
1410
|
/**
|
|
1676
1411
|
* 绘制
|
|
@@ -1678,14 +1413,14 @@ class RenderManager extends Component {
|
|
|
1678
1413
|
draw(synchronize = true) {
|
|
1679
1414
|
this.container.clear();
|
|
1680
1415
|
const position = [], doorPosition = [], windowPosition = [];
|
|
1681
|
-
this.lines.forEach((
|
|
1682
|
-
|
|
1683
|
-
if (
|
|
1416
|
+
this.lines.forEach((line2) => {
|
|
1417
|
+
line2.points.forEach((p) => {
|
|
1418
|
+
if (line2.userData.isDoor) doorPosition.push(p.x, p.y, 0);
|
|
1684
1419
|
else position.push(p.x, p.y, 0);
|
|
1685
1420
|
});
|
|
1686
|
-
if (
|
|
1687
|
-
|
|
1688
|
-
const center = Point.from(p), direction =
|
|
1421
|
+
if (line2.userData.isWindow && line2.userData.drawDoorData) {
|
|
1422
|
+
line2.userData.drawDoorData.forEach(({ width, p }) => {
|
|
1423
|
+
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));
|
|
1689
1424
|
windowPosition.push(start.x, start.y, 1e-3);
|
|
1690
1425
|
windowPosition.push(end.x, end.y, 1e-3);
|
|
1691
1426
|
});
|
|
@@ -1756,12 +1491,12 @@ class RenderManager extends Component {
|
|
|
1756
1491
|
* 转为json
|
|
1757
1492
|
*/
|
|
1758
1493
|
toJson() {
|
|
1759
|
-
return this.lines.map((
|
|
1760
|
-
const userData =
|
|
1494
|
+
return this.lines.map((line2) => {
|
|
1495
|
+
const userData = line2.userData;
|
|
1761
1496
|
const drawDoorData = userData.drawDoorData;
|
|
1762
1497
|
return {
|
|
1763
|
-
start:
|
|
1764
|
-
end:
|
|
1498
|
+
start: line2.start.toJson(),
|
|
1499
|
+
end: line2.end.toJson(),
|
|
1765
1500
|
insetionArr: [],
|
|
1766
1501
|
isDoor: userData.isDoor,
|
|
1767
1502
|
doorDirectConnection: userData.isDoor,
|
|
@@ -1819,6 +1554,7 @@ class DrawDoorLine extends CommandFlowComponent {
|
|
|
1819
1554
|
shortcutKeys = ["control", "m"];
|
|
1820
1555
|
commandName = "draw-door-line";
|
|
1821
1556
|
onAddFromParent(parent) {
|
|
1557
|
+
super.onAddFromParent(parent);
|
|
1822
1558
|
const editor = parent.findComponentByName("Editor"), eventInput = editor.eventInput, commandManager = editor.commandManager;
|
|
1823
1559
|
this.editor.container.add(this.container);
|
|
1824
1560
|
const commandFlow = this.commandManager.addCommandFlow("draw-door-line").add(this.createInterrupt()).add(this.createCursor("no-drop")).add(this.selectPoint.bind(this));
|
|
@@ -1834,7 +1570,7 @@ class DrawDoorLine extends CommandFlowComponent {
|
|
|
1834
1570
|
* @param next
|
|
1835
1571
|
*/
|
|
1836
1572
|
selectPoint(next) {
|
|
1837
|
-
let editor = this.parent?.findComponentByName("Editor"), start = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 65280 })),
|
|
1573
|
+
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([
|
|
1838
1574
|
new THREE.Vector3(-1e4, 0, 0),
|
|
1839
1575
|
new THREE.Vector3(1e4, 0, 0),
|
|
1840
1576
|
new THREE.Vector3(0, -1e4, 0),
|
|
@@ -1846,13 +1582,13 @@ class DrawDoorLine extends CommandFlowComponent {
|
|
|
1846
1582
|
gapSize: 0.1,
|
|
1847
1583
|
linewidth: 0.1
|
|
1848
1584
|
});
|
|
1849
|
-
this.container.add(
|
|
1585
|
+
this.container.add(line2);
|
|
1850
1586
|
let currentPoint = null;
|
|
1851
1587
|
this.addEventRecord(
|
|
1852
1588
|
"clear",
|
|
1853
1589
|
editor.addEventListener("pointerPositionChange", () => {
|
|
1854
1590
|
const { point, find } = editor.renderManager.adsorption(0.05);
|
|
1855
|
-
start &&
|
|
1591
|
+
start && line2.setPoint(start, point);
|
|
1856
1592
|
if (find) {
|
|
1857
1593
|
circle.position.set(point.x, point.y, 0);
|
|
1858
1594
|
this.container.add(circle);
|
|
@@ -1874,7 +1610,7 @@ class DrawDoorLine extends CommandFlowComponent {
|
|
|
1874
1610
|
}
|
|
1875
1611
|
}),
|
|
1876
1612
|
function() {
|
|
1877
|
-
|
|
1613
|
+
line2.removeFromParent();
|
|
1878
1614
|
circle.removeFromParent();
|
|
1879
1615
|
auxiliaryLine.removeFromParent();
|
|
1880
1616
|
}
|
|
@@ -1885,10 +1621,10 @@ class DrawDoorLine extends CommandFlowComponent {
|
|
|
1885
1621
|
completed(points) {
|
|
1886
1622
|
const editor = this.editor, lines = [];
|
|
1887
1623
|
for (let i = 0; i < points.length; i += 2) {
|
|
1888
|
-
const
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
lines.push(
|
|
1624
|
+
const line2 = new LineSegment(Point.from(points[i]), Point.from(points[i + 1]));
|
|
1625
|
+
line2.userData.isDoor = true;
|
|
1626
|
+
line2.userData.doorDirectConnection = true;
|
|
1627
|
+
lines.push(line2);
|
|
1892
1628
|
}
|
|
1893
1629
|
editor.renderManager.addLines(lines);
|
|
1894
1630
|
editor.renderManager.draw();
|
|
@@ -1900,7 +1636,8 @@ class DrawWindow extends CommandFlowComponent {
|
|
|
1900
1636
|
interruptKeys = ["escape"];
|
|
1901
1637
|
shortcutKeys = ["control", "q"];
|
|
1902
1638
|
commandName = "draw-window-line";
|
|
1903
|
-
onAddFromParent() {
|
|
1639
|
+
onAddFromParent(parent) {
|
|
1640
|
+
super.onAddFromParent(parent);
|
|
1904
1641
|
this.editor.container.add(this.container);
|
|
1905
1642
|
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));
|
|
1906
1643
|
commandFlow.addEventListener("finally", this.createFinally());
|
|
@@ -1915,11 +1652,11 @@ class DrawWindow extends CommandFlowComponent {
|
|
|
1915
1652
|
selectPointStart(next) {
|
|
1916
1653
|
let currentPoint = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 16711935 })), currentLine = null;
|
|
1917
1654
|
this.addEventRecord("selectPointStart").add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
1918
|
-
const { point, line, find } = this.editor.renderManager.adsorption();
|
|
1655
|
+
const { point, line: line2, find } = this.editor.renderManager.adsorption();
|
|
1919
1656
|
if (find) {
|
|
1920
1657
|
this.domElement.style.cursor = "none";
|
|
1921
1658
|
circle.position.copy(point);
|
|
1922
|
-
currentLine =
|
|
1659
|
+
currentLine = line2;
|
|
1923
1660
|
currentPoint = point.clone();
|
|
1924
1661
|
this.container.add(circle);
|
|
1925
1662
|
} else {
|
|
@@ -1938,11 +1675,11 @@ class DrawWindow extends CommandFlowComponent {
|
|
|
1938
1675
|
/** 选择结束点
|
|
1939
1676
|
* @param next
|
|
1940
1677
|
*/
|
|
1941
|
-
selectPointEnd(next, { point, line }) {
|
|
1678
|
+
selectPointEnd(next, { point, line: line2 }) {
|
|
1942
1679
|
let currentPoint = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 16711935 }));
|
|
1943
1680
|
this.addEventRecord("clear").add(() => circle.removeFromParent()).add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
1944
1681
|
const { point: point2, find, line: l } = this.editor.renderManager.adsorption();
|
|
1945
|
-
if (find && l ===
|
|
1682
|
+
if (find && l === line2) {
|
|
1946
1683
|
this.domElement.style.cursor = "none";
|
|
1947
1684
|
circle.position.copy(point2);
|
|
1948
1685
|
currentPoint = point2.clone();
|
|
@@ -1953,30 +1690,540 @@ class DrawWindow extends CommandFlowComponent {
|
|
|
1953
1690
|
circle.removeFromParent();
|
|
1954
1691
|
}
|
|
1955
1692
|
})).add(this.eventInput.addEventListener("codeChange", () => {
|
|
1956
|
-
if (this.eventInput.isKeyDown("mouse_0") && currentPoint) next({ line, start: point, end: currentPoint });
|
|
1693
|
+
if (this.eventInput.isKeyDown("mouse_0") && currentPoint) next({ line: line2, start: point, end: currentPoint });
|
|
1957
1694
|
}));
|
|
1958
1695
|
}
|
|
1959
1696
|
/** 执行完成
|
|
1960
1697
|
*/
|
|
1961
1698
|
completed(data) {
|
|
1962
|
-
const start = data.start, end = data.end,
|
|
1963
|
-
|
|
1964
|
-
if (!
|
|
1965
|
-
|
|
1699
|
+
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();
|
|
1700
|
+
line2.userData.isWindow = true;
|
|
1701
|
+
if (!line2.userData.drawDoorData) line2.userData.drawDoorData = [];
|
|
1702
|
+
line2.userData.drawDoorData.push({
|
|
1966
1703
|
p: new THREE.Vector3(center.x, center.y, 0),
|
|
1967
1704
|
width: len,
|
|
1968
|
-
full: Math.abs(len -
|
|
1705
|
+
full: Math.abs(len - line2.length()) < 0.01
|
|
1969
1706
|
});
|
|
1970
1707
|
this.renderManager.draw();
|
|
1971
1708
|
}
|
|
1972
1709
|
}
|
|
1710
|
+
const _hoisted_1 = {
|
|
1711
|
+
key: 0,
|
|
1712
|
+
class: "mt-[5px] text-[#888] text-[10px] absolute left-[10px] bottom-[10px] rounded-[8px] min-w-[150px] bg-black/15 p-[10px]"
|
|
1713
|
+
};
|
|
1714
|
+
const _hoisted_2 = { class: "inline-block ml-[10px]" };
|
|
1715
|
+
const _hoisted_3 = {
|
|
1716
|
+
key: 0,
|
|
1717
|
+
class: "p-[5px] min-w-[140px]"
|
|
1718
|
+
};
|
|
1719
|
+
const _hoisted_4 = { class: "text-[14px] flex flex-col" };
|
|
1720
|
+
const _hoisted_5 = ["onClick"];
|
|
1721
|
+
const _hoisted_6 = { class: "flex flex-row items-center" };
|
|
1722
|
+
const _hoisted_7 = { class: "flex justify-center items-center size-[20px] bg-[#f0f0f0] rounded-[2px] mr-[10px]" };
|
|
1723
|
+
const _hoisted_8 = ["src"];
|
|
1724
|
+
const _hoisted_9 = {
|
|
1725
|
+
style: { "--el-checkbox-font-size": "10px" },
|
|
1726
|
+
class: "flex flex-row items-center justify-between gap-[10px] mt-[10px] text-[10px]"
|
|
1727
|
+
};
|
|
1728
|
+
const _hoisted_10 = {
|
|
1729
|
+
key: 0,
|
|
1730
|
+
class: "flex flex-row items-center justify-between gap-[10px] mt-[10px] text-[10px]"
|
|
1731
|
+
};
|
|
1732
|
+
const _hoisted_11 = { class: "border-t-1 border-t-[#eee] mt-[5px] p-[5px_0px] h-[20px] flex items-center gap-[10px]" };
|
|
1733
|
+
const _hoisted_12 = {
|
|
1734
|
+
key: 1,
|
|
1735
|
+
class: "select-none flex-1 flex justify-center text-[12px] text-[#999]"
|
|
1736
|
+
};
|
|
1737
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1738
|
+
__name: "EditorTool",
|
|
1739
|
+
props: {
|
|
1740
|
+
dxfSystem: {}
|
|
1741
|
+
},
|
|
1742
|
+
setup(__props) {
|
|
1743
|
+
const props = __props;
|
|
1744
|
+
const VITE_NODE_ENV = void 0;
|
|
1745
|
+
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), 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(true), selectLineCount = ref(0), shortcutKeys = [
|
|
1746
|
+
{ "name": "绘制连续线段", "shortcut": "Ctrl + L" },
|
|
1747
|
+
{ "name": "绘制线段确认", "shortcut": "Enter" },
|
|
1748
|
+
{ "name": "绘制门线", "shortcut": "Ctrl + M" },
|
|
1749
|
+
{ "name": "绘制窗户线", "shortcut": "Ctrl + Q" },
|
|
1750
|
+
{ "name": "移动线段点", "shortcut": "Ctrl + P" },
|
|
1751
|
+
{ "name": "删除线段", "shortcut": "选中 + Delete" },
|
|
1752
|
+
{ "name": "删除窗户线", "shortcut": "选中 + Q + Delete" },
|
|
1753
|
+
{ "name": "选中", "shortcut": "鼠标左键" },
|
|
1754
|
+
{ "name": "多选", "shortcut": "鼠标左键 + Ctrl" },
|
|
1755
|
+
{ "name": "取消选中", "shortcut": "鼠标左键 + Alt" },
|
|
1756
|
+
{ "name": "框选", "shortcut": "鼠标左键 + 移动" },
|
|
1757
|
+
{ "name": "线段同方向合并", "shortcut": "Ctrl + G" },
|
|
1758
|
+
{ "name": "线段连接", "shortcut": "选中 + Shift + L" },
|
|
1759
|
+
{ "name": "线段交点连接", "shortcut": "选中 + Ctrl + Shift + L" },
|
|
1760
|
+
{ "name": "取消命令", "shortcut": "Esc" }
|
|
1761
|
+
], commandList = [
|
|
1762
|
+
{
|
|
1763
|
+
command: "default",
|
|
1764
|
+
name: "默认",
|
|
1765
|
+
show: false
|
|
1766
|
+
},
|
|
1767
|
+
{
|
|
1768
|
+
command: "draw-line",
|
|
1769
|
+
name: "绘制线段",
|
|
1770
|
+
src: images["./assets/images/line.svg"].default,
|
|
1771
|
+
show: true
|
|
1772
|
+
},
|
|
1773
|
+
{
|
|
1774
|
+
command: "draw-door-line",
|
|
1775
|
+
name: "绘制门线",
|
|
1776
|
+
show: true,
|
|
1777
|
+
src: images["./assets/images/door.svg"].default
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
command: "draw-window-line",
|
|
1781
|
+
name: "绘制窗户线",
|
|
1782
|
+
show: true,
|
|
1783
|
+
src: images["./assets/images/window.svg"].default
|
|
1784
|
+
},
|
|
1785
|
+
{
|
|
1786
|
+
command: "point",
|
|
1787
|
+
name: "点修改",
|
|
1788
|
+
show: true,
|
|
1789
|
+
src: images["./assets/images/selectPoint.svg"].default
|
|
1790
|
+
}
|
|
1791
|
+
];
|
|
1792
|
+
watch(toolBarPosition, () => localStorage.setItem("editorToolPosition", JSON.stringify(toolBarPosition.value)));
|
|
1793
|
+
watch(showShortcutKey, () => localStorage.setItem("showShortcutKey", showShortcutKey.value + ""));
|
|
1794
|
+
watch(toolBarExpand, () => localStorage.setItem("toolBarExpand", toolBarExpand.value + ""));
|
|
1795
|
+
function setEditorToolPosition(left, top, rect = elRef.value.getBoundingClientRect(), toolBarRect = toolBarRef.value.getBoundingClientRect()) {
|
|
1796
|
+
const minX = 0, maxX = rect.width - toolBarRect.width, minY = 0, maxY = rect.height - toolBarRect.height;
|
|
1797
|
+
left = Math.max(minX, Math.min(left, maxX));
|
|
1798
|
+
top = Math.max(minY, Math.min(top, maxY));
|
|
1799
|
+
toolBarPosition.value = { left, top };
|
|
1800
|
+
}
|
|
1801
|
+
function startCurrentCommandItem(item) {
|
|
1802
|
+
if (currentCommand.value === item.command) return;
|
|
1803
|
+
editor.commandManager.start(item.command);
|
|
1804
|
+
}
|
|
1805
|
+
function setLines(lines) {
|
|
1806
|
+
if (lines) {
|
|
1807
|
+
localStorage.setItem("lines", JSON.stringify(lines));
|
|
1808
|
+
try {
|
|
1809
|
+
dxfSystem.Dxf.set(lines);
|
|
1810
|
+
dxfSystem.Dxf.lineOffset();
|
|
1811
|
+
} catch (error) {
|
|
1812
|
+
console.log(error);
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
async function selectLocalFile() {
|
|
1817
|
+
const data = await SelectLocalFile.json();
|
|
1818
|
+
if (Array.isArray(data)) {
|
|
1819
|
+
localStorage.removeItem("orbitControls");
|
|
1820
|
+
setLines(data);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
function dragMoveHelper({ offsetX, offsetY }) {
|
|
1824
|
+
domEventRegister.mouseMoveEventProxylock = true;
|
|
1825
|
+
const cusor = document.body.style.cursor;
|
|
1826
|
+
document.body.style.cursor = "move";
|
|
1827
|
+
const move = (e) => {
|
|
1828
|
+
const rect = elRef.value.getBoundingClientRect(), toolBarRect = toolBarRef.value.getBoundingClientRect();
|
|
1829
|
+
setEditorToolPosition(
|
|
1830
|
+
e.pageX - rect.left - offsetX,
|
|
1831
|
+
e.pageY - rect.top - offsetY,
|
|
1832
|
+
rect,
|
|
1833
|
+
toolBarRect
|
|
1834
|
+
);
|
|
1835
|
+
e.stopPropagation();
|
|
1836
|
+
document.body.style.cursor = "move";
|
|
1837
|
+
};
|
|
1838
|
+
const end = () => {
|
|
1839
|
+
document.body.removeEventListener("mousemove", move);
|
|
1840
|
+
document.removeEventListener("mouseup", end);
|
|
1841
|
+
document.body.style.cursor = cusor;
|
|
1842
|
+
domEventRegister.mouseMoveEventProxylock = false;
|
|
1843
|
+
};
|
|
1844
|
+
document.body.addEventListener("mousemove", move);
|
|
1845
|
+
document.addEventListener("mouseup", end);
|
|
1846
|
+
}
|
|
1847
|
+
watch(originalLineVisible, () => dxfSystem.Variable.set("originalLineVisible", originalLineVisible.value));
|
|
1848
|
+
watch(dxfVisible, () => dxfSystem.Variable.set("dxfVisible", dxfVisible.value));
|
|
1849
|
+
watch(whiteModelVisible, () => dxfSystem.Variable.set("whiteModelVisible", whiteModelVisible.value));
|
|
1850
|
+
dxfSystem.Variable.addEventListener("isLook", (e) => isLook.value = e.value);
|
|
1851
|
+
dxfSystem.Variable.addEventListener("originalLineVisible", (e) => originalLineVisible.value = e.value);
|
|
1852
|
+
dxfSystem.Variable.addEventListener("dxfVisible", (e) => dxfVisible.value = e.value);
|
|
1853
|
+
dxfSystem.Variable.addEventListener("whiteModelVisible", (e) => whiteModelVisible.value = e.value);
|
|
1854
|
+
const startedEventCancel = editor.commandManager.addEventListener("started", (e) => {
|
|
1855
|
+
currentCommand.value = e.name;
|
|
1856
|
+
});
|
|
1857
|
+
if (localStorage.getItem("showShortcutKey")) {
|
|
1858
|
+
showShortcutKey.value = localStorage.getItem("showShortcutKey") === "true";
|
|
1859
|
+
}
|
|
1860
|
+
if (localStorage.getItem("toolBarExpand")) {
|
|
1861
|
+
toolBarExpand.value = localStorage.getItem("toolBarExpand") === "true";
|
|
1862
|
+
}
|
|
1863
|
+
onMounted(() => {
|
|
1864
|
+
toolBarRef.value.style.display = "none";
|
|
1865
|
+
setTimeout(() => {
|
|
1866
|
+
toolBarRef.value.style.display = "block";
|
|
1867
|
+
if (localStorage.getItem("editorToolPosition")) {
|
|
1868
|
+
const { left, top } = JSON.parse(localStorage.getItem("editorToolPosition") ?? "{}");
|
|
1869
|
+
setEditorToolPosition(left, top);
|
|
1870
|
+
}
|
|
1871
|
+
}, 20);
|
|
1872
|
+
defaultComponent.addEventListener("selectLineChange", () => {
|
|
1873
|
+
selectLineCount.value = defaultComponent.selectLines.length;
|
|
1874
|
+
});
|
|
1875
|
+
});
|
|
1876
|
+
onUnmounted(() => {
|
|
1877
|
+
domEventRegister.mouseMoveEventProxylock = false;
|
|
1878
|
+
startedEventCancel();
|
|
1879
|
+
});
|
|
1880
|
+
return (_ctx, _cache) => {
|
|
1881
|
+
return openBlock(), createElementBlock("div", {
|
|
1882
|
+
ref_key: "elRef",
|
|
1883
|
+
ref: elRef,
|
|
1884
|
+
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]"
|
|
1885
|
+
}, [
|
|
1886
|
+
createVNode(Transition, null, {
|
|
1887
|
+
default: withCtx(() => [
|
|
1888
|
+
showShortcutKey.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
1889
|
+
(openBlock(), createElementBlock(Fragment, null, renderList(shortcutKeys, (item) => {
|
|
1890
|
+
return createElementVNode("p", {
|
|
1891
|
+
class: "p-[2px_0px] flex justify-between text-right border-b-1 border-b-[rgba(255,255,255,0.1)] last-of-type:border-b-0",
|
|
1892
|
+
key: item.name
|
|
1893
|
+
}, [
|
|
1894
|
+
createTextVNode(toDisplayString(item.name) + ": ", 1),
|
|
1895
|
+
createElementVNode("span", _hoisted_2, toDisplayString(item.shortcut), 1)
|
|
1896
|
+
]);
|
|
1897
|
+
}), 64))
|
|
1898
|
+
])) : createCommentVNode("", true)
|
|
1899
|
+
]),
|
|
1900
|
+
_: 1
|
|
1901
|
+
}),
|
|
1902
|
+
createElementVNode("div", {
|
|
1903
|
+
ref_key: "toolBarRef",
|
|
1904
|
+
ref: toolBarRef,
|
|
1905
|
+
style: normalizeStyle({ left: toolBarPosition.value.left + "px", top: toolBarPosition.value.top + "px" }),
|
|
1906
|
+
class: normalizeClass(["pointer-events-auto max-w-[260px] transition-[border-radius] text-[#333] absolute z-[11] bg-white select-none", { "rounded-[8px] ": toolBarExpand.value }]),
|
|
1907
|
+
onMousedown: _cache[10] || (_cache[10] = (e) => e.stopPropagation())
|
|
1908
|
+
}, [
|
|
1909
|
+
createElementVNode("div", {
|
|
1910
|
+
onMousedown: dragMoveHelper,
|
|
1911
|
+
class: normalizeClass([{ "border-b-[#eee]": toolBarExpand.value }, "flex flex-row justify-between header text-[14px] font-bold p-[10px 0px] border-b-1"])
|
|
1912
|
+
}, [
|
|
1913
|
+
_cache[12] || (_cache[12] = createStaticVNode('<div class="flex flex-row" data-v-c228f697><div class="p-[2px_5px] flex items-center pointer-events-none" data-v-c228f697><svg fill="#aaa" width="20" height="20" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" data-v-c228f697><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-c228f697></path></svg></div><h5 class="flex text-[14px] items-center pointer-events-none" data-v-c228f697>绘制工具</h5></div>', 1)),
|
|
1914
|
+
createElementVNode("div", {
|
|
1915
|
+
onMousedown: _cache[0] || (_cache[0] = (e) => e.stopPropagation()),
|
|
1916
|
+
onClick: _cache[1] || (_cache[1] = ($event) => toolBarExpand.value = !toolBarExpand.value),
|
|
1917
|
+
class: "cursor-pointer flex items-center p-[0px_5px]"
|
|
1918
|
+
}, [
|
|
1919
|
+
(openBlock(), createElementBlock("svg", {
|
|
1920
|
+
fill: "#666",
|
|
1921
|
+
class: normalizeClass([{ "rotate-90": toolBarExpand.value }, "transition-all"]),
|
|
1922
|
+
viewBox: "0 0 1024 1024",
|
|
1923
|
+
version: "1.1",
|
|
1924
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1925
|
+
width: "12",
|
|
1926
|
+
height: "12"
|
|
1927
|
+
}, _cache[11] || (_cache[11] = [
|
|
1928
|
+
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)
|
|
1929
|
+
]), 2))
|
|
1930
|
+
], 32)
|
|
1931
|
+
], 34),
|
|
1932
|
+
toolBarExpand.value ? (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
1933
|
+
createElementVNode("ul", _hoisted_4, [
|
|
1934
|
+
(openBlock(), createElementBlock(Fragment, null, renderList(commandList, (item) => {
|
|
1935
|
+
return openBlock(), createElementBlock(Fragment, {
|
|
1936
|
+
key: item.command
|
|
1937
|
+
}, [
|
|
1938
|
+
item.show ? (openBlock(), createElementBlock("li", {
|
|
1939
|
+
key: 0,
|
|
1940
|
+
onClick: ($event) => startCurrentCommandItem(item),
|
|
1941
|
+
class: normalizeClass([{ "!bg-[#409eff] text-[#fff]": currentCommand.value === item.command }, "text-[12px] hover:bg-[#ddd] transition-all rounded-[6px] p-[5px] flex flex-row items-center justify-between cursor-pointer"])
|
|
1942
|
+
}, [
|
|
1943
|
+
createElementVNode("div", _hoisted_6, [
|
|
1944
|
+
createElementVNode("div", _hoisted_7, [
|
|
1945
|
+
createElementVNode("img", {
|
|
1946
|
+
class: "size-[14px]",
|
|
1947
|
+
src: item.src,
|
|
1948
|
+
alt: "",
|
|
1949
|
+
srcset: ""
|
|
1950
|
+
}, null, 8, _hoisted_8)
|
|
1951
|
+
]),
|
|
1952
|
+
createElementVNode("span", null, toDisplayString(item.name), 1)
|
|
1953
|
+
]),
|
|
1954
|
+
currentCommand.value === item.command ? (openBlock(), createElementBlock("div", {
|
|
1955
|
+
key: 0,
|
|
1956
|
+
class: "active:scale-[0.7] transition-all",
|
|
1957
|
+
onClick: _cache[2] || (_cache[2] = (e) => (unref(editor).cancelCommand(), e.stopPropagation()))
|
|
1958
|
+
}, _cache[13] || (_cache[13] = [
|
|
1959
|
+
createElementVNode("svg", {
|
|
1960
|
+
fill: "#fff",
|
|
1961
|
+
width: "16",
|
|
1962
|
+
height: "16",
|
|
1963
|
+
viewBox: "0 0 1024 1024",
|
|
1964
|
+
version: "1.1",
|
|
1965
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1966
|
+
}, [
|
|
1967
|
+
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" }),
|
|
1968
|
+
createElementVNode("path", { d: "M236.437333 463.914667l549.333333 0 0 96.874667-549.333333 0 0-96.874667Z" })
|
|
1969
|
+
], -1)
|
|
1970
|
+
]))) : createCommentVNode("", true)
|
|
1971
|
+
], 10, _hoisted_5)) : createCommentVNode("", true)
|
|
1972
|
+
], 64);
|
|
1973
|
+
}), 64))
|
|
1974
|
+
]),
|
|
1975
|
+
createElementVNode("div", _hoisted_9, [
|
|
1976
|
+
createVNode(unref(ElCheckbox), {
|
|
1977
|
+
size: "small",
|
|
1978
|
+
modelValue: showShortcutKey.value,
|
|
1979
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => showShortcutKey.value = $event),
|
|
1980
|
+
label: "快捷键提示"
|
|
1981
|
+
}, null, 8, ["modelValue"]),
|
|
1982
|
+
createVNode(unref(ElCheckbox), {
|
|
1983
|
+
size: "small",
|
|
1984
|
+
modelValue: dxfVisible.value,
|
|
1985
|
+
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => dxfVisible.value = $event),
|
|
1986
|
+
label: "dxf"
|
|
1987
|
+
}, null, 8, ["modelValue"])
|
|
1988
|
+
]),
|
|
1989
|
+
unref(VITE_NODE_ENV) !== "lib" ? (openBlock(), createElementBlock("div", _hoisted_10, [
|
|
1990
|
+
createVNode(unref(ElButton), {
|
|
1991
|
+
style: { "padding": "5px", "font-size": "10px" },
|
|
1992
|
+
size: "small",
|
|
1993
|
+
type: "success",
|
|
1994
|
+
onClick: selectLocalFile
|
|
1995
|
+
}, {
|
|
1996
|
+
default: withCtx(() => _cache[14] || (_cache[14] = [
|
|
1997
|
+
createTextVNode(" 选择文件 ", -1)
|
|
1998
|
+
])),
|
|
1999
|
+
_: 1,
|
|
2000
|
+
__: [14]
|
|
2001
|
+
}),
|
|
2002
|
+
createVNode(unref(ElButton), {
|
|
2003
|
+
style: { "padding": "5px", "font-size": "10px" },
|
|
2004
|
+
size: "small",
|
|
2005
|
+
type: "primary",
|
|
2006
|
+
onClick: _cache[5] || (_cache[5] = ($event) => unref(dxfSystem).Dxf.download("test.dxf"))
|
|
2007
|
+
}, {
|
|
2008
|
+
default: withCtx(() => _cache[15] || (_cache[15] = [
|
|
2009
|
+
createTextVNode(" 下载 DXF ", -1)
|
|
2010
|
+
])),
|
|
2011
|
+
_: 1,
|
|
2012
|
+
__: [15]
|
|
2013
|
+
})
|
|
2014
|
+
])) : createCommentVNode("", true),
|
|
2015
|
+
createVNode(Transition, null, {
|
|
2016
|
+
default: withCtx(() => [
|
|
2017
|
+
createElementVNode("div", _hoisted_11, [
|
|
2018
|
+
selectLineCount.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2019
|
+
selectLineCount.value == 2 ? (openBlock(), createElementBlock("div", {
|
|
2020
|
+
key: 0,
|
|
2021
|
+
onClick: _cache[6] || (_cache[6] = ($event) => unref(defaultComponent).mergeLine()),
|
|
2022
|
+
title: "合并",
|
|
2023
|
+
class: "active:scale-[0.8] transition-all cursor-pointer"
|
|
2024
|
+
}, _cache[16] || (_cache[16] = [
|
|
2025
|
+
createElementVNode("svg", {
|
|
2026
|
+
viewBox: "0 0 1024 1024",
|
|
2027
|
+
version: "1.1",
|
|
2028
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2029
|
+
fill: "#555",
|
|
2030
|
+
width: "16",
|
|
2031
|
+
height: "16"
|
|
2032
|
+
}, [
|
|
2033
|
+
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" })
|
|
2034
|
+
], -1)
|
|
2035
|
+
]))) : createCommentVNode("", true),
|
|
2036
|
+
selectLineCount.value == 2 ? (openBlock(), createElementBlock("div", {
|
|
2037
|
+
key: 1,
|
|
2038
|
+
onClick: _cache[7] || (_cache[7] = ($event) => unref(defaultComponent).connection()),
|
|
2039
|
+
title: "两点连接",
|
|
2040
|
+
class: "active:scale-[0.8] transition-all cursor-pointer"
|
|
2041
|
+
}, _cache[17] || (_cache[17] = [
|
|
2042
|
+
createElementVNode("svg", {
|
|
2043
|
+
viewBox: "0 0 1024 1024",
|
|
2044
|
+
version: "1.1",
|
|
2045
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2046
|
+
fill: "#555",
|
|
2047
|
+
width: "16",
|
|
2048
|
+
height: "16"
|
|
2049
|
+
}, [
|
|
2050
|
+
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" })
|
|
2051
|
+
], -1)
|
|
2052
|
+
]))) : createCommentVNode("", true),
|
|
2053
|
+
selectLineCount.value == 2 ? (openBlock(), createElementBlock("div", {
|
|
2054
|
+
key: 2,
|
|
2055
|
+
onClick: _cache[8] || (_cache[8] = ($event) => unref(defaultComponent).intersectionConnection()),
|
|
2056
|
+
title: "延长线连接",
|
|
2057
|
+
class: "active:scale-[0.8] transition-all cursor-pointer"
|
|
2058
|
+
}, _cache[18] || (_cache[18] = [
|
|
2059
|
+
createElementVNode("svg", {
|
|
2060
|
+
viewBox: "0 0 1024 1024",
|
|
2061
|
+
version: "1.1",
|
|
2062
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2063
|
+
fill: "#555",
|
|
2064
|
+
width: "16",
|
|
2065
|
+
height: "16"
|
|
2066
|
+
}, [
|
|
2067
|
+
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" }),
|
|
2068
|
+
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" }),
|
|
2069
|
+
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" })
|
|
2070
|
+
], -1)
|
|
2071
|
+
]))) : createCommentVNode("", true),
|
|
2072
|
+
createElementVNode("div", {
|
|
2073
|
+
onClick: _cache[9] || (_cache[9] = ($event) => unref(defaultComponent).deleteSelectLine()),
|
|
2074
|
+
title: "删除",
|
|
2075
|
+
class: "active:scale-[0.8] transition-all cursor-pointer"
|
|
2076
|
+
}, _cache[19] || (_cache[19] = [
|
|
2077
|
+
createElementVNode("svg", {
|
|
2078
|
+
viewBox: "0 0 1024 1024",
|
|
2079
|
+
version: "1.1",
|
|
2080
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2081
|
+
fill: "#555",
|
|
2082
|
+
width: "16",
|
|
2083
|
+
height: "16"
|
|
2084
|
+
}, [
|
|
2085
|
+
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" })
|
|
2086
|
+
], -1)
|
|
2087
|
+
]))
|
|
2088
|
+
], 64)) : (openBlock(), createElementBlock("div", _hoisted_12, " 无可用操作 "))
|
|
2089
|
+
])
|
|
2090
|
+
]),
|
|
2091
|
+
_: 1
|
|
2092
|
+
})
|
|
2093
|
+
])) : createCommentVNode("", true)
|
|
2094
|
+
], 38)
|
|
2095
|
+
], 512);
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
});
|
|
2099
|
+
const _export_sfc = (sfc, props) => {
|
|
2100
|
+
const target = sfc.__vccOpts || sfc;
|
|
2101
|
+
for (const [key, val] of props) {
|
|
2102
|
+
target[key] = val;
|
|
2103
|
+
}
|
|
2104
|
+
return target;
|
|
2105
|
+
};
|
|
2106
|
+
const EditorTool = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c228f697"]]);
|
|
2107
|
+
let Editor$1 = class Editor extends Component {
|
|
2108
|
+
static name = "Editor";
|
|
2109
|
+
container = new THREE.Group();
|
|
2110
|
+
get renderer() {
|
|
2111
|
+
return this.parent?.findComponentByName("Renderer");
|
|
2112
|
+
}
|
|
2113
|
+
get dxf() {
|
|
2114
|
+
return this.parent?.findComponentByName("Dxf");
|
|
2115
|
+
}
|
|
2116
|
+
get variable() {
|
|
2117
|
+
return this.parent?.findComponentByName("Variable");
|
|
2118
|
+
}
|
|
2119
|
+
get eventInput() {
|
|
2120
|
+
return this.parent?.findComponentByName("EventInput");
|
|
2121
|
+
}
|
|
2122
|
+
get renderManager() {
|
|
2123
|
+
return this.parent?.findComponentByName("RenderManager");
|
|
2124
|
+
}
|
|
2125
|
+
get domEventRegister() {
|
|
2126
|
+
return this.parent?.findComponentByName("DomEventRegister");
|
|
2127
|
+
}
|
|
2128
|
+
get domContainer() {
|
|
2129
|
+
return this.parent?.findComponentByName("DomContainer");
|
|
2130
|
+
}
|
|
2131
|
+
commandManager = new CommandManager();
|
|
2132
|
+
plane = new THREE.Mesh(new THREE.PlaneGeometry(2e3, 2e3, 2, 2));
|
|
2133
|
+
app;
|
|
2134
|
+
domElement = document.createElement("div");
|
|
2135
|
+
onAddFromParent() {
|
|
2136
|
+
setTimeout(() => this.openEdit(), 10);
|
|
2137
|
+
const grid = new THREE.GridHelper(200, 100, 6710886, 4473924);
|
|
2138
|
+
grid.rotation.x = Math.PI * 0.5;
|
|
2139
|
+
grid.position.z = -0.01;
|
|
2140
|
+
this.container.add(grid);
|
|
2141
|
+
this.container.add(this.plane);
|
|
2142
|
+
this.plane.visible = false;
|
|
2143
|
+
const cancelEvent = this.addEventListener("update", () => {
|
|
2144
|
+
if (this.domContainer.domElement.parentElement) {
|
|
2145
|
+
this.domContainer.domElement.parentElement.appendChild(this.domElement);
|
|
2146
|
+
cancelEvent();
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2149
|
+
setTimeout(() => {
|
|
2150
|
+
this.app = createApp(EditorTool, { dxfSystem: this.parent });
|
|
2151
|
+
this.app.mount(this.domElement);
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2154
|
+
/**
|
|
2155
|
+
* 取消命令,由其他命令组件监听事件后注册事件监听实现
|
|
2156
|
+
*/
|
|
2157
|
+
cancelCommand() {
|
|
2158
|
+
this.dispatchEvent({
|
|
2159
|
+
type: "cancelCommand"
|
|
2160
|
+
});
|
|
2161
|
+
}
|
|
2162
|
+
coords = new THREE.Vector2();
|
|
2163
|
+
pointerPosition = new THREE.Vector2();
|
|
2164
|
+
_exitEditCallBack;
|
|
2165
|
+
/**
|
|
2166
|
+
* 打开编辑器
|
|
2167
|
+
*/
|
|
2168
|
+
openEdit() {
|
|
2169
|
+
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;
|
|
2170
|
+
this.container.position.z = dxf.originalZAverage;
|
|
2171
|
+
renderer.scene.add(this.container);
|
|
2172
|
+
camera.position.set(center.x, center.y, 14);
|
|
2173
|
+
if (orbitControls) {
|
|
2174
|
+
orbitControls.target.set(center.x, center.y, 0);
|
|
2175
|
+
orbitControls.enableRotate = false;
|
|
2176
|
+
}
|
|
2177
|
+
const mousemoveFun = () => {
|
|
2178
|
+
renderer.renderer.getSize(size);
|
|
2179
|
+
const x = domEventRegister.pointer.x / size.x * 2 - 1;
|
|
2180
|
+
const y = -(domEventRegister.pointer.y / size.y * 2 - 1);
|
|
2181
|
+
coords.set(x, y);
|
|
2182
|
+
raycaster.setFromCamera(coords, renderer.camera);
|
|
2183
|
+
const intersections = raycaster.intersectObject(this.plane);
|
|
2184
|
+
if (intersections.length) {
|
|
2185
|
+
pointerPosition.copy(intersections[0].point);
|
|
2186
|
+
this.dispatchEvent({
|
|
2187
|
+
type: "pointerPositionChange",
|
|
2188
|
+
position: pointerPosition
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
};
|
|
2192
|
+
domEventRegister.addEventListener("mousemove", mousemoveFun);
|
|
2193
|
+
this.commandManager.disabled = false;
|
|
2194
|
+
this.commandManager.start("default");
|
|
2195
|
+
this._exitEditCallBack = () => {
|
|
2196
|
+
domEventRegister.removeEventListener("mousemove", mousemoveFun);
|
|
2197
|
+
camera.position.copy(cameraPosition);
|
|
2198
|
+
orbitControls.enableRotate = true;
|
|
2199
|
+
orbitControls.target.copy(target);
|
|
2200
|
+
};
|
|
2201
|
+
}
|
|
2202
|
+
/**
|
|
2203
|
+
* 退出编辑
|
|
2204
|
+
*/
|
|
2205
|
+
exitEdit() {
|
|
2206
|
+
if (typeof this._exitEditCallBack === "function") {
|
|
2207
|
+
this._exitEditCallBack();
|
|
2208
|
+
this._exitEditCallBack = void 0;
|
|
2209
|
+
this.commandManager.disabled = true;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
destroy() {
|
|
2213
|
+
this.exitEdit();
|
|
2214
|
+
this.renderer.scene.remove(this.container);
|
|
2215
|
+
this.domElement.remove();
|
|
2216
|
+
this.app?.unmount();
|
|
2217
|
+
}
|
|
2218
|
+
};
|
|
1973
2219
|
class PointDrag extends CommandFlowComponent {
|
|
1974
2220
|
static name = "PointDrag";
|
|
1975
2221
|
container = new THREE.Group();
|
|
1976
2222
|
interruptKeys = ["escape"];
|
|
1977
2223
|
shortcutKeys = ["control", "p"];
|
|
1978
2224
|
commandName = "point";
|
|
1979
|
-
onAddFromParent() {
|
|
2225
|
+
onAddFromParent(parent) {
|
|
2226
|
+
super.onAddFromParent(parent);
|
|
1980
2227
|
this.editor.container.add(this.container);
|
|
1981
2228
|
this.container.position.z = 1e-3;
|
|
1982
2229
|
const commandFlow = this.commandManager.addCommandFlow(this.commandName).add(this.createInterrupt()).add(this.createCursor("crosshair")).add(this.selectPoint.bind(this)).add(this.drag.bind(this));
|
|
@@ -1992,11 +2239,11 @@ class PointDrag extends CommandFlowComponent {
|
|
|
1992
2239
|
selectPoint(next) {
|
|
1993
2240
|
let currentPoint = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 16711935 })), currentLine = null;
|
|
1994
2241
|
this.addEventRecord("selectPointStart").add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
1995
|
-
const { point, line, find, mode } = this.editor.renderManager.adsorption();
|
|
2242
|
+
const { point, line: line2, find, mode } = this.editor.renderManager.adsorption();
|
|
1996
2243
|
if (find && mode === "point") {
|
|
1997
2244
|
this.domElement.style.cursor = "none";
|
|
1998
2245
|
circle.position.copy(point);
|
|
1999
|
-
currentLine =
|
|
2246
|
+
currentLine = line2;
|
|
2000
2247
|
currentPoint = point.clone();
|
|
2001
2248
|
this.container.add(circle);
|
|
2002
2249
|
} else {
|
|
@@ -2018,15 +2265,15 @@ class PointDrag extends CommandFlowComponent {
|
|
|
2018
2265
|
* @param next
|
|
2019
2266
|
* @param param1
|
|
2020
2267
|
*/
|
|
2021
|
-
drag(next, { point, line }) {
|
|
2268
|
+
drag(next, { point, line: line2 }) {
|
|
2022
2269
|
this.domElement.style.cursor = "crosshair";
|
|
2023
|
-
const mode =
|
|
2270
|
+
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 }));
|
|
2024
2271
|
this.container.add(lines);
|
|
2025
2272
|
this.addEventRecord("clear").add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
2026
2273
|
let { point: point2, find } = this.editor.renderManager.adsorption(), cursor = "none";
|
|
2027
2274
|
if (point2) {
|
|
2028
2275
|
if (this.eventInput.isKeyDown("shift")) {
|
|
2029
|
-
const p =
|
|
2276
|
+
const p = line2.projectPoint(Point.from(point2), false);
|
|
2030
2277
|
point2.set(p?.x ?? point2.x, p?.y ?? point2.y, 0);
|
|
2031
2278
|
find = true;
|
|
2032
2279
|
cursor = "crosshair";
|
|
@@ -2045,18 +2292,18 @@ class PointDrag extends CommandFlowComponent {
|
|
|
2045
2292
|
})).add(this.eventInput.addEventListener("codeChange", () => {
|
|
2046
2293
|
if (this.eventInput.isKeyDown("mouse_0")) {
|
|
2047
2294
|
this.canceEventRecord("selectPointStart");
|
|
2048
|
-
next({ point: end, line, mode });
|
|
2295
|
+
next({ point: end, line: line2, mode });
|
|
2049
2296
|
}
|
|
2050
2297
|
})).add(() => circle.removeFromParent()).add(() => lines.removeFromParent());
|
|
2051
2298
|
}
|
|
2052
2299
|
/** 执行完成
|
|
2053
2300
|
*/
|
|
2054
2301
|
completed(data) {
|
|
2055
|
-
const { line, point, mode } = data;
|
|
2056
|
-
this.renderManager.removeLine(
|
|
2057
|
-
if (mode === "end")
|
|
2058
|
-
else if (mode === "start")
|
|
2059
|
-
this.renderManager.addLine(
|
|
2302
|
+
const { line: line2, point, mode } = data;
|
|
2303
|
+
this.renderManager.removeLine(line2);
|
|
2304
|
+
if (mode === "end") line2.end.set(point.x, point.y);
|
|
2305
|
+
else if (mode === "start") line2.start.set(point.x, point.y);
|
|
2306
|
+
this.renderManager.addLine(line2);
|
|
2060
2307
|
this.renderManager.draw();
|
|
2061
2308
|
}
|
|
2062
2309
|
}
|