build-dxf 0.0.19-9 → 0.0.20-1
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 +1 -1
- package/src/build.d.ts +7 -5
- package/src/build.js +54 -31
- package/src/index.css +375 -515
- package/src/index3.js +742 -392
- package/src/pages/Editor.vue.d.ts +3 -1
- package/src/utils/ComponentManager/Component.d.ts +1 -0
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/CommandFlowComponent.d.ts +9 -2
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/Default.d.ts +7 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawLine.d.ts +2 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/DrawWindow.d.ts +2 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/PointDrag.d.ts +2 -1
- package/src/utils/DxfSystem/plugin/Editor/components/Editor.d.ts +7 -0
- package/src/utils/DxfSystem/plugin/Editor/index.d.ts +8 -1
- package/src/utils/DxfSystem/plugin/Editor/pages/EditorTool.vue.d.ts +1 -0
- package/src/utils/Quadtree/LineSegment.d.ts +1 -1
- package/src/components/Editor.vue.d.ts +0 -26
- package/src/pages/Editor02.vue.d.ts +0 -4
package/package.json
CHANGED
package/src/build.d.ts
CHANGED
|
@@ -7,25 +7,27 @@ export * from './utils/DxfSystem/plugin/ModelDataPlugin';
|
|
|
7
7
|
* @param camera
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
export declare function createEditor(dom: HTMLDivElement, camera?: THREE.Camera, orbitControls?: boolean): Promise<{
|
|
10
|
+
export declare function createEditor(dom: HTMLDivElement, camera?: THREE.Camera, orbitControls?: boolean, viewPermission?: 'admin'): Promise<{
|
|
11
11
|
dxfSystem: DxfSystem;
|
|
12
|
-
getFileAll: () => {
|
|
12
|
+
getFileAll: () => Promise<{
|
|
13
13
|
dxf: File;
|
|
14
14
|
obj: File;
|
|
15
15
|
glb: File;
|
|
16
16
|
gltf: File;
|
|
17
|
-
|
|
17
|
+
json: File;
|
|
18
|
+
}>;
|
|
18
19
|
}>;
|
|
19
20
|
/**
|
|
20
21
|
* 获取所有文件数据
|
|
21
22
|
* @param dxfSystem
|
|
22
23
|
*/
|
|
23
|
-
export declare function getFileAll(dxfSystem?: DxfSystem): {
|
|
24
|
+
export declare function getFileAll(dxfSystem?: DxfSystem): Promise<{
|
|
24
25
|
dxf: File;
|
|
25
26
|
obj: File;
|
|
26
27
|
glb: File;
|
|
27
28
|
gltf: File;
|
|
28
|
-
|
|
29
|
+
json: File;
|
|
30
|
+
}>;
|
|
29
31
|
/** 获取全局DxfSystem
|
|
30
32
|
* @returns
|
|
31
33
|
*/
|
package/src/build.js
CHANGED
|
@@ -44,6 +44,7 @@ class EventDispatcher extends EventDispatcher$1 {
|
|
|
44
44
|
}
|
|
45
45
|
class Component extends EventDispatcher {
|
|
46
46
|
parent;
|
|
47
|
+
destroyed = false;
|
|
47
48
|
constructor(...arg) {
|
|
48
49
|
super();
|
|
49
50
|
this.addEventListener("addFromParent", (e) => {
|
|
@@ -60,6 +61,7 @@ class Component extends EventDispatcher {
|
|
|
60
61
|
onRemoveFromParent(parent) {
|
|
61
62
|
}
|
|
62
63
|
destroy() {
|
|
64
|
+
this.destroyed = true;
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
class ComponentManager extends EventDispatcher {
|
|
@@ -1025,7 +1027,7 @@ class LineSegment {
|
|
|
1025
1027
|
return projP1;
|
|
1026
1028
|
}
|
|
1027
1029
|
/**
|
|
1028
|
-
*
|
|
1030
|
+
* 判断线段是否与另一条线段相交(包含共用端点或部分重合的情况)
|
|
1029
1031
|
* @param line
|
|
1030
1032
|
*/
|
|
1031
1033
|
intersectLineSegment(line) {
|
|
@@ -1033,14 +1035,32 @@ class LineSegment {
|
|
|
1033
1035
|
const p2 = this.end;
|
|
1034
1036
|
const p3 = line.start;
|
|
1035
1037
|
const p4 = line.end;
|
|
1036
|
-
function crossProduct(
|
|
1037
|
-
return (
|
|
1038
|
+
function crossProduct(a, b, c) {
|
|
1039
|
+
return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
|
1040
|
+
}
|
|
1041
|
+
function isPointOnSegment(pt, segStart, segEnd) {
|
|
1042
|
+
return Math.min(segStart.x, segEnd.x) - 1e-10 <= pt.x && pt.x <= Math.max(segStart.x, segEnd.x) + 1e-10 && Math.min(segStart.y, segEnd.y) - 1e-10 <= pt.y && pt.y <= Math.max(segStart.y, segEnd.y) + 1e-10;
|
|
1038
1043
|
}
|
|
1039
1044
|
const d1 = crossProduct(p1, p2, p3);
|
|
1040
1045
|
const d2 = crossProduct(p1, p2, p4);
|
|
1041
1046
|
const d3 = crossProduct(p3, p4, p1);
|
|
1042
1047
|
const d4 = crossProduct(p3, p4, p2);
|
|
1043
|
-
|
|
1048
|
+
if (d1 * d2 < 0 && d3 * d4 < 0) {
|
|
1049
|
+
return true;
|
|
1050
|
+
}
|
|
1051
|
+
if (Math.abs(d1) < 1e-10 && isPointOnSegment(p3, p1, p2)) {
|
|
1052
|
+
return true;
|
|
1053
|
+
}
|
|
1054
|
+
if (Math.abs(d2) < 1e-10 && isPointOnSegment(p4, p1, p2)) {
|
|
1055
|
+
return true;
|
|
1056
|
+
}
|
|
1057
|
+
if (Math.abs(d3) < 1e-10 && isPointOnSegment(p1, p3, p4)) {
|
|
1058
|
+
return true;
|
|
1059
|
+
}
|
|
1060
|
+
if (Math.abs(d4) < 1e-10 && isPointOnSegment(p2, p3, p4)) {
|
|
1061
|
+
return true;
|
|
1062
|
+
}
|
|
1063
|
+
return false;
|
|
1044
1064
|
}
|
|
1045
1065
|
/**
|
|
1046
1066
|
* 获取交点
|
|
@@ -1455,7 +1475,7 @@ class Dxf extends Component {
|
|
|
1455
1475
|
filterLines.push(line2);
|
|
1456
1476
|
} else filterLines.push(line);
|
|
1457
1477
|
}
|
|
1458
|
-
return filterLines.length >
|
|
1478
|
+
return filterLines.length > 2 ? linesToPath(this.mergeSameDirectionLine(filterLines)) : [];
|
|
1459
1479
|
}
|
|
1460
1480
|
/**
|
|
1461
1481
|
* 移除短线段
|
|
@@ -1478,26 +1498,25 @@ class Dxf extends Component {
|
|
|
1478
1498
|
nextline = lines[++i];
|
|
1479
1499
|
} else break;
|
|
1480
1500
|
}
|
|
1481
|
-
if (nextline)
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
}
|
|
1494
|
-
} else {
|
|
1495
|
-
preLine.points[1].copy(nextline.points[0]);
|
|
1501
|
+
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);
|
|
1496
1513
|
}
|
|
1497
|
-
|
|
1514
|
+
} else {
|
|
1515
|
+
preLine.points[1].copy(nextline.points[0]);
|
|
1498
1516
|
}
|
|
1517
|
+
filterLines.push(nextline);
|
|
1499
1518
|
}
|
|
1500
|
-
return filterLines.length >
|
|
1519
|
+
return filterLines.length > 2 ? linesToPath(filterLines) : [];
|
|
1501
1520
|
}
|
|
1502
1521
|
/** 线偏移
|
|
1503
1522
|
* @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
|
|
@@ -2704,10 +2723,12 @@ class DxfSystem extends ComponentManager {
|
|
|
2704
2723
|
return this;
|
|
2705
2724
|
}
|
|
2706
2725
|
destroy() {
|
|
2707
|
-
this.components.forEach((com) => {
|
|
2708
|
-
this.removeComponent(com);
|
|
2726
|
+
[...this.components].forEach((com) => {
|
|
2709
2727
|
com.destroy();
|
|
2710
2728
|
});
|
|
2729
|
+
[...this.components].forEach((com) => {
|
|
2730
|
+
this.removeComponent(com);
|
|
2731
|
+
});
|
|
2711
2732
|
}
|
|
2712
2733
|
}
|
|
2713
2734
|
const exporter = new OBJExporter();
|
|
@@ -3077,7 +3098,7 @@ function loadEditorPlugin() {
|
|
|
3077
3098
|
return import("./index3.js");
|
|
3078
3099
|
}
|
|
3079
3100
|
let gloabalDxfSystem = null;
|
|
3080
|
-
async function createEditor(dom, camera, orbitControls = false) {
|
|
3101
|
+
async function createEditor(dom, camera, orbitControls = false, viewPermission) {
|
|
3081
3102
|
const mp = await Promise.resolve().then(() => index);
|
|
3082
3103
|
const rp = await loadRenderPlugin();
|
|
3083
3104
|
const editor = await loadEditorPlugin();
|
|
@@ -3090,7 +3111,7 @@ async function createEditor(dom, camera, orbitControls = false) {
|
|
|
3090
3111
|
detailsPoint: false,
|
|
3091
3112
|
orbitControls,
|
|
3092
3113
|
camera
|
|
3093
|
-
})).usePlugin(editor.Editor);
|
|
3114
|
+
})).usePlugin(editor.Editor.create({ viewPermission }));
|
|
3094
3115
|
const domContainer = dxfSystem.findComponentByType(rp.components.DomContainer);
|
|
3095
3116
|
domContainer && dom.appendChild(domContainer.domElement);
|
|
3096
3117
|
gloabalDxfSystem = dxfSystem;
|
|
@@ -3099,17 +3120,19 @@ async function createEditor(dom, camera, orbitControls = false) {
|
|
|
3099
3120
|
getFileAll: () => getFileAll(dxfSystem)
|
|
3100
3121
|
};
|
|
3101
3122
|
}
|
|
3102
|
-
function getFileAll(dxfSystem = gloabalDxfSystem) {
|
|
3123
|
+
async function getFileAll(dxfSystem = gloabalDxfSystem) {
|
|
3103
3124
|
const whiteModel = dxfSystem.findComponentByName("WhiteModel");
|
|
3104
3125
|
const dxf = new File([dxfSystem.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" });
|
|
3105
|
-
const obj = new File([whiteModel.toOBJBlob()], "model.obj", { type: "application/octet-stream" });
|
|
3106
|
-
const glb = new File([whiteModel.toGltfBlob(true)], "model.glb", { type: "application/octet-stream" });
|
|
3107
|
-
const gltf = new File([whiteModel.toGltfBlob(false)], "model.gltf", { type: "application/json" });
|
|
3126
|
+
const obj = new File([await whiteModel.toOBJBlob()], "model.obj", { type: "application/octet-stream" });
|
|
3127
|
+
const glb = new File([await whiteModel.toGltfBlob(true)], "model.glb", { type: "application/octet-stream" });
|
|
3128
|
+
const gltf = new File([await whiteModel.toGltfBlob(false)], "model.gltf", { type: "application/json" });
|
|
3129
|
+
const json = new File([JSON.stringify(dxfSystem.Dxf.originalData)], "json.json", { type: "application/json" });
|
|
3108
3130
|
return {
|
|
3109
3131
|
dxf,
|
|
3110
3132
|
obj,
|
|
3111
3133
|
glb,
|
|
3112
|
-
gltf
|
|
3134
|
+
gltf,
|
|
3135
|
+
json
|
|
3113
3136
|
};
|
|
3114
3137
|
}
|
|
3115
3138
|
function getGlobalDxfSystem() {
|