build-dxf 0.1.156 → 0.1.158
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
package/src/build.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Brush, Evaluator, SUBTRACTION } from "three-bvh-csg";
|
|
|
8
8
|
import { OBJExporter } from "three/examples/jsm/exporters/OBJExporter.js";
|
|
9
9
|
const VITE_OSS_BASEURL = "https://image.cnyang.cn/common-assets/".endsWith("/") ? "https://image.cnyang.cn/common-assets/" : "https://image.cnyang.cn/common-assets//";
|
|
10
10
|
const DEFAULT_WALL_WIDTH = 0.12;
|
|
11
|
+
const MAX_WALL_WIDTH = 0.3;
|
|
11
12
|
const DEFAULT_WALL_HEIGHT = 2.8;
|
|
12
13
|
const DEFAULT_DOOR_HEIGHT = 2.1;
|
|
13
14
|
const DOUBLE_DOOR_WIDTH = 1.5;
|
|
@@ -9711,7 +9712,7 @@ class DoubleWallFinder {
|
|
|
9711
9712
|
* @returns
|
|
9712
9713
|
*/
|
|
9713
9714
|
static find(lines, obstacle = [], esp = 0.4) {
|
|
9714
|
-
lines = LineSegmentUtils.GroupBuilder(LineSegmentUtils.group(lines, (
|
|
9715
|
+
lines = LineSegmentUtils.GroupBuilder(LineSegmentUtils.group(lines, (_line) => "lines")).handle("lines", (lines2) => {
|
|
9715
9716
|
const parallelAxis = lines2[0], verticalAxis = parallelAxis.clone().rotate(Math.PI * 0.5), [group1, group2] = LineSegmentUtils.groupByParallelToAxis(lines2, lines2[0], 5), newLines1 = this.group(group1, parallelAxis, verticalAxis, esp), newLines2 = this.group(group2, verticalAxis, parallelAxis, esp), appendLines = newLines1.concat(newLines2);
|
|
9716
9717
|
lines2 = lines2.concat(appendLines);
|
|
9717
9718
|
return lines2;
|
|
@@ -10107,7 +10108,14 @@ function clippingInsertObjectDoubleWall(lines) {
|
|
|
10107
10108
|
}
|
|
10108
10109
|
if (!polygons.length) return [lines];
|
|
10109
10110
|
polygons = Polygon.booleanOp(polygons[0], polygons.slice(1), { type: "Union", scale: 1e4 });
|
|
10110
|
-
const newLines = polygons.map((poly2) => poly2.toLines()).flat().
|
|
10111
|
+
const newLines = polygons.map((poly2) => poly2.toLines()).flat().flatMap((line) => {
|
|
10112
|
+
let list = quadtree.queryRect(line.toRectangle(2e-4, "butt")).map((res) => res.line).filter((l) => l.isParallelTo(line, 10));
|
|
10113
|
+
if (list.length) {
|
|
10114
|
+
const newLines2 = LineSegmentUtils.clippingByLines(line, list);
|
|
10115
|
+
return newLines2 ?? [];
|
|
10116
|
+
}
|
|
10117
|
+
return [line];
|
|
10118
|
+
});
|
|
10111
10119
|
lines.push(...newLines);
|
|
10112
10120
|
PointUtils.adsorb(lines.flatMap((line) => line.points), 1e-4);
|
|
10113
10121
|
lines = splitIntersectedLine(lines.map((line) => line.clone()), 1e-9);
|
|
@@ -12009,7 +12017,7 @@ function correction(lines, targettLine, option) {
|
|
|
12009
12017
|
const max = Math.max(...projValues), min = Math.min(...projValues), dist = precision4((max - min) * axis.length);
|
|
12010
12018
|
if (dist < DEFAULT_WALL_WIDTH) return;
|
|
12011
12019
|
group2.forEach((line) => {
|
|
12012
|
-
line.userData.wallWidth = dist;
|
|
12020
|
+
line.userData.wallWidth = Math.min(dist, MAX_WALL_WIDTH);
|
|
12013
12021
|
});
|
|
12014
12022
|
},
|
|
12015
12023
|
onLayoutDesign(lines3, delKey) {
|
|
@@ -12096,6 +12104,7 @@ function breakpointMerging(lines) {
|
|
|
12096
12104
|
function init(lines, option) {
|
|
12097
12105
|
lines = breakpointMerging(lines);
|
|
12098
12106
|
lines = splitIntersectedLine(lines, 1e-9, { balconyRailing: { behavior: "discard", filteringRatio: 0.2 } });
|
|
12107
|
+
WallHole.merge(lines);
|
|
12099
12108
|
if (option.trajectory) {
|
|
12100
12109
|
sparse(option.trajectory, 0.2);
|
|
12101
12110
|
sparse(option.trajectory, 0.5);
|
|
@@ -13746,7 +13755,6 @@ class Scenario {
|
|
|
13746
13755
|
const edges = new THREE.EdgesGeometry(geometry);
|
|
13747
13756
|
new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: 0 }));
|
|
13748
13757
|
if (colorValue && liangOriginalData) {
|
|
13749
|
-
cube.material.color = new THREE.Color(5214420);
|
|
13750
13758
|
const point1 = new THREE.Vector3(liangOriginalData.start.x, liangOriginalData.start.y, 0);
|
|
13751
13759
|
const point2 = new THREE.Vector3(liangOriginalData.end.x, liangOriginalData.end.y, 0);
|
|
13752
13760
|
this.liangNum = this.liangNum + 1;
|
|
@@ -14745,10 +14753,11 @@ class Scenario {
|
|
|
14745
14753
|
generateBeamModel(line) {
|
|
14746
14754
|
let basePoints;
|
|
14747
14755
|
let expansionPoints;
|
|
14756
|
+
let cube;
|
|
14748
14757
|
if (!line.userData.expansionWidth && !line.userData.expansionDirction) {
|
|
14749
14758
|
let wallWidth;
|
|
14750
14759
|
if (line.userData.wallWidth) {
|
|
14751
|
-
wallWidth = line.userData.wallWidth;
|
|
14760
|
+
wallWidth = line.userData.wallWidth / 2;
|
|
14752
14761
|
} else {
|
|
14753
14762
|
wallWidth = 0.06;
|
|
14754
14763
|
}
|
|
@@ -14757,7 +14766,16 @@ class Scenario {
|
|
|
14757
14766
|
let startingPoint = this.xinLine(MobileX, MobileY, line.start, this.height ? this.height : 0);
|
|
14758
14767
|
let finishLine = this.xinLine(MobileX, MobileY, line.end, this.height ? this.height : 0);
|
|
14759
14768
|
basePoints = [startingPoint[0], startingPoint[1], finishLine[1], finishLine[0]];
|
|
14760
|
-
|
|
14769
|
+
const geometry = this.createParallelepipedFromBase(basePoints, line.userData.height);
|
|
14770
|
+
const material2 = new THREE.MeshStandardMaterial({
|
|
14771
|
+
color: 5214420,
|
|
14772
|
+
side: THREE.DoubleSide
|
|
14773
|
+
});
|
|
14774
|
+
const beamList = WallHoleDrawData.singleHoleLine(line);
|
|
14775
|
+
cube = new THREE.Mesh(geometry, material2);
|
|
14776
|
+
for (const w in beamList) {
|
|
14777
|
+
cube = this.pierceTheBeam(cube, beamList[Number(w)], wallWidth, 0);
|
|
14778
|
+
}
|
|
14761
14779
|
} else {
|
|
14762
14780
|
const directionX = line.userData.expansionDirction.x * line.userData.expansionWidth;
|
|
14763
14781
|
const directionY = line.userData.expansionDirction.y * line.userData.expansionWidth;
|
|
@@ -14766,23 +14784,42 @@ class Scenario {
|
|
|
14766
14784
|
let startExpansion = new THREE.Vector3(pointStart.x + directionX, pointStart.y + directionY, this.height ? this.height : 0);
|
|
14767
14785
|
let endExpansion = new THREE.Vector3(pointEnd.x + directionX, pointEnd.y + directionY, this.height ? this.height : 0);
|
|
14768
14786
|
basePoints = [pointStart, pointEnd, endExpansion, startExpansion];
|
|
14769
|
-
|
|
14787
|
+
const geometry = this.createParallelepipedFromBase(basePoints, line.userData.height);
|
|
14788
|
+
const material2 = new THREE.MeshStandardMaterial({
|
|
14789
|
+
color: 5214420,
|
|
14790
|
+
side: THREE.DoubleSide
|
|
14791
|
+
});
|
|
14792
|
+
const beamList = WallHoleDrawData.singleHoleLine(line);
|
|
14793
|
+
cube = new THREE.Mesh(geometry, material2);
|
|
14794
|
+
for (const w in beamList) {
|
|
14795
|
+
cube = this.pierceTheBeam(cube, beamList[Number(w)], line, 1);
|
|
14796
|
+
}
|
|
14770
14797
|
}
|
|
14771
|
-
const geometry = this.createParallelepipedFromBase(basePoints, line.userData.height);
|
|
14772
14798
|
const material = new THREE.MeshStandardMaterial({
|
|
14773
14799
|
// color: 0x4f90d4,
|
|
14774
14800
|
color: this.color,
|
|
14775
14801
|
side: THREE.DoubleSide
|
|
14776
14802
|
});
|
|
14777
|
-
const
|
|
14778
|
-
const
|
|
14803
|
+
const beamLint = WallHoleDrawData.singleHoleLine(line);
|
|
14804
|
+
const point1 = new THREE.Vector3(basePoints[0].x, basePoints[0].y, basePoints[0].z + beamLint[0].userData.height - 1e-3);
|
|
14805
|
+
const point2 = new THREE.Vector3(basePoints[1].x, basePoints[1].y, basePoints[1].z + beamLint[0].userData.height - 1e-3);
|
|
14806
|
+
const point3 = new THREE.Vector3(basePoints[2].x, basePoints[2].y, basePoints[2].z + beamLint[0].userData.height - 1e-3);
|
|
14807
|
+
const point4 = new THREE.Vector3(basePoints[3].x, basePoints[3].y, basePoints[3].z + beamLint[0].userData.height - 1e-3);
|
|
14808
|
+
expansionPoints = this.expandRectangleSimple(point1, point2, point3, point4, 1e-3);
|
|
14809
|
+
const bodyGeometry = this.createParallelepipedFromBase(expansionPoints, line.userData.height - beamLint[0].userData.height + 2e-3);
|
|
14779
14810
|
const brush1 = new Brush(cube.geometry);
|
|
14780
14811
|
brush1.updateMatrixWorld();
|
|
14781
14812
|
const brush2 = new Brush(bodyGeometry);
|
|
14782
14813
|
brush2.updateMatrixWorld();
|
|
14783
14814
|
const evaluator = new Evaluator();
|
|
14784
|
-
const
|
|
14785
|
-
|
|
14815
|
+
const wallCube = evaluator.evaluate(brush1, brush2, SUBTRACTION);
|
|
14816
|
+
wallCube.material = new THREE.MeshStandardMaterial({
|
|
14817
|
+
// color: 0x4f90d4,
|
|
14818
|
+
color: this.color,
|
|
14819
|
+
side: THREE.DoubleSide
|
|
14820
|
+
});
|
|
14821
|
+
this.group.add(wallCube);
|
|
14822
|
+
const result = new THREE.Mesh(bodyGeometry, material);
|
|
14786
14823
|
this.liangNum = this.liangNum + 1;
|
|
14787
14824
|
result.name = `梁_${this.liangNum}`;
|
|
14788
14825
|
result.userData.category = "beam";
|
|
@@ -14792,6 +14829,38 @@ class Scenario {
|
|
|
14792
14829
|
result.userData.groundHeight = line.userData.rooftopPz;
|
|
14793
14830
|
return result;
|
|
14794
14831
|
}
|
|
14832
|
+
pierceTheBeam(model, line, wall, num) {
|
|
14833
|
+
if (num) {
|
|
14834
|
+
const brush1 = new Brush(model.geometry);
|
|
14835
|
+
const directionX = wall.userData.expansionDirction.x * wall.userData.expansionWidth;
|
|
14836
|
+
const directionY = wall.userData.expansionDirction.y * wall.userData.expansionWidth;
|
|
14837
|
+
let pointStart = new THREE.Vector3(line.start.x, line.start.y, this.height ? this.height : 0);
|
|
14838
|
+
let pointEnd = new THREE.Vector3(line.end.x, line.end.y, this.height ? this.height : 0);
|
|
14839
|
+
let startExpansion = new THREE.Vector3(pointStart.x + directionX, pointStart.y + directionY, this.height ? this.height : 0);
|
|
14840
|
+
let endExpansion = new THREE.Vector3(pointEnd.x + directionX, pointEnd.y + directionY, this.height ? this.height : 0);
|
|
14841
|
+
const expansionPoints = this.expandRectangleSimple(pointStart, pointEnd, endExpansion, startExpansion, 0.01);
|
|
14842
|
+
const bodyGeometry = this.createParallelepipedFromBase(expansionPoints, line.userData.height);
|
|
14843
|
+
const brush2 = new Brush(bodyGeometry);
|
|
14844
|
+
brush2.updateMatrixWorld();
|
|
14845
|
+
const evaluator = new Evaluator();
|
|
14846
|
+
const result = evaluator.evaluate(brush1, brush2, SUBTRACTION);
|
|
14847
|
+
return result;
|
|
14848
|
+
} else {
|
|
14849
|
+
const brush1 = new Brush(model.geometry);
|
|
14850
|
+
brush1.updateMatrixWorld();
|
|
14851
|
+
const MobileX = this.angleToXAxisDegrees(line.start.x, line.start.y, line.end.x, line.end.y, wall, true);
|
|
14852
|
+
const MobileY = this.angleToXAxisDegrees(line.start.x, line.start.y, line.end.x, line.end.y, wall, false);
|
|
14853
|
+
let startingPoint = this.xinLine(MobileX, MobileY, line.start, this.height ? this.height : 0);
|
|
14854
|
+
let finishLine = this.xinLine(MobileX, MobileY, line.end, this.height ? this.height : 0);
|
|
14855
|
+
const expansionPoints = this.expandRectangleSimple(startingPoint[0], startingPoint[1], finishLine[1], finishLine[0], 0.01);
|
|
14856
|
+
const bodyGeometry = this.createParallelepipedFromBase(expansionPoints, line.userData.height);
|
|
14857
|
+
const brush2 = new Brush(bodyGeometry);
|
|
14858
|
+
brush2.updateMatrixWorld();
|
|
14859
|
+
const evaluator = new Evaluator();
|
|
14860
|
+
const result = evaluator.evaluate(brush1, brush2, SUBTRACTION);
|
|
14861
|
+
return result;
|
|
14862
|
+
}
|
|
14863
|
+
}
|
|
14795
14864
|
// 生成柱模型
|
|
14796
14865
|
generateColumnModel(data, lines, Height) {
|
|
14797
14866
|
let basePoints = [];
|
|
@@ -23000,13 +23069,14 @@ function findRooms(lines, trajectory2) {
|
|
|
23000
23069
|
}
|
|
23001
23070
|
function removeRoomSundries(lines, { trajectory: trajectory2 }) {
|
|
23002
23071
|
if (trajectory2) {
|
|
23003
|
-
const
|
|
23004
|
-
|
|
23005
|
-
const removeLines = ls2.filter((line) => {
|
|
23072
|
+
const rooms = findRooms(lines, trajectory2), counterMap = new CounterMap();
|
|
23073
|
+
findDiscretePoint(lines).forEach((l) => counterMap.increment(l));
|
|
23074
|
+
const ls2 = counterMap.getByCount(2), removeLines = ls2.filter((line) => {
|
|
23006
23075
|
const center = line.center;
|
|
23007
|
-
return !!rooms.find((room) =>
|
|
23008
|
-
|
|
23009
|
-
|
|
23076
|
+
return !!rooms.find((room) => {
|
|
23077
|
+
return room.ploy.pointWithin(center) && !room.lines.find((l) => l == line);
|
|
23078
|
+
});
|
|
23079
|
+
}), set2 = new Set(removeLines);
|
|
23010
23080
|
lines = lines.filter((line) => !set2.has(line));
|
|
23011
23081
|
}
|
|
23012
23082
|
return lines;
|
package/src/constants.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const API_BASE_URL = "";
|
|
2
2
|
export declare const VITE_OSS_BASEURL: any;
|
|
3
3
|
export declare const DEFAULT_WALL_WIDTH = 0.12;
|
|
4
|
+
export declare const MAX_WALL_WIDTH = 0.3;
|
|
4
5
|
export declare const DEFAULT_WALL_HEIGHT = 2.8;
|
|
5
6
|
export declare const DOUBLE_WALL_FIND_WIDTH = 0.4;
|
|
6
7
|
export declare const DEFAULT_DOOR_HEIGHT = 2.1;
|
|
@@ -85,7 +85,7 @@ export declare class WallHole {
|
|
|
85
85
|
* @param line
|
|
86
86
|
* @returns
|
|
87
87
|
*/
|
|
88
|
-
static getMinWidth(key: HoleStorageType, type?: HoleType): 0.
|
|
88
|
+
static getMinWidth(key: HoleStorageType, type?: HoleType): 0.3 | 0.2 | 0.05 | 0.35;
|
|
89
89
|
/** 清理孔洞
|
|
90
90
|
* @param target
|
|
91
91
|
* @param key
|
|
@@ -80,7 +80,8 @@ export default class Scenario {
|
|
|
80
80
|
overhangWallOffset(data: any, index: string, height: number): THREE.Mesh<THREE.ExtrudeGeometry, THREE.MeshStandardMaterial, THREE.Object3DEventMap> | null;
|
|
81
81
|
dashedLineCeilingTreatment(data: any, index: number | string, item: any): THREE.Mesh<THREE.ExtrudeGeometry, THREE.MeshStandardMaterial, THREE.Object3DEventMap> | null;
|
|
82
82
|
overallTreatmentOfSingleLineWalls(data: any): void;
|
|
83
|
-
generateBeamModel(line: any):
|
|
83
|
+
generateBeamModel(line: any): THREE.Mesh<THREE.ExtrudeGeometry, THREE.MeshStandardMaterial, THREE.Object3DEventMap>;
|
|
84
|
+
pierceTheBeam(model: any, line: LineSegment, wall: any, num: number): Brush;
|
|
84
85
|
generateColumnModel(data: any, lines: any, Height: number): THREE.Mesh<THREE.ExtrudeGeometry, THREE.MeshStandardMaterial, THREE.Object3DEventMap> | null;
|
|
85
86
|
addThePassModel(line: LineSegment): void;
|
|
86
87
|
createAPlane(lines: LineSegment<Record<string, any>>[], menList: LineSegment<Record<string, any>>[]): void;
|