build-dxf 0.0.19-9 → 0.0.20-1
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.d.ts +7 -5
- package/src/build.js +54 -31
- package/src/index.css +375 -515
- package/src/index3.js +742 -392
- package/src/pages/Editor.vue.d.ts +3 -1
- package/src/utils/ComponentManager/Component.d.ts +1 -0
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/CommandFlowComponent.d.ts +9 -2
- 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 +7 -0
- package/src/utils/DxfSystem/plugin/Editor/index.d.ts +8 -1
- package/src/utils/DxfSystem/plugin/Editor/pages/EditorTool.vue.d.ts +1 -0
- package/src/utils/Quadtree/LineSegment.d.ts +1 -1
- 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 { 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, 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 } 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,
|
|
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";
|
|
5
5
|
import "clipper-lib";
|
|
6
6
|
import "dxf-writer";
|
|
7
7
|
import "three/addons/controls/OrbitControls.js";
|
|
@@ -258,7 +258,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
258
258
|
};
|
|
259
259
|
}
|
|
260
260
|
});
|
|
261
|
-
var Badge = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__file", "badge.vue"]]);
|
|
261
|
+
var Badge = /* @__PURE__ */ _export_sfc$1(_sfc_main$2, [["__file", "badge.vue"]]);
|
|
262
262
|
const ElBadge = withInstall(Badge);
|
|
263
263
|
const configProviderProps = buildProps({
|
|
264
264
|
a11y: {
|
|
@@ -565,7 +565,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
565
565
|
};
|
|
566
566
|
}
|
|
567
567
|
});
|
|
568
|
-
var MessageConstructor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "message.vue"]]);
|
|
568
|
+
var MessageConstructor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1, [["__file", "message.vue"]]);
|
|
569
569
|
let seed = 1;
|
|
570
570
|
const normalizeOptions = (params) => {
|
|
571
571
|
const options = !params || isString$1(params) || isVNode(params) || isFunction(params) ? { message: params } : params;
|
|
@@ -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);
|
|
@@ -750,9 +764,10 @@ class CommandFlowComponent extends Component {
|
|
|
750
764
|
* 创建清理
|
|
751
765
|
* @returns
|
|
752
766
|
*/
|
|
753
|
-
createFinally() {
|
|
767
|
+
createFinally(keys = []) {
|
|
754
768
|
return () => {
|
|
755
769
|
this.canceEventRecord("clear");
|
|
770
|
+
keys.forEach((k) => this.canceEventRecord(k));
|
|
756
771
|
};
|
|
757
772
|
}
|
|
758
773
|
}
|
|
@@ -764,7 +779,8 @@ class DrawLine extends CommandFlowComponent {
|
|
|
764
779
|
shortcutKeys = ["control", "l"];
|
|
765
780
|
confirmKeys = ["enter"];
|
|
766
781
|
commandName = "draw-line";
|
|
767
|
-
onAddFromParent() {
|
|
782
|
+
onAddFromParent(parent) {
|
|
783
|
+
super.onAddFromParent(parent);
|
|
768
784
|
this.editor.container.add(this.container);
|
|
769
785
|
const commandFlow = this.commandManager.addCommandFlow(this.commandName).add(this.createInterrupt()).add(this.createCursor("crosshair")).add(this.selectPoint.bind(this));
|
|
770
786
|
commandFlow.addEventListener("finally", this.createFinally());
|
|
@@ -777,7 +793,7 @@ class DrawLine extends CommandFlowComponent {
|
|
|
777
793
|
* @param next
|
|
778
794
|
*/
|
|
779
795
|
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,
|
|
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([
|
|
781
797
|
new THREE.Vector3(-1e4, 0, 0),
|
|
782
798
|
new THREE.Vector3(1e4, 0, 0),
|
|
783
799
|
new THREE.Vector3(0, -1e4, 0),
|
|
@@ -789,9 +805,9 @@ class DrawLine extends CommandFlowComponent {
|
|
|
789
805
|
gapSize: 0.1,
|
|
790
806
|
linewidth: 0.1
|
|
791
807
|
});
|
|
792
|
-
this.container.add(
|
|
808
|
+
this.container.add(line2);
|
|
793
809
|
const updateLine = () => {
|
|
794
|
-
|
|
810
|
+
line2.setPoint(...points, start, end);
|
|
795
811
|
auxiliaryLine.position.copy(end);
|
|
796
812
|
this.container.add(auxiliaryLine);
|
|
797
813
|
auxiliaryLine.computeLineDistances();
|
|
@@ -845,7 +861,7 @@ class DrawLine extends CommandFlowComponent {
|
|
|
845
861
|
} else if (editor.eventInput.isKeyDowns(this.confirmKeys)) next(points);
|
|
846
862
|
}),
|
|
847
863
|
function() {
|
|
848
|
-
|
|
864
|
+
line2.removeFromParent();
|
|
849
865
|
circle.removeFromParent();
|
|
850
866
|
auxiliaryLine.removeFromParent();
|
|
851
867
|
}
|
|
@@ -889,6 +905,9 @@ class Default extends Component {
|
|
|
889
905
|
if (this.selectLines.indexOf(lineSegment) > -1) return;
|
|
890
906
|
this.selectLines.push(lineSegment);
|
|
891
907
|
this.updateSelectLinesGeometry();
|
|
908
|
+
this.dispatchEvent({
|
|
909
|
+
type: "selectLineChange"
|
|
910
|
+
});
|
|
892
911
|
}
|
|
893
912
|
/** 移除选择的线段
|
|
894
913
|
* @param lineSegment
|
|
@@ -898,15 +917,27 @@ class Default extends Component {
|
|
|
898
917
|
if (i > -1) {
|
|
899
918
|
this.selectLines.splice(i, 1);
|
|
900
919
|
this.updateSelectLinesGeometry();
|
|
920
|
+
this.dispatchEvent({
|
|
921
|
+
type: "selectLineChange"
|
|
922
|
+
});
|
|
901
923
|
}
|
|
902
924
|
}
|
|
925
|
+
/**
|
|
926
|
+
* 移除所有选中线段
|
|
927
|
+
*/
|
|
928
|
+
removeSelectLineAll() {
|
|
929
|
+
this.selectLines.length = 0;
|
|
930
|
+
this.dispatchEvent({
|
|
931
|
+
type: "selectLineChange"
|
|
932
|
+
});
|
|
933
|
+
}
|
|
903
934
|
/**
|
|
904
935
|
* 删除选择的线段
|
|
905
936
|
*/
|
|
906
937
|
deleteSelectLine() {
|
|
907
938
|
const editor = this.editor;
|
|
908
|
-
this.selectLines.forEach((
|
|
909
|
-
this.
|
|
939
|
+
this.selectLines.forEach((line2) => editor.renderManager.removeLine(line2));
|
|
940
|
+
this.removeSelectLineAll();
|
|
910
941
|
this.updateSelectLinesGeometry();
|
|
911
942
|
ElMessage({ message: "删除成功", type: "success" });
|
|
912
943
|
}
|
|
@@ -915,9 +946,9 @@ class Default extends Component {
|
|
|
915
946
|
*/
|
|
916
947
|
deleteSelectWindow() {
|
|
917
948
|
let is = false;
|
|
918
|
-
this.selectLines.forEach((
|
|
919
|
-
if (!
|
|
920
|
-
|
|
949
|
+
this.selectLines.forEach((line2) => {
|
|
950
|
+
if (!line2.userData.isWindow) return;
|
|
951
|
+
line2.userData = {};
|
|
921
952
|
is = true;
|
|
922
953
|
});
|
|
923
954
|
this.editor.renderManager.draw();
|
|
@@ -945,8 +976,8 @@ class Default extends Component {
|
|
|
945
976
|
}
|
|
946
977
|
}
|
|
947
978
|
if (start && end) {
|
|
948
|
-
const
|
|
949
|
-
editor.renderManager.addLine(
|
|
979
|
+
const line2 = new LineSegment(start.clone(), end.clone());
|
|
980
|
+
editor.renderManager.addLine(line2);
|
|
950
981
|
editor.renderManager.draw();
|
|
951
982
|
ElMessage({ message: "连接成功", type: "success" });
|
|
952
983
|
}
|
|
@@ -995,8 +1026,8 @@ class Default extends Component {
|
|
|
995
1026
|
const p2Next = line2.points[(j + 1) % 2];
|
|
996
1027
|
editor.renderManager.removeLine(line1);
|
|
997
1028
|
editor.renderManager.removeLine(line2);
|
|
998
|
-
const
|
|
999
|
-
editor.renderManager.addLine(
|
|
1029
|
+
const line3 = new LineSegment(p1Next, p2Next);
|
|
1030
|
+
editor.renderManager.addLine(line3);
|
|
1000
1031
|
editor.renderManager.draw();
|
|
1001
1032
|
ElMessage({ message: "已合并", type: "success" });
|
|
1002
1033
|
return;
|
|
@@ -1012,10 +1043,11 @@ class Default extends Component {
|
|
|
1012
1043
|
updateSelectLinesGeometry() {
|
|
1013
1044
|
if (this._timer) clearTimeout(this._timer);
|
|
1014
1045
|
this._timer = setTimeout(() => {
|
|
1046
|
+
if (this.destroyed) return;
|
|
1015
1047
|
if (this.selectLines.length) this.container.add(this.selectLineObject3D);
|
|
1016
1048
|
else this.selectLineObject3D.removeFromParent();
|
|
1017
1049
|
const editor = this.editor;
|
|
1018
|
-
const position = this.selectLines.flatMap((
|
|
1050
|
+
const position = this.selectLines.flatMap((line2) => line2.expandToRectangle(0.04, "bothSides").createGeometry());
|
|
1019
1051
|
this.selectLineObject3D.geometry = editor.renderManager.createGeometry({ position }, position.length / 3);
|
|
1020
1052
|
}, 10);
|
|
1021
1053
|
}
|
|
@@ -1081,7 +1113,7 @@ class Default extends Component {
|
|
|
1081
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);
|
|
1082
1114
|
const box = new Box2(minX, maxX, minY, maxY);
|
|
1083
1115
|
const resultList = editor.renderManager.quadtree.queryBox(box);
|
|
1084
|
-
this.
|
|
1116
|
+
this.removeSelectLineAll();
|
|
1085
1117
|
resultList.forEach((result) => this.addSelectLine(result.line));
|
|
1086
1118
|
this.updateSelectLinesGeometry();
|
|
1087
1119
|
};
|
|
@@ -1092,13 +1124,13 @@ class Default extends Component {
|
|
|
1092
1124
|
"clear",
|
|
1093
1125
|
// 注册鼠标指针位置变化事件
|
|
1094
1126
|
editor.addEventListener("pointerPositionChange", () => {
|
|
1095
|
-
const { line } = editor.renderManager.adsorption(0.05);
|
|
1096
|
-
if (
|
|
1097
|
-
const rectangle =
|
|
1127
|
+
const { line: line2 } = editor.renderManager.adsorption(0.05);
|
|
1128
|
+
if (line2) {
|
|
1129
|
+
const rectangle = line2.expandToRectangle(0.02, "bothSides");
|
|
1098
1130
|
object3D.geometry = editor.renderManager.createGeometry({ position: rectangle.createGeometry() }, 6);
|
|
1099
1131
|
this.container.add(object3D);
|
|
1100
1132
|
dom.style.cursor = "pointer";
|
|
1101
|
-
currentSelectLine =
|
|
1133
|
+
currentSelectLine = line2;
|
|
1102
1134
|
} else {
|
|
1103
1135
|
object3D.removeFromParent();
|
|
1104
1136
|
dom.style.cursor = "default";
|
|
@@ -1111,7 +1143,7 @@ class Default extends Component {
|
|
|
1111
1143
|
if (eventInput.isKeyDown("alt")) {
|
|
1112
1144
|
return this.removeSelectLine(currentSelectLine);
|
|
1113
1145
|
}
|
|
1114
|
-
if (!eventInput.isKeyDown("control")) this.
|
|
1146
|
+
if (!eventInput.isKeyDown("control")) this.removeSelectLineAll();
|
|
1115
1147
|
this.addSelectLine(currentSelectLine);
|
|
1116
1148
|
} else if (eventInput.isOnlyKeyDown("delete")) {
|
|
1117
1149
|
this.deleteSelectLine();
|
|
@@ -1135,7 +1167,7 @@ class Default extends Component {
|
|
|
1135
1167
|
*/
|
|
1136
1168
|
finally() {
|
|
1137
1169
|
this.canceEventRecord("clear");
|
|
1138
|
-
this.
|
|
1170
|
+
this.removeSelectLineAll();
|
|
1139
1171
|
this.updateSelectLinesGeometry();
|
|
1140
1172
|
}
|
|
1141
1173
|
}
|
|
@@ -1248,294 +1280,26 @@ class CommandManager extends EventDispatcher {
|
|
|
1248
1280
|
}
|
|
1249
1281
|
}
|
|
1250
1282
|
}
|
|
1251
|
-
const
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
const
|
|
1257
|
-
const
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
{ "name": "删除线段", "shortcut": "选中 + Delete" },
|
|
1272
|
-
{ "name": "删除窗户线", "shortcut": "选中 + Q + Delete" },
|
|
1273
|
-
{ "name": "选中", "shortcut": "鼠标左键" },
|
|
1274
|
-
{ "name": "多选", "shortcut": "鼠标左键 + Ctrl" },
|
|
1275
|
-
{ "name": "取消选中", "shortcut": "鼠标左键 + Alt" },
|
|
1276
|
-
{ "name": "框选", "shortcut": "鼠标左键 + 移动" },
|
|
1277
|
-
{ "name": "线段同方向合并", "shortcut": "Ctrl + G" },
|
|
1278
|
-
{ "name": "线段连接", "shortcut": "选中 + Shift + L" },
|
|
1279
|
-
{ "name": "线段交点连接", "shortcut": "选中 + Ctrl + Shift + L" },
|
|
1280
|
-
{ "name": "取消命令", "shortcut": "Esc" }
|
|
1281
|
-
];
|
|
1282
|
-
watchEffect(() => localStorage.setItem("EditorToolPosition", JSON.stringify(toolBarPosition.value)));
|
|
1283
|
-
function setEditorToolPosition(left, top) {
|
|
1284
|
-
const dom = elRef.value, toolBarDom = elRef.value, rect = dom.getBoundingClientRect(), toolBarRect = toolBarDom.getBoundingClientRect(), minX = 0, maxX = toolBarRect.width - rect.width, minY = 0, maxY = toolBarRect.height - rect.height;
|
|
1285
|
-
left = Math.max(minX, Math.min(left, maxX));
|
|
1286
|
-
top = Math.max(minY, Math.min(top, maxY));
|
|
1287
|
-
toolBarPosition.value = { left, top };
|
|
1288
|
-
console.log(left, top);
|
|
1289
|
-
}
|
|
1290
|
-
function setLines(lines) {
|
|
1291
|
-
if (lines) {
|
|
1292
|
-
localStorage.setItem("lines", JSON.stringify(lines));
|
|
1293
|
-
try {
|
|
1294
|
-
dxfSystem.Dxf.set(lines);
|
|
1295
|
-
dxfSystem.Dxf.lineOffset();
|
|
1296
|
-
} catch (error) {
|
|
1297
|
-
console.log(error);
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
async function selectLocalFile() {
|
|
1302
|
-
const data = await SelectLocalFile.json();
|
|
1303
|
-
if (Array.isArray(data)) {
|
|
1304
|
-
localStorage.removeItem("orbitControls");
|
|
1305
|
-
setLines(data);
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
function dragMoveHelper(e) {
|
|
1309
|
-
domEventRegister.mouseMoveEventProxylock = true;
|
|
1310
|
-
const cusor = document.body.style.cursor;
|
|
1311
|
-
document.body.style.cursor = "move";
|
|
1312
|
-
const move = (e2) => {
|
|
1313
|
-
setEditorToolPosition(
|
|
1314
|
-
toolBarPosition.value.left + e2.movementX,
|
|
1315
|
-
toolBarPosition.value.top + e2.movementY
|
|
1316
|
-
);
|
|
1317
|
-
e2.stopPropagation();
|
|
1318
|
-
document.body.style.cursor = "move";
|
|
1319
|
-
};
|
|
1320
|
-
const end = () => {
|
|
1321
|
-
document.body.removeEventListener("mousemove", move);
|
|
1322
|
-
document.body.removeEventListener("mouseup", end);
|
|
1323
|
-
document.body.style.cursor = cusor;
|
|
1324
|
-
domEventRegister.mouseMoveEventProxylock = false;
|
|
1325
|
-
};
|
|
1326
|
-
document.body.addEventListener("mousemove", move);
|
|
1327
|
-
document.body.addEventListener("mouseup", end);
|
|
1328
|
-
}
|
|
1329
|
-
watch(originalLineVisible, () => dxfSystem.Variable.set("originalLineVisible", originalLineVisible.value));
|
|
1330
|
-
watch(dxfVisible, () => dxfSystem.Variable.set("dxfVisible", dxfVisible.value));
|
|
1331
|
-
watch(whiteModelVisible, () => dxfSystem.Variable.set("whiteModelVisible", whiteModelVisible.value));
|
|
1332
|
-
dxfSystem.Variable.addEventListener("isLook", (e) => isLook.value = e.value);
|
|
1333
|
-
dxfSystem.Variable.addEventListener("originalLineVisible", (e) => originalLineVisible.value = e.value);
|
|
1334
|
-
dxfSystem.Variable.addEventListener("dxfVisible", (e) => dxfVisible.value = e.value);
|
|
1335
|
-
dxfSystem.Variable.addEventListener("whiteModelVisible", (e) => whiteModelVisible.value = e.value);
|
|
1336
|
-
onMounted(() => {
|
|
1337
|
-
if (localStorage.getItem("EditorToolPosition")) {
|
|
1338
|
-
const { left, top } = JSON.parse(localStorage.getItem("EditorToolPosition") ?? "{}");
|
|
1339
|
-
setEditorToolPosition(left, top);
|
|
1340
|
-
}
|
|
1341
|
-
});
|
|
1342
|
-
onUnmounted(() => {
|
|
1343
|
-
domEventRegister.mouseMoveEventProxylock = false;
|
|
1344
|
-
});
|
|
1345
|
-
return (_ctx, _cache) => {
|
|
1346
|
-
return openBlock(), createElementBlock("div", {
|
|
1347
|
-
ref_key: "elRef",
|
|
1348
|
-
ref: elRef,
|
|
1349
|
-
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]"
|
|
1350
|
-
}, [
|
|
1351
|
-
createElementVNode("div", _hoisted_1, [
|
|
1352
|
-
(openBlock(), createElementBlock(Fragment, null, renderList(shortcutKeys, (item) => {
|
|
1353
|
-
return createElementVNode("p", {
|
|
1354
|
-
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",
|
|
1355
|
-
key: item.name
|
|
1356
|
-
}, [
|
|
1357
|
-
createTextVNode(toDisplayString(item.name) + ": ", 1),
|
|
1358
|
-
createElementVNode("span", _hoisted_2, toDisplayString(item.shortcut), 1)
|
|
1359
|
-
]);
|
|
1360
|
-
}), 64))
|
|
1361
|
-
]),
|
|
1362
|
-
createElementVNode("div", {
|
|
1363
|
-
ref_key: "toolBarRef",
|
|
1364
|
-
ref: toolBarRef,
|
|
1365
|
-
style: normalizeStyle({ left: toolBarPosition.value.left + "px", top: toolBarPosition.value.top + "px" }),
|
|
1366
|
-
class: "pointer-events-auto text-[#333] absolute rounded-[8px] min-w-[140px] z-[1000] bg-white select-none"
|
|
1367
|
-
}, [
|
|
1368
|
-
createElementVNode("div", _hoisted_3, [
|
|
1369
|
-
(openBlock(), createElementBlock("svg", {
|
|
1370
|
-
onMousedown: dragMoveHelper,
|
|
1371
|
-
class: "m-[0px_5px]",
|
|
1372
|
-
fill: "#aaa",
|
|
1373
|
-
width: "20",
|
|
1374
|
-
height: "20",
|
|
1375
|
-
viewBox: "0 0 1024 1024",
|
|
1376
|
-
version: "1.1",
|
|
1377
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
1378
|
-
}, _cache[2] || (_cache[2] = [
|
|
1379
|
-
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" }, null, -1)
|
|
1380
|
-
]), 32)),
|
|
1381
|
-
_cache[3] || (_cache[3] = createElementVNode("span", null, "小工具", -1))
|
|
1382
|
-
]),
|
|
1383
|
-
createElementVNode("div", _hoisted_4, [
|
|
1384
|
-
createElementVNode("ul", _hoisted_5, [
|
|
1385
|
-
(openBlock(), createElementBlock(Fragment, null, renderList(4, (i) => {
|
|
1386
|
-
return createElementVNode("li", {
|
|
1387
|
-
key: i,
|
|
1388
|
-
class: "hover:bg-[#ddd] transition-all rounded-[6px] p-[5px] flex flex-row items-center cursor-pointer"
|
|
1389
|
-
}, _cache[4] || (_cache[4] = [
|
|
1390
|
-
createElementVNode("div", { class: "p-[5px] bg-[#f0f0f0] rounded-[6px] mr-[10px]" }, [
|
|
1391
|
-
createElementVNode("img", {
|
|
1392
|
-
class: "w-[20px] h-[20px]",
|
|
1393
|
-
src: _imports_0,
|
|
1394
|
-
alt: "",
|
|
1395
|
-
srcset: ""
|
|
1396
|
-
})
|
|
1397
|
-
], -1),
|
|
1398
|
-
createElementVNode("span", null, "直线", -1)
|
|
1399
|
-
]));
|
|
1400
|
-
}), 64))
|
|
1401
|
-
]),
|
|
1402
|
-
createElementVNode("div", _hoisted_6, [
|
|
1403
|
-
createVNode(unref(ElCheckbox), {
|
|
1404
|
-
modelValue: dxfVisible.value,
|
|
1405
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => dxfVisible.value = $event),
|
|
1406
|
-
label: "dxf"
|
|
1407
|
-
}, null, 8, ["modelValue"]),
|
|
1408
|
-
createVNode(unref(ElButton), {
|
|
1409
|
-
size: "small",
|
|
1410
|
-
type: "success",
|
|
1411
|
-
onClick: selectLocalFile
|
|
1412
|
-
}, {
|
|
1413
|
-
default: withCtx(() => _cache[5] || (_cache[5] = [
|
|
1414
|
-
createTextVNode(" 选择文件 ", -1)
|
|
1415
|
-
])),
|
|
1416
|
-
_: 1,
|
|
1417
|
-
__: [5]
|
|
1418
|
-
}),
|
|
1419
|
-
createVNode(unref(ElButton), {
|
|
1420
|
-
size: "small",
|
|
1421
|
-
type: "primary",
|
|
1422
|
-
onClick: _cache[1] || (_cache[1] = ($event) => unref(dxfSystem).Dxf.download("test.dxf"))
|
|
1423
|
-
}, {
|
|
1424
|
-
default: withCtx(() => _cache[6] || (_cache[6] = [
|
|
1425
|
-
createTextVNode(" 下载 DXF ", -1)
|
|
1426
|
-
])),
|
|
1427
|
-
_: 1,
|
|
1428
|
-
__: [6]
|
|
1429
|
-
})
|
|
1430
|
-
])
|
|
1431
|
-
])
|
|
1432
|
-
], 4)
|
|
1433
|
-
], 512);
|
|
1434
|
-
};
|
|
1435
|
-
}
|
|
1436
|
-
});
|
|
1437
|
-
let Editor$1 = class Editor extends Component {
|
|
1438
|
-
static name = "Editor";
|
|
1439
|
-
container = new THREE.Group();
|
|
1440
|
-
get renderer() {
|
|
1441
|
-
return this.parent?.findComponentByName("Renderer");
|
|
1442
|
-
}
|
|
1443
|
-
get dxf() {
|
|
1444
|
-
return this.parent?.findComponentByName("Dxf");
|
|
1445
|
-
}
|
|
1446
|
-
get variable() {
|
|
1447
|
-
return this.parent?.findComponentByName("Variable");
|
|
1448
|
-
}
|
|
1449
|
-
get eventInput() {
|
|
1450
|
-
return this.parent?.findComponentByName("EventInput");
|
|
1451
|
-
}
|
|
1452
|
-
get renderManager() {
|
|
1453
|
-
return this.parent?.findComponentByName("RenderManager");
|
|
1454
|
-
}
|
|
1455
|
-
get domEventRegister() {
|
|
1456
|
-
return this.parent?.findComponentByName("DomEventRegister");
|
|
1457
|
-
}
|
|
1458
|
-
get domContainer() {
|
|
1459
|
-
return this.parent?.findComponentByName("DomContainer");
|
|
1460
|
-
}
|
|
1461
|
-
commandManager = new CommandManager();
|
|
1462
|
-
plane = new THREE.Mesh(new THREE.PlaneGeometry(2e3, 2e3, 2, 2));
|
|
1463
|
-
app;
|
|
1464
|
-
domElement = document.createElement("div");
|
|
1465
|
-
onAddFromParent() {
|
|
1466
|
-
setTimeout(() => this.openEdit(), 10);
|
|
1467
|
-
const grid = new THREE.GridHelper(200, 100, 6710886, 4473924);
|
|
1468
|
-
grid.rotation.x = Math.PI * 0.5;
|
|
1469
|
-
grid.position.z = -0.01;
|
|
1470
|
-
this.container.add(grid);
|
|
1471
|
-
this.container.add(this.plane);
|
|
1472
|
-
this.plane.visible = false;
|
|
1473
|
-
this.app = createApp(_sfc_main, { dxfSystem: this.parent });
|
|
1474
|
-
this.app.mount(this.domElement);
|
|
1475
|
-
const cancelEvent = this.addEventListener("update", () => {
|
|
1476
|
-
if (this.domContainer.domElement.parentElement) {
|
|
1477
|
-
this.domContainer.domElement.parentElement.appendChild(this.domElement);
|
|
1478
|
-
cancelEvent();
|
|
1479
|
-
}
|
|
1480
|
-
});
|
|
1481
|
-
}
|
|
1482
|
-
coords = new THREE.Vector2();
|
|
1483
|
-
pointerPosition = new THREE.Vector2();
|
|
1484
|
-
_exitEditCallBack;
|
|
1485
|
-
/**
|
|
1486
|
-
* 打开编辑器
|
|
1487
|
-
*/
|
|
1488
|
-
openEdit() {
|
|
1489
|
-
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;
|
|
1490
|
-
this.container.position.z = dxf.originalZAverage;
|
|
1491
|
-
renderer.scene.add(this.container);
|
|
1492
|
-
camera.position.set(center.x, center.y, 14);
|
|
1493
|
-
if (orbitControls) {
|
|
1494
|
-
orbitControls.target.set(center.x, center.y, 0);
|
|
1495
|
-
orbitControls.enableRotate = false;
|
|
1496
|
-
}
|
|
1497
|
-
const mousemoveFun = () => {
|
|
1498
|
-
renderer.renderer.getSize(size);
|
|
1499
|
-
const x = domEventRegister.pointer.x / size.x * 2 - 1;
|
|
1500
|
-
const y = -(domEventRegister.pointer.y / size.y * 2 - 1);
|
|
1501
|
-
coords.set(x, y);
|
|
1502
|
-
raycaster.setFromCamera(coords, renderer.camera);
|
|
1503
|
-
const intersections = raycaster.intersectObject(this.plane);
|
|
1504
|
-
if (intersections.length) {
|
|
1505
|
-
pointerPosition.copy(intersections[0].point);
|
|
1506
|
-
this.dispatchEvent({
|
|
1507
|
-
type: "pointerPositionChange",
|
|
1508
|
-
position: pointerPosition
|
|
1509
|
-
});
|
|
1510
|
-
}
|
|
1511
|
-
};
|
|
1512
|
-
domEventRegister.addEventListener("mousemove", mousemoveFun);
|
|
1513
|
-
this.commandManager.disabled = false;
|
|
1514
|
-
this.commandManager.start("default");
|
|
1515
|
-
this._exitEditCallBack = () => {
|
|
1516
|
-
domEventRegister.removeEventListener("mousemove", mousemoveFun);
|
|
1517
|
-
camera.position.copy(cameraPosition);
|
|
1518
|
-
orbitControls.enableRotate = true;
|
|
1519
|
-
orbitControls.target.copy(target);
|
|
1520
|
-
};
|
|
1521
|
-
}
|
|
1522
|
-
/**
|
|
1523
|
-
* 退出编辑
|
|
1524
|
-
*/
|
|
1525
|
-
exitEdit() {
|
|
1526
|
-
if (typeof this._exitEditCallBack === "function") {
|
|
1527
|
-
this._exitEditCallBack();
|
|
1528
|
-
this._exitEditCallBack = void 0;
|
|
1529
|
-
this.commandManager.disabled = true;
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
destroy() {
|
|
1533
|
-
this.exitEdit();
|
|
1534
|
-
this.renderer.scene.remove(this.container);
|
|
1535
|
-
this.domElement.remove();
|
|
1536
|
-
this.app?.unmount();
|
|
1537
|
-
}
|
|
1538
|
-
};
|
|
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({
|
|
1285
|
+
__proto__: null,
|
|
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({
|
|
1290
|
+
__proto__: null,
|
|
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({
|
|
1295
|
+
__proto__: null,
|
|
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({
|
|
1300
|
+
__proto__: null,
|
|
1301
|
+
default: window$1
|
|
1302
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1539
1303
|
class RenderManager extends Component {
|
|
1540
1304
|
static name = "RenderManager";
|
|
1541
1305
|
container = new THREE.Group();
|
|
@@ -1575,37 +1339,37 @@ class RenderManager extends Component {
|
|
|
1575
1339
|
if (box.width === 0 || box.height === 0) box.set(-200, -200, 200, 200);
|
|
1576
1340
|
this.quadtree = new Quadtree(box);
|
|
1577
1341
|
this.lines.length = 0;
|
|
1578
|
-
this.dxf.lineSegments.forEach((
|
|
1579
|
-
if (
|
|
1580
|
-
this.addLine(
|
|
1342
|
+
this.dxf.lineSegments.forEach((line2) => {
|
|
1343
|
+
if (line2.userData.isDoor && !line2.userData.doorDirectConnection) return;
|
|
1344
|
+
this.addLine(line2.clone());
|
|
1581
1345
|
});
|
|
1582
|
-
this.dxf.doorLineSegment.forEach((
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1346
|
+
this.dxf.doorLineSegment.forEach((line2) => {
|
|
1347
|
+
const door2 = line2.clone();
|
|
1348
|
+
door2.userData = {
|
|
1585
1349
|
isDoor: true,
|
|
1586
1350
|
doorDirectConnection: true
|
|
1587
1351
|
};
|
|
1588
|
-
this.addLine(
|
|
1352
|
+
this.addLine(door2);
|
|
1589
1353
|
});
|
|
1590
1354
|
this.draw();
|
|
1591
1355
|
}
|
|
1592
1356
|
/** 添加线段
|
|
1593
1357
|
* @param line
|
|
1594
1358
|
*/
|
|
1595
|
-
addLine(
|
|
1596
|
-
if (!
|
|
1597
|
-
this.lines.push(
|
|
1598
|
-
this.pointVirtualGrid.insert(
|
|
1599
|
-
this.pointVirtualGrid.insert(
|
|
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);
|
|
1600
1364
|
const quadtreeNode = {
|
|
1601
|
-
line,
|
|
1365
|
+
line: line2,
|
|
1602
1366
|
userData: void 0
|
|
1603
1367
|
};
|
|
1604
|
-
|
|
1368
|
+
line2.userData.quadtreeNode = quadtreeNode;
|
|
1605
1369
|
this.quadtree.insert(quadtreeNode);
|
|
1606
1370
|
this.actionHistory.add({
|
|
1607
1371
|
type: "addLine",
|
|
1608
|
-
data: [
|
|
1372
|
+
data: [line2]
|
|
1609
1373
|
});
|
|
1610
1374
|
}
|
|
1611
1375
|
/**
|
|
@@ -1614,15 +1378,15 @@ class RenderManager extends Component {
|
|
|
1614
1378
|
*/
|
|
1615
1379
|
addLines(lines) {
|
|
1616
1380
|
for (let i = 0; i < lines.length; i++) {
|
|
1617
|
-
const
|
|
1618
|
-
this.lines.push(
|
|
1619
|
-
this.pointVirtualGrid.insert(
|
|
1620
|
-
this.pointVirtualGrid.insert(
|
|
1381
|
+
const line2 = lines[i];
|
|
1382
|
+
this.lines.push(line2);
|
|
1383
|
+
this.pointVirtualGrid.insert(line2.start, line2);
|
|
1384
|
+
this.pointVirtualGrid.insert(line2.end, line2);
|
|
1621
1385
|
const quadtreeNode = {
|
|
1622
|
-
line,
|
|
1386
|
+
line: line2,
|
|
1623
1387
|
userData: void 0
|
|
1624
1388
|
};
|
|
1625
|
-
|
|
1389
|
+
line2.userData.quadtreeNode = quadtreeNode;
|
|
1626
1390
|
this.quadtree.insert(quadtreeNode);
|
|
1627
1391
|
}
|
|
1628
1392
|
this.actionHistory.add({
|
|
@@ -1633,16 +1397,16 @@ class RenderManager extends Component {
|
|
|
1633
1397
|
/** 移除线段
|
|
1634
1398
|
* @param line
|
|
1635
1399
|
*/
|
|
1636
|
-
removeLine(
|
|
1637
|
-
|
|
1638
|
-
this.pointVirtualGrid.remove(
|
|
1639
|
-
this.pointVirtualGrid.remove(
|
|
1640
|
-
const index = this.lines.indexOf(
|
|
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);
|
|
1641
1405
|
this.lines.splice(index, 1);
|
|
1642
1406
|
this.draw();
|
|
1643
1407
|
this.actionHistory.add({
|
|
1644
1408
|
type: "removeLine",
|
|
1645
|
-
data: [
|
|
1409
|
+
data: [line2]
|
|
1646
1410
|
});
|
|
1647
1411
|
}
|
|
1648
1412
|
/**
|
|
@@ -1651,14 +1415,14 @@ class RenderManager extends Component {
|
|
|
1651
1415
|
draw(synchronize = true) {
|
|
1652
1416
|
this.container.clear();
|
|
1653
1417
|
const position = [], doorPosition = [], windowPosition = [];
|
|
1654
|
-
this.lines.forEach((
|
|
1655
|
-
|
|
1656
|
-
if (
|
|
1418
|
+
this.lines.forEach((line2) => {
|
|
1419
|
+
line2.points.forEach((p) => {
|
|
1420
|
+
if (line2.userData.isDoor) doorPosition.push(p.x, p.y, 0);
|
|
1657
1421
|
else position.push(p.x, p.y, 0);
|
|
1658
1422
|
});
|
|
1659
|
-
if (
|
|
1660
|
-
|
|
1661
|
-
const center = Point.from(p), direction =
|
|
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));
|
|
1662
1426
|
windowPosition.push(start.x, start.y, 1e-3);
|
|
1663
1427
|
windowPosition.push(end.x, end.y, 1e-3);
|
|
1664
1428
|
});
|
|
@@ -1729,13 +1493,14 @@ class RenderManager extends Component {
|
|
|
1729
1493
|
* 转为json
|
|
1730
1494
|
*/
|
|
1731
1495
|
toJson() {
|
|
1732
|
-
return this.lines.map((
|
|
1733
|
-
const userData =
|
|
1496
|
+
return this.lines.map((line2) => {
|
|
1497
|
+
const userData = line2.userData;
|
|
1734
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) }));
|
|
1735
1500
|
return {
|
|
1736
|
-
start:
|
|
1737
|
-
end:
|
|
1738
|
-
insetionArr
|
|
1501
|
+
start: line2.start.toJson(),
|
|
1502
|
+
end: line2.end.toJson(),
|
|
1503
|
+
insetionArr,
|
|
1739
1504
|
isDoor: userData.isDoor,
|
|
1740
1505
|
doorDirectConnection: userData.isDoor,
|
|
1741
1506
|
isWindow: userData.isWindow,
|
|
@@ -1792,6 +1557,7 @@ class DrawDoorLine extends CommandFlowComponent {
|
|
|
1792
1557
|
shortcutKeys = ["control", "m"];
|
|
1793
1558
|
commandName = "draw-door-line";
|
|
1794
1559
|
onAddFromParent(parent) {
|
|
1560
|
+
super.onAddFromParent(parent);
|
|
1795
1561
|
const editor = parent.findComponentByName("Editor"), eventInput = editor.eventInput, commandManager = editor.commandManager;
|
|
1796
1562
|
this.editor.container.add(this.container);
|
|
1797
1563
|
const commandFlow = this.commandManager.addCommandFlow("draw-door-line").add(this.createInterrupt()).add(this.createCursor("no-drop")).add(this.selectPoint.bind(this));
|
|
@@ -1807,7 +1573,7 @@ class DrawDoorLine extends CommandFlowComponent {
|
|
|
1807
1573
|
* @param next
|
|
1808
1574
|
*/
|
|
1809
1575
|
selectPoint(next) {
|
|
1810
|
-
let editor = this.parent?.findComponentByName("Editor"), start = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 65280 })),
|
|
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([
|
|
1811
1577
|
new THREE.Vector3(-1e4, 0, 0),
|
|
1812
1578
|
new THREE.Vector3(1e4, 0, 0),
|
|
1813
1579
|
new THREE.Vector3(0, -1e4, 0),
|
|
@@ -1819,13 +1585,13 @@ class DrawDoorLine extends CommandFlowComponent {
|
|
|
1819
1585
|
gapSize: 0.1,
|
|
1820
1586
|
linewidth: 0.1
|
|
1821
1587
|
});
|
|
1822
|
-
this.container.add(
|
|
1588
|
+
this.container.add(line2);
|
|
1823
1589
|
let currentPoint = null;
|
|
1824
1590
|
this.addEventRecord(
|
|
1825
1591
|
"clear",
|
|
1826
1592
|
editor.addEventListener("pointerPositionChange", () => {
|
|
1827
1593
|
const { point, find } = editor.renderManager.adsorption(0.05);
|
|
1828
|
-
start &&
|
|
1594
|
+
start && line2.setPoint(start, point);
|
|
1829
1595
|
if (find) {
|
|
1830
1596
|
circle.position.set(point.x, point.y, 0);
|
|
1831
1597
|
this.container.add(circle);
|
|
@@ -1847,7 +1613,7 @@ class DrawDoorLine extends CommandFlowComponent {
|
|
|
1847
1613
|
}
|
|
1848
1614
|
}),
|
|
1849
1615
|
function() {
|
|
1850
|
-
|
|
1616
|
+
line2.removeFromParent();
|
|
1851
1617
|
circle.removeFromParent();
|
|
1852
1618
|
auxiliaryLine.removeFromParent();
|
|
1853
1619
|
}
|
|
@@ -1858,10 +1624,10 @@ class DrawDoorLine extends CommandFlowComponent {
|
|
|
1858
1624
|
completed(points) {
|
|
1859
1625
|
const editor = this.editor, lines = [];
|
|
1860
1626
|
for (let i = 0; i < points.length; i += 2) {
|
|
1861
|
-
const
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
lines.push(
|
|
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);
|
|
1865
1631
|
}
|
|
1866
1632
|
editor.renderManager.addLines(lines);
|
|
1867
1633
|
editor.renderManager.draw();
|
|
@@ -1873,10 +1639,11 @@ class DrawWindow extends CommandFlowComponent {
|
|
|
1873
1639
|
interruptKeys = ["escape"];
|
|
1874
1640
|
shortcutKeys = ["control", "q"];
|
|
1875
1641
|
commandName = "draw-window-line";
|
|
1876
|
-
onAddFromParent() {
|
|
1642
|
+
onAddFromParent(parent) {
|
|
1643
|
+
super.onAddFromParent(parent);
|
|
1877
1644
|
this.editor.container.add(this.container);
|
|
1878
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));
|
|
1879
|
-
commandFlow.addEventListener("finally", this.createFinally());
|
|
1646
|
+
commandFlow.addEventListener("finally", this.createFinally(["selectPointStart"]));
|
|
1880
1647
|
commandFlow.addEventListener("completed", (e) => this.completed(e.data));
|
|
1881
1648
|
this.eventInput.addKeyCombination(this.commandName, this.shortcutKeys);
|
|
1882
1649
|
this.eventInput.addEventListener("codeChange", async () => this.eventInput.isKeyCombination(this.commandName) && await this.commandManager.start(this.commandName));
|
|
@@ -1888,11 +1655,11 @@ class DrawWindow extends CommandFlowComponent {
|
|
|
1888
1655
|
selectPointStart(next) {
|
|
1889
1656
|
let currentPoint = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 16711935 })), currentLine = null;
|
|
1890
1657
|
this.addEventRecord("selectPointStart").add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
1891
|
-
const { point, line, find } = this.editor.renderManager.adsorption();
|
|
1658
|
+
const { point, line: line2, find } = this.editor.renderManager.adsorption();
|
|
1892
1659
|
if (find) {
|
|
1893
1660
|
this.domElement.style.cursor = "none";
|
|
1894
1661
|
circle.position.copy(point);
|
|
1895
|
-
currentLine =
|
|
1662
|
+
currentLine = line2;
|
|
1896
1663
|
currentPoint = point.clone();
|
|
1897
1664
|
this.container.add(circle);
|
|
1898
1665
|
} else {
|
|
@@ -1911,11 +1678,11 @@ class DrawWindow extends CommandFlowComponent {
|
|
|
1911
1678
|
/** 选择结束点
|
|
1912
1679
|
* @param next
|
|
1913
1680
|
*/
|
|
1914
|
-
selectPointEnd(next, { point, line }) {
|
|
1681
|
+
selectPointEnd(next, { point, line: line2 }) {
|
|
1915
1682
|
let currentPoint = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 16711935 }));
|
|
1916
1683
|
this.addEventRecord("clear").add(() => circle.removeFromParent()).add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
1917
1684
|
const { point: point2, find, line: l } = this.editor.renderManager.adsorption();
|
|
1918
|
-
if (find && l ===
|
|
1685
|
+
if (find && l === line2) {
|
|
1919
1686
|
this.domElement.style.cursor = "none";
|
|
1920
1687
|
circle.position.copy(point2);
|
|
1921
1688
|
currentPoint = point2.clone();
|
|
@@ -1926,30 +1693,607 @@ class DrawWindow extends CommandFlowComponent {
|
|
|
1926
1693
|
circle.removeFromParent();
|
|
1927
1694
|
}
|
|
1928
1695
|
})).add(this.eventInput.addEventListener("codeChange", () => {
|
|
1929
|
-
if (this.eventInput.isKeyDown("mouse_0") && currentPoint) next({ line, start: point, end: currentPoint });
|
|
1696
|
+
if (this.eventInput.isKeyDown("mouse_0") && currentPoint) next({ line: line2, start: point, end: currentPoint });
|
|
1930
1697
|
}));
|
|
1931
1698
|
}
|
|
1932
1699
|
/** 执行完成
|
|
1933
1700
|
*/
|
|
1934
1701
|
completed(data) {
|
|
1935
|
-
const start = data.start, end = data.end,
|
|
1936
|
-
|
|
1937
|
-
if (!
|
|
1938
|
-
|
|
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({
|
|
1939
1706
|
p: new THREE.Vector3(center.x, center.y, 0),
|
|
1940
1707
|
width: len,
|
|
1941
|
-
full: Math.abs(len -
|
|
1708
|
+
full: Math.abs(len - line2.length()) < 0.01
|
|
1942
1709
|
});
|
|
1943
1710
|
this.renderManager.draw();
|
|
1944
1711
|
}
|
|
1945
1712
|
}
|
|
1713
|
+
const _hoisted_1 = {
|
|
1714
|
+
key: 0,
|
|
1715
|
+
class: "mt-[5px] text-[#ccc] text-[11px] absolute left-[10px] bottom-[10px] rounded-[8px] min-w-[150px] bg-black/15 p-[10px]"
|
|
1716
|
+
};
|
|
1717
|
+
const _hoisted_2 = { class: "text-start max-w-[100px]" };
|
|
1718
|
+
const _hoisted_3 = { class: "inline-block ml-[10px] text-[var(--color-primary)]" };
|
|
1719
|
+
const _hoisted_4 = {
|
|
1720
|
+
key: 0,
|
|
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 = {
|
|
1729
|
+
key: 1,
|
|
1730
|
+
class: "text-[#999]"
|
|
1731
|
+
};
|
|
1732
|
+
const _hoisted_11 = {
|
|
1733
|
+
style: { "--el-color-primary": "var(--primary-color)" },
|
|
1734
|
+
class: "flex flex-row items-center justify-between gap-[10px] mt-[10px] text-[10px]"
|
|
1735
|
+
};
|
|
1736
|
+
const _hoisted_12 = {
|
|
1737
|
+
key: 0,
|
|
1738
|
+
class: "flex flex-row items-center flex-wrap justify-between gap-[10px] mt-[10px] text-[10px]"
|
|
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({
|
|
1746
|
+
__name: "EditorTool",
|
|
1747
|
+
props: {
|
|
1748
|
+
dxfSystem: {},
|
|
1749
|
+
permission: {}
|
|
1750
|
+
},
|
|
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 };
|
|
1757
|
+
}
|
|
1758
|
+
function startCurrentCommandItem(item) {
|
|
1759
|
+
if (currentCommand.value === item.command) return;
|
|
1760
|
+
editor.commandManager.start(item.command);
|
|
1761
|
+
}
|
|
1762
|
+
function setLines(lines) {
|
|
1763
|
+
if (lines) {
|
|
1764
|
+
localStorage.setItem("lines", JSON.stringify(lines));
|
|
1765
|
+
try {
|
|
1766
|
+
dxfSystem.Dxf.set(lines);
|
|
1767
|
+
dxfSystem.Dxf.lineOffset();
|
|
1768
|
+
} catch (error) {
|
|
1769
|
+
console.log(error);
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
async function selectLocalFile() {
|
|
1774
|
+
const data = await SelectLocalFile.json();
|
|
1775
|
+
if (Array.isArray(data)) {
|
|
1776
|
+
localStorage.removeItem("orbitControls");
|
|
1777
|
+
setLines(data);
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
function dragMoveHelper({ offsetX, offsetY }) {
|
|
1781
|
+
domEventRegister.mouseMoveEventProxylock = true;
|
|
1782
|
+
const cusor = document.body.style.cursor;
|
|
1783
|
+
document.body.style.cursor = "move";
|
|
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";
|
|
1794
|
+
};
|
|
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);
|
|
1803
|
+
}
|
|
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 = [
|
|
1823
|
+
{
|
|
1824
|
+
command: "default",
|
|
1825
|
+
name: "默认",
|
|
1826
|
+
show: false,
|
|
1827
|
+
shortcut: ""
|
|
1828
|
+
},
|
|
1829
|
+
{
|
|
1830
|
+
command: "draw-line",
|
|
1831
|
+
name: "绘制线段",
|
|
1832
|
+
src: images["./assets/images/line.svg"].default,
|
|
1833
|
+
show: true,
|
|
1834
|
+
shortcut: "Ctrl + L"
|
|
1835
|
+
},
|
|
1836
|
+
{
|
|
1837
|
+
command: "draw-door-line",
|
|
1838
|
+
name: "绘制门线",
|
|
1839
|
+
show: true,
|
|
1840
|
+
src: images["./assets/images/door.svg"].default,
|
|
1841
|
+
shortcut: "Ctrl + M"
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
command: "draw-window-line",
|
|
1845
|
+
name: "绘制窗户线",
|
|
1846
|
+
show: true,
|
|
1847
|
+
src: images["./assets/images/window.svg"].default,
|
|
1848
|
+
shortcut: "Ctrl + Q"
|
|
1849
|
+
},
|
|
1850
|
+
{
|
|
1851
|
+
command: "point",
|
|
1852
|
+
name: "点修改",
|
|
1853
|
+
show: true,
|
|
1854
|
+
src: images["./assets/images/selectPoint.svg"].default,
|
|
1855
|
+
shortcut: "Ctrl + P"
|
|
1856
|
+
}
|
|
1857
|
+
];
|
|
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;
|
|
1870
|
+
});
|
|
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);
|
|
1892
|
+
});
|
|
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]"
|
|
1904
|
+
}, [
|
|
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())
|
|
1927
|
+
}, [
|
|
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"])
|
|
1931
|
+
}, [
|
|
1932
|
+
_cache[15] || (_cache[15] = createStaticVNode('<div class="flex flex-row" data-v-a5aa9d5a><div class="p-[2px_5px] flex items-center pointer-events-none" data-v-a5aa9d5a><svg fill="#aaa" width="20" height="20" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" data-v-a5aa9d5a><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-a5aa9d5a></path></svg></div><h5 class="flex text-[12px] items-center pointer-events-none" data-v-a5aa9d5a>绘制工具</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]"
|
|
1937
|
+
}, [
|
|
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"])
|
|
1961
|
+
}, [
|
|
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))
|
|
1994
|
+
]),
|
|
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-a5aa9d5a"]]);
|
|
2169
|
+
let Editor$1 = class Editor extends Component {
|
|
2170
|
+
static name = "Editor";
|
|
2171
|
+
container = new THREE.Group();
|
|
2172
|
+
get renderer() {
|
|
2173
|
+
return this.parent?.findComponentByName("Renderer");
|
|
2174
|
+
}
|
|
2175
|
+
get dxf() {
|
|
2176
|
+
return this.parent?.findComponentByName("Dxf");
|
|
2177
|
+
}
|
|
2178
|
+
get variable() {
|
|
2179
|
+
return this.parent?.findComponentByName("Variable");
|
|
2180
|
+
}
|
|
2181
|
+
get eventInput() {
|
|
2182
|
+
return this.parent?.findComponentByName("EventInput");
|
|
2183
|
+
}
|
|
2184
|
+
get renderManager() {
|
|
2185
|
+
return this.parent?.findComponentByName("RenderManager");
|
|
2186
|
+
}
|
|
2187
|
+
get domEventRegister() {
|
|
2188
|
+
return this.parent?.findComponentByName("DomEventRegister");
|
|
2189
|
+
}
|
|
2190
|
+
get domContainer() {
|
|
2191
|
+
return this.parent?.findComponentByName("DomContainer");
|
|
2192
|
+
}
|
|
2193
|
+
commandManager = new CommandManager();
|
|
2194
|
+
plane = new THREE.Mesh(new THREE.PlaneGeometry(2e3, 2e3, 2, 2));
|
|
2195
|
+
app;
|
|
2196
|
+
domElement = document.createElement("div");
|
|
2197
|
+
viewPermission;
|
|
2198
|
+
constructor(viewPermission) {
|
|
2199
|
+
super();
|
|
2200
|
+
this.viewPermission = viewPermission;
|
|
2201
|
+
}
|
|
2202
|
+
onAddFromParent() {
|
|
2203
|
+
setTimeout(() => this.openEdit(), 10);
|
|
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
|
+
}
|
|
2215
|
+
});
|
|
2216
|
+
setTimeout(() => {
|
|
2217
|
+
this.app = createApp(EditorTool, { dxfSystem: this.parent, permission: this.viewPermission });
|
|
2218
|
+
this.app.mount(this.domElement);
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* 取消命令,由其他命令组件监听事件后注册事件监听实现
|
|
2223
|
+
*/
|
|
2224
|
+
cancelCommand() {
|
|
2225
|
+
this.dispatchEvent({
|
|
2226
|
+
type: "cancelCommand"
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
coords = new THREE.Vector2();
|
|
2230
|
+
pointerPosition = new THREE.Vector2();
|
|
2231
|
+
_exitEditCallBack;
|
|
2232
|
+
/**
|
|
2233
|
+
* 打开编辑器
|
|
2234
|
+
*/
|
|
2235
|
+
openEdit() {
|
|
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
|
+
}
|
|
2258
|
+
};
|
|
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
|
+
}
|
|
2269
|
+
};
|
|
2270
|
+
}
|
|
2271
|
+
/**
|
|
2272
|
+
* 退出编辑
|
|
2273
|
+
*/
|
|
2274
|
+
exitEdit() {
|
|
2275
|
+
if (typeof this._exitEditCallBack === "function") {
|
|
2276
|
+
this._exitEditCallBack();
|
|
2277
|
+
this._exitEditCallBack = void 0;
|
|
2278
|
+
this.commandManager.disabled = true;
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
destroy() {
|
|
2282
|
+
super.destroy();
|
|
2283
|
+
this.exitEdit();
|
|
2284
|
+
this.renderer.scene.remove(this.container);
|
|
2285
|
+
this.domElement.remove();
|
|
2286
|
+
this.app?.unmount();
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
1946
2289
|
class PointDrag extends CommandFlowComponent {
|
|
1947
2290
|
static name = "PointDrag";
|
|
1948
2291
|
container = new THREE.Group();
|
|
1949
2292
|
interruptKeys = ["escape"];
|
|
1950
2293
|
shortcutKeys = ["control", "p"];
|
|
1951
2294
|
commandName = "point";
|
|
1952
|
-
onAddFromParent() {
|
|
2295
|
+
onAddFromParent(parent) {
|
|
2296
|
+
super.onAddFromParent(parent);
|
|
1953
2297
|
this.editor.container.add(this.container);
|
|
1954
2298
|
this.container.position.z = 1e-3;
|
|
1955
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));
|
|
@@ -1965,11 +2309,11 @@ class PointDrag extends CommandFlowComponent {
|
|
|
1965
2309
|
selectPoint(next) {
|
|
1966
2310
|
let currentPoint = null, circle = new THREE.Mesh(new THREE.SphereGeometry(0.05), new THREE.MeshBasicMaterial({ color: 16711935 })), currentLine = null;
|
|
1967
2311
|
this.addEventRecord("selectPointStart").add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
1968
|
-
const { point, line, find, mode } = this.editor.renderManager.adsorption();
|
|
2312
|
+
const { point, line: line2, find, mode } = this.editor.renderManager.adsorption();
|
|
1969
2313
|
if (find && mode === "point") {
|
|
1970
2314
|
this.domElement.style.cursor = "none";
|
|
1971
2315
|
circle.position.copy(point);
|
|
1972
|
-
currentLine =
|
|
2316
|
+
currentLine = line2;
|
|
1973
2317
|
currentPoint = point.clone();
|
|
1974
2318
|
this.container.add(circle);
|
|
1975
2319
|
} else {
|
|
@@ -1991,15 +2335,15 @@ class PointDrag extends CommandFlowComponent {
|
|
|
1991
2335
|
* @param next
|
|
1992
2336
|
* @param param1
|
|
1993
2337
|
*/
|
|
1994
|
-
drag(next, { point, line }) {
|
|
2338
|
+
drag(next, { point, line: line2 }) {
|
|
1995
2339
|
this.domElement.style.cursor = "crosshair";
|
|
1996
|
-
const mode =
|
|
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 }));
|
|
1997
2341
|
this.container.add(lines);
|
|
1998
2342
|
this.addEventRecord("clear").add(this.editor.addEventListener("pointerPositionChange", () => {
|
|
1999
2343
|
let { point: point2, find } = this.editor.renderManager.adsorption(), cursor = "none";
|
|
2000
2344
|
if (point2) {
|
|
2001
2345
|
if (this.eventInput.isKeyDown("shift")) {
|
|
2002
|
-
const p =
|
|
2346
|
+
const p = line2.projectPoint(Point.from(point2), false);
|
|
2003
2347
|
point2.set(p?.x ?? point2.x, p?.y ?? point2.y, 0);
|
|
2004
2348
|
find = true;
|
|
2005
2349
|
cursor = "crosshair";
|
|
@@ -2018,23 +2362,23 @@ class PointDrag extends CommandFlowComponent {
|
|
|
2018
2362
|
})).add(this.eventInput.addEventListener("codeChange", () => {
|
|
2019
2363
|
if (this.eventInput.isKeyDown("mouse_0")) {
|
|
2020
2364
|
this.canceEventRecord("selectPointStart");
|
|
2021
|
-
next({ point: end, line, mode });
|
|
2365
|
+
next({ point: end, line: line2, mode });
|
|
2022
2366
|
}
|
|
2023
2367
|
})).add(() => circle.removeFromParent()).add(() => lines.removeFromParent());
|
|
2024
2368
|
}
|
|
2025
2369
|
/** 执行完成
|
|
2026
2370
|
*/
|
|
2027
2371
|
completed(data) {
|
|
2028
|
-
const { line, point, mode } = data;
|
|
2029
|
-
this.renderManager.removeLine(
|
|
2030
|
-
if (mode === "end")
|
|
2031
|
-
else if (mode === "start")
|
|
2032
|
-
this.renderManager.addLine(
|
|
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);
|
|
2033
2377
|
this.renderManager.draw();
|
|
2034
2378
|
}
|
|
2035
2379
|
}
|
|
2036
|
-
function
|
|
2037
|
-
dxfSystem.addComponent(new Editor$1());
|
|
2380
|
+
function Editor_(dxfSystem, option = {}) {
|
|
2381
|
+
dxfSystem.addComponent(new Editor$1(option.viewPermission));
|
|
2038
2382
|
dxfSystem.addComponent(new RenderManager());
|
|
2039
2383
|
dxfSystem.addComponent(new Default());
|
|
2040
2384
|
dxfSystem.addComponent(new DrawLine());
|
|
@@ -2042,6 +2386,12 @@ function Editor2(dxfSystem) {
|
|
|
2042
2386
|
dxfSystem.addComponent(new DrawWindow());
|
|
2043
2387
|
dxfSystem.addComponent(new PointDrag());
|
|
2044
2388
|
}
|
|
2389
|
+
const Editor2 = Object.assign(Editor_, {
|
|
2390
|
+
create(option = {}) {
|
|
2391
|
+
return (dxfSystem) => Editor_(dxfSystem, option);
|
|
2392
|
+
}
|
|
2393
|
+
});
|
|
2045
2394
|
export {
|
|
2046
|
-
Editor2 as Editor
|
|
2395
|
+
Editor2 as Editor,
|
|
2396
|
+
Editor_
|
|
2047
2397
|
};
|