build-dxf 0.1.25 → 0.1.27

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "build-dxf",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "线段构建双线墙壁的dxf版本",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/build.js CHANGED
@@ -46,7 +46,7 @@ class EventDispatcher extends EventDispatcher$1 {
46
46
  canceEventRecord(name) {
47
47
  const list = this.eventRecordStack.get(name);
48
48
  if (list) {
49
- list.forEach((cancel) => cancel());
49
+ list.reverse().forEach((cancel) => cancel());
50
50
  this.eventRecordStack.delete(name);
51
51
  }
52
52
  }
@@ -1652,11 +1652,12 @@ class LineSegment {
1652
1652
  /** 克隆
1653
1653
  * @returns
1654
1654
  */
1655
- clone(userData = true) {
1655
+ clone(userData = true, cloneUUid = false) {
1656
1656
  const line = new LineSegment(
1657
1657
  this.points[0].clone(),
1658
1658
  this.points[1].clone()
1659
1659
  );
1660
+ if (cloneUUid) line.uuid = this.uuid;
1660
1661
  if (userData) line.userData = cloneUserData(this.userData);
1661
1662
  return line;
1662
1663
  }
@@ -14616,7 +14617,6 @@ class DoorFind {
14616
14617
  dock = { dockLine: endList[0].userData, dockPoint: endList[0].point, point: line.end, pointType: "end" };
14617
14618
  }
14618
14619
  const point2 = this.adsorpt(dock, line);
14619
- console.log(111);
14620
14620
  line.userData.doorDirectConnection = true;
14621
14621
  if (point2) {
14622
14622
  line.userData.doorAutomaticFind = true;
@@ -14992,7 +14992,7 @@ class Dxf extends Component {
14992
14992
  let lines = this.lineSegments.filter((line) => !line.userData.isDoor);
14993
14993
  let doorLineList = [...this.doorLineSegment];
14994
14994
  if (clone2) {
14995
- lines = lines.map((line) => line.clone());
14995
+ lines = lines.map((line) => line.clone(true, true));
14996
14996
  doorLineList = doorLineList.map((line) => line.clone());
14997
14997
  }
14998
14998
  doorLineList.forEach((line) => Object.assign(line.userData, {
package/src/index.css CHANGED
@@ -284,8 +284,8 @@
284
284
  width: 100%;
285
285
  }
286
286
 
287
- .max-w-\[200px\] {
288
- max-width: 200px;
287
+ .max-w-\[150px\] {
288
+ max-width: 150px;
289
289
  }
290
290
 
291
291
  .min-w-\[150px\] {
@@ -738,16 +738,14 @@
738
738
  -webkit-tap-highlight-color: transparent;
739
739
  }
740
740
 
741
- [data-v-cd15d420] {
742
- font-family: 微软雅黑;
743
- /* font-size: 14px; */
741
+ [data-v-88eae165] {
742
+ font-family: 微软雅黑;
744
743
  }
745
- .number[data-v-cd15d420] {
746
- color: #a7a7a7;
747
- /* font-weight: 600; */
744
+ .number[data-v-88eae165] {
745
+ color: #a7a7a7
748
746
  }
749
747
 
750
- [data-v-09ada29e] {
748
+ [data-v-a41b5baa] {
751
749
  font-family: 宋体;
752
750
  }
753
751
 
package/src/index3.js CHANGED
@@ -100,8 +100,13 @@ const __vite_glob_0_18 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
100
100
  __proto__: null,
101
101
  default: window$1
102
102
  }, Symbol.toStringTag, { value: "Module" }));
103
- const ____ = "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='1769079533165'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='4803'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M352%20128a134.4%20134.4%200%200%201%20128.832%2096H921.6a38.4%2038.4%200%200%201%200%2076.8H480.832a134.4%20134.4%200%200%201-257.664%200H102.4a38.4%2038.4%200%201%201%200-76.8h120.768A134.4%20134.4%200%200%201%20352%20128z%20m0%2076.8a57.6%2057.6%200%201%200%200%20115.2%2057.6%2057.6%200%200%200%200-115.2z'%20fill='%23666666'%20p-id='4804'%3e%3c/path%3e%3cpath%20d='M64%20467.2m38.4%200l819.2%200q38.4%200%2038.4%2038.4l0%200q0%2038.4-38.4%2038.4l-819.2%200q-38.4%200-38.4-38.4l0%200q0-38.4%2038.4-38.4Z'%20fill='%23666666'%20p-id='4805'%3e%3c/path%3e%3cpath%20d='M672%20614.4a134.4%20134.4%200%200%201%20128.832%2096H921.6a38.4%2038.4%200%200%201%200%2076.8h-120.768a134.4%20134.4%200%200%201-257.664%200H102.4a38.4%2038.4%200%200%201%200-76.8h440.768A134.4%20134.4%200%200%201%20672%20614.4z%20m0%2076.8a57.6%2057.6%200%201%200%200%20115.2%2057.6%2057.6%200%200%200%200-115.2z'%20fill='%23666666'%20p-id='4806'%3e%3c/path%3e%3c/svg%3e";
103
+ const ____$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='1769079533165'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='4803'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M352%20128a134.4%20134.4%200%200%201%20128.832%2096H921.6a38.4%2038.4%200%200%201%200%2076.8H480.832a134.4%20134.4%200%200%201-257.664%200H102.4a38.4%2038.4%200%201%201%200-76.8h120.768A134.4%20134.4%200%200%201%20352%20128z%20m0%2076.8a57.6%2057.6%200%201%200%200%20115.2%2057.6%2057.6%200%200%200%200-115.2z'%20fill='%23666666'%20p-id='4804'%3e%3c/path%3e%3cpath%20d='M64%20467.2m38.4%200l819.2%200q38.4%200%2038.4%2038.4l0%200q0%2038.4-38.4%2038.4l-819.2%200q-38.4%200-38.4-38.4l0%200q0-38.4%2038.4-38.4Z'%20fill='%23666666'%20p-id='4805'%3e%3c/path%3e%3cpath%20d='M672%20614.4a134.4%20134.4%200%200%201%20128.832%2096H921.6a38.4%2038.4%200%200%201%200%2076.8h-120.768a134.4%20134.4%200%200%201-257.664%200H102.4a38.4%2038.4%200%200%201%200-76.8h440.768A134.4%20134.4%200%200%201%20672%20614.4z%20m0%2076.8a57.6%2057.6%200%201%200%200%20115.2%2057.6%2057.6%200%200%200%200-115.2z'%20fill='%23666666'%20p-id='4806'%3e%3c/path%3e%3c/svg%3e";
104
104
  const __vite_glob_0_19 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
105
+ __proto__: null,
106
+ default: ____$1
107
+ }, Symbol.toStringTag, { value: "Module" }));
108
+ const ____ = "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='1769568667919'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='11114'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M512%20617.386667c17.749333%200%2032.213333%2014.250667%2032.213333%2031.829333v182.954667a32%2032%200%200%201-32.213333%2031.829333%2032%2032%200%200%201-32.170667-31.829333v-182.954667A32%2032%200%200%201%20512%20617.386667zM96.170667%20297.216c17.749333%200%2032.213333%2014.250667%2032.213333%2031.829333v365.909334a32%2032%200%200%201-32.213333%2031.829333%2032%2032%200%200%201-32.170667-31.829333V329.045333a32%2032%200%200%201%2032.170667-31.829333zM927.829333%20297.216c17.792%200%2032.213333%2014.250667%2032.213334%2031.829333v365.909334a32%2032%200%200%201-32.213334%2031.829333%2032%2032%200%200%201-32.170666-31.829333V329.045333a32%2032%200%200%201%2032.170666-31.829333zM396.8%20580.992a32.426667%2032.426667%200%200%201%2045.525333%200%2031.658667%2031.658667%200%200%201%200%2045.056l-46.208%2045.696a32.426667%2032.426667%200%200%201-45.482666%200%2031.616%2031.616%200%200%201%200-45.056l46.208-45.653333zM581.674667%20580.949333a32.426667%2032.426667%200%200%201%2045.482666%200l46.208%2045.738667a31.658667%2031.658667%200%200%201%200%2045.056%2032.426667%2032.426667%200%200%201-45.482666%200l-46.208-45.738667a31.616%2031.616%200%200%201%200-45.056zM214.485333%20441.6a32.426667%2032.426667%200%200%201%2043.093334%202.133333c9.941333%209.898667%2011.904%2024.576%206.058666%2036.437334h109.781334a32%2032%200%200%201%2032.170666%2031.829333%2032%2032%200%200%201-32.170666%2031.872H263.637333a31.573333%2031.573333%200%200%201-6.101333%2036.437333%2032.426667%2032.426667%200%200%201-43.050667%202.133334l-2.432-2.133334-46.208-45.781333a31.616%2031.616%200%200%201%200-45.013333L212.053333%20443.733333l2.432-2.133333zM766.464%20443.733333a32.426667%2032.426667%200%200%201%2045.482667%200l46.208%2045.781334%202.218666%202.389333a31.616%2031.616%200%200%201-2.218666%2042.666667L811.946667%20580.266667l-2.432%202.133333a32.426667%2032.426667%200%200%201-43.093334-2.133333%2031.573333%2031.573333%200%200%201-6.101333-36.437334H650.666667a32%2032%200%200%201-32.170667-31.872%2032%2032%200%200%201%2032.170667-31.829333h109.781333a31.488%2031.488%200%200%201%206.058667-36.437333zM512%20466.304c25.514667%200%2046.208%2020.48%2046.208%2045.738667%200%2025.258667-20.693333%2045.696-46.208%2045.696s-46.208-20.48-46.208-45.696c0-25.258667%2020.693333-45.738667%2046.208-45.738667zM350.848%20352.256a32.426667%2032.426667%200%200%201%2045.482667%200.085333l46.08%2045.696a31.658667%2031.658667%200%200%201-0.128%2045.098667%2032.426667%2032.426667%200%200%201-45.482667-0.085333L350.72%20397.312a31.616%2031.616%200%200%201%200.128-45.056zM627.882667%20352.298667a32.426667%2032.426667%200%200%201%2045.482666%200%2031.616%2031.616%200%200%201%200%2045.056l-46.208%2045.653333a32.426667%2032.426667%200%200%201-45.482666%200%2031.616%2031.616%200%200%201%200-45.013333l46.208-45.696zM512%20160c17.749333%200%2032.213333%2014.250667%2032.213333%2031.829333v182.954667A32%2032%200%200%201%20512%20406.613333a32%2032%200%200%201-32.170667-31.829333V191.829333A32%2032%200%200%201%20512%20160z'%20p-id='11115'%3e%3c/path%3e%3c/svg%3e";
109
+ const __vite_glob_0_20 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
105
110
  __proto__: null,
106
111
  default: ____
107
112
  }, Symbol.toStringTag, { value: "Module" }));
@@ -10647,12 +10652,14 @@ class CommandFlowComponent extends Component {
10647
10652
  get confirmKeys() {
10648
10653
  return this.constructor.confirmKeys;
10649
10654
  }
10655
+ container = new THREE.Group();
10650
10656
  constructor() {
10651
10657
  super();
10652
- }
10653
- onAddFromParent(parent) {
10654
- this.editor.addEventListener("cancelCommand", () => {
10655
- this.cancel();
10658
+ this.addEventListener("addFromParent", () => {
10659
+ this.editor.container.add(this.container);
10660
+ this.editor.addEventListener("cancelCommand", () => {
10661
+ this.cancel();
10662
+ });
10656
10663
  });
10657
10664
  }
10658
10665
  /**
@@ -10755,6 +10762,274 @@ class CommandFlowComponent extends Component {
10755
10762
  formatText(text, color = "var(--primary-color)", style = "") {
10756
10763
  return `<span style="color: ${color};${style}">${text}</span>`;
10757
10764
  }
10765
+ /** 创建追随提示消息
10766
+ * @param text
10767
+ * @param clearNames
10768
+ * @param style
10769
+ * @returns
10770
+ */
10771
+ createFollowPrompts(text, clearNames, style = {}) {
10772
+ const pointer = this.editor.domEventRegister.pointer;
10773
+ const textObj = document.createElement("div");
10774
+ textObj.innerText = text;
10775
+ textObj.style.position = "absolute";
10776
+ textObj.style.color = "#fff";
10777
+ textObj.style.fontSize = "10px";
10778
+ textObj.style.padding = "4px 6px";
10779
+ textObj.style.background = "rgba(0,0,0,0.3)";
10780
+ textObj.style.whiteSpace = "nowrap";
10781
+ textObj.style.borderRadius = "6px";
10782
+ textObj.style.pointerEvents = "none";
10783
+ Object.assign(textObj.style, style);
10784
+ this.domElement.appendChild(textObj);
10785
+ let height = 0;
10786
+ const { destroy } = this.createPointerMove(() => {
10787
+ textObj.style.left = pointer.x + "px";
10788
+ textObj.style.top = pointer.y - height + "px";
10789
+ }), resizeObserver = new ResizeObserver(() => {
10790
+ const rect = textObj.getBoundingClientRect();
10791
+ height = rect.height;
10792
+ }), cancel = () => {
10793
+ destroy();
10794
+ resizeObserver.disconnect();
10795
+ textObj.remove();
10796
+ };
10797
+ resizeObserver.observe(textObj);
10798
+ clearNames.forEach((name) => this.addEventRecord(name, cancel));
10799
+ return textObj;
10800
+ }
10801
+ /** 创建线段选择器
10802
+ * @returns
10803
+ */
10804
+ createLineSelector() {
10805
+ const editor = this.editor, eventInput = editor.eventInput, object3D = new THREE.Mesh(), wiLine = new LineSegment();
10806
+ let currentSelectLine = null;
10807
+ let cursor = this.domElement.style.cursor;
10808
+ wiLine.userData.isWinLine = true;
10809
+ object3D.position.z = 2e-3;
10810
+ object3D.material = new THREE.MeshBasicMaterial({ color: 55561 });
10811
+ let mode = "none";
10812
+ const update = (line2) => {
10813
+ const rectangle = line2.expandToRectangle(0.025, "bothSides");
10814
+ object3D.geometry = editor.renderManager.createGeometry({ position: rectangle.createGeometry() }, 6);
10815
+ this.container.add(object3D);
10816
+ };
10817
+ function getWindow(line2, point) {
10818
+ if (line2.userData.isWindow) {
10819
+ const direction = line2.direction();
10820
+ if (mode === "all" || mode === "window") {
10821
+ const index2 = line2.userData.drawWindow?.findIndex((d) => {
10822
+ Point.from(d.p).expandAsLine(direction, d.width, {}, wiLine).directionMove(direction, -d.width * 0.5);
10823
+ return wiLine.isPointOnSegment(Point.from(point));
10824
+ });
10825
+ if (index2 > -1) {
10826
+ wiLine.currentData.line = line2;
10827
+ wiLine.currentData.index = index2;
10828
+ wiLine.userData.isWinLine = true;
10829
+ return wiLine;
10830
+ }
10831
+ }
10832
+ }
10833
+ return null;
10834
+ }
10835
+ function getDoor(line2) {
10836
+ if (line2.userData.isDoor) return line2;
10837
+ return null;
10838
+ }
10839
+ const ppcEventCancel = editor.addEventListener("pointerPositionChange", () => {
10840
+ const { line: line2, point } = editor.renderManager.adsorption();
10841
+ currentSelectLine = null;
10842
+ if (line2) {
10843
+ this.container.add(object3D);
10844
+ if (mode === "window" || mode === "all") {
10845
+ const winLine = getWindow(line2, point);
10846
+ if (winLine) currentSelectLine = winLine;
10847
+ }
10848
+ if (!currentSelectLine && (mode === "door" || mode === "all")) {
10849
+ const doorLine = getDoor(line2);
10850
+ if (doorLine) currentSelectLine = doorLine;
10851
+ }
10852
+ if (!currentSelectLine && (mode === "wall" || mode === "all")) {
10853
+ if (!line2.userData.isDoor) currentSelectLine = line2;
10854
+ }
10855
+ }
10856
+ if (currentSelectLine) {
10857
+ update(currentSelectLine);
10858
+ this.domElement.style.cursor = "pointer";
10859
+ } else {
10860
+ object3D.removeFromParent();
10861
+ currentSelectLine = null;
10862
+ this.domElement.style.cursor = cursor;
10863
+ }
10864
+ });
10865
+ return {
10866
+ get: async (mode_ = "all") => {
10867
+ mode = mode_;
10868
+ currentSelectLine = null;
10869
+ return new Promise((resolve) => {
10870
+ const eventCancel = eventInput.addEventListener("codeChange", () => {
10871
+ if (eventInput.isKeyDown("mouse_0") && currentSelectLine) {
10872
+ resolve(currentSelectLine);
10873
+ eventCancel();
10874
+ object3D.removeFromParent();
10875
+ this.domElement.style.cursor = cursor;
10876
+ }
10877
+ });
10878
+ });
10879
+ },
10880
+ destroy() {
10881
+ ppcEventCancel();
10882
+ object3D.removeFromParent();
10883
+ }
10884
+ };
10885
+ }
10886
+ /** 创建点选择器
10887
+ * @returns
10888
+ */
10889
+ createPointSelector() {
10890
+ const editor = this.editor, eventInput = editor.eventInput, pointMesh = this.renderer.createCircle(new Point(0, 0), { size: 12, color: 65280 }, this.container);
10891
+ let cursor = this.domElement.style.cursor;
10892
+ let mode = "null";
10893
+ let point = null;
10894
+ let line2 = void 0;
10895
+ pointMesh.position.z = 5e-3;
10896
+ pointMesh.visible = false;
10897
+ const ppcEventCancel = editor.addEventListener("pointerPositionChange", () => {
10898
+ point = null;
10899
+ if (mode !== "null") {
10900
+ let { point: p, mode: m, line: l } = editor.renderManager.adsorption(0.08);
10901
+ line2 = l;
10902
+ if (!m) m = "empty";
10903
+ if (mode === "all") point = p;
10904
+ if (!point && mode.indexOf(m) > -1) point = p;
10905
+ }
10906
+ if (point) {
10907
+ pointMesh.position.copy(point);
10908
+ if (this.domElement.style.cursor !== "none") cursor = this.domElement.style.cursor;
10909
+ this.domElement.style.cursor = "none";
10910
+ pointMesh.visible = true;
10911
+ } else {
10912
+ this.domElement.style.cursor = cursor;
10913
+ pointMesh.visible = false;
10914
+ }
10915
+ });
10916
+ return {
10917
+ get: async (mode_) => {
10918
+ mode = mode_;
10919
+ return new Promise((resolve) => {
10920
+ const eventCancel = eventInput.addEventListener("codeChange", () => {
10921
+ if (eventInput.isKeyDown("mouse_0") && point) {
10922
+ mode = "null";
10923
+ this.domElement.style.cursor = cursor;
10924
+ resolve({ point: Point.from(point), line: line2 });
10925
+ eventCancel();
10926
+ }
10927
+ });
10928
+ });
10929
+ },
10930
+ destroy() {
10931
+ ppcEventCancel();
10932
+ pointMesh.removeFromParent();
10933
+ }
10934
+ };
10935
+ }
10936
+ /**
10937
+ * 创建拖拽点
10938
+ */
10939
+ createDragPoint(point, onChange) {
10940
+ point = point.clone();
10941
+ const div = document.createElement("div");
10942
+ const defaultWidth = "10px";
10943
+ const object3D = this.renderer.createText("", point, {
10944
+ position: "absolute",
10945
+ background: "rgb(255,255,255)",
10946
+ borderRadius: "100px",
10947
+ width: defaultWidth,
10948
+ height: defaultWidth,
10949
+ pointerEvents: "all",
10950
+ cursor: "pointer",
10951
+ transition: "0.25s background"
10952
+ }, this.container);
10953
+ const move = () => {
10954
+ const { point: pos, line: line2 } = this.renderManager.adsorption();
10955
+ if (line2) {
10956
+ object3D.element.style.width = defaultWidth;
10957
+ object3D.element.style.height = defaultWidth;
10958
+ } else {
10959
+ object3D.element.style.width = "2px";
10960
+ object3D.element.style.height = "2px";
10961
+ }
10962
+ object3D.position.x = pos.x;
10963
+ object3D.position.y = pos.y;
10964
+ point.copy(pos);
10965
+ onChange(point);
10966
+ };
10967
+ const mouseup = () => {
10968
+ object3D.element.style.pointerEvents = "all";
10969
+ object3D.element.style.background = "#fff";
10970
+ object3D.element.style.width = defaultWidth;
10971
+ object3D.element.style.height = defaultWidth;
10972
+ document.removeEventListener("mousemove", move);
10973
+ document.removeEventListener("mouseup", mouseup);
10974
+ };
10975
+ object3D.element.addEventListener("mousedown", (e) => {
10976
+ object3D.element.style.pointerEvents = "none";
10977
+ object3D.element.style.background = "#00ff00";
10978
+ object3D.element.style.width = "2px";
10979
+ object3D.element.style.height = "2px";
10980
+ document.addEventListener("mousemove", move);
10981
+ document.addEventListener("mouseup", mouseup);
10982
+ e.stopPropagation();
10983
+ e.preventDefault();
10984
+ });
10985
+ const cancel = () => {
10986
+ div.remove();
10987
+ object3D.removeFromParent();
10988
+ };
10989
+ return cancel;
10990
+ }
10991
+ /**
10992
+ * 创建选择点
10993
+ */
10994
+ createClickPoint(point, onClick) {
10995
+ const div = document.createElement("div");
10996
+ const defaultWidth = "10px";
10997
+ const object3D = this.renderer.createText("", point, {
10998
+ position: "absolute",
10999
+ background: "rgb(255,255,255)",
11000
+ borderRadius: "100px",
11001
+ width: defaultWidth,
11002
+ height: defaultWidth,
11003
+ pointerEvents: "all",
11004
+ cursor: "pointer",
11005
+ transition: "0.25s background"
11006
+ }, this.container);
11007
+ object3D.element.addEventListener("mousedown", (e) => {
11008
+ onClick();
11009
+ e.stopPropagation();
11010
+ e.preventDefault();
11011
+ });
11012
+ const cancel = () => {
11013
+ div.remove();
11014
+ object3D.removeFromParent();
11015
+ };
11016
+ return cancel;
11017
+ }
11018
+ /** 等待一组按键按下
11019
+ * @param keys
11020
+ * @returns
11021
+ */
11022
+ awaitOnlyKey(keys2) {
11023
+ return new Promise((resolve) => {
11024
+ const cancel = this.eventInput.addEventListener("codeChange", () => {
11025
+ if (this.eventInput.isOnlyKeyDowns(keys2)) {
11026
+ resolve(true);
11027
+ cancel();
11028
+ }
11029
+ });
11030
+ this.addEventRecord("clear", cancel);
11031
+ });
11032
+ }
10758
11033
  }
10759
11034
  class Default extends CommandFlowComponent {
10760
11035
  static name = "Default";
@@ -11691,18 +11966,19 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
11691
11966
  function dragMoveHelper(e) {
11692
11967
  if (isMobile() && e instanceof MouseEvent) return;
11693
11968
  let offsetX = 0, offsetY = 0;
11969
+ isdrag.value = true;
11694
11970
  if (e instanceof MouseEvent) {
11695
11971
  offsetX = e.offsetX;
11696
11972
  offsetY = e.offsetY;
11697
11973
  } else if (e instanceof TouchEvent) {
11698
- const rect = e.target.getBoundingClientRect(), touch = e.touches[0];
11699
- offsetX = touch.pageX - rect.left;
11700
- offsetY = touch.pageY - rect.top;
11974
+ const rect2 = e.target.getBoundingClientRect(), touch = e.touches[0];
11975
+ offsetX = touch.pageX - rect2.left;
11976
+ offsetY = touch.pageY - rect2.top;
11701
11977
  }
11702
11978
  const cusor = document.body.style.cursor;
11703
11979
  document.body.style.cursor = "move";
11980
+ const rect = elRef.value.getBoundingClientRect(), toolBarRect = toolBarRef.value.getBoundingClientRect();
11704
11981
  const move = (e2) => {
11705
- const rect = elRef.value.getBoundingClientRect(), toolBarRect = toolBarRef.value.getBoundingClientRect();
11706
11982
  setEditorToolPosition(
11707
11983
  e2.pageX - rect.left - offsetX,
11708
11984
  e2.pageY - rect.top - offsetY,
@@ -11710,16 +11986,18 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
11710
11986
  toolBarRect
11711
11987
  );
11712
11988
  e2.stopPropagation();
11989
+ e2.preventDefault();
11713
11990
  document.body.style.cursor = "move";
11714
11991
  };
11715
11992
  const end = () => {
11716
- document.body.removeEventListener("mousemove", move);
11993
+ document.removeEventListener("mousemove", move);
11717
11994
  document.removeEventListener("mouseup", end);
11718
11995
  document.body.style.cursor = cusor;
11996
+ isdrag.value = false;
11719
11997
  };
11720
11998
  const touchmove = (e2) => {
11721
11999
  if (e2.touches.length) {
11722
- const rect = elRef.value.getBoundingClientRect(), toolBarRect = toolBarRef.value.getBoundingClientRect(), touch = e2.touches[0];
12000
+ const touch = e2.touches[0];
11723
12001
  setEditorToolPosition(
11724
12002
  touch.pageX - rect.left - offsetX,
11725
12003
  touch.pageY - rect.top - offsetY,
@@ -11733,18 +12011,20 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
11733
12011
  }
11734
12012
  };
11735
12013
  const touchend = () => {
11736
- document.body.removeEventListener("touchmove", touchmove);
11737
- document.body.removeEventListener("touchend", touchend);
12014
+ document.removeEventListener("touchmove", touchmove);
12015
+ document.removeEventListener("touchend", touchend);
11738
12016
  document.body.style.cursor = cusor;
12017
+ isdrag.value = false;
11739
12018
  };
11740
12019
  if (isMobile()) {
11741
- document.body.addEventListener("touchmove", touchmove, { passive: false });
12020
+ document.addEventListener("touchmove", touchmove, { passive: false });
11742
12021
  document.addEventListener("touchend", touchend);
11743
12022
  } else {
11744
- document.body.addEventListener("mousemove", move);
12023
+ document.addEventListener("mousemove", move);
11745
12024
  document.addEventListener("mouseup", end);
11746
12025
  }
11747
12026
  e.stopPropagation();
12027
+ e.preventDefault();
11748
12028
  }
11749
12029
  function onClickIcon() {
11750
12030
  emits("clickIcon");
@@ -11752,7 +12032,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
11752
12032
  const props = __props;
11753
12033
  const emits = __emit;
11754
12034
  const showContent = useModel(__props, "showContent");
11755
- const elRef = ref(), toolBarRef = ref(), toolBarPosition = ref({ left: props.position?.x ?? 10, top: props.position?.y ?? 100 }), resizeObserver = new ResizeObserver(() => setEditorToolPosition(toolBarPosition.value.left, toolBarPosition.value.top));
12035
+ const elRef = ref(), toolBarRef = ref(), toolBarPosition = ref({ left: props.position?.x ?? 10, top: props.position?.y ?? 100 }), resizeObserver = new ResizeObserver(() => setEditorToolPosition(toolBarPosition.value.left, toolBarPosition.value.top)), isdrag = ref(false);
11756
12036
  watch(showContent, () => {
11757
12037
  if (showContent.value) {
11758
12038
  nextTick(() => setEditorToolPosition(toolBarPosition.value.left, toolBarPosition.value.top));
@@ -11773,7 +12053,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
11773
12053
  return openBlock(), createElementBlock("div", {
11774
12054
  ref_key: "elRef",
11775
12055
  ref: elRef,
11776
- class: "editorTool pointer-events-none overflow-hidden absolute left-0 top-0 w-full h-full z-[20] flex flex-row justify-between p-[5px] box-border select-none pointer-events-[all]"
12056
+ class: normalizeClass([{ "pointer-events-none": isdrag.value }, "editorTool pointer-events-none overflow-hidden absolute left-0 top-0 w-full h-full z-[20] flex flex-row justify-between p-[5px] box-border select-none pointer-events-[all]"])
11777
12057
  }, [
11778
12058
  createElementVNode("div", {
11779
12059
  ref_key: "toolBarRef",
@@ -11813,7 +12093,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
11813
12093
  renderSlot(_ctx.$slots, "default")
11814
12094
  ])) : createCommentVNode("", true)
11815
12095
  ], 38)
11816
- ], 512);
12096
+ ], 2);
11817
12097
  };
11818
12098
  }
11819
12099
  });
@@ -11906,7 +12186,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
11906
12186
  props: {
11907
12187
  selectLines: {}
11908
12188
  },
11909
- emits: ["update"],
12189
+ emits: ["update", "clickIcon"],
11910
12190
  setup(__props, { emit: __emit }) {
11911
12191
  const props = __props, emits = __emit, selectLines = props.selectLines, map = /* @__PURE__ */ new Map(), userDataList = computed(() => {
11912
12192
  return selectLines.value.map((line2) => {
@@ -11919,7 +12199,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
11919
12199
  return openBlock(), createBlock(_sfc_main$3, {
11920
12200
  title: "属性",
11921
12201
  name: "PropertiesPanel",
11922
- style: { "z-index": "201" }
12202
+ style: { "z-index": "201" },
12203
+ onClickIcon: _cache[5] || (_cache[5] = ($event) => emits("clickIcon"))
11923
12204
  }, {
11924
12205
  default: withCtx(() => [
11925
12206
  createElementVNode("div", {
@@ -11941,18 +12222,18 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
11941
12222
  return openBlock(), createElementBlock("p", _hoisted_8$1, [
11942
12223
  createElementVNode("span", _hoisted_9$1, toDisplayString(index2 === 0 ? "开始" : "结束"), 1),
11943
12224
  createElementVNode("span", _hoisted_10$1, "x:" + toDisplayString(point.x.toFixed(2)), 1),
11944
- _cache[5] || (_cache[5] = createElementVNode("span", { class: "mr-[20px]" }, null, -1)),
12225
+ _cache[6] || (_cache[6] = createElementVNode("span", { class: "mr-[20px]" }, null, -1)),
11945
12226
  createElementVNode("span", _hoisted_11$1, "y:" + toDisplayString(point.y.toFixed(2)), 1)
11946
12227
  ]);
11947
12228
  }), 256)),
11948
12229
  createElementVNode("p", _hoisted_12$1, [
11949
- _cache[6] || (_cache[6] = createElementVNode("span", { class: "mr-[5px]" }, "长度", -1)),
12230
+ _cache[7] || (_cache[7] = createElementVNode("span", { class: "mr-[5px]" }, "长度", -1)),
11950
12231
  createElementVNode("span", _hoisted_13$1, toDisplayString(Number(line2.length().toFixed(4))) + "m", 1)
11951
12232
  ])
11952
12233
  ]),
11953
12234
  createElementVNode("div", _hoisted_14$1, [
11954
12235
  userDataList.value[i].isSelectWindow ? (openBlock(), createElementBlock("p", _hoisted_15$1, [
11955
- _cache[7] || (_cache[7] = createElementVNode("span", { class: "mr-[5px] w-[50px]" }, "窗户宽度", -1)),
12236
+ _cache[8] || (_cache[8] = createElementVNode("span", { class: "mr-[5px] w-[50px]" }, "窗户宽度", -1)),
11956
12237
  createVNode(_sfc_main$2, {
11957
12238
  onBlur: _cache[0] || (_cache[0] = ($event) => emits("update")),
11958
12239
  modelValue: userDataList.value[i].width,
@@ -11971,7 +12252,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
11971
12252
  }, null, 8, ["modelValue", "onUpdate:modelValue"])
11972
12253
  ]),
11973
12254
  line2.userData.isDoor ? (openBlock(), createElementBlock("p", _hoisted_18, [
11974
- _cache[8] || (_cache[8] = createElementVNode("span", { class: "mr-[5px] w-[50px]" }, "门高度", -1)),
12255
+ _cache[9] || (_cache[9] = createElementVNode("span", { class: "mr-[5px] w-[50px]" }, "门高度", -1)),
11975
12256
  createVNode(_sfc_main$2, {
11976
12257
  onBlur: _cache[2] || (_cache[2] = ($event) => emits("update")),
11977
12258
  modelValue: userDataList.value[i].drawDoorData.height,
@@ -11980,7 +12261,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
11980
12261
  }, null, 8, ["modelValue", "onUpdate:modelValue"])
11981
12262
  ])) : createCommentVNode("", true),
11982
12263
  userDataList.value[i].isSelectWindow ? (openBlock(), createElementBlock("p", _hoisted_19, [
11983
- _cache[9] || (_cache[9] = createElementVNode("span", { class: "mr-[5px] w-[50px]" }, "离地高度", -1)),
12264
+ _cache[10] || (_cache[10] = createElementVNode("span", { class: "mr-[5px] w-[50px]" }, "离地高度", -1)),
11984
12265
  createVNode(_sfc_main$2, {
11985
12266
  onBlur: _cache[3] || (_cache[3] = ($event) => emits("update")),
11986
12267
  modelValue: userDataList.value[i].groundClearance,
@@ -12008,7 +12289,7 @@ const _export_sfc = (sfc, props) => {
12008
12289
  }
12009
12290
  return target;
12010
12291
  };
12011
- const PropertiesPanelView = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-cd15d420"]]);
12292
+ const PropertiesPanelView = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-88eae165"]]);
12012
12293
  class PropertiesPanel extends CommandFlowComponent {
12013
12294
  static name = "PropertiesPanel";
12014
12295
  container = new THREE.Group();
@@ -12059,7 +12340,7 @@ class PropertiesPanel extends CommandFlowComponent {
12059
12340
  this.isOpen = true;
12060
12341
  const container = document.createElement("div");
12061
12342
  container.tabIndex = 1;
12062
- ["mousemove", "mousedown", "keydown", "keyup"].forEach((key) => container.addEventListener(key, (e) => e.stopPropagation()));
12343
+ ["mousedown", "keydown", "keyup"].forEach((key) => container.addEventListener(key, (e) => e.stopPropagation()));
12063
12344
  this.domElement.appendChild(container);
12064
12345
  const selectLines = ref([]);
12065
12346
  const update = () => {
@@ -12091,7 +12372,7 @@ class PropertiesPanel extends CommandFlowComponent {
12091
12372
  position: this.editor.domEventRegister.pointer.clone(),
12092
12373
  onClickIcon: () => {
12093
12374
  eventCloses.forEach((eventClose) => eventClose());
12094
- this.domElement.removeChild(container);
12375
+ container.remove();
12095
12376
  this.container.clear();
12096
12377
  this.isOpen = false;
12097
12378
  },
@@ -12759,59 +13040,41 @@ class PointDrag extends CommandFlowComponent {
12759
13040
  super.onAddFromParent(parent);
12760
13041
  this.editor.container.add(this.container);
12761
13042
  this.container.position.z = 1e-3;
12762
- const commandFlow = this.commandManager.addCommandFlow(this.commandName).add(this.createInterrupt()).add(this.createCursor("crosshair")).add(this.selectPoint.bind(this), { prompt: `请选择需要修改线段的 ${this.formatText("端点")}, ${this.formatText("ESC")} 取消命令` }).add(this.drag.bind(this), { prompt: `${this.formatText("Shift")} 键锁定线段移动方向,${this.formatText("L")} 键输入线段长度` }).addRollback(this.rollback.bind(this)).addRevokeRollback(this.revokeRollback.bind(this));
13043
+ const commandFlow = this.commandManager.addCommandFlow(this.commandName).add(this.createInterrupt()).add(this.selectLine.bind(this), { prompt: `请选择需要修改的线段, ${this.formatText("ESC")} 取消命令` }).add(this.selectPoint.bind(this), { prompt: `请选择需要修改线段的 ${this.formatText("端点")}, ${this.formatText("ESC")} 取消命令` }).add(this.drag.bind(this), { prompt: `${this.formatText("Shift")} 键锁定线段移动方向,${this.formatText("L")} 键输入线段长度` }).addRollback(this.rollback.bind(this)).addRevokeRollback(this.revokeRollback.bind(this));
12763
13044
  commandFlow.addEventListener("finally", this.createFinally());
12764
13045
  commandFlow.addEventListener("completed", (e) => this.completed(e.data));
12765
13046
  this.eventInput.addKeyCombination(this.commandName, this.shortcutKeys);
12766
13047
  this.eventInput.addEventListener("codeChange", async () => this.eventInput.isKeyCombination(this.commandName) && await this.commandManager.start(this.commandName));
12767
13048
  this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
12768
13049
  }
13050
+ async selectLine(next) {
13051
+ this.createFollowPrompts("请选择需要修改的线段", ["clear", "selectLine"]);
13052
+ const lineSelector = this.createLineSelector();
13053
+ this.addEventRecord("clear", lineSelector.destroy);
13054
+ const line2 = await lineSelector.get("wall");
13055
+ lineSelector.destroy();
13056
+ this.canceEventRecord("selectLine");
13057
+ next(line2);
13058
+ }
12769
13059
  /** 选择开始点
12770
13060
  * @param next
12771
13061
  */
12772
- selectPoint(next) {
12773
- let currentPoint = null, circle = this.renderer.createCircle(Point.zero(), { color: 16711935 }), currentLine = null, lineObj = new Lines([], 15658734);
12774
- this.container.add(lineObj);
12775
- lineObj.visible = false;
12776
- lineObj.position.z = -1e-3;
12777
- const eventChange = this.editor.addEventListener("pointerPositionChange", () => {
12778
- const { point, line: line2, find, mode } = this.editor.renderManager.adsorption();
12779
- this.dispatchEvent({ type: "pointerMove", point });
12780
- if (find && mode === "point") {
12781
- this.domElement.style.cursor = "none";
12782
- circle.position.copy(point);
12783
- currentLine = line2;
12784
- currentPoint = point.clone();
12785
- this.container.add(circle);
12786
- lineObj.visible = true;
12787
- const points = line2.expandToRectangle(0.02, "bothSides").points.map((p) => new THREE.Vector3(p.x, p.y, 0));
12788
- lineObj.setPoint(...points);
12789
- } else {
12790
- this.domElement.style.cursor = "no-drop";
12791
- currentPoint = null;
12792
- lineObj.visible = false;
12793
- circle.removeFromParent();
12794
- }
12795
- });
12796
- this.addEventRecord("selectPointStart").add(eventChange).add(() => lineObj.removeFromParent()).add(this.eventInput.addEventListener("codeChange", () => {
12797
- if (this.eventInput.isKeyDown("mouse_0") && currentPoint) {
12798
- this.canceEventRecord("selectPointStart");
12799
- circle.material.color.set(65280);
12800
- next({ point: currentPoint, line: currentLine });
12801
- }
12802
- }));
12803
- this.addEventRecord("clear").add(() => {
12804
- circle.removeFromParent();
12805
- eventChange();
12806
- lineObj.removeFromParent();
12807
- });
13062
+ selectPoint(next, line2) {
13063
+ this.createFollowPrompts("请选择一个端点", ["selectPoint", "clear"]);
13064
+ const list = [
13065
+ this.createClickPoint(line2.start, () => {
13066
+ this.canceEventRecord("selectPoint");
13067
+ next({ line: line2, point: new THREE.Vector3(line2.start.x, line2.start.y, 0) });
13068
+ }),
13069
+ this.createClickPoint(line2.end, () => {
13070
+ this.canceEventRecord("selectPoint");
13071
+ next({ line: line2, point: new THREE.Vector3(line2.end.x, line2.end.y, 0) });
13072
+ })
13073
+ ];
13074
+ this.addEventRecord("selectPoint", ...list);
13075
+ this.addEventRecord("clear", ...list);
12808
13076
  }
12809
- /** 拖拽点
12810
- * @description 拖拽点到指定位置
12811
- * @param next
12812
- * @param param1
12813
- */
12814
- drag(next, { point, line: line2 }) {
13077
+ drag(next, { line: line2, point }) {
12815
13078
  this.domElement.style.cursor = "crosshair";
12816
13079
  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 = this.renderer.createCircle(Point.zero(), { color: 16711935, size: 10 }), textObj3D = this.renderer.createText("", new THREE.Vector3(0, 0, 0), {
12817
13080
  // background: 'rgba(0,0,0,0.5)',
@@ -12992,9 +13255,163 @@ class StorageHelper {
12992
13255
  localStorage.setItem(key, String(vaalue));
12993
13256
  }
12994
13257
  }
13258
+ function buildDashedHelperLine$1(start, end, offset = 0.5) {
13259
+ const offsetDistance = end.normal(start).multiplyScalar(offset);
13260
+ const startOffPoint = start.clone().add(offsetDistance);
13261
+ const endOffPoint = end.clone().add(offsetDistance);
13262
+ return [
13263
+ start,
13264
+ startOffPoint,
13265
+ endOffPoint,
13266
+ end
13267
+ ];
13268
+ }
13269
+ class RayDistance extends CommandFlowComponent {
13270
+ static name = "RayDistance";
13271
+ container = new THREE.Group();
13272
+ static shortcutKeys = ["R"];
13273
+ static commandName = "RayDistance";
13274
+ onAddFromParent(parent) {
13275
+ super.onAddFromParent(parent);
13276
+ this.editor.container.add(this.container);
13277
+ const commandFlow = this.commandManager.addCommandFlow(this.commandName).add(this.createInterrupt()).add(this.createCursor("no-drop")).add(this.selectPoint.bind(this), { prompt: `请选择线段上的一个点作为发射点, ${this.formatText("ESC")} 取消命令` }).add(this.ray.bind(this), { prompt: `按 ${this.formatText("Enter")} 重新选择发射点, ${this.formatText("ESC")} 取消命令` }).setLoop(true);
13278
+ commandFlow.writeOperationList = false;
13279
+ commandFlow.addEventListener("finally", this.createFinally());
13280
+ this.eventInput.addKeyCombination(this.commandName, this.shortcutKeys);
13281
+ this.eventInput.addEventListener("codeChange", async () => this.eventInput.isKeyCombination(this.commandName) && await this.commandManager.start(this.commandName));
13282
+ this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
13283
+ }
13284
+ /** 选择点
13285
+ * @param next
13286
+ */
13287
+ async selectPoint(next) {
13288
+ const pointSelector = this.createPointSelector();
13289
+ this.addEventRecord("clear", () => {
13290
+ pointSelector.destroy();
13291
+ this.container.clear();
13292
+ });
13293
+ const result = await pointSelector.get("line_point");
13294
+ next(result);
13295
+ }
13296
+ /** 射线
13297
+ * @param points
13298
+ */
13299
+ async ray(next, { line: line2, point }) {
13300
+ const normal = line2.normal(), nNormal = normal.clone().multiplyScalar(-1), rayLine1 = new LineSegment(point, point.clone().add(normal.multiplyScalar(100))), rayLine2 = new LineSegment(point, point.clone().add(nNormal.multiplyScalar(100)));
13301
+ const lineObj = this.renderer.createLineSegments([rayLine1, rayLine2], 0, { color: 196352 }, this.container);
13302
+ [rayLine1, rayLine2].forEach((rayLine) => {
13303
+ const points = this.renderManager.quadtree.queryLineSegment(rayLine).filter((item) => item.line !== rayLine).map((item) => rayLine.getIntersection(item.line)).filter((p) => !!p);
13304
+ points.sort((a, b) => point.distance(a) - point.distance(b)).forEach((p, i) => {
13305
+ const distance = point.distance(p) * 1e3;
13306
+ if (distance < 1e-3) return;
13307
+ const points2 = buildDashedHelperLine$1(point, p, i * 0.3);
13308
+ const auxiliaryLine = new Lines();
13309
+ auxiliaryLine.position.z = 6e-3;
13310
+ auxiliaryLine.material = new THREE.LineDashedMaterial({
13311
+ color: 16777215,
13312
+ dashSize: 0.02,
13313
+ gapSize: 0.02
13314
+ });
13315
+ auxiliaryLine.setPoint(...points2.map((p2) => new THREE.Vector3(p2.x, p2.y, 0)));
13316
+ this.container.add(auxiliaryLine);
13317
+ setTimeout(() => auxiliaryLine.computeLineDistances());
13318
+ const text = this.renderer.createText(Number(distance.toFixed(0)) + "mm", points2[1].clone().add(points2[2]).multiplyScalar(0.5), {
13319
+ background: "#333333",
13320
+ padding: "2px 4px",
13321
+ borderRadius: "6px",
13322
+ color: "#fff"
13323
+ }, this.container);
13324
+ const circle = this.renderer.createCircle(p, {}, this.container);
13325
+ this.addEventRecord("clear", () => {
13326
+ auxiliaryLine.removeFromParent();
13327
+ text.removeFromParent();
13328
+ circle.removeFromParent();
13329
+ });
13330
+ });
13331
+ });
13332
+ this.addEventRecord("clear", () => {
13333
+ lineObj.removeFromParent();
13334
+ });
13335
+ await this.awaitOnlyKey(["enter"]);
13336
+ next();
13337
+ }
13338
+ }
13339
+ function buildDashedHelperLine(start, end, offset = 0.5) {
13340
+ const offsetDistance = end.normal(start).multiplyScalar(offset);
13341
+ const startOffPoint = start.clone().add(offsetDistance);
13342
+ const endOffPoint = end.clone().add(offsetDistance);
13343
+ return [
13344
+ start,
13345
+ startOffPoint,
13346
+ endOffPoint,
13347
+ end
13348
+ ];
13349
+ }
13350
+ class ManualDistance extends CommandFlowComponent {
13351
+ static name = "ManualDistance";
13352
+ container = new THREE.Group();
13353
+ static shortcutKeys = ["M"];
13354
+ static commandName = "ManualDistance";
13355
+ onAddFromParent(parent) {
13356
+ super.onAddFromParent(parent);
13357
+ this.editor.container.add(this.container);
13358
+ const commandFlow = this.commandManager.addCommandFlow(this.commandName).add(this.createInterrupt()).add(this.createCursor("no-drop")).add(this.selectPoint.bind(this), { prompt: `请选择两个点, ${this.formatText("ESC")} 取消命令` }).add(this.ray.bind(this), { prompt: `按 ${this.formatText("Enter")} 重新选择, ${this.formatText("ESC")} 取消命令` }).setLoop(true);
13359
+ commandFlow.writeOperationList = false;
13360
+ commandFlow.addEventListener("finally", this.createFinally());
13361
+ this.eventInput.addKeyCombination(this.commandName, this.shortcutKeys);
13362
+ this.eventInput.addEventListener("codeChange", async () => this.eventInput.isKeyCombination(this.commandName) && await this.commandManager.start(this.commandName));
13363
+ this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
13364
+ }
13365
+ /** 选择点
13366
+ * @param next
13367
+ */
13368
+ async selectPoint(next) {
13369
+ const pointSelector = this.createPointSelector();
13370
+ this.addEventRecord("clear", () => {
13371
+ this.container.clear();
13372
+ pointSelector.destroy();
13373
+ });
13374
+ const point1 = (await pointSelector.get("all")).point;
13375
+ this.renderer.createCircle(point1, {}, this.container);
13376
+ const point2 = (await pointSelector.get("all")).point;
13377
+ this.renderer.createCircle(point2, {}, this.container);
13378
+ pointSelector.destroy();
13379
+ next({ point1, point2 });
13380
+ }
13381
+ /** 射线
13382
+ * @param points
13383
+ */
13384
+ async ray(next, { point1, point2 }) {
13385
+ this.renderer.createLineSegments([new LineSegment(point1, point2)], 0, { color: 65280 }, this.container);
13386
+ const distance = point1.distance(point2) * 1e3;
13387
+ const points = buildDashedHelperLine(point1, point2, 0.3);
13388
+ const auxiliaryLine = new Lines();
13389
+ auxiliaryLine.position.z = 6e-3;
13390
+ auxiliaryLine.material = new THREE.LineDashedMaterial({
13391
+ color: 16777215,
13392
+ dashSize: 0.02,
13393
+ gapSize: 0.02
13394
+ });
13395
+ auxiliaryLine.setPoint(...points.map((p) => new THREE.Vector3(p.x, p.y, 0)));
13396
+ this.container.add(auxiliaryLine);
13397
+ setTimeout(() => auxiliaryLine.computeLineDistances());
13398
+ const text = this.renderer.createText(Number(distance.toFixed(0)) + "mm", points[1].clone().add(points[2]).multiplyScalar(0.5), {
13399
+ background: "#333333",
13400
+ padding: "2px 4px",
13401
+ borderRadius: "6px",
13402
+ color: "#fff"
13403
+ }, this.container);
13404
+ this.addEventRecord("clear", () => {
13405
+ auxiliaryLine.removeFromParent();
13406
+ text.removeFromParent();
13407
+ });
13408
+ await this.awaitOnlyKey(["enter"]);
13409
+ next();
13410
+ }
13411
+ }
12995
13412
  const _hoisted_1 = {
12996
13413
  key: 0,
12997
- class: "p-[5px] max-w-[200px] min-w-[200px]"
13414
+ class: "p-[5px] max-w-[150px] min-w-[150px]"
12998
13415
  };
12999
13416
  const _hoisted_2 = { class: "text-[14px] flex flex-col" };
13000
13417
  const _hoisted_3 = ["onClick"];
@@ -13056,7 +13473,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
13056
13473
  queueMicrotask(() => variable.set("currentKeyUp", "enter"));
13057
13474
  }
13058
13475
  const props = __props;
13059
- const dxfVisible = ref(true), isLook = ref(false), toolBarExpand = ref(StorageHelper.getBoolean("toolBarExpand", true)), currentCommand = ref(""), dxfSystem = toRaw(props.dxfSystem), domEventRegister = dxfSystem.findComponentByType(DomEventRegister), editor = dxfSystem.findComponentByType(Editor), defaultComponent = dxfSystem.findComponentByType(Default), whiteModel = dxfSystem.findComponentByType(WhiteModel), threeVJia = dxfSystem.findComponentByType(ThreeVJia), variable = dxfSystem.findComponentByType(Variable), drawLine = dxfSystem.findComponentByType(DrawLine), rollbackCount = ref(0), revokeRollbackCount = ref(0), drawLineCount = ref(0), images = /* @__PURE__ */ Object.assign({ "./assets/images/VerticalCorr.svg": __vite_glob_0_0, "./assets/images/VerticalCorrContinue.svg": __vite_glob_0_1, "./assets/images/angle.svg": __vite_glob_0_2, "./assets/images/close.svg": __vite_glob_0_3, "./assets/images/connection.svg": __vite_glob_0_4, "./assets/images/cutLine.svg": __vite_glob_0_5, "./assets/images/deleteSelectLine.svg": __vite_glob_0_6, "./assets/images/deleteSelectWindow.svg": __vite_glob_0_7, "./assets/images/door.svg": __vite_glob_0_8, "./assets/images/dxf.svg": __vite_glob_0_9, "./assets/images/intersectionConnection.svg": __vite_glob_0_10, "./assets/images/line.svg": __vite_glob_0_11, "./assets/images/mergeLine.svg": __vite_glob_0_12, "./assets/images/revokeRollback.svg": __vite_glob_0_13, "./assets/images/rollback.svg": __vite_glob_0_14, "./assets/images/selectAll.svg": __vite_glob_0_15, "./assets/images/selectPoint.svg": __vite_glob_0_16, "./assets/images/verticalLine.svg": __vite_glob_0_17, "./assets/images/window.svg": __vite_glob_0_18, "./assets/images/属性面板.svg": __vite_glob_0_19 }), selectLineCount = ref(0), selectWinLineCount = ref(0), hasWindowLine = ref(false), commandList = [
13476
+ const dxfVisible = ref(true), isLook = ref(false), toolBarExpand = ref(StorageHelper.getBoolean("toolBarExpand", true)), currentCommand = ref(""), dxfSystem = toRaw(props.dxfSystem), domEventRegister = dxfSystem.findComponentByType(DomEventRegister), editor = dxfSystem.findComponentByType(Editor), defaultComponent = dxfSystem.findComponentByType(Default), whiteModel = dxfSystem.findComponentByType(WhiteModel), threeVJia = dxfSystem.findComponentByType(ThreeVJia), variable = dxfSystem.findComponentByType(Variable), drawLine = dxfSystem.findComponentByType(DrawLine), rollbackCount = ref(0), revokeRollbackCount = ref(0), drawLineCount = ref(0), images = /* @__PURE__ */ Object.assign({ "./assets/images/VerticalCorr.svg": __vite_glob_0_0, "./assets/images/VerticalCorrContinue.svg": __vite_glob_0_1, "./assets/images/angle.svg": __vite_glob_0_2, "./assets/images/close.svg": __vite_glob_0_3, "./assets/images/connection.svg": __vite_glob_0_4, "./assets/images/cutLine.svg": __vite_glob_0_5, "./assets/images/deleteSelectLine.svg": __vite_glob_0_6, "./assets/images/deleteSelectWindow.svg": __vite_glob_0_7, "./assets/images/door.svg": __vite_glob_0_8, "./assets/images/dxf.svg": __vite_glob_0_9, "./assets/images/intersectionConnection.svg": __vite_glob_0_10, "./assets/images/line.svg": __vite_glob_0_11, "./assets/images/mergeLine.svg": __vite_glob_0_12, "./assets/images/revokeRollback.svg": __vite_glob_0_13, "./assets/images/rollback.svg": __vite_glob_0_14, "./assets/images/selectAll.svg": __vite_glob_0_15, "./assets/images/selectPoint.svg": __vite_glob_0_16, "./assets/images/verticalLine.svg": __vite_glob_0_17, "./assets/images/window.svg": __vite_glob_0_18, "./assets/images/属性面板.svg": __vite_glob_0_19, "./assets/images/激光测距.svg": __vite_glob_0_20 }), selectLineCount = ref(0), selectWinLineCount = ref(0), hasWindowLine = ref(false), commandList = [
13060
13477
  {
13061
13478
  command: "default",
13062
13479
  name: "默认",
@@ -13098,6 +13515,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
13098
13515
  show: true,
13099
13516
  src: images["./assets/images/cutLine.svg"].default,
13100
13517
  shortcut: ClippingLine.shortcutKeys.join(" + ")
13518
+ },
13519
+ {
13520
+ command: RayDistance.commandName,
13521
+ name: "射线测距",
13522
+ show: true,
13523
+ src: images["./assets/images/激光测距.svg"].default,
13524
+ shortcut: RayDistance.shortcutKeys.join(" + ")
13525
+ },
13526
+ {
13527
+ command: ManualDistance.commandName,
13528
+ name: "手动测距",
13529
+ show: true,
13530
+ src: images["./assets/images/激光测距.svg"].default,
13531
+ shortcut: ManualDistance.shortcutKeys.join(" + ")
13101
13532
  }
13102
13533
  ], otherCommandList = [
13103
13534
  {
@@ -13190,11 +13621,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
13190
13621
  }
13191
13622
  },
13192
13623
  {
13193
- command: DeleteSelectLine.commandName,
13624
+ command: PropertiesPanel.commandName,
13194
13625
  name: "属性面板",
13195
13626
  show: computed(() => true),
13196
13627
  src: images["./assets/images/属性面板.svg"].default,
13197
- shortcut: DeleteSelectLine.shortcutKeys.join(" + "),
13628
+ shortcut: PropertiesPanel.shortcutKeys.join(" + "),
13198
13629
  action() {
13199
13630
  variable.set("currentKeyDown", "i");
13200
13631
  queueMicrotask(() => variable.set("currentKeyUp", "i"));
@@ -13495,7 +13926,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
13495
13926
  };
13496
13927
  }
13497
13928
  });
13498
- const EditorTool = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-09ada29e"]]);
13929
+ const EditorTool = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-a41b5baa"]]);
13499
13930
  class Editor extends Component {
13500
13931
  static name = "Editor";
13501
13932
  container = new THREE.Group();
@@ -13682,6 +14113,8 @@ function Editor_(dxfSystem, option = {}) {
13682
14113
  dxfSystem.addComponent(new VerticalReferenceLine());
13683
14114
  dxfSystem.addComponent(new ClippingLine());
13684
14115
  dxfSystem.addComponent(new PropertiesPanel());
14116
+ dxfSystem.addComponent(new RayDistance());
14117
+ dxfSystem.addComponent(new ManualDistance());
13685
14118
  }
13686
14119
  const EditorPlugin = Object.assign(Editor_, {
13687
14120
  create(option = {}) {
@@ -1,4 +1,4 @@
1
- import { Component, ComponentManager } from '../../../../../ComponentManager';
1
+ import { Component } from '../../../../../ComponentManager';
2
2
  import { Editor } from '../Editor';
3
3
  import { EventInput, Renderer } from '../../../RenderPlugin/components';
4
4
  import { CommandManager } from '../../../../../CommandManager';
@@ -6,6 +6,7 @@ import { RenderManager } from '../RenderManager';
6
6
  import { Default } from './Default';
7
7
  import { LineSegment } from '../../../../../LineSegment';
8
8
  import { Point } from '../../../../../Point';
9
+ import * as THREE from "three";
9
10
  export declare class CommandFlowComponent<TEventMap extends {} = {}> extends Component<TEventMap & {}> {
10
11
  static interruptKeys: string[];
11
12
  static confirmKeys: string[];
@@ -28,8 +29,8 @@ export declare class CommandFlowComponent<TEventMap extends {} = {}> extends Com
28
29
  get interruptKeys(): string[];
29
30
  get shortcutKeys(): string[];
30
31
  get confirmKeys(): string[];
32
+ container: THREE.Group<THREE.Object3DEventMap>;
31
33
  constructor();
32
- onAddFromParent(parent: ComponentManager): void;
33
34
  /**
34
35
  * 取消
35
36
  */
@@ -60,4 +61,41 @@ export declare class CommandFlowComponent<TEventMap extends {} = {}> extends Com
60
61
  setBaseLine(line: LineSegment | null, point: Point | null): void;
61
62
  };
62
63
  formatText(text: string, color?: string, style?: string): string;
64
+ /** 创建追随提示消息
65
+ * @param text
66
+ * @param clearNames
67
+ * @param style
68
+ * @returns
69
+ */
70
+ createFollowPrompts(text: string, clearNames: string[], style?: Record<string, any>): HTMLDivElement;
71
+ /** 创建线段选择器
72
+ * @returns
73
+ */
74
+ createLineSelector(): {
75
+ get: (mode_?: "all" | "wall" | "door" | "window" | "none") => Promise<unknown>;
76
+ destroy(): void;
77
+ };
78
+ /** 创建点选择器
79
+ * @returns
80
+ */
81
+ createPointSelector(): {
82
+ get: (mode_: "all" | "point" | "line" | "empty" | "line_point" | "line_empty" | "point_empty" | "null") => Promise<{
83
+ point: Point;
84
+ line?: LineSegment;
85
+ }>;
86
+ destroy(): void;
87
+ };
88
+ /**
89
+ * 创建拖拽点
90
+ */
91
+ createDragPoint(point: Point, onChange: (p: Point) => void): () => void;
92
+ /**
93
+ * 创建选择点
94
+ */
95
+ createClickPoint(point: Point, onClick: () => void): () => void;
96
+ /** 等待一组按键按下
97
+ * @param keys
98
+ * @returns
99
+ */
100
+ awaitOnlyKey(keys: string[]): Promise<unknown>;
63
101
  }
@@ -0,0 +1,23 @@
1
+ import { CommandFlowComponent } from './CommandFlowComponent';
2
+ import { ComponentManager } from '../../../../../ComponentManager';
3
+ import { Point } from '../../../../../Point';
4
+ import * as THREE from "three";
5
+ /**
6
+ * 生成长度标记辅助虚线
7
+ */
8
+ export declare function buildDashedHelperLine(start: Point, end: Point, offset?: number): Point[];
9
+ export declare class ManualDistance extends CommandFlowComponent<{}> {
10
+ static name: string;
11
+ container: THREE.Group<THREE.Object3DEventMap>;
12
+ static shortcutKeys: string[];
13
+ static commandName: string;
14
+ onAddFromParent(parent: ComponentManager): void;
15
+ /** 选择点
16
+ * @param next
17
+ */
18
+ private selectPoint;
19
+ /** 射线
20
+ * @param points
21
+ */
22
+ private ray;
23
+ }
@@ -12,18 +12,14 @@ export declare class PointDrag extends CommandFlowComponent<{
12
12
  static shortcutKeys: string[];
13
13
  static commandName: string;
14
14
  onAddFromParent(parent: ComponentManager): void;
15
+ selectLine(next: any): Promise<void>;
15
16
  /** 选择开始点
16
17
  * @param next
17
18
  */
18
- selectPoint(next: any): void;
19
- /** 拖拽点
20
- * @description 拖拽点到指定位置
21
- * @param next
22
- * @param param1
23
- */
24
- drag(next: any, { point, line }: {
25
- point: THREE.Vector3;
19
+ selectPoint(next: any, line: LineSegment): void;
20
+ drag(next: any, { line, point }: {
26
21
  line: LineSegment;
22
+ point: THREE.Vector3;
27
23
  }): void;
28
24
  /** 执行完成
29
25
  */
@@ -0,0 +1,23 @@
1
+ import { CommandFlowComponent } from './CommandFlowComponent';
2
+ import { ComponentManager } from '../../../../../ComponentManager';
3
+ import { Point } from '../../../../../Point';
4
+ import * as THREE from "three";
5
+ /**
6
+ * 生成长度标记辅助虚线
7
+ */
8
+ export declare function buildDashedHelperLine(start: Point, end: Point, offset?: number): Point[];
9
+ export declare class RayDistance extends CommandFlowComponent<{}> {
10
+ static name: string;
11
+ container: THREE.Group<THREE.Object3DEventMap>;
12
+ static shortcutKeys: string[];
13
+ static commandName: string;
14
+ onAddFromParent(parent: ComponentManager): void;
15
+ /** 选择点
16
+ * @param next
17
+ */
18
+ private selectPoint;
19
+ /** 射线
20
+ * @param points
21
+ */
22
+ private ray;
23
+ }
@@ -10,7 +10,9 @@ type __VLS_Props = {
10
10
  };
11
11
  declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
12
12
  update: (...args: any[]) => void;
13
+ clickIcon: (...args: any[]) => void;
13
14
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
14
15
  onUpdate?: ((...args: any[]) => any) | undefined;
16
+ onClickIcon?: ((...args: any[]) => any) | undefined;
15
17
  }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
16
18
  export default _default;
@@ -217,7 +217,7 @@ export declare class LineSegment<T = Record<string, any>> {
217
217
  /** 克隆
218
218
  * @returns
219
219
  */
220
- clone(userData?: boolean): LineSegment<T>;
220
+ clone(userData?: boolean, cloneUUid?: boolean): LineSegment<T>;
221
221
  /**
222
222
  * 获取最长线段
223
223
  * @param lines