build-dxf 0.1.23 → 0.1.25

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.23",
3
+ "version": "0.1.25",
4
4
  "description": "线段构建双线墙壁的dxf版本",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/build.js CHANGED
@@ -6097,31 +6097,46 @@ class Scenario {
6097
6097
  }
6098
6098
  // 绘制模型
6099
6099
  drawTheModel(data, num, index2, wallHeight) {
6100
- const basePoints = [
6101
- new THREE.Vector3(data[0].x, data[0].y, this.height ? this.height : 0),
6102
- new THREE.Vector3(data[1].x, data[1].y, this.height ? this.height : 0),
6103
- new THREE.Vector3(data[2].x, data[2].y, this.height ? this.height : 0),
6104
- // 可以不是矩形
6105
- new THREE.Vector3(data[3].x, data[3].y, this.height ? this.height : 0)
6106
- ];
6107
- const spacing = basePoints[0].distanceTo(basePoints[3]);
6108
- if (spacing < 5e-3) {
6109
- return null;
6100
+ let basePoints = [];
6101
+ for (const i in data) {
6102
+ basePoints.push(new THREE.Vector3(data[i].x, data[i].y, this.height ? this.height : 0));
6103
+ }
6104
+ if (basePoints.length === 4) {
6105
+ const spacing = basePoints[0].distanceTo(basePoints[3]);
6106
+ if (spacing < 5e-3) {
6107
+ return null;
6108
+ } else {
6109
+ const geometry = this.createParallelepipedFromBase(basePoints, wallHeight);
6110
+ const material = new THREE.MeshStandardMaterial({
6111
+ color: this.color,
6112
+ side: THREE.DoubleSide
6113
+ // roughness: this.numdu,
6114
+ // metalness: 0.0,
6115
+ // envMapRotation: new THREE.Euler(0, 0, 0),
6116
+ // polygonOffset: true,
6117
+ // polygonOffsetFactor: 10,
6118
+ // polygonOffsetUnits: 10,
6119
+ });
6120
+ const cube = new THREE.Mesh(geometry, material);
6121
+ const edges = new THREE.EdgesGeometry(geometry);
6122
+ new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: 0 }));
6123
+ if (num === 0) {
6124
+ cube.name = `双线墙_${index2}`;
6125
+ cube.userData.category = "doubleWall";
6126
+ } else {
6127
+ cube.name = `单线墙_${index2}`;
6128
+ cube.userData.category = "wall";
6129
+ }
6130
+ return cube;
6131
+ }
6110
6132
  } else {
6111
6133
  const geometry = this.createParallelepipedFromBase(basePoints, wallHeight);
6112
6134
  const material = new THREE.MeshStandardMaterial({
6113
6135
  color: this.color,
6114
6136
  side: THREE.DoubleSide
6115
- // roughness: this.numdu,
6116
- // metalness: 0.0,
6117
- // envMapRotation: new THREE.Euler(0, 0, 0),
6118
- // polygonOffset: true,
6119
- // polygonOffsetFactor: 10,
6120
- // polygonOffsetUnits: 10,
6121
6137
  });
6122
6138
  const cube = new THREE.Mesh(geometry, material);
6123
- const edges = new THREE.EdgesGeometry(geometry);
6124
- new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: 0 }));
6139
+ new THREE.EdgesGeometry(geometry);
6125
6140
  if (num === 0) {
6126
6141
  cube.name = `双线墙_${index2}`;
6127
6142
  cube.userData.category = "doubleWall";
@@ -6512,7 +6527,6 @@ class Scenario {
6512
6527
  menModel.name = `门_${index2}`;
6513
6528
  menModel.userData.category = "door";
6514
6529
  menModel.userData.uuid = doorList?.uuid;
6515
- console.log(doorList);
6516
6530
  menModel.userData.width = distance2;
6517
6531
  menModel.userData.height = Height ? Height : this.doorHeight;
6518
6532
  menModel.userData.groundHeight = groundHeight;
@@ -6555,9 +6569,11 @@ class Scenario {
6555
6569
  createParallelepipedFromBase(points, height) {
6556
6570
  const shape = new THREE.Shape();
6557
6571
  shape.moveTo(points[0].x, points[0].y);
6558
- shape.lineTo(points[1].x, points[1].y);
6559
- shape.lineTo(points[2].x, points[2].y);
6560
- shape.lineTo(points[3].x, points[3].y);
6572
+ for (const i in points) {
6573
+ if (i !== "0") {
6574
+ shape.lineTo(points[i].x, points[i].y);
6575
+ }
6576
+ }
6561
6577
  shape.lineTo(points[0].x, points[0].y);
6562
6578
  const geometry = new THREE.ExtrudeGeometry(shape, {
6563
6579
  depth: height,
@@ -14843,6 +14859,9 @@ const PRE_PROCESSOR = {
14843
14859
  Clipping(lines) {
14844
14860
  return lines = lineSegmentClipping(lines, 0);
14845
14861
  },
14862
+ clipDoubleWall(lines) {
14863
+ return lines;
14864
+ },
14846
14865
  RemoveShortLine(lines, option) {
14847
14866
  return lines = lines.filter((line) => line.length() > (option.minWidth ?? 1e-5));
14848
14867
  },
@@ -19040,7 +19059,8 @@ async function getFileAll(dxfSystem = gloabalDxfSystem) {
19040
19059
  const obj = new File([await whiteModel.toOBJBlob()], "model.obj", { type: "application/octet-stream" });
19041
19060
  const glb = new File([await whiteModel.toGltfBlob(true)], "model.glb", { type: "application/octet-stream" });
19042
19061
  const gltf2 = new File([await whiteModel.toGltfBlob(false)], "model.gltf", { type: "application/json" });
19043
- const json = new File([JSON.stringify(dxfSystem.Dxf.originalData)], "json.json", { type: "application/json" });
19062
+ const originalData = lineDataToOriginalData(dxfSystem.Dxf.getLineSegments(), dxfSystem.Dxf.originalZAverage);
19063
+ const json = new File([JSON.stringify(originalData)], "json.json", { type: "application/json" });
19044
19064
  return {
19045
19065
  dxf,
19046
19066
  obj,
@@ -7,7 +7,7 @@ import { Dxf } from './Dxf';
7
7
  */
8
8
  export declare class CorrectionDxf<TEventMap extends {} = {}> extends Dxf<{} & TEventMap> {
9
9
  static name: string;
10
- static readonly PRE_PROCESSOR: Record<"DoorFind" | "AxisAlignCorr" | "BoundExt" | "AngleCorr" | "ResetGeometricCenter" | "WallHeightHandle" | "Clipping" | "RemoveShortLine", (lines: import('../..').LineSegment[], option: SetDataOption, ...arg: any[]) => import('../..').LineSegment[]>;
10
+ static readonly PRE_PROCESSOR: Record<"DoorFind" | "clipDoubleWall" | "AxisAlignCorr" | "BoundExt" | "AngleCorr" | "ResetGeometricCenter" | "WallHeightHandle" | "Clipping" | "RemoveShortLine", (lines: import('../..').LineSegment[], option: SetDataOption, ...arg: any[]) => import('../..').LineSegment[]>;
11
11
  rotateCorrCad?: CAD;
12
12
  constructor();
13
13
  onAddFromParent(parent: DxfSystem): void;
@@ -5,7 +5,7 @@ import { Quadtree } from '../../Quadtree';
5
5
  import { SetDataOption, DataItem, LineUserData, OriginalDataItem, Unit } from '../type';
6
6
  import { CAD } from '../utils/CAD';
7
7
  type PreProcessor = (lines: LineSegment[], option: SetDataOption, ...arg: any[]) => LineSegment[];
8
- export declare const PRE_PROCESSOR: Record<"DoorFind" | "AxisAlignCorr" | "BoundExt" | "AngleCorr" | "ResetGeometricCenter" | "WallHeightHandle" | "Clipping" | "RemoveShortLine", PreProcessor>;
8
+ export declare const PRE_PROCESSOR: Record<"DoorFind" | "clipDoubleWall" | "AxisAlignCorr" | "BoundExt" | "AngleCorr" | "ResetGeometricCenter" | "WallHeightHandle" | "Clipping" | "RemoveShortLine", PreProcessor>;
9
9
  /**
10
10
  * 将点云结构转换为DXF格式
11
11
  */
@@ -22,7 +22,7 @@ export declare class Dxf<TEventMap extends {} = {}> extends Component<{
22
22
  };
23
23
  } & TEventMap> {
24
24
  static name: string;
25
- static readonly PRE_PROCESSOR: Record<"DoorFind" | "AxisAlignCorr" | "BoundExt" | "AngleCorr" | "ResetGeometricCenter" | "WallHeightHandle" | "Clipping" | "RemoveShortLine", PreProcessor>;
25
+ static readonly PRE_PROCESSOR: Record<"DoorFind" | "clipDoubleWall" | "AxisAlignCorr" | "BoundExt" | "AngleCorr" | "ResetGeometricCenter" | "WallHeightHandle" | "Clipping" | "RemoveShortLine", PreProcessor>;
26
26
  width: number;
27
27
  originalData: OriginalDataItem[];
28
28
  data: DataItem[];