build-dxf 0.0.9 → 0.0.11
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/README.md +21 -3
- package/package.json +16 -21
- package/src/App.vue.d.ts +2 -0
- package/src/build.d.ts +3 -0
- package/src/build.js +2023 -0
- package/src/components/Card.vue.d.ts +9 -0
- package/src/index.css +1 -0
- package/src/index.js +5 -1758
- package/src/index2.js +7367 -0
- package/src/main.d.ts +0 -0
- package/src/pages/Dxf.vue.d.ts +2 -0
- package/src/router/index.d.ts +2 -0
- package/src/utils/ComponentManager/Component.d.ts +17 -0
- package/src/utils/ComponentManager/ComponentManager.d.ts +47 -0
- package/src/utils/ComponentManager/EventDispatcher.d.ts +4 -0
- package/src/utils/ComponentManager/index.d.ts +4 -0
- package/src/utils/ComponentManager/uuid.d.ts +1 -0
- package/src/utils/DxfSystem/components/Dxf.d.ts +150 -0
- package/src/utils/DxfSystem/components/LineAnalysis.d.ts +85 -0
- package/src/utils/DxfSystem/components/Variable.d.ts +33 -0
- package/src/utils/DxfSystem/index.d.ts +16 -0
- package/src/utils/DxfSystem/plugin/ModelDataPlugin/components/DetailsPoint.d.ts +39 -0
- package/src/utils/DxfSystem/plugin/ModelDataPlugin/components/DxfLineModel.d.ts +10 -0
- package/src/utils/DxfSystem/plugin/ModelDataPlugin/components/WhiteModel.d.ts +21 -0
- package/src/utils/DxfSystem/plugin/ModelDataPlugin/components/index.d.ts +3 -0
- package/src/utils/DxfSystem/plugin/ModelDataPlugin/index.d.ts +4 -0
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/DetailsPointRender.d.ts +48 -0
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/DomContainer.d.ts +8 -0
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/DomEventRegister.d.ts +23 -0
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/ModelDataRender.d.ts +13 -0
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/OriginalLineRender.d.ts +16 -0
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/Renderer.d.ts +82 -0
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/index.d.ts +6 -0
- package/src/utils/DxfSystem/plugin/RenderPlugin/index.d.ts +5 -0
- package/src/utils/DxfSystem/plugin/RenderPlugin/pages/Dxf.vue.d.ts +21 -0
- package/src/utils/DxfSystem/plugin/index.d.ts +1 -0
- package/src/utils/Lines.d.ts +11 -0
- package/src/utils/PointVirtualGrid/index.d.ts +70 -0
- package/src/utils/Quadtree/Box2.d.ts +89 -0
- package/src/utils/Quadtree/LineSegment.d.ts +29 -0
- package/src/utils/Quadtree/Point.d.ts +113 -0
- package/src/utils/Quadtree/Quadtree.d.ts +60 -0
- package/src/utils/Quadtree/Rectangle.d.ts +40 -0
- package/src/utils/drawLinePathToPng.d.ts +7 -0
- package/src/utils/selectLocalFile.d.ts +7 -0
- package/src/index.d.ts +0 -525
- package/src/plugins/ModelDataPlugin/index.d.ts +0 -596
- package/src/plugins/ModelDataPlugin/index.js +0 -498
- package/src/plugins/RenderPlugin/index.d.ts +0 -762
- package/src/plugins/RenderPlugin/index.js +0 -19348
|
@@ -1,498 +0,0 @@
|
|
|
1
|
-
import * as THREE from "three";
|
|
2
|
-
import { EventDispatcher as EventDispatcher$1 } from "three";
|
|
3
|
-
import "clipper-lib";
|
|
4
|
-
import "dxf-writer";
|
|
5
|
-
import { OBJExporter } from "three/examples/jsm/exporters/OBJExporter.js";
|
|
6
|
-
function uuid() {
|
|
7
|
-
return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(c) {
|
|
8
|
-
var r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
9
|
-
return v.toString(16);
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
class EventDispatcher extends EventDispatcher$1 {
|
|
13
|
-
uuid = uuid();
|
|
14
|
-
}
|
|
15
|
-
class Component extends EventDispatcher {
|
|
16
|
-
parent;
|
|
17
|
-
constructor(...arg) {
|
|
18
|
-
super();
|
|
19
|
-
this.addEventListener("addFromParent", (e) => {
|
|
20
|
-
this.parent = e.parent;
|
|
21
|
-
this.onAddFromParent(e.parent);
|
|
22
|
-
});
|
|
23
|
-
this.addEventListener("removeFromParent", (e) => {
|
|
24
|
-
this.parent = void 0;
|
|
25
|
-
this.onRemoveFromParent(e.parent);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
onAddFromParent(parent) {
|
|
29
|
-
}
|
|
30
|
-
onRemoveFromParent(parent) {
|
|
31
|
-
}
|
|
32
|
-
destroy() {
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
class Point {
|
|
36
|
-
x;
|
|
37
|
-
y;
|
|
38
|
-
get X() {
|
|
39
|
-
return this.x;
|
|
40
|
-
}
|
|
41
|
-
get Y() {
|
|
42
|
-
return this.y;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
* @param x
|
|
47
|
-
* @param y
|
|
48
|
-
*/
|
|
49
|
-
constructor(x = 0, y = 0) {
|
|
50
|
-
this.x = x;
|
|
51
|
-
this.y = y;
|
|
52
|
-
}
|
|
53
|
-
set(x, y) {
|
|
54
|
-
this.x = x;
|
|
55
|
-
this.y = y;
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
setX(x) {
|
|
59
|
-
this.x = x;
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
setY(y) {
|
|
63
|
-
this.y = y;
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
68
|
-
* @param point
|
|
69
|
-
* @returns
|
|
70
|
-
*/
|
|
71
|
-
equal(point) {
|
|
72
|
-
return point.x === this.x && point.y === this.y;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
* @param arr
|
|
77
|
-
*/
|
|
78
|
-
setByArray(arr) {
|
|
79
|
-
this.x = arr[0];
|
|
80
|
-
this.y = arr[1];
|
|
81
|
-
return this;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
85
|
-
*/
|
|
86
|
-
toArray() {
|
|
87
|
-
return [this.x, this.y];
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* multiplyScalar
|
|
91
|
-
* @param scalar
|
|
92
|
-
*/
|
|
93
|
-
mutiplyScalar(scalar) {
|
|
94
|
-
this.x *= scalar;
|
|
95
|
-
this.y *= scalar;
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
multiplyScalar(scalar) {
|
|
99
|
-
this.x *= scalar;
|
|
100
|
-
this.y *= scalar;
|
|
101
|
-
return this;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* @param scalar
|
|
106
|
-
* @returns
|
|
107
|
-
*/
|
|
108
|
-
divisionScalar(scalar) {
|
|
109
|
-
this.x /= scalar;
|
|
110
|
-
this.y /= scalar;
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* 减法
|
|
115
|
-
* @description 将当前点的坐标减去指定点的坐标
|
|
116
|
-
* @param point
|
|
117
|
-
* @returns
|
|
118
|
-
*/
|
|
119
|
-
division(point) {
|
|
120
|
-
this.x -= point.x;
|
|
121
|
-
this.y -= point.y;
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* 加法
|
|
126
|
-
* @description 将当前点的坐标加上指定点的坐标
|
|
127
|
-
* @param point
|
|
128
|
-
* @returns
|
|
129
|
-
*/
|
|
130
|
-
add(point) {
|
|
131
|
-
this.x += point.x;
|
|
132
|
-
this.y += point.y;
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* 保留小数位数
|
|
137
|
-
* @param count
|
|
138
|
-
*/
|
|
139
|
-
fixed(count) {
|
|
140
|
-
this.x = Number(this.x.toFixed(count));
|
|
141
|
-
this.y = Number(this.y.toFixed(count));
|
|
142
|
-
return this;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* 归一化
|
|
146
|
-
* @description 将当前点的坐标归一化为单位向量
|
|
147
|
-
* @returns
|
|
148
|
-
*/
|
|
149
|
-
normalize() {
|
|
150
|
-
const length = Math.sqrt(this.x * this.x + this.y * this.y);
|
|
151
|
-
if (length === 0) return this;
|
|
152
|
-
this.x /= length;
|
|
153
|
-
this.y /= length;
|
|
154
|
-
return this;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* 获取单位法向量
|
|
158
|
-
* @description 计算当前点到指定点的方向向量,并返回逆时针旋转90度后的单位法向量
|
|
159
|
-
* @param point
|
|
160
|
-
* @returns
|
|
161
|
-
*/
|
|
162
|
-
normal(point) {
|
|
163
|
-
const dx = this.x - point.x;
|
|
164
|
-
const dy = this.y - point.y;
|
|
165
|
-
const length = Math.sqrt(dx * dx + dy * dy);
|
|
166
|
-
const nx = -dy / length;
|
|
167
|
-
const ny = dx / length;
|
|
168
|
-
return new Point(nx, ny);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* 获取由传入的点到该点的单位方向向量
|
|
172
|
-
* @description 计算当前点到指定点的方向向量,并返回单位方向
|
|
173
|
-
* @param point
|
|
174
|
-
* @returns
|
|
175
|
-
*/
|
|
176
|
-
direction(point) {
|
|
177
|
-
const dx = this.x - point.x;
|
|
178
|
-
const dy = this.y - point.y;
|
|
179
|
-
const length = Math.sqrt(dx * dx + dy * dy);
|
|
180
|
-
if (length === 0) return new Point(0, 0);
|
|
181
|
-
return new Point(dx / length, dy / length);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* 计算模长
|
|
185
|
-
* @returns
|
|
186
|
-
*/
|
|
187
|
-
magnitude() {
|
|
188
|
-
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* 计算点点积
|
|
192
|
-
* @param point
|
|
193
|
-
* @returns
|
|
194
|
-
*/
|
|
195
|
-
dot(point) {
|
|
196
|
-
return this.x * point.x + this.y * point.y;
|
|
197
|
-
}
|
|
198
|
-
/** 计算两个向量夹角
|
|
199
|
-
* @description 公式:a · b = |a| × |b| × cosθ
|
|
200
|
-
* @param point
|
|
201
|
-
* @returns
|
|
202
|
-
*/
|
|
203
|
-
angleBetween(point) {
|
|
204
|
-
const dotProduct = this.dot(point);
|
|
205
|
-
const magnitude1 = this.magnitude();
|
|
206
|
-
const magnitude2 = point.magnitude();
|
|
207
|
-
if (magnitude1 === 0 || magnitude2 === 0) return 0;
|
|
208
|
-
const cosTheta = dotProduct / (magnitude1 * magnitude2);
|
|
209
|
-
const clampedCosTheta = Math.max(-1, Math.min(1, cosTheta));
|
|
210
|
-
return Math.acos(clampedCosTheta);
|
|
211
|
-
}
|
|
212
|
-
/** 获取向量长度
|
|
213
|
-
*/
|
|
214
|
-
length() {
|
|
215
|
-
const magnitude = Math.sqrt(this.x * this.x + this.y * this.y);
|
|
216
|
-
if (Math.abs(magnitude - Math.round(magnitude)) < 1e-9) {
|
|
217
|
-
return Math.round(magnitude);
|
|
218
|
-
}
|
|
219
|
-
return magnitude;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* 获取两个点长度
|
|
223
|
-
* @param point
|
|
224
|
-
*/
|
|
225
|
-
distance(point) {
|
|
226
|
-
return Math.sqrt(
|
|
227
|
-
(this.x - point.x) * (this.x - point.x) + (this.y - point.y) * (this.y - point.y)
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* 克隆
|
|
232
|
-
* @returns
|
|
233
|
-
*/
|
|
234
|
-
clone() {
|
|
235
|
-
return new Point(this.x, this.y);
|
|
236
|
-
}
|
|
237
|
-
static from(arr) {
|
|
238
|
-
if (Array.isArray(arr)) {
|
|
239
|
-
return new Point(arr[0], arr[1]);
|
|
240
|
-
} else if ("x" in arr && "y" in arr) {
|
|
241
|
-
return new Point(arr.x, arr.y);
|
|
242
|
-
} else if ("X" in arr && "Y" in arr) {
|
|
243
|
-
return new Point(arr.X, arr.Y);
|
|
244
|
-
}
|
|
245
|
-
return this.zero();
|
|
246
|
-
}
|
|
247
|
-
static zero() {
|
|
248
|
-
return new Point(0, 0);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
const exporter = new OBJExporter();
|
|
252
|
-
function lineSqueezing(p1, p2, width = 0.1) {
|
|
253
|
-
const normal = p2.normal(p1);
|
|
254
|
-
const pDirect = p2.direction(p1).mutiplyScalar(width * 0.5);
|
|
255
|
-
const nDirect = p1.direction(p2).mutiplyScalar(width * 0.5);
|
|
256
|
-
const offsetX = normal.x * width * 0.5;
|
|
257
|
-
const offsetY = normal.y * width * 0.5;
|
|
258
|
-
return {
|
|
259
|
-
points: [
|
|
260
|
-
// 第一条线
|
|
261
|
-
new Point(p1.x + offsetX, p1.y + offsetY).add(nDirect),
|
|
262
|
-
new Point(p2.x + offsetX, p2.y + offsetY).add(pDirect),
|
|
263
|
-
// 第二条线
|
|
264
|
-
new Point(p1.x - offsetX, p1.y - offsetY).add(nDirect),
|
|
265
|
-
new Point(p2.x - offsetX, p2.y - offsetY).add(pDirect)
|
|
266
|
-
],
|
|
267
|
-
indices: [0, 1, 1, 3, 3, 2, 2, 0],
|
|
268
|
-
rectIndices: [0, 1, 3, 2, 0]
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
class WhiteModel extends Component {
|
|
272
|
-
Dxf = null;
|
|
273
|
-
Variable = null;
|
|
274
|
-
// dxf数据白模
|
|
275
|
-
whiteModelGroup = new THREE.Group();
|
|
276
|
-
// 原始数据白模
|
|
277
|
-
originalWhiteMode = new THREE.Group();
|
|
278
|
-
onAddFromParent(parent) {
|
|
279
|
-
this.Dxf = parent.findComponentByName("Dxf");
|
|
280
|
-
this.Variable = parent.findComponentByName("Variable");
|
|
281
|
-
this.originalWhiteMode.visible = false;
|
|
282
|
-
this.Dxf?.addEventListener("lineOffset", () => {
|
|
283
|
-
this.updateModel();
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
updateModel() {
|
|
287
|
-
this.Variable?.set("whiteModelVisible", false);
|
|
288
|
-
const dxf = this.Dxf;
|
|
289
|
-
this.originalWhiteMode.clear();
|
|
290
|
-
this.whiteModelGroup.clear();
|
|
291
|
-
this.whiteModelGroup.position.z = dxf.originalZAverage;
|
|
292
|
-
this.originalWhiteMode.position.z = dxf.originalZAverage;
|
|
293
|
-
dxf.wallsGroup.forEach((points) => {
|
|
294
|
-
const shape = new THREE.Shape();
|
|
295
|
-
points.forEach((p, i) => i === 0 ? shape.moveTo(p.x / dxf.scale, p.y / dxf.scale) : shape.lineTo(p.x / dxf.scale, p.y / dxf.scale));
|
|
296
|
-
const geometry = new THREE.ExtrudeGeometry(shape, {
|
|
297
|
-
depth: 2.8,
|
|
298
|
-
bevelSize: 0
|
|
299
|
-
});
|
|
300
|
-
const mesh = new THREE.Mesh(geometry);
|
|
301
|
-
mesh.material = new THREE.MeshStandardMaterial({ color: 16777215, transparent: true, opacity: 0.8 });
|
|
302
|
-
this.whiteModelGroup.add(mesh);
|
|
303
|
-
this.whiteModelGroup.add(
|
|
304
|
-
new THREE.LineSegments(new THREE.EdgesGeometry(geometry), new THREE.LineBasicMaterial({ color: 6710886 }))
|
|
305
|
-
);
|
|
306
|
-
});
|
|
307
|
-
const walls = dxf.originalData.map(({ start, end, insetionArr }) => {
|
|
308
|
-
const startVec3 = new Point(start.x, start.y).mutiplyScalar(dxf.scale), endVec3 = new Point(end.x, end.y).mutiplyScalar(dxf.scale), { points, indices, rectIndices } = lineSqueezing(startVec3, endVec3, dxf.width);
|
|
309
|
-
return {
|
|
310
|
-
points,
|
|
311
|
-
indices,
|
|
312
|
-
rectIndices,
|
|
313
|
-
insetions: (insetionArr ?? []).map((insetion) => insetion.index)
|
|
314
|
-
};
|
|
315
|
-
});
|
|
316
|
-
walls.forEach((wall) => {
|
|
317
|
-
const shape = new THREE.Shape();
|
|
318
|
-
wall.rectIndices.forEach((index2, i) => {
|
|
319
|
-
const p = wall.points[index2];
|
|
320
|
-
if (i === 0) shape.moveTo(p.x, p.y);
|
|
321
|
-
else shape.lineTo(p.x, p.y);
|
|
322
|
-
});
|
|
323
|
-
const geometry = new THREE.ExtrudeGeometry(shape, {
|
|
324
|
-
depth: 2.8,
|
|
325
|
-
bevelSize: 0
|
|
326
|
-
});
|
|
327
|
-
if (geometry.attributes.position.array.filter((num) => Number.isNaN(num)).length) return;
|
|
328
|
-
const mesh = new THREE.Mesh(geometry);
|
|
329
|
-
this.originalWhiteMode?.add(mesh);
|
|
330
|
-
});
|
|
331
|
-
this.dispatchEvent({
|
|
332
|
-
type: "updateModel",
|
|
333
|
-
originalWhiteMode: this.originalWhiteMode,
|
|
334
|
-
whiteModelGroup: this.whiteModelGroup
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
toOBJ() {
|
|
338
|
-
return new Promise((resolve) => {
|
|
339
|
-
resolve(exporter.parse(this.whiteModelGroup));
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
async toBlob() {
|
|
343
|
-
const buffer = await this.toOBJ();
|
|
344
|
-
if (buffer) {
|
|
345
|
-
return new Blob([buffer], { type: "application/octet-stream" });
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
async download(filename) {
|
|
349
|
-
if (typeof window !== "undefined") {
|
|
350
|
-
const blob = await this.toBlob();
|
|
351
|
-
if (!blob) return;
|
|
352
|
-
const a = document.createElement("a");
|
|
353
|
-
a.href = URL.createObjectURL(blob);
|
|
354
|
-
a.download = filename;
|
|
355
|
-
a.click();
|
|
356
|
-
} else if (typeof global !== "undefined") {
|
|
357
|
-
const buffer = await this.toOBJ();
|
|
358
|
-
if (buffer) {
|
|
359
|
-
const packageName = "fs";
|
|
360
|
-
const { default: fs } = await import(
|
|
361
|
-
/* @vite-ignore */
|
|
362
|
-
packageName
|
|
363
|
-
);
|
|
364
|
-
fs.writeFileSync(filename, buffer);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
class DetailsPoint extends Component {
|
|
370
|
-
Dxf = null;
|
|
371
|
-
WhiteModel = null;
|
|
372
|
-
Variable = null;
|
|
373
|
-
desPoints = [];
|
|
374
|
-
raylines = [];
|
|
375
|
-
data = [];
|
|
376
|
-
onAddFromParent(parent) {
|
|
377
|
-
this.Dxf = parent.findComponentByName("Dxf");
|
|
378
|
-
this.Variable = parent.findComponentByName("Variable");
|
|
379
|
-
this.Dxf?.addEventListener("setDta", () => {
|
|
380
|
-
this.updateModel();
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* 设置值
|
|
385
|
-
* @param data
|
|
386
|
-
*/
|
|
387
|
-
async set(data) {
|
|
388
|
-
if (typeof data === "string") {
|
|
389
|
-
if (typeof global !== "undefined") {
|
|
390
|
-
const packageName = "fs";
|
|
391
|
-
const { default: fs } = await import(
|
|
392
|
-
/* @vite-ignore */
|
|
393
|
-
packageName
|
|
394
|
-
);
|
|
395
|
-
const buffer = fs.readFileSync(data);
|
|
396
|
-
const json = JSON.parse(buffer.toString("utf-8"));
|
|
397
|
-
this.set(json);
|
|
398
|
-
return;
|
|
399
|
-
} else {
|
|
400
|
-
throw new Error("非node环境不允许使用路径");
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
this.data = data;
|
|
404
|
-
this.updateModel();
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* 设置射线辅助
|
|
408
|
-
*/
|
|
409
|
-
racasterHelper(position, direction, far) {
|
|
410
|
-
this.raylines.push([
|
|
411
|
-
position.clone(),
|
|
412
|
-
position.clone().add(direction.clone().multiplyScalar(far))
|
|
413
|
-
]);
|
|
414
|
-
direction.z = 0;
|
|
415
|
-
this.raylines.push([
|
|
416
|
-
position.clone(),
|
|
417
|
-
position.clone().add(direction.clone().multiplyScalar(far))
|
|
418
|
-
]);
|
|
419
|
-
}
|
|
420
|
-
_timer = null;
|
|
421
|
-
/**
|
|
422
|
-
* 更新模型
|
|
423
|
-
*/
|
|
424
|
-
updateModel() {
|
|
425
|
-
if (this._timer) clearTimeout(this._timer);
|
|
426
|
-
this._timer = setTimeout(() => {
|
|
427
|
-
this._timer = null;
|
|
428
|
-
const whiteModel = this.parent?.findComponentByName("WhiteModel");
|
|
429
|
-
this.raylines.length = 0;
|
|
430
|
-
this.desPoints.length = 0;
|
|
431
|
-
this.data.forEach((item) => {
|
|
432
|
-
const position = new THREE.Vector3(
|
|
433
|
-
item.position.x,
|
|
434
|
-
item.position.y,
|
|
435
|
-
item.position.z
|
|
436
|
-
);
|
|
437
|
-
const direction = new THREE.Vector3(
|
|
438
|
-
item.direction.x,
|
|
439
|
-
item.direction.y,
|
|
440
|
-
item.direction.z
|
|
441
|
-
);
|
|
442
|
-
const far = 100;
|
|
443
|
-
this.racasterHelper(position, direction, far);
|
|
444
|
-
direction.z = 0;
|
|
445
|
-
const raycaster = new THREE.Raycaster(position, direction, 0, far);
|
|
446
|
-
const list = raycaster.intersectObject(whiteModel.originalWhiteMode);
|
|
447
|
-
if (list.length) {
|
|
448
|
-
const { point } = list[0];
|
|
449
|
-
this.desPoints.push({
|
|
450
|
-
message: item.desc,
|
|
451
|
-
position,
|
|
452
|
-
intersection: point
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
this.dispatchEvent({
|
|
457
|
-
type: "handleSuccess",
|
|
458
|
-
desPoints: this.desPoints
|
|
459
|
-
});
|
|
460
|
-
}, 50);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
class DxfLineModel extends Component {
|
|
464
|
-
dxfLineModel = new THREE.LineSegments();
|
|
465
|
-
dxfDoorsLineModel = new THREE.LineSegments();
|
|
466
|
-
dxfModelGroup = new THREE.Group();
|
|
467
|
-
onAddFromParent(parent) {
|
|
468
|
-
const dxf = parent.findComponentByName("Dxf");
|
|
469
|
-
this.dxfModelGroup.add(this.dxfLineModel);
|
|
470
|
-
this.dxfModelGroup.add(this.dxfDoorsLineModel);
|
|
471
|
-
this.dxfDoorsLineModel.material = new THREE.LineBasicMaterial({ color: 16776960, vertexColors: true });
|
|
472
|
-
dxf?.addEventListener("lineOffset", () => this.updateMode());
|
|
473
|
-
}
|
|
474
|
-
updateMode() {
|
|
475
|
-
const dxf = this.parent?.findComponentByName("Dxf");
|
|
476
|
-
this.dxfLineModel.clear();
|
|
477
|
-
const dxfArray = dxf.to3DArray(1 / dxf.scale);
|
|
478
|
-
this.dxfLineModel.geometry = new THREE.BufferGeometry().setAttribute("position", new THREE.BufferAttribute(dxfArray, 3, true));
|
|
479
|
-
const doorsArray = new Float32Array(dxf.doors.flatMap(([p1, p2]) => [p1.x, p1.y, dxf.originalZAverage, p2.x, p2.y, dxf.originalZAverage])).map((n) => n / dxf.scale);
|
|
480
|
-
const doorsColorArray = new Float32Array(dxf.doors.flatMap(() => [1, 0, 0, 0, 1, 0]));
|
|
481
|
-
this.dxfDoorsLineModel.geometry = new THREE.BufferGeometry().setAttribute("position", new THREE.BufferAttribute(doorsArray, 3, true)).setAttribute("color", new THREE.BufferAttribute(doorsColorArray, 3));
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
485
|
-
__proto__: null,
|
|
486
|
-
DetailsPoint,
|
|
487
|
-
DxfLineModel,
|
|
488
|
-
WhiteModel
|
|
489
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
490
|
-
function ModelDataPlugin(dxfSystem) {
|
|
491
|
-
dxfSystem.addComponent(new DxfLineModel());
|
|
492
|
-
dxfSystem.addComponent(new WhiteModel());
|
|
493
|
-
dxfSystem.addComponent(new DetailsPoint());
|
|
494
|
-
}
|
|
495
|
-
export {
|
|
496
|
-
ModelDataPlugin,
|
|
497
|
-
index as components
|
|
498
|
-
};
|