build-dxf 0.1.154 → 0.1.155

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.154",
3
+ "version": "0.1.155",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/build.js CHANGED
@@ -12590,8 +12590,8 @@ class BayWindow {
12590
12590
  console.log("夹角异常1", Meshlist);
12591
12591
  continue;
12592
12592
  }
12593
- this.bayWindowGroup.add(Meshlist.mesh1);
12594
- this.bayWindowGroup.add(Meshlist.mesh2);
12593
+ Scenario.Instance.group.add(Meshlist.mesh1);
12594
+ Scenario.Instance.group.add(Meshlist.mesh2);
12595
12595
  }
12596
12596
  }
12597
12597
  }
@@ -13254,8 +13254,9 @@ class BayWindow {
13254
13254
  menModel.rotation.y = angleRad;
13255
13255
  menModel.scale.set((distance2 + 0.12) / size2.x, height / size2.y, wallWidth / size2.z);
13256
13256
  menModel.position.set(center.x, center.y, groundClearance);
13257
- menModel.name = `窗_${index2}`;
13258
- menModel.userData.category = "window";
13257
+ Scenario.Instance.windowForm = Scenario.Instance.windowForm + 1;
13258
+ menModel.name = `窗体_${Scenario.Instance.windowForm}`;
13259
+ menModel.userData.category = "windowForm";
13259
13260
  menModel.userData.winUuid = data.userData.winUuid;
13260
13261
  menModel.userData.lineUuid = data.userData.lineUuid;
13261
13262
  menModel.userData.width = distance2;
@@ -13411,7 +13412,17 @@ class Scenario {
13411
13412
  box;
13412
13413
  singleLineWallValue;
13413
13414
  liangNum;
13415
+ // 梁堆叠
13414
13416
  zhuNum;
13417
+ // 柱堆叠
13418
+ poortNum;
13419
+ // 垭口堆叠
13420
+ doorNum;
13421
+ // 门堆叠
13422
+ windowNum;
13423
+ // 窗堆叠
13424
+ windowForm;
13425
+ // 飘窗体堆叠
13415
13426
  static _instance;
13416
13427
  static get Instance() {
13417
13428
  return Scenario._instance;
@@ -13425,6 +13436,10 @@ class Scenario {
13425
13436
  this.axesHelper = new THREE.AxesHelper(20);
13426
13437
  this.liangNum = 0;
13427
13438
  this.zhuNum = 0;
13439
+ this.poortNum = 0;
13440
+ this.doorNum = 0;
13441
+ this.windowNum = 0;
13442
+ this.windowForm = 0;
13428
13443
  this.scene.add(this.axesHelper);
13429
13444
  this.group = null;
13430
13445
  this.closedArray = [];
@@ -13494,6 +13509,10 @@ class Scenario {
13494
13509
  this.group = new Group$1();
13495
13510
  this.liangNum = 0;
13496
13511
  this.zhuNum = 0;
13512
+ this.poortNum = 0;
13513
+ this.doorNum = 0;
13514
+ this.windowNum = 0;
13515
+ this.windowForm = 0;
13497
13516
  this.expandedList = [];
13498
13517
  if (!BayWindow.Instance) new BayWindow();
13499
13518
  BayWindow.Instance.bayWindowExpansion = [];
@@ -13629,8 +13648,11 @@ class Scenario {
13629
13648
  } else if (doubleLinesWindow[x].userData.type === "door") {
13630
13649
  this.singleLineWallMountedDoor(doubleLinesWindow[x], x);
13631
13650
  } else if (doubleLinesWindow[x].userData.type === "beam") ;
13632
- else ;
13633
- this.group.add(this.windowTreatment(doubleLinesWindow[x], Mesh, wallHeight));
13651
+ else if (doubleLinesWindow[x].userData.type === "passageEntrance") {
13652
+ this.addThePassModel(doubleLinesWindow[x]);
13653
+ }
13654
+ let mesh = this.windowTreatment(doubleLinesWindow[x], Mesh, wallHeight);
13655
+ this.group.add(mesh);
13634
13656
  } else if (houMesh) {
13635
13657
  if (Number(x) === doubleLinesWindow.length - 1) {
13636
13658
  const edges = new THREE.EdgesGeometry(this.windowTreatment(doubleLinesWindow[x], houMesh, wallHeight).geometry);
@@ -13640,8 +13662,11 @@ class Scenario {
13640
13662
  } else if (doubleLinesWindow[x].userData.type === "door") {
13641
13663
  this.singleLineWallMountedDoor(doubleLinesWindow[x], x);
13642
13664
  } else if (doubleLinesWindow[x].userData.type === "beam") ;
13643
- else ;
13644
- this.group.add(this.windowTreatment(doubleLinesWindow[x], houMesh, wallHeight));
13665
+ else if (doubleLinesWindow[x].userData.type === "passageEntrance") {
13666
+ this.addThePassModel(doubleLinesWindow[x]);
13667
+ }
13668
+ let mesh = this.windowTreatment(doubleLinesWindow[x], houMesh, wallHeight);
13669
+ this.group.add(mesh);
13645
13670
  } else {
13646
13671
  if (doubleLinesWindow[x].userData.type === "window") {
13647
13672
  this.installWindows(doubleLinesWindow[x], x);
@@ -13649,6 +13674,9 @@ class Scenario {
13649
13674
  this.singleLineWallMountedDoor(doubleLinesWindow[x], x);
13650
13675
  }
13651
13676
  if (doubleLinesWindow[x].userData.type === "beam") ;
13677
+ else if (doubleLinesWindow[x].userData.type === "passageEntrance") {
13678
+ this.addThePassModel(doubleLinesWindow[x]);
13679
+ }
13652
13680
  houMesh = this.windowTreatment(doubleLinesWindow[x], houMesh, wallHeight);
13653
13681
  }
13654
13682
  } else {
@@ -13657,7 +13685,9 @@ class Scenario {
13657
13685
  } else if (doubleLinesWindow[x].userData.type === "door") {
13658
13686
  this.singleLineWallMountedDoor(doubleLinesWindow[x], x);
13659
13687
  } else if (doubleLinesWindow[x].userData.type === "beam") ;
13660
- else ;
13688
+ else if (doubleLinesWindow[x].userData.type === "passageEntrance") {
13689
+ this.addThePassModel(doubleLinesWindow[x]);
13690
+ }
13661
13691
  houMesh = this.windowTreatment(doubleLinesWindow[x], Mesh, wallHeight);
13662
13692
  }
13663
13693
  }
@@ -14076,7 +14106,8 @@ class Scenario {
14076
14106
  menModel.rotation.y = angleRad;
14077
14107
  menModel.scale.set(distance2 / size2.x, height / size2.y, wallWidth / size2.z);
14078
14108
  menModel.position.set(data.center.x, data.center.y, groundClearance);
14079
- menModel.name = `窗_${index2}`;
14109
+ this.windowNum = this.windowNum + 1;
14110
+ menModel.name = `窗_${this.windowNum}`;
14080
14111
  menModel.userData.category = "window";
14081
14112
  menModel.userData.winUuid = data.userData.winUuid;
14082
14113
  menModel.userData.lineUuid = data.userData.lineUuid;
@@ -14115,7 +14146,8 @@ class Scenario {
14115
14146
  menModel.rotation.y = angleRad;
14116
14147
  menModel.scale.set(distance2 / size2.x, height / size2.y, wallWidth / size2.z);
14117
14148
  menModel.position.set(data.center.x, data.center.y, groundClearance);
14118
- menModel.name = `门_${index2}`;
14149
+ this.doorNum = this.doorNum + 1;
14150
+ menModel.name = `门_${this.doorNum}`;
14119
14151
  menModel.userData.category = "door";
14120
14152
  menModel.userData.winUuid = data.userData.winUuid;
14121
14153
  menModel.userData.lineUuid = data.userData.lineUuid;
@@ -14263,7 +14295,7 @@ class Scenario {
14263
14295
  const evaluator = new Evaluator();
14264
14296
  const result = evaluator.evaluate(brush1, brush2, SUBTRACTION);
14265
14297
  result.material = mesh.material;
14266
- if (mesh.userData.category === "beam") {
14298
+ if (mesh.userData.category === "beam" || mesh.userData.category === "passageEntrance") {
14267
14299
  result.name = mesh.name;
14268
14300
  result.userData = mesh.userData;
14269
14301
  }
@@ -14372,6 +14404,82 @@ class Scenario {
14372
14404
  const point22 = new THREE.Vector3(point2.x - x - xOverflow, point2.y + y - YOverflow, wallHeight);
14373
14405
  return [point1, point22];
14374
14406
  }
14407
+ // 只往长边方向偏移指定距离的新坐标
14408
+ expandRectangleAlongLongSide(p1, p2, p3, p4, expandAmount = 0.01) {
14409
+ const edge12 = new THREE.Vector3().copy(p2).sub(p1);
14410
+ const edge23 = new THREE.Vector3().copy(p3).sub(p2);
14411
+ const edge34 = new THREE.Vector3().copy(p4).sub(p3);
14412
+ const edge41 = new THREE.Vector3().copy(p1).sub(p4);
14413
+ const len12 = edge12.length();
14414
+ const len23 = edge23.length();
14415
+ const len34 = edge34.length();
14416
+ const len41 = edge41.length();
14417
+ let longEdgeDirection;
14418
+ let longEdgeStart1, longEdgeEnd1;
14419
+ let longEdgeStart2, longEdgeEnd2;
14420
+ if (len12 >= len23 && len12 >= len34 && len12 >= len41) {
14421
+ longEdgeDirection = edge12.clone().normalize();
14422
+ edge23.clone().normalize();
14423
+ longEdgeStart1 = p1;
14424
+ longEdgeEnd1 = p2;
14425
+ longEdgeStart2 = p4;
14426
+ longEdgeEnd2 = p3;
14427
+ } else if (len23 >= len12 && len23 >= len34 && len23 >= len41) {
14428
+ longEdgeDirection = edge23.clone().normalize();
14429
+ edge34.clone().normalize();
14430
+ longEdgeStart1 = p2;
14431
+ longEdgeEnd1 = p3;
14432
+ longEdgeStart2 = p1;
14433
+ longEdgeEnd2 = p4;
14434
+ } else if (len34 >= len12 && len34 >= len23 && len34 >= len41) {
14435
+ longEdgeDirection = edge34.clone().normalize();
14436
+ edge41.clone().normalize();
14437
+ longEdgeStart1 = p3;
14438
+ longEdgeEnd1 = p4;
14439
+ longEdgeStart2 = p2;
14440
+ longEdgeEnd2 = p1;
14441
+ } else {
14442
+ longEdgeDirection = edge41.clone().normalize();
14443
+ edge12.clone().normalize();
14444
+ longEdgeStart1 = p4;
14445
+ longEdgeEnd1 = p1;
14446
+ longEdgeStart2 = p3;
14447
+ longEdgeEnd2 = p2;
14448
+ }
14449
+ const newP1 = longEdgeStart1.clone().add(longEdgeDirection.clone().multiplyScalar(-expandAmount));
14450
+ const newP2 = longEdgeEnd1.clone().add(longEdgeDirection.clone().multiplyScalar(expandAmount));
14451
+ const newP3 = longEdgeEnd2.clone().add(longEdgeDirection.clone().multiplyScalar(expandAmount));
14452
+ const newP4 = longEdgeStart2.clone().add(longEdgeDirection.clone().multiplyScalar(-expandAmount));
14453
+ return [newP1, newP2, newP3, newP4];
14454
+ }
14455
+ // 往长边和短边方向都偏移指定距离的新坐标
14456
+ expandRectangleSimple(p1, p2, p3, p4, expandAmount = 0.01) {
14457
+ const edge12 = new THREE.Vector3().copy(p2).sub(p1);
14458
+ const edge14 = new THREE.Vector3().copy(p4).sub(p1);
14459
+ const len12 = edge12.length();
14460
+ const len14 = edge14.length();
14461
+ let longEdgeDir, shortEdgeDir;
14462
+ let halfLong, halfShort;
14463
+ if (len12 >= len14) {
14464
+ longEdgeDir = edge12.clone().normalize();
14465
+ shortEdgeDir = edge14.clone().normalize();
14466
+ halfLong = len12 / 2;
14467
+ halfShort = len14 / 2;
14468
+ } else {
14469
+ longEdgeDir = edge14.clone().normalize();
14470
+ shortEdgeDir = edge12.clone().normalize();
14471
+ halfLong = len14 / 2;
14472
+ halfShort = len12 / 2;
14473
+ }
14474
+ const center = new THREE.Vector3().copy(p1).add(p2).add(p3).add(p4).multiplyScalar(0.25);
14475
+ const newHalfLong = halfLong + expandAmount;
14476
+ const newHalfShort = halfShort + expandAmount;
14477
+ const newP1 = center.clone().addScaledVector(longEdgeDir, -newHalfLong).addScaledVector(shortEdgeDir, -newHalfShort);
14478
+ const newP2 = center.clone().addScaledVector(longEdgeDir, newHalfLong).addScaledVector(shortEdgeDir, -newHalfShort);
14479
+ const newP3 = center.clone().addScaledVector(longEdgeDir, newHalfLong).addScaledVector(shortEdgeDir, newHalfShort);
14480
+ const newP4 = center.clone().addScaledVector(longEdgeDir, -newHalfLong).addScaledVector(shortEdgeDir, newHalfShort);
14481
+ return [newP1, newP2, newP3, newP4];
14482
+ }
14375
14483
  // 外扩还是内缩偏移点坐标
14376
14484
  xinLine1(x, y, pointa, pointb, num, wallHeight) {
14377
14485
  let point1;
@@ -14583,7 +14691,9 @@ class Scenario {
14583
14691
  this.installWindows(winDraw[x2], x2);
14584
14692
  } else if (winDraw[x2].userData.type === "door") {
14585
14693
  this.singleLineWallMountedDoor(winDraw[x2], x2);
14586
- } else ;
14694
+ } else if (winDraw[x2].userData.type === "passageEntrance") {
14695
+ this.addThePassModel(winDraw[x2]);
14696
+ }
14587
14697
  let mesh = this.windowTreatment(winDraw[x2], Mesh, wallHeight);
14588
14698
  this.group.add(mesh);
14589
14699
  } else if (houMesh) {
@@ -14593,7 +14703,9 @@ class Scenario {
14593
14703
  this.installWindows(winDraw[x2], x2);
14594
14704
  } else if (winDraw[x2].userData.type === "door") {
14595
14705
  this.singleLineWallMountedDoor(winDraw[x2], x2);
14596
- } else ;
14706
+ } else if (winDraw[x2].userData.type === "passageEntrance") {
14707
+ this.addThePassModel(winDraw[x2]);
14708
+ }
14597
14709
  new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: 0 }));
14598
14710
  let mesh = this.windowTreatment(winDraw[x2], houMesh, wallHeight);
14599
14711
  this.group.add(mesh);
@@ -14604,7 +14716,9 @@ class Scenario {
14604
14716
  this.singleLineWallMountedDoor(winDraw[x2], x2);
14605
14717
  } else if (winDraw[x2].userData.type === "beam") {
14606
14718
  console.log("梁");
14607
- } else ;
14719
+ } else if (winDraw[x2].userData.type === "passageEntrance") {
14720
+ this.addThePassModel(winDraw[x2]);
14721
+ }
14608
14722
  houMesh = this.windowTreatment(winDraw[x2], houMesh, wallHeight);
14609
14723
  }
14610
14724
  } else {
@@ -14614,7 +14728,9 @@ class Scenario {
14614
14728
  this.singleLineWallMountedDoor(winDraw[x2], x2);
14615
14729
  } else if (winDraw[x2].userData.type === "beam") {
14616
14730
  console.log("梁");
14617
- } else ;
14731
+ } else if (winDraw[x2].userData.type === "passageEntrance") {
14732
+ this.addThePassModel(winDraw[x2]);
14733
+ }
14618
14734
  houMesh = this.windowTreatment(winDraw[x2], Mesh, wallHeight);
14619
14735
  }
14620
14736
  }
@@ -14628,7 +14744,8 @@ class Scenario {
14628
14744
  // 生成梁模型
14629
14745
  generateBeamModel(line) {
14630
14746
  let basePoints;
14631
- if (!line.userData.expansionWidth) {
14747
+ let expansionPoints;
14748
+ if (!line.userData.expansionWidth && !line.userData.expansionDirction) {
14632
14749
  let wallWidth;
14633
14750
  if (line.userData.wallWidth) {
14634
14751
  wallWidth = line.userData.wallWidth;
@@ -14637,17 +14754,19 @@ class Scenario {
14637
14754
  }
14638
14755
  const MobileX = this.angleToXAxisDegrees(line.start.x, line.start.y, line.end.x, line.end.y, wallWidth, true);
14639
14756
  const MobileY = this.angleToXAxisDegrees(line.start.x, line.start.y, line.end.x, line.end.y, wallWidth, false);
14640
- let startingPoint = this.xinLine(MobileX, MobileY, line.start, 0);
14641
- let finishLine = this.xinLine(MobileX, MobileY, line.end, 1);
14757
+ let startingPoint = this.xinLine(MobileX, MobileY, line.start, this.height ? this.height : 0);
14758
+ let finishLine = this.xinLine(MobileX, MobileY, line.end, this.height ? this.height : 0);
14642
14759
  basePoints = [startingPoint[0], startingPoint[1], finishLine[1], finishLine[0]];
14760
+ expansionPoints = this.expandRectangleSimple(startingPoint[0], startingPoint[1], finishLine[1], finishLine[0], 0.01);
14643
14761
  } else {
14644
14762
  const directionX = line.userData.expansionDirction.x * line.userData.expansionWidth;
14645
14763
  const directionY = line.userData.expansionDirction.y * line.userData.expansionWidth;
14646
- let pointStart = new THREE.Vector3(line.start.x, line.start.y, this.height);
14647
- let pointEnd = new THREE.Vector3(line.end.x, line.end.y, this.height);
14648
- let startExpansion = new THREE.Vector3(pointStart.x + directionX, pointStart.y + directionY, this.height);
14649
- let endExpansion = new THREE.Vector3(pointEnd.x + directionX, pointEnd.y + directionY, this.height);
14764
+ let pointStart = new THREE.Vector3(line.start.x, line.start.y, this.height ? this.height : 0);
14765
+ let pointEnd = new THREE.Vector3(line.end.x, line.end.y, this.height ? this.height : 0);
14766
+ let startExpansion = new THREE.Vector3(pointStart.x + directionX, pointStart.y + directionY, this.height ? this.height : 0);
14767
+ let endExpansion = new THREE.Vector3(pointEnd.x + directionX, pointEnd.y + directionY, this.height ? this.height : 0);
14650
14768
  basePoints = [pointStart, pointEnd, endExpansion, startExpansion];
14769
+ expansionPoints = this.expandRectangleSimple(pointStart, pointEnd, endExpansion, startExpansion, 0.01);
14651
14770
  }
14652
14771
  const geometry = this.createParallelepipedFromBase(basePoints, line.userData.height);
14653
14772
  const material = new THREE.MeshStandardMaterial({
@@ -14656,7 +14775,7 @@ class Scenario {
14656
14775
  side: THREE.DoubleSide
14657
14776
  });
14658
14777
  const cube = new THREE.Mesh(geometry, material);
14659
- const bodyGeometry = this.createParallelepipedFromBase(basePoints, line.userData.rooftopPz);
14778
+ const bodyGeometry = this.createParallelepipedFromBase(expansionPoints, line.userData.rooftopPz);
14660
14779
  const brush1 = new Brush(cube.geometry);
14661
14780
  brush1.updateMatrixWorld();
14662
14781
  const brush2 = new Brush(bodyGeometry);
@@ -14675,7 +14794,6 @@ class Scenario {
14675
14794
  }
14676
14795
  // 生成柱模型
14677
14796
  generateColumnModel(data, lines, Height) {
14678
- console.log(lines);
14679
14797
  let basePoints = [];
14680
14798
  for (const i in data) {
14681
14799
  basePoints.push(new THREE.Vector3(data[i].x, data[i].y, this.height ? this.height : 0));
@@ -14729,6 +14847,32 @@ class Scenario {
14729
14847
  return cube;
14730
14848
  }
14731
14849
  }
14850
+ // 安装垭口模型
14851
+ addThePassModel(line) {
14852
+ const MobileX = this.angleToXAxisDegrees(line.start.x, line.start.y, line.end.x, line.end.y, line.userData.wallWidth * 0.5, true);
14853
+ const MobileY = this.angleToXAxisDegrees(line.start.x, line.start.y, line.end.x, line.end.y, line.userData.wallWidth * 0.5, false);
14854
+ let startingPoint = this.xinLine(MobileX, MobileY, line.start, this.height ? this.height : 0);
14855
+ let finishLine = this.xinLine(MobileX, MobileY, line.end, this.height ? this.height : 0);
14856
+ let basePoints = [startingPoint[0], startingPoint[1], finishLine[1], finishLine[0]];
14857
+ const geometry = this.createParallelepipedFromBase(basePoints, line.userData.height);
14858
+ const material = new THREE.MeshStandardMaterial({
14859
+ color: 5214420,
14860
+ transparent: true,
14861
+ opacity: 0,
14862
+ side: THREE.DoubleSide
14863
+ });
14864
+ const cube = new THREE.Mesh(geometry, material);
14865
+ if (line.userData.type === "passageEntrance") {
14866
+ this.poortNum = this.poortNum + 1;
14867
+ cube.name = `垭口_${this.poortNum}`;
14868
+ cube.userData.category = "passageEntrance";
14869
+ cube.userData.height = line.userData.height;
14870
+ cube.userData.width = line.length;
14871
+ cube.userData.depth = line.userData.wallWidth;
14872
+ cube.userData.groundHeight = 0;
14873
+ }
14874
+ this.group.add(cube);
14875
+ }
14732
14876
  //
14733
14877
  createAPlane(lines, menList) {
14734
14878
  const lineList = lines;
@@ -40,6 +40,10 @@ export default class Scenario {
40
40
  singleLineWallValue: any;
41
41
  liangNum: number;
42
42
  zhuNum: number;
43
+ poortNum: number;
44
+ doorNum: number;
45
+ windowNum: number;
46
+ windowForm: number;
43
47
  private static _instance?;
44
48
  static get Instance(): Scenario | undefined;
45
49
  constructor(scene: THREE.Scene, camera: THREE.PerspectiveCamera, renderer: THREE.WebGLRenderer, controls: OrbitControls);
@@ -62,6 +66,8 @@ export default class Scenario {
62
66
  doorHoleOpening(wallHeight: number, data: any, data1: any, groundHeight?: number, Height?: number, distance?: number, center?: THREE.Vector3, angleRad?: any, index?: string, doorList?: LineSegment): void;
63
67
  angleToXAxisDegrees(x1: number, y1: number, x2: number, y2: number, wide: number, cd: boolean): number;
64
68
  xinLine(x: number, y: number, point: THREE.Vector3 | Point, wallHeight: number): THREE.Vector3[];
69
+ expandRectangleAlongLongSide(p1: THREE.Vector3, p2: THREE.Vector3, p3: THREE.Vector3, p4: THREE.Vector3, expandAmount?: number): THREE.Vector3[];
70
+ expandRectangleSimple(p1: THREE.Vector3, p2: THREE.Vector3, p3: THREE.Vector3, p4: THREE.Vector3, expandAmount?: number): THREE.Vector3[];
65
71
  xinLine1(x: number, y: number, pointa: THREE.Vector3, pointb: THREE.Vector3, num: number, wallHeight: number): any[];
66
72
  createParallelepipedFromBase(points: any, height: number): THREE.ExtrudeGeometry;
67
73
  correctionSorting(bitem: any): {
@@ -76,6 +82,7 @@ export default class Scenario {
76
82
  overallTreatmentOfSingleLineWalls(data: any): void;
77
83
  generateBeamModel(line: any): Brush;
78
84
  generateColumnModel(data: any, lines: any, Height: number): THREE.Mesh<THREE.ExtrudeGeometry, THREE.MeshStandardMaterial, THREE.Object3DEventMap> | null;
85
+ addThePassModel(line: LineSegment): void;
79
86
  createAPlane(lines: LineSegment<Record<string, any>>[], menList: LineSegment<Record<string, any>>[]): void;
80
87
  modelLoader(): Promise<void>;
81
88
  windowModelLoader(): Promise<void>;