build-dxf 0.0.20-2 → 0.0.20-4

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.0.20-2",
3
+ "version": "0.0.20-4",
4
4
  "description": "线段构建双线墙壁的dxf版本",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/build.js CHANGED
@@ -365,10 +365,11 @@ class Point {
365
365
  this.x = p.x ?? 0;
366
366
  this.y = p.y ?? 0;
367
367
  }
368
- toJson() {
368
+ toJson(z = 0) {
369
369
  return {
370
370
  x: this.x,
371
- y: this.y
371
+ y: this.y,
372
+ z
372
373
  };
373
374
  }
374
375
  static from(arr) {
@@ -1475,7 +1476,7 @@ class Dxf extends Component {
1475
1476
  filterLines.push(line2);
1476
1477
  } else filterLines.push(line);
1477
1478
  }
1478
- return filterLines.length > 2 ? linesToPath(this.mergeSameDirectionLine(filterLines)) : [];
1479
+ return filterLines.length > 3 ? linesToPath(this.mergeSameDirectionLine(filterLines)) : [];
1479
1480
  }
1480
1481
  /**
1481
1482
  * 移除短线段
@@ -1485,7 +1486,7 @@ class Dxf extends Component {
1485
1486
  removeShortLine(path, shortLine = this.shortLine) {
1486
1487
  const lines = pathToLines(path), filterLines = [], PI_1 = Math.PI / 180;
1487
1488
  for (let i = 0; i < lines.length; i++) {
1488
- const line = lines[i], len = line.length();
1489
+ const line = lines[i], len = line.length(), currentIndex = i;
1489
1490
  if (len > shortLine || filterLines.length === 0) {
1490
1491
  filterLines.push(line);
1491
1492
  continue;
@@ -1499,24 +1500,29 @@ class Dxf extends Component {
1499
1500
  } else break;
1500
1501
  }
1501
1502
  if (!nextline) continue;
1502
- const intersectPoint = preLine.getIntersection(nextline);
1503
- if (intersectPoint) {
1504
- const p0 = preLine.points[1].clone(), p1 = nextline.points[0].clone();
1505
- preLine.points[1].copy(intersectPoint);
1506
- nextline.points[0].copy(intersectPoint);
1507
- if (preLine.length() < this.width) {
1508
- preLine.points[1].copy(p0);
1509
- nextline.points[0].copy(p0);
1510
- } else if (nextline.length() < this.width) {
1511
- preLine.points[1].copy(p1);
1512
- nextline.points[0].copy(p1);
1503
+ const targetLine = lines[i - 1];
1504
+ if (preLine.length() > targetLine.length()) {
1505
+ const intersectPoint = preLine.getIntersection(nextline);
1506
+ if (intersectPoint) {
1507
+ const p0 = preLine.points[1].clone(), p1 = nextline.points[0].clone();
1508
+ preLine.points[1].copy(intersectPoint);
1509
+ nextline.points[0].copy(intersectPoint);
1510
+ if (preLine.length() < this.width) {
1511
+ preLine.points[1].copy(p0);
1512
+ nextline.points[0].copy(p0);
1513
+ } else if (nextline.length() < this.width) {
1514
+ preLine.points[1].copy(p1);
1515
+ nextline.points[0].copy(p1);
1516
+ }
1517
+ } else {
1518
+ preLine.points[1].copy(nextline.points[0]);
1513
1519
  }
1520
+ filterLines.push(nextline);
1514
1521
  } else {
1515
- preLine.points[1].copy(nextline.points[0]);
1522
+ i = currentIndex;
1516
1523
  }
1517
- filterLines.push(nextline);
1518
1524
  }
1519
- return filterLines.length > 2 ? linesToPath(filterLines) : [];
1525
+ return filterLines.length > 3 ? linesToPath(filterLines) : [];
1520
1526
  }
1521
1527
  /** 线偏移
1522
1528
  * @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
package/src/index.css CHANGED
@@ -104,6 +104,10 @@
104
104
  z-index: 11;
105
105
  }
106
106
 
107
+ .z-\[20\] {
108
+ z-index: 20;
109
+ }
110
+
107
111
  .z-\[1000\] {
108
112
  z-index: 1000;
109
113
  }
@@ -238,12 +242,12 @@
238
242
  width: 200px;
239
243
  }
240
244
 
241
- .w-full {
242
- width: 100%;
245
+ .w-fit {
246
+ width: fit-content;
243
247
  }
244
248
 
245
- .max-w-\[100px\] {
246
- max-width: 100px;
249
+ .w-full {
250
+ width: 100%;
247
251
  }
248
252
 
249
253
  .max-w-\[150px\] {
@@ -616,7 +620,7 @@
616
620
  inherits: false
617
621
  }
618
622
 
619
- [data-v-26d57fb7] {
623
+ [data-v-a95f67da] {
620
624
  font-family: 宋体;
621
625
  }
622
626
 
package/src/index2.js CHANGED
@@ -644,17 +644,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
644
644
  ])),
645
645
  _: 1,
646
646
  __: [9]
647
- }),
648
- createVNode(unref(ElButton), {
649
- size: "small",
650
- type: "success",
651
- onClick: selectDetailsPointFile
652
- }, {
653
- default: withCtx(() => _cache[10] || (_cache[10] = [
654
- createTextVNode(" 编辑模式 ", -1)
655
- ])),
656
- _: 1,
657
- __: [10]
658
647
  })
659
648
  ]),
660
649
  isLook.value ? (openBlock(), createElementBlock("div", {
@@ -680,7 +669,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
680
669
  label: "墙体(E)"
681
670
  }, null, 8, ["modelValue"])
682
671
  ]),
683
- _cache[11] || (_cache[11] = createStaticVNode('<div class="mt-[5px] text-[#c9c9c9] text-[10px]"><p class="text-right">详情点射线辅助线快捷键:R</p><p class="text-right">墙壁合并追加线快捷键:A</p><p class="text-right">线段序号快捷键:T</p><p class="text-right">线段端点标示快捷键:P</p><p class="text-right">线段长度(单位米)快捷键:L</p></div>', 1))
672
+ _cache[10] || (_cache[10] = createStaticVNode('<div class="mt-[5px] text-[#c9c9c9] text-[10px]"><p class="text-right">详情点射线辅助线快捷键:R</p><p class="text-right">墙壁合并追加线快捷键:A</p><p class="text-right">线段序号快捷键:T</p><p class="text-right">线段端点标示快捷键:P</p><p class="text-right">线段长度(单位米)快捷键:L</p></div>', 1))
684
673
  ])
685
674
  ])
686
675
  ], 512);
package/src/index3.js CHANGED
@@ -1498,11 +1498,12 @@ class RenderManager extends Component {
1498
1498
  const drawDoorData = userData.drawDoorData;
1499
1499
  const insetionArr = this.quadtree.queryLineSegment(line2).filter((r) => r.line !== line2 && !r.userData?.isDoor).map((r) => ({ index: this.lines.indexOf(r.line) }));
1500
1500
  return {
1501
- start: line2.start.toJson(),
1502
- end: line2.end.toJson(),
1501
+ start: line2.start.toJson(this.dxf.originalZAverage),
1502
+ end: line2.end.toJson(this.dxf.originalZAverage),
1503
1503
  insetionArr,
1504
1504
  isDoor: userData.isDoor,
1505
1505
  doorDirectConnection: userData.isDoor,
1506
+ length: line2.length(),
1506
1507
  isWindow: userData.isWindow,
1507
1508
  drawDoorData: drawDoorData && drawDoorData.map((w) => ({
1508
1509
  p: { x: w.p.x, y: w.p.y, z: w.p.z },
@@ -1735,7 +1736,7 @@ const _hoisted_11 = {
1735
1736
  };
1736
1737
  const _hoisted_12 = {
1737
1738
  key: 0,
1738
- class: "flex flex-row items-center flex-wrap justify-between gap-[10px] mt-[10px] text-[10px]"
1739
+ class: "flex flex-row items-center justify-between gap-[10px] mt-[10px] text-[10px]"
1739
1740
  };
1740
1741
  const _hoisted_13 = { class: "border-t-1 border-t-[#eee] mt-[5px] pt-[5px] h-[20px] flex items-center gap-[10px]" };
1741
1742
  const _hoisted_14 = {
@@ -1885,7 +1886,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1885
1886
  } else {
1886
1887
  nextTick(() => resizeObserver.observe(elRef.value));
1887
1888
  }
1888
- }, 20);
1889
+ }, 100);
1889
1890
  defaultComponent.addEventListener("selectLineChange", () => {
1890
1891
  selectLineCount.value = defaultComponent.selectLines.length;
1891
1892
  hasWindowLine.value = defaultComponent.selectLines.some((l) => l.userData.isWindow);
@@ -1900,13 +1901,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1900
1901
  return openBlock(), createElementBlock("div", {
1901
1902
  ref_key: "elRef",
1902
1903
  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
+ 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]"
1904
1905
  }, [
1905
1906
  createVNode(Transition, null, {
1906
1907
  default: withCtx(() => [
1907
1908
  showShortcutKey.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
1908
1909
  (openBlock(), createElementBlock(Fragment, null, renderList(shortcutKeys, (item) => {
1909
- return createElementVNode("p", {
1910
+ return createElementVNode("div", {
1910
1911
  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
1912
  key: item.name
1912
1913
  }, [
@@ -1922,14 +1923,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1922
1923
  ref_key: "toolBarRef",
1923
1924
  ref: toolBarRef,
1924
1925
  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
+ class: normalizeClass(["pointer-events-auto w-fit max-w-[260px] transition-[border-radius] text-[#333] absolute z-[11] bg-white select-none", { "rounded-[8px] ": toolBarExpand.value }]),
1926
1927
  onMousedown: _cache[13] || (_cache[13] = (e) => e.stopPropagation())
1927
1928
  }, [
1928
1929
  createElementVNode("div", {
1929
1930
  onMousedown: dragMoveHelper,
1930
1931
  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
  }, [
1932
- _cache[15] || (_cache[15] = createStaticVNode('<div class="flex flex-row" data-v-26d57fb7><div class="p-[2px_5px] flex items-center pointer-events-none" data-v-26d57fb7><svg fill="#aaa" width="20" height="20" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" data-v-26d57fb7><path d="M341.333333 298.666667a85.333333 85.333333 0 1 0 0-170.666667 85.333333 85.333333 0 0 0 0 170.666667z m0 298.666666a85.333333 85.333333 0 1 0 0-170.666666 85.333333 85.333333 0 0 0 0 170.666666z m85.333334 213.333334a85.333333 85.333333 0 1 1-170.666667 0 85.333333 85.333333 0 0 1 170.666667 0z m256-512a85.333333 85.333333 0 1 0 0-170.666667 85.333333 85.333333 0 0 0 0 170.666667z m85.333333 213.333333a85.333333 85.333333 0 1 1-170.666667 0 85.333333 85.333333 0 0 1 170.666667 0z m-85.333333 384a85.333333 85.333333 0 1 0 0-170.666667 85.333333 85.333333 0 0 0 0 170.666667z" data-v-26d57fb7></path></svg></div><h5 class="flex text-[12px] items-center pointer-events-none" data-v-26d57fb7>绘制工具</h5></div>', 1)),
1933
+ _cache[15] || (_cache[15] = createStaticVNode('<div class="flex flex-row" data-v-a95f67da><div class="p-[2px_5px] flex items-center pointer-events-none" data-v-a95f67da><svg fill="#aaa" width="20" height="20" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" data-v-a95f67da><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-a95f67da></path></svg></div><h5 class="flex text-[12px] items-center pointer-events-none" data-v-a95f67da>绘制工具</h5></div>', 1)),
1933
1934
  createElementVNode("div", {
1934
1935
  onMousedown: _cache[0] || (_cache[0] = (e) => e.stopPropagation()),
1935
1936
  onClick: _cache[1] || (_cache[1] = ($event) => toolBarExpand.value = !toolBarExpand.value),
@@ -2008,7 +2009,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2008
2009
  ]),
2009
2010
  _ctx.permission === "admin" ? (openBlock(), createElementBlock("div", _hoisted_12, [
2010
2011
  createVNode(unref(ElButton), {
2011
- style: { "padding": "5px", "font-size": "10px" },
2012
+ style: { "padding": "0px", "font-size": "10px" },
2012
2013
  size: "small",
2013
2014
  type: "success",
2014
2015
  onClick: selectLocalFile
@@ -2020,37 +2021,37 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2020
2021
  __: [17]
2021
2022
  }),
2022
2023
  createVNode(unref(ElButton), {
2023
- style: { "padding": "5px", "font-size": "10px" },
2024
+ style: { "padding": "0px", "font-size": "10px" },
2024
2025
  size: "small",
2025
2026
  type: "primary",
2026
- onClick: _cache[5] || (_cache[5] = ($event) => unref(dxfSystem).Dxf.download("test.dxf"))
2027
+ onClick: _cache[5] || (_cache[5] = ($event) => console.log(unref(dxfSystem).Dxf.originalData))
2027
2028
  }, {
2028
2029
  default: withCtx(() => _cache[18] || (_cache[18] = [
2029
- createTextVNode(" 下载 DXF ", -1)
2030
+ createTextVNode(" 打印Json ", -1)
2030
2031
  ])),
2031
2032
  _: 1,
2032
2033
  __: [18]
2033
2034
  }),
2034
2035
  createVNode(unref(ElButton), {
2035
- style: { "padding": "5px", "font-size": "10px" },
2036
+ style: { "padding": "0px", "font-size": "10px" },
2036
2037
  size: "small",
2037
2038
  type: "primary",
2038
- onClick: _cache[6] || (_cache[6] = ($event) => unref(whiteModel).downloadGltf("test.glb", true))
2039
+ onClick: _cache[6] || (_cache[6] = ($event) => unref(dxfSystem).Dxf.download("test.dxf"))
2039
2040
  }, {
2040
2041
  default: withCtx(() => _cache[19] || (_cache[19] = [
2041
- createTextVNode(" 下载 白膜 ", -1)
2042
+ createTextVNode(" 下载DXF ", -1)
2042
2043
  ])),
2043
2044
  _: 1,
2044
2045
  __: [19]
2045
2046
  }),
2046
2047
  createVNode(unref(ElButton), {
2047
- style: { "padding": "5px", "font-size": "10px" },
2048
+ style: { "padding": "0px", "font-size": "10px" },
2048
2049
  size: "small",
2049
2050
  type: "primary",
2050
- onClick: _cache[7] || (_cache[7] = ($event) => console.log(unref(dxfSystem).Dxf.originalData))
2051
+ onClick: _cache[7] || (_cache[7] = ($event) => unref(whiteModel).downloadGltf("test.glb", true))
2051
2052
  }, {
2052
2053
  default: withCtx(() => _cache[20] || (_cache[20] = [
2053
- createTextVNode(" 打印Json ", -1)
2054
+ createTextVNode(" 下载白膜 ", -1)
2054
2055
  ])),
2055
2056
  _: 1,
2056
2057
  __: [20]
@@ -2165,7 +2166,7 @@ const _export_sfc = (sfc, props) => {
2165
2166
  }
2166
2167
  return target;
2167
2168
  };
2168
- const EditorTool = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-26d57fb7"]]);
2169
+ const EditorTool = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-a95f67da"]]);
2169
2170
  let Editor$1 = class Editor extends Component {
2170
2171
  static name = "Editor";
2171
2172
  container = new THREE.Group();
@@ -22,6 +22,7 @@ export interface OriginalDataItem {
22
22
  z?: number;
23
23
  };
24
24
  }[];
25
+ length: number;
25
26
  isDoor?: boolean;
26
27
  doorDirectConnection?: boolean;
27
28
  drawDoorData?: {
@@ -125,9 +125,10 @@ export declare class Point<T = Record<string, any>> {
125
125
  x: number;
126
126
  y: number;
127
127
  }): void;
128
- toJson(): {
128
+ toJson(z?: number): {
129
129
  x: number;
130
130
  y: number;
131
+ z: number;
131
132
  };
132
133
  static from(arr: any): Point<Record<string, any>>;
133
134
  static zero(): Point<Record<string, any>>;