build-dxf 0.1.45 → 0.1.46

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.
Files changed (22) hide show
  1. package/package.json +1 -1
  2. package/src/build.js +16 -13
  3. package/src/index3.js +35 -27
  4. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/{CommandFlowComponent.d.ts → CFComponent.d.ts} +29 -0
  5. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/ClippingLine.d.ts +1 -1
  6. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/Default.d.ts +1 -1
  7. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DeleteSelectLine.d.ts +1 -1
  8. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawDoorLine.d.ts +1 -1
  9. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawLine.d.ts +1 -1
  10. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawWindow.d.ts +1 -1
  11. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/ManualDistance.d.ts +1 -1
  12. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/MergeLine.d.ts +1 -1
  13. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/PointDrag/index.d.ts +1 -1
  14. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/PropertiesPanel.d.ts +1 -1
  15. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/RayDistance.d.ts +1 -1
  16. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/SelectAll.d.ts +1 -1
  17. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/TwoLineConnectionLine.d.ts +1 -1
  18. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/TwoPointConnection.d.ts +1 -1
  19. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/VerticalCorr.d.ts +1 -1
  20. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/VerticalCorrContinue.d.ts +1 -1
  21. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/VerticalReferenceLine.d.ts +1 -1
  22. package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/ViewAngle.d.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "build-dxf",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "description": "线段构建双线墙壁的dxf版本",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/build.js CHANGED
@@ -3132,18 +3132,22 @@ class Polygon extends Array {
3132
3132
  * @returns
3133
3133
  */
3134
3134
  static fromByLinePath(lines, polygon2 = new Polygon()) {
3135
- const points = lines.flatMap((line, index2) => {
3136
- if (index2 === 0) {
3137
- const lines2 = lines[index2 + 1];
3138
- if (line.sameEndpointAsStart(lines2)) return [line.end, line.start];
3139
- else return [line.start, line.end];
3140
- } else {
3141
- const lines2 = lines[index2 - 1];
3142
- if (line.sameEndpointAsStart(lines2)) return [line.end];
3143
- else return [line.start];
3144
- }
3145
- });
3146
- polygon2.set(points);
3135
+ if (lines.length < 2) {
3136
+ polygon2.set(lines[0].points);
3137
+ } else {
3138
+ const points = lines.flatMap((line, index2) => {
3139
+ if (index2 === 0) {
3140
+ const lines2 = lines[index2 + 1];
3141
+ if (line.sameEndpointAsStart(lines2)) return [line.end, line.start];
3142
+ else return [line.start, line.end];
3143
+ } else {
3144
+ const lines2 = lines[index2 - 1];
3145
+ if (line.sameEndpointAsStart(lines2)) return [line.end];
3146
+ else return [line.start];
3147
+ }
3148
+ });
3149
+ polygon2.set(points);
3150
+ }
3147
3151
  return polygon2;
3148
3152
  }
3149
3153
  }
@@ -14643,7 +14647,6 @@ class DoorFind {
14643
14647
  const openDoors = doors.filter((line) => !line.userData.doorDirectConnection), closeDoors = doors.filter((line) => line.userData.doorDirectConnection);
14644
14648
  this.grid = createPointVirtualGrid(noDoorLines);
14645
14649
  this.quadtree = createQuadtree([...noDoorLines, ...closeDoors]);
14646
- openDoors.forEach((l) => l.userData.doorDirectConnection = true);
14647
14650
  closeDoors.forEach((line) => this.findCloseDoors(line));
14648
14651
  openDoors.forEach((line) => this.findOpenDoors(line));
14649
14652
  }
package/src/index3.js CHANGED
@@ -10504,10 +10504,11 @@ class CommandFlowComponent extends Component {
10504
10504
  });
10505
10505
  };
10506
10506
  const end = () => {
10507
+ if (ended) return;
10508
+ ended = true;
10507
10509
  handle.destroy();
10508
10510
  pointMesh.removeFromParent();
10509
10511
  resolve_ && resolve_(null);
10510
- ended = true;
10511
10512
  editor.renderManager.setAuxiliaryLineVisible(false);
10512
10513
  };
10513
10514
  const {
@@ -10561,6 +10562,13 @@ class CommandFlowComponent extends Component {
10561
10562
  return this;
10562
10563
  }
10563
10564
  };
10565
+ },
10566
+ // 等待每一个按键
10567
+ async awaitEach(callBack, mode_ = "all") {
10568
+ for await (const result of this.points(mode_)) {
10569
+ callBack(result);
10570
+ }
10571
+ return this;
10564
10572
  }
10565
10573
  };
10566
10574
  }
@@ -14914,23 +14922,21 @@ class RayDistance extends CommandFlowComponent {
14914
14922
  onAddFromParent(parent) {
14915
14923
  super.onAddFromParent(parent);
14916
14924
  this.editor.container.add(this.container);
14917
- 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);
14918
- commandFlow.writeOperationRecord = false;
14919
- commandFlow.addEventListener("finally", this.createFinally());
14920
- this.eventInput.addKeyCombination(this.commandName, this.shortcutKeys);
14921
- this.eventInput.addEventListener("codeChange", async () => this.eventInput.isKeyCombination(this.commandName) && await this.commandManager.start(this.commandName));
14922
- this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
14925
+ const commandFlow = this.initCommandFlow({
14926
+ shortcutKeys: this.shortcutKeys,
14927
+ writeOperationRecord: false,
14928
+ loop: true
14929
+ });
14930
+ commandFlow.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")} 取消命令` });
14923
14931
  }
14924
14932
  /** 选择点
14925
14933
  * @param next
14926
14934
  */
14927
14935
  async selectPoint(next) {
14928
14936
  const pointSelector = this.createPointSelector();
14929
- this.addEventRecord("clear", () => {
14930
- pointSelector.end();
14931
- this.container.clear();
14932
- });
14937
+ this.addEventRecord("clear", () => this.container.clear());
14933
14938
  const result = await pointSelector.next("line_point");
14939
+ if (!result) return;
14934
14940
  next(result);
14935
14941
  }
14936
14942
  /** 射线
@@ -14995,28 +15001,30 @@ class ManualDistance extends CommandFlowComponent {
14995
15001
  onAddFromParent(parent) {
14996
15002
  super.onAddFromParent(parent);
14997
15003
  this.editor.container.add(this.container);
14998
- 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);
14999
- commandFlow.writeOperationRecord = false;
15000
- commandFlow.addEventListener("finally", this.createFinally());
15001
- this.eventInput.addKeyCombination(this.commandName, this.shortcutKeys);
15002
- this.eventInput.addEventListener("codeChange", async () => this.eventInput.isKeyCombination(this.commandName) && await this.commandManager.start(this.commandName));
15003
- this.eventInput.addCancelDefaultBehavior(() => this.eventInput.isOnlyKeyDowns(this.shortcutKeys));
15004
+ const commandFlow = this.initCommandFlow({
15005
+ shortcutKeys: this.shortcutKeys,
15006
+ writeOperationRecord: false,
15007
+ loop: true
15008
+ });
15009
+ commandFlow.add(this.createCursor("crosshair")).add(this.selectPoint.bind(this), { prompt: `请选择两个点, ${this.formatText("ESC")} 取消命令` }).add(this.ray.bind(this), { prompt: `按 ${this.formatText("Enter")} 重新选择, ${this.formatText("ESC")} 取消命令` });
15004
15010
  }
15005
15011
  /** 选择点
15006
15012
  * @param next
15007
15013
  */
15008
15014
  async selectPoint(next) {
15009
15015
  const pointSelector = this.createPointSelector();
15010
- this.addEventRecord("clear", () => {
15011
- this.container.clear();
15012
- pointSelector.end();
15013
- });
15014
- const point1 = (await pointSelector.next("all")).point;
15015
- this.renderer.createCircle(point1, {}, this.container);
15016
- const point2 = (await pointSelector.next("all")).point;
15017
- this.renderer.createCircle(point2, {}, this.container);
15018
- pointSelector.end();
15019
- next({ point1, point2 });
15016
+ this.addEventRecord(this.COMMAND_END_EVEBT_RECORD_NAME, () => this.container.clear());
15017
+ let points = [];
15018
+ await pointSelector.awaitEach((result) => {
15019
+ if (!result) return;
15020
+ const { point } = result;
15021
+ this.renderer.createCircle(point, {}, this.container);
15022
+ points.push(point);
15023
+ if (points.length === 2) pointSelector.end();
15024
+ }, "all");
15025
+ if (points.length === 2) {
15026
+ next({ point1: points[0], point2: points[1] });
15027
+ }
15020
15028
  }
15021
15029
  /** 射线
15022
15030
  * @param points
@@ -187,6 +187,35 @@ export declare class CommandFlowComponent<TEventMap extends {} = {}> extends Com
187
187
  }>;
188
188
  [Symbol.asyncIterator](): /*elided*/ any;
189
189
  };
190
+ awaitEach(callBack: (result: {
191
+ point: Point<Record<string, any>>;
192
+ line?: LineSegment;
193
+ } | null) => void, mode_?: "all" | "point" | "line" | "empty" | "line_point" | "line_empty" | "point_empty" | "null"): Promise<{
194
+ readonly ended: boolean;
195
+ end: () => void;
196
+ next: (mode_: "all" | "point" | "line" | "empty" | "line_point" | "line_empty" | "point_empty" | "null") => Promise<{
197
+ point: Point;
198
+ line?: LineSegment;
199
+ } | null>;
200
+ setBaseLine(line: LineSegment<Record<string, any>> | null, point: Point | null): void;
201
+ points(mode_: "all" | "point" | "line" | "empty" | "line_point" | "line_empty" | "point_empty" | "null"): {
202
+ next(): Promise<{
203
+ value: {
204
+ point: Point;
205
+ line?: LineSegment;
206
+ };
207
+ done: boolean;
208
+ } | {
209
+ value: null;
210
+ done: boolean;
211
+ }>;
212
+ [Symbol.asyncIterator](): /*elided*/ any;
213
+ };
214
+ awaitEach(callBack: (result: {
215
+ point: Point<Record<string, any>>;
216
+ line?: LineSegment;
217
+ } | null) => void, mode_?: "all" | "point" | "line" | "empty" | "line_point" | "line_empty" | "point_empty" | "null"): Promise</*elided*/ any>;
218
+ }>;
190
219
  };
191
220
  /**
192
221
  * 创建拖拽点
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { LineSegment } from '../../../../../LineSegment';
3
3
  import { ComponentManager } from '../../../../../ComponentManager';
4
4
  import { Point } from '../../../../../Point';
@@ -1,5 +1,5 @@
1
1
  import { LineSegment } from '../../../../../LineSegment';
2
- import { CommandFlowComponent } from './CommandFlowComponent';
2
+ import { CommandFlowComponent } from './CFComponent';
3
3
  import { LineUserData } from '../../../../type';
4
4
  import * as THREE from "three";
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  /**
4
4
  * 删除选择的线段
@@ -1,6 +1,6 @@
1
1
  import { ComponentManager } from '../../../../../ComponentManager';
2
2
  import { LineSegment } from '../../../../../LineSegment';
3
- import { CommandFlowComponent } from './CommandFlowComponent';
3
+ import { CommandFlowComponent } from './CFComponent';
4
4
  import * as THREE from "three";
5
5
  export declare class DrawDoorLine extends CommandFlowComponent<{
6
6
  pointerMove: {
@@ -1,5 +1,5 @@
1
1
  import { LineSegment } from '../../../../../LineSegment';
2
- import { CommandFlowComponent } from './CommandFlowComponent';
2
+ import { CommandFlowComponent } from './CFComponent';
3
3
  import { ComponentManager } from '../../../../../ComponentManager';
4
4
  import * as THREE from "three";
5
5
  export declare class DrawLine extends CommandFlowComponent<{
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { LineSegment } from '../../../../../LineSegment';
3
3
  import { ComponentManager } from '../../../../../ComponentManager';
4
4
  import { LineUserData } from '../../../../type';
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  import { Point } from '../../../../../Point';
4
4
  import * as THREE from "three";
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  /**
4
4
  * 合并同向线段
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from '../CommandFlowComponent';
1
+ import { CommandFlowComponent } from '../CFComponent';
2
2
  import { ComponentManager } from '../../../../../../ComponentManager';
3
3
  import { WindowValueOption } from './modifyWindow';
4
4
  import { DoorValueOption } from './modifyDoor';
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  import { LineSegment } from '../../../../../LineSegment';
4
4
  import * as THREE from "three";
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  import { Point } from '../../../../../Point';
4
4
  import * as THREE from "three";
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  import { LineSegment } from '../../../../../LineSegment';
4
4
  import * as THREE from "three";
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  /**
4
4
  * 两线段链接
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  /**
4
4
  * 两点链接
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  import { LineSegment } from '../../../../../LineSegment';
4
4
  import { Point } from '../../../../../Point';
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  import { LineSegment } from '../../../../../LineSegment';
4
4
  import * as THREE from "three";
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  /**
4
4
  * 设置y轴垂直基准线段
@@ -1,4 +1,4 @@
1
- import { CommandFlowComponent } from './CommandFlowComponent';
1
+ import { CommandFlowComponent } from './CFComponent';
2
2
  import { ComponentManager } from '../../../../../ComponentManager';
3
3
  /**
4
4
  * 合并同向线段