build-dxf 0.0.19-8 → 0.0.19-9
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/index.css +110 -0
- package/src/index2.js +2 -402
- package/src/index3.js +153 -55
- package/src/selectLocalFile.js +443 -21
- package/src/utils/DxfSystem/plugin/Editor/pages/EditorTool.vue.d.ts +4 -1
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/DomEventRegister.d.ts +5 -2
package/package.json
CHANGED
package/src/index.css
CHANGED
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
--spacing: .25rem;
|
|
32
32
|
--font-weight-bold: 700;
|
|
33
33
|
--radius-lg: .5rem;
|
|
34
|
+
--default-transition-duration: .15s;
|
|
35
|
+
--default-transition-timing-function: cubic-bezier(.4, 0, .2, 1);
|
|
34
36
|
--default-font-family: var(--font-sans);
|
|
35
37
|
--default-mono-font-family: var(--font-mono);
|
|
36
38
|
}
|
|
@@ -322,6 +324,10 @@
|
|
|
322
324
|
top: 50px;
|
|
323
325
|
}
|
|
324
326
|
|
|
327
|
+
.bottom-\[10px\] {
|
|
328
|
+
bottom: 10px;
|
|
329
|
+
}
|
|
330
|
+
|
|
325
331
|
.left-0 {
|
|
326
332
|
left: calc(var(--spacing) * 0);
|
|
327
333
|
}
|
|
@@ -372,6 +378,10 @@
|
|
|
372
378
|
}
|
|
373
379
|
}
|
|
374
380
|
|
|
381
|
+
.m-\[0px_5px\] {
|
|
382
|
+
margin: 0 5px;
|
|
383
|
+
}
|
|
384
|
+
|
|
375
385
|
.mt-\[5px\] {
|
|
376
386
|
margin-top: 5px;
|
|
377
387
|
}
|
|
@@ -380,10 +390,18 @@
|
|
|
380
390
|
margin-top: 10px;
|
|
381
391
|
}
|
|
382
392
|
|
|
393
|
+
.mr-\[10px\] {
|
|
394
|
+
margin-right: 10px;
|
|
395
|
+
}
|
|
396
|
+
|
|
383
397
|
.ml-\[1\.4em\] {
|
|
384
398
|
margin-left: 1.4em;
|
|
385
399
|
}
|
|
386
400
|
|
|
401
|
+
.ml-\[10px\] {
|
|
402
|
+
margin-left: 10px;
|
|
403
|
+
}
|
|
404
|
+
|
|
387
405
|
.box-border {
|
|
388
406
|
box-sizing: border-box;
|
|
389
407
|
}
|
|
@@ -418,6 +436,10 @@
|
|
|
418
436
|
height: 6px;
|
|
419
437
|
}
|
|
420
438
|
|
|
439
|
+
.h-\[20px\] {
|
|
440
|
+
height: 20px;
|
|
441
|
+
}
|
|
442
|
+
|
|
421
443
|
.h-\[100vh\] {
|
|
422
444
|
height: 100vh;
|
|
423
445
|
}
|
|
@@ -426,6 +448,14 @@
|
|
|
426
448
|
height: fit-content;
|
|
427
449
|
}
|
|
428
450
|
|
|
451
|
+
.h-full {
|
|
452
|
+
height: 100%;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.w-\[20px\] {
|
|
456
|
+
width: 20px;
|
|
457
|
+
}
|
|
458
|
+
|
|
429
459
|
.w-\[100vw\] {
|
|
430
460
|
width: 100vw;
|
|
431
461
|
}
|
|
@@ -446,6 +476,14 @@
|
|
|
446
476
|
min-width: 100px;
|
|
447
477
|
}
|
|
448
478
|
|
|
479
|
+
.min-w-\[140px\] {
|
|
480
|
+
min-width: 140px;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
.min-w-\[150px\] {
|
|
484
|
+
min-width: 150px;
|
|
485
|
+
}
|
|
486
|
+
|
|
449
487
|
.cursor-pointer {
|
|
450
488
|
cursor: pointer;
|
|
451
489
|
}
|
|
@@ -454,6 +492,10 @@
|
|
|
454
492
|
resize: both;
|
|
455
493
|
}
|
|
456
494
|
|
|
495
|
+
.flex-col {
|
|
496
|
+
flex-direction: column;
|
|
497
|
+
}
|
|
498
|
+
|
|
457
499
|
.flex-row {
|
|
458
500
|
flex-direction: row;
|
|
459
501
|
}
|
|
@@ -474,6 +516,14 @@
|
|
|
474
516
|
gap: 5px;
|
|
475
517
|
}
|
|
476
518
|
|
|
519
|
+
.gap-\[10px\] {
|
|
520
|
+
gap: 10px;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.overflow-hidden {
|
|
524
|
+
overflow: hidden;
|
|
525
|
+
}
|
|
526
|
+
|
|
477
527
|
.rounded-\[6px\] {
|
|
478
528
|
border-radius: 6px;
|
|
479
529
|
}
|
|
@@ -499,6 +549,23 @@
|
|
|
499
549
|
border-width: 1px;
|
|
500
550
|
}
|
|
501
551
|
|
|
552
|
+
.border-b-1 {
|
|
553
|
+
border-bottom-style: var(--tw-border-style);
|
|
554
|
+
border-bottom-width: 1px;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.border-b-\[\#eee\] {
|
|
558
|
+
border-bottom-color: #eee;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.border-b-\[rgba\(255\,255\,255\,0\.1\)\] {
|
|
562
|
+
border-bottom-color: #ffffff1a;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.bg-\[\#f0f0f0\] {
|
|
566
|
+
background-color: #f0f0f0;
|
|
567
|
+
}
|
|
568
|
+
|
|
502
569
|
.bg-\[rgba\(255\,255\,255\,1\)\] {
|
|
503
570
|
background-color: #fff;
|
|
504
571
|
}
|
|
@@ -511,6 +578,16 @@
|
|
|
511
578
|
background-color: var(--color-black);
|
|
512
579
|
}
|
|
513
580
|
|
|
581
|
+
.bg-black\/15 {
|
|
582
|
+
background-color: #00000026;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
586
|
+
.bg-black\/15 {
|
|
587
|
+
background-color: color-mix(in oklab, var(--color-black) 15%, transparent);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
514
591
|
.bg-white {
|
|
515
592
|
background-color: var(--color-white);
|
|
516
593
|
}
|
|
@@ -519,10 +596,18 @@
|
|
|
519
596
|
padding: 0 10px;
|
|
520
597
|
}
|
|
521
598
|
|
|
599
|
+
.p-\[2px_0px\] {
|
|
600
|
+
padding: 2px 0;
|
|
601
|
+
}
|
|
602
|
+
|
|
522
603
|
.p-\[5px\] {
|
|
523
604
|
padding: 5px;
|
|
524
605
|
}
|
|
525
606
|
|
|
607
|
+
.p-\[5px_0px\] {
|
|
608
|
+
padding: 5px 0;
|
|
609
|
+
}
|
|
610
|
+
|
|
526
611
|
.p-\[5px_20px\] {
|
|
527
612
|
padding: 5px 20px;
|
|
528
613
|
}
|
|
@@ -553,6 +638,14 @@
|
|
|
553
638
|
font-weight: var(--font-weight-bold);
|
|
554
639
|
}
|
|
555
640
|
|
|
641
|
+
.text-\[\#333\] {
|
|
642
|
+
color: #333;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
.text-\[\#888\] {
|
|
646
|
+
color: #888;
|
|
647
|
+
}
|
|
648
|
+
|
|
556
649
|
.text-\[\#c9c9c9\] {
|
|
557
650
|
color: #c9c9c9;
|
|
558
651
|
}
|
|
@@ -566,10 +659,27 @@
|
|
|
566
659
|
filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );
|
|
567
660
|
}
|
|
568
661
|
|
|
662
|
+
.transition-all {
|
|
663
|
+
transition-property: all;
|
|
664
|
+
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
|
665
|
+
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
|
666
|
+
}
|
|
667
|
+
|
|
569
668
|
.select-none {
|
|
570
669
|
-webkit-user-select: none;
|
|
571
670
|
user-select: none;
|
|
572
671
|
}
|
|
672
|
+
|
|
673
|
+
.last-of-type\:border-b-0:last-of-type {
|
|
674
|
+
border-bottom-style: var(--tw-border-style);
|
|
675
|
+
border-bottom-width: 0;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
@media (hover: hover) {
|
|
679
|
+
.hover\:bg-\[\#ddd\]:hover {
|
|
680
|
+
background-color: #ddd;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
573
683
|
}
|
|
574
684
|
|
|
575
685
|
@property --tw-border-style {
|
package/src/index2.js
CHANGED
|
@@ -1,208 +1,10 @@
|
|
|
1
1
|
import { C as Component, P as Point, V as Variable, D as DxfSystem, M as ModelDataPlugin, a as DetailsPoint, W as WhiteModel } from "./build.js";
|
|
2
2
|
import * as THREE from "three";
|
|
3
|
-
import { Group
|
|
3
|
+
import { Group } from "three";
|
|
4
4
|
import "clipper-lib";
|
|
5
5
|
import "dxf-writer";
|
|
6
|
-
import {
|
|
7
|
-
import { CSS2DObject, CSS2DRenderer } from "three/addons/renderers/CSS2DRenderer.js";
|
|
8
|
-
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
|
9
|
-
import * as TWEEN from "@tweenjs/tween.js";
|
|
6
|
+
import { E as ElButton, R as Renderer, L as Lines, D as DomEventRegister, a as DomContainer, b as ElCheckbox, S as SelectLocalFile } from "./selectLocalFile.js";
|
|
10
7
|
import { defineComponent, createElementBlock, openBlock, createElementVNode, toDisplayString, createVNode, unref, withCtx, createTextVNode, createApp, ref, watch, onMounted, onUnmounted, createCommentVNode, createStaticVNode } from "vue";
|
|
11
|
-
import { E as ElButton, L as Lines, a as ElCheckbox, S as SelectLocalFile } from "./selectLocalFile.js";
|
|
12
|
-
THREE.Object3D.DEFAULT_UP = new THREE.Vector3(0, 0, 1);
|
|
13
|
-
class Renderer extends Component {
|
|
14
|
-
static name = "Renderer";
|
|
15
|
-
static CSS2DObject = CSS2DObject;
|
|
16
|
-
static CSS3DObject = CSS3DObject;
|
|
17
|
-
static CSS3DSprite = CSS3DSprite;
|
|
18
|
-
static Group = THREE.Group;
|
|
19
|
-
static Object3D = THREE.Object3D;
|
|
20
|
-
static Mesh = THREE.Mesh;
|
|
21
|
-
static Line = THREE.Line;
|
|
22
|
-
static LineSegments = THREE.LineSegments;
|
|
23
|
-
static Points = THREE.Points;
|
|
24
|
-
scene;
|
|
25
|
-
camera;
|
|
26
|
-
renderer;
|
|
27
|
-
orbitControls;
|
|
28
|
-
resizeObserver;
|
|
29
|
-
description;
|
|
30
|
-
html2DRenderer;
|
|
31
|
-
html3DRenderer;
|
|
32
|
-
container = new THREE.Group();
|
|
33
|
-
onUpdate;
|
|
34
|
-
onResize;
|
|
35
|
-
tweenTaskList = [];
|
|
36
|
-
constructor(description) {
|
|
37
|
-
super();
|
|
38
|
-
this.description = description;
|
|
39
|
-
const {
|
|
40
|
-
scene = new THREE.Scene(),
|
|
41
|
-
camera = new THREE.PerspectiveCamera(45, 1, 0.01, 1e3)
|
|
42
|
-
} = description;
|
|
43
|
-
this.camera = camera;
|
|
44
|
-
this.scene = scene;
|
|
45
|
-
scene.add(this.container);
|
|
46
|
-
this.renderer = new THREE.WebGLRenderer({
|
|
47
|
-
canvas: this.description.canvas,
|
|
48
|
-
antialias: true
|
|
49
|
-
});
|
|
50
|
-
this.renderer.setPixelRatio(window.devicePixelRatio);
|
|
51
|
-
if (description.htmlRenderer) {
|
|
52
|
-
if (description.htmlRenderer["2d"]) {
|
|
53
|
-
this.html2DRenderer = new CSS2DRenderer();
|
|
54
|
-
Object.assign(this.html2DRenderer.domElement.style, { position: "absolute", left: "0px", top: "0px" });
|
|
55
|
-
description.htmlRenderer["2d"].appendChild(this.html2DRenderer.domElement);
|
|
56
|
-
}
|
|
57
|
-
if (description.htmlRenderer["3d"]) {
|
|
58
|
-
this.html3DRenderer = new CSS3DRenderer();
|
|
59
|
-
Object.assign(this.html3DRenderer.domElement.style, { position: "absolute", left: "0px", top: "0px" });
|
|
60
|
-
description.htmlRenderer["3d"].appendChild(this.html3DRenderer.domElement);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (description.orbitControls) {
|
|
64
|
-
this.orbitControls = new OrbitControls(this.camera, description.orbitControls.domElement);
|
|
65
|
-
Object.assign(this.orbitControls, description.orbitControls);
|
|
66
|
-
}
|
|
67
|
-
if (this.description.resizeObserver) {
|
|
68
|
-
const dom = this.description.resizeObserver;
|
|
69
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
70
|
-
const camera2 = this.camera;
|
|
71
|
-
const { width, height } = dom.getBoundingClientRect();
|
|
72
|
-
this.renderer.setSize(width, height);
|
|
73
|
-
if (this.html2DRenderer) this.html2DRenderer.setSize(width, height);
|
|
74
|
-
if (this.html3DRenderer) this.html3DRenderer.setSize(width, height);
|
|
75
|
-
if (camera2 instanceof THREE.PerspectiveCamera) {
|
|
76
|
-
camera2.aspect = width / height;
|
|
77
|
-
} else if (camera2 instanceof THREE.OrthographicCamera) {
|
|
78
|
-
camera2.left = -width * 0.5;
|
|
79
|
-
camera2.right = width * 0.5;
|
|
80
|
-
camera2.top = height * 0.5;
|
|
81
|
-
camera2.bottom = -height * 0.5;
|
|
82
|
-
}
|
|
83
|
-
camera2.updateProjectionMatrix();
|
|
84
|
-
this.onResize && this.onResize(width, height);
|
|
85
|
-
this.dispatchEvent({ type: "resize", width, height });
|
|
86
|
-
});
|
|
87
|
-
this.resizeObserver.observe(dom);
|
|
88
|
-
}
|
|
89
|
-
this.renderer.setAnimationLoop(() => {
|
|
90
|
-
if (this.html2DRenderer) this.html2DRenderer.render(this.scene, this.camera);
|
|
91
|
-
if (this.html3DRenderer) this.html3DRenderer.render(this.scene, this.camera);
|
|
92
|
-
this.renderer.render(this.scene, this.camera);
|
|
93
|
-
if (this.orbitControls && this.orbitControls.enabled) this.orbitControls.update();
|
|
94
|
-
this.tweenTaskList.forEach((tween) => tween.update());
|
|
95
|
-
this.onUpdate && this.onUpdate();
|
|
96
|
-
this.parent?.components.forEach((c) => c.dispatchEvent({ type: "update" }));
|
|
97
|
-
});
|
|
98
|
-
this.scene.add(new THREE.AmbientLight(16777215, 0.5));
|
|
99
|
-
this.scene.background = new THREE.Color(3355443);
|
|
100
|
-
const directLight = new THREE.DirectionalLight(16777215, 4);
|
|
101
|
-
directLight.position.set(100, -100, 100);
|
|
102
|
-
this.scene.add(directLight);
|
|
103
|
-
camera.position.set(10, 10, 10);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* 世界坐标转屏幕坐标
|
|
107
|
-
* @param worldPosition
|
|
108
|
-
* @param camera
|
|
109
|
-
* @param renderer
|
|
110
|
-
* @returns
|
|
111
|
-
*/
|
|
112
|
-
worldToScreenPosition(worldPosition) {
|
|
113
|
-
const vector = new THREE.Vector3();
|
|
114
|
-
vector.copy(worldPosition);
|
|
115
|
-
vector.project(this.camera);
|
|
116
|
-
const x = (vector.x * 0.5 + 0.5) * this.renderer.domElement.clientWidth;
|
|
117
|
-
const z = (-vector.z * 0.5 + 0.5) * this.renderer.domElement.clientHeight;
|
|
118
|
-
return new THREE.Vector2(x, z);
|
|
119
|
-
}
|
|
120
|
-
cameraPositionRecord = [];
|
|
121
|
-
/**
|
|
122
|
-
* 相机
|
|
123
|
-
* @param position
|
|
124
|
-
* @param lookAt
|
|
125
|
-
* @param onEnd
|
|
126
|
-
*/
|
|
127
|
-
cameraTo(position, lookAt, onEnd) {
|
|
128
|
-
this.cameraPositionRecord.push([
|
|
129
|
-
this.camera.position.clone(),
|
|
130
|
-
this.camera.quaternion.clone()
|
|
131
|
-
]);
|
|
132
|
-
const tween = new TWEEN.Tween(this.camera.position);
|
|
133
|
-
tween.to(position, 600);
|
|
134
|
-
tween.start();
|
|
135
|
-
tween.onUpdate(() => {
|
|
136
|
-
this.camera.lookAt(lookAt);
|
|
137
|
-
});
|
|
138
|
-
tween.onComplete(() => {
|
|
139
|
-
const i = this.tweenTaskList.indexOf(tween);
|
|
140
|
-
this.tweenTaskList.splice(i, 1);
|
|
141
|
-
onEnd && onEnd();
|
|
142
|
-
});
|
|
143
|
-
this.tweenTaskList.push(tween);
|
|
144
|
-
}
|
|
145
|
-
cameraBack() {
|
|
146
|
-
if (this.cameraPositionRecord.length) {
|
|
147
|
-
const [pos, quat] = this.cameraPositionRecord.pop();
|
|
148
|
-
this.camera.position.copy(pos);
|
|
149
|
-
this.camera.quaternion.copy(quat);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* 创建点
|
|
154
|
-
* @param pos
|
|
155
|
-
*/
|
|
156
|
-
createPointMesh(pos, size = 0.02, parameters, parent = this.container) {
|
|
157
|
-
const box = new THREE.Mesh(
|
|
158
|
-
new THREE.SphereGeometry(size),
|
|
159
|
-
new THREE.MeshBasicMaterial(parameters)
|
|
160
|
-
);
|
|
161
|
-
if (pos instanceof Point) box.position.set(pos.x, pos.y, 0);
|
|
162
|
-
else if (pos instanceof THREE.Vector3) box.position.copy(pos);
|
|
163
|
-
parent.add(box);
|
|
164
|
-
return box;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* 创建文本
|
|
168
|
-
* @param text
|
|
169
|
-
* @param pos
|
|
170
|
-
* @param style
|
|
171
|
-
*/
|
|
172
|
-
createText(text, pos, style, parent = this.container) {
|
|
173
|
-
const div = document.createElement("div");
|
|
174
|
-
div.innerHTML = text;
|
|
175
|
-
div.style.pointerEvents = "none";
|
|
176
|
-
Object.assign(div.style, { fontSize: "10px", color: "#ffffff", ...style });
|
|
177
|
-
const css2DObject = new Renderer.CSS2DObject(div);
|
|
178
|
-
if (pos instanceof Point) css2DObject.position.set(pos.x, pos.y, 0);
|
|
179
|
-
else if (pos instanceof THREE.Vector3) css2DObject.position.copy(pos);
|
|
180
|
-
parent.add(css2DObject);
|
|
181
|
-
return css2DObject;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* 创建几何缓冲区
|
|
185
|
-
* @param map
|
|
186
|
-
* @param count
|
|
187
|
-
*/
|
|
188
|
-
createLineSegments(map, count, parameters, parent = this.container) {
|
|
189
|
-
const geometry = new THREE.BufferGeometry();
|
|
190
|
-
Object.keys(map).forEach((key) => {
|
|
191
|
-
const value = map[key];
|
|
192
|
-
geometry.setAttribute(key, new THREE.BufferAttribute(new Float32Array(value), value.length / count));
|
|
193
|
-
});
|
|
194
|
-
const lineSegmentList = new THREE.LineSegments(geometry, new THREE.LineBasicMaterial({ ...parameters }));
|
|
195
|
-
parent.add(lineSegmentList);
|
|
196
|
-
return lineSegmentList;
|
|
197
|
-
}
|
|
198
|
-
destroy() {
|
|
199
|
-
if (this.resizeObserver) {
|
|
200
|
-
this.renderer.dispose();
|
|
201
|
-
this.resizeObserver.disconnect();
|
|
202
|
-
this.resizeObserver = void 0;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
8
|
function drawLinePathToPng(points, width, height, color = "#fff", lineWidth = 2) {
|
|
207
9
|
const can = document.createElement("canvas"), ctx = can.getContext("2d");
|
|
208
10
|
can.width = width;
|
|
@@ -456,42 +258,6 @@ class DetailsPointRender extends Component {
|
|
|
456
258
|
renderer.camera.updateProjectionMatrix();
|
|
457
259
|
}
|
|
458
260
|
}
|
|
459
|
-
class DomContainer extends Component {
|
|
460
|
-
static name = "DomContainer";
|
|
461
|
-
domElement = document.createElement("div");
|
|
462
|
-
canvas = document.createElement("canvas");
|
|
463
|
-
html2DRenderer = document.createElement("div");
|
|
464
|
-
html3DRenderer = document.createElement("div");
|
|
465
|
-
constructor() {
|
|
466
|
-
super();
|
|
467
|
-
this.domElement.id = "build-dxf-container";
|
|
468
|
-
this.domElement.appendChild(this.canvas);
|
|
469
|
-
this.domElement.appendChild(this.html3DRenderer);
|
|
470
|
-
this.domElement.appendChild(this.html2DRenderer);
|
|
471
|
-
Object.assign(this.domElement.style, {
|
|
472
|
-
width: "100%",
|
|
473
|
-
height: "100%",
|
|
474
|
-
position: "relative",
|
|
475
|
-
userSelect: "none"
|
|
476
|
-
});
|
|
477
|
-
Object.assign(this.html3DRenderer.style, {
|
|
478
|
-
position: "absolute",
|
|
479
|
-
left: 0,
|
|
480
|
-
top: 0,
|
|
481
|
-
// zIndex: 9,
|
|
482
|
-
width: "100%",
|
|
483
|
-
height: "100%"
|
|
484
|
-
});
|
|
485
|
-
Object.assign(this.html2DRenderer.style, {
|
|
486
|
-
position: "absolute",
|
|
487
|
-
left: 0,
|
|
488
|
-
top: 0,
|
|
489
|
-
// zIndex: 10,
|
|
490
|
-
width: "100%",
|
|
491
|
-
height: "100%"
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
261
|
class OriginalLineRender extends Component {
|
|
496
262
|
static name = "OriginalLineRender";
|
|
497
263
|
Dxf = null;
|
|
@@ -618,172 +384,6 @@ class ModelDataRender extends Component {
|
|
|
618
384
|
variable?.addEventListener("currentKeyUp", (e) => e.value === "e" && variable.set("whiteModelVisible", !variable.whiteModelVisible));
|
|
619
385
|
}
|
|
620
386
|
}
|
|
621
|
-
class DomEventRegister extends Component {
|
|
622
|
-
static name = "DomEventRegister";
|
|
623
|
-
cancelDefaultBehaviorList = [];
|
|
624
|
-
pointer = new Vector2();
|
|
625
|
-
_isMouseEnter = false;
|
|
626
|
-
set isMouseEnter(isMouseEnter) {
|
|
627
|
-
if (this._isMouseEnter === isMouseEnter) return;
|
|
628
|
-
this._isMouseEnter = isMouseEnter;
|
|
629
|
-
}
|
|
630
|
-
get isMouseEnter() {
|
|
631
|
-
return this._isMouseEnter;
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* 组件被添加到父组件上时调用
|
|
635
|
-
*/
|
|
636
|
-
onAddFromParent() {
|
|
637
|
-
this.initMouseMoveEventProxy();
|
|
638
|
-
this.initKeyEvent();
|
|
639
|
-
this.initWheelEvent();
|
|
640
|
-
this.autoBodyCursor();
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* 初始化鼠标事件代理(判断鼠标是否在domElement上)
|
|
644
|
-
*/
|
|
645
|
-
initMouseMoveEventProxy() {
|
|
646
|
-
const domContainer = this.parent?.findComponentByType(DomContainer), domElement = domContainer.domElement, variable = this.parent?.findComponentByType(Variable), globalMousemoveFun = (e) => {
|
|
647
|
-
const rect = domElement.getBoundingClientRect(), offsetX = e.clientX - rect.left, offsetY = e.clientY - rect.top;
|
|
648
|
-
if (offsetX >= 0 && offsetY >= 0 && offsetX <= rect.width && offsetY <= rect.height) {
|
|
649
|
-
this.pointer.set(offsetX, offsetY);
|
|
650
|
-
this.dispatchEvent({
|
|
651
|
-
type: "mousemove",
|
|
652
|
-
x: offsetX,
|
|
653
|
-
y: offsetY,
|
|
654
|
-
moveX: e.movementX,
|
|
655
|
-
moveY: e.movementY
|
|
656
|
-
});
|
|
657
|
-
this.isMouseEnter = true;
|
|
658
|
-
} else {
|
|
659
|
-
this.isMouseEnter = false;
|
|
660
|
-
}
|
|
661
|
-
}, globalMousedownFun = (e) => {
|
|
662
|
-
if (!this.isMouseEnter) return;
|
|
663
|
-
const rect = domElement.getBoundingClientRect();
|
|
664
|
-
variable.set("currentMouseDown", "mouse_" + e.button);
|
|
665
|
-
this.dispatchEvent({
|
|
666
|
-
type: "mousedown",
|
|
667
|
-
x: e.clientX - rect.left,
|
|
668
|
-
y: e.clientY - rect.top
|
|
669
|
-
});
|
|
670
|
-
}, globalMouseupFun = (e) => {
|
|
671
|
-
if (!this.isMouseEnter) return;
|
|
672
|
-
variable.set("currentMouseUp", "mouse_" + e.button);
|
|
673
|
-
};
|
|
674
|
-
document.addEventListener("mousemove", globalMousemoveFun);
|
|
675
|
-
document.addEventListener("mousedown", globalMousedownFun);
|
|
676
|
-
document.addEventListener("mouseup", globalMouseupFun);
|
|
677
|
-
this.addEventRecord("destory", () => {
|
|
678
|
-
document.removeEventListener("mousemove", globalMousemoveFun);
|
|
679
|
-
document.removeEventListener("mousedown", globalMousedownFun);
|
|
680
|
-
document.removeEventListener("mouseup", globalMouseupFun);
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* 初始化键盘事件
|
|
685
|
-
*/
|
|
686
|
-
initKeyEvent() {
|
|
687
|
-
const variable = this.parent?.findComponentByType(Variable);
|
|
688
|
-
document.body.tabIndex = 1;
|
|
689
|
-
const onKeyup = (e) => {
|
|
690
|
-
if (!this.isMouseEnter) return;
|
|
691
|
-
const key = e.key.toLocaleLowerCase();
|
|
692
|
-
variable.set("currentKeyUp", key);
|
|
693
|
-
for (let i = 0; i < this.cancelDefaultBehaviorList.length; i++) {
|
|
694
|
-
const element = this.cancelDefaultBehaviorList[i];
|
|
695
|
-
if (element(e)) e.preventDefault();
|
|
696
|
-
}
|
|
697
|
-
};
|
|
698
|
-
document.body.addEventListener("keyup", onKeyup);
|
|
699
|
-
const onKeydown = (e) => {
|
|
700
|
-
if (!this.isMouseEnter) return;
|
|
701
|
-
const key = e.key.toLocaleLowerCase();
|
|
702
|
-
variable.set("currentKeyDown", key);
|
|
703
|
-
for (let i = 0; i < this.cancelDefaultBehaviorList.length; i++) {
|
|
704
|
-
const element = this.cancelDefaultBehaviorList[i];
|
|
705
|
-
if (element(e)) e.preventDefault();
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
document.body.addEventListener("keydown", onKeydown);
|
|
709
|
-
const onFocus = () => variable.set("focus", true);
|
|
710
|
-
document.body.addEventListener("focus", onFocus);
|
|
711
|
-
const onBlur = () => variable.set("focus", false);
|
|
712
|
-
document.body.addEventListener("blur", onBlur);
|
|
713
|
-
this.addEventRecord("destory", () => {
|
|
714
|
-
document.body.removeEventListener("keyup", onKeyup);
|
|
715
|
-
document.body.removeEventListener("keydown", onKeydown);
|
|
716
|
-
document.body.removeEventListener("focus", onFocus);
|
|
717
|
-
document.body.removeEventListener("blur", onBlur);
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* 初始化滚轮事件
|
|
722
|
-
*/
|
|
723
|
-
initWheelEvent() {
|
|
724
|
-
const variable = this.parent?.findComponentByType(Variable);
|
|
725
|
-
const onWheel = (e) => variable.set("currentWheel", e.wheelDelta);
|
|
726
|
-
document.body.addEventListener("wheel", onWheel);
|
|
727
|
-
this.addEventRecord("destory", () => {
|
|
728
|
-
document.body.removeEventListener("wheel", onWheel);
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
/**
|
|
732
|
-
* 根据domElement的cursor自动设置body的cursor
|
|
733
|
-
*/
|
|
734
|
-
autoBodyCursor() {
|
|
735
|
-
const domContainer = this.parent?.findComponentByType(DomContainer), domElement = domContainer.domElement;
|
|
736
|
-
let bodyCursor = null;
|
|
737
|
-
this.addEventListener("update", () => {
|
|
738
|
-
if (this.isMouseEnter) {
|
|
739
|
-
if (bodyCursor === null) {
|
|
740
|
-
bodyCursor = document.body.style.cursor;
|
|
741
|
-
}
|
|
742
|
-
document.body.style.cursor = domElement.style.cursor;
|
|
743
|
-
} else {
|
|
744
|
-
if (bodyCursor !== null) {
|
|
745
|
-
document.body.style.cursor = bodyCursor;
|
|
746
|
-
bodyCursor = null;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
*
|
|
753
|
-
* @param callBack
|
|
754
|
-
*/
|
|
755
|
-
addCancelDefaultBehavior(callBack) {
|
|
756
|
-
this.cancelDefaultBehaviorList.push(callBack);
|
|
757
|
-
return this;
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
*
|
|
761
|
-
* @param el
|
|
762
|
-
* @param callBack
|
|
763
|
-
* @param offset
|
|
764
|
-
* @param condition
|
|
765
|
-
*/
|
|
766
|
-
dragMoveHelper(el, callBack, offset = { x: 0, y: 0 }, condition = () => true) {
|
|
767
|
-
el.addEventListener("mousedown", () => {
|
|
768
|
-
if (!condition()) return;
|
|
769
|
-
const move = (e) => {
|
|
770
|
-
offset.x += e.movementX;
|
|
771
|
-
offset.y += e.movementY;
|
|
772
|
-
callBack({ ...offset }, e.movementX, e.movementY);
|
|
773
|
-
};
|
|
774
|
-
const end = () => {
|
|
775
|
-
document.removeEventListener("mousemove", move);
|
|
776
|
-
document.removeEventListener("mouseup", end);
|
|
777
|
-
};
|
|
778
|
-
document.addEventListener("mousemove", move);
|
|
779
|
-
document.addEventListener("mouseup", end);
|
|
780
|
-
});
|
|
781
|
-
callBack({ ...offset }, 0, 0);
|
|
782
|
-
}
|
|
783
|
-
destroy() {
|
|
784
|
-
this.canceEventRecord("destory");
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
387
|
class EventInput extends Component {
|
|
788
388
|
static name = "EventInput";
|
|
789
389
|
keyList = /* @__PURE__ */ new Set();
|