build-dxf 0.0.19-5 → 0.0.19-7
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 +1 -1
- package/src/build.js +2 -2
- package/src/index2.js +100 -40
- package/src/index3.js +2 -1
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/DomEventRegister.d.ts +22 -4
- package/src/utils/DxfSystem/plugin/RenderPlugin/components/Renderer.d.ts +1 -1
- package/src/utils/DxfSystem/plugin/RenderPlugin/index.d.ts +1 -1
package/package.json
CHANGED
package/src/build.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export * from './utils/DxfSystem/plugin/ModelDataPlugin';
|
|
|
7
7
|
* @param camera
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
export declare function createEditor(dom: HTMLDivElement, camera?: THREE.
|
|
10
|
+
export declare function createEditor(dom: HTMLDivElement, camera?: THREE.Camera, orbitControls?: boolean): Promise<{
|
|
11
11
|
dxfSystem: DxfSystem;
|
|
12
12
|
}>;
|
package/src/build.js
CHANGED
|
@@ -3076,7 +3076,7 @@ function loadRenderPlugin() {
|
|
|
3076
3076
|
function loadEditorPlugin() {
|
|
3077
3077
|
return import("./index3.js");
|
|
3078
3078
|
}
|
|
3079
|
-
async function createEditor(dom, camera) {
|
|
3079
|
+
async function createEditor(dom, camera, orbitControls = false) {
|
|
3080
3080
|
const mp = await Promise.resolve().then(() => index);
|
|
3081
3081
|
const rp = await loadRenderPlugin();
|
|
3082
3082
|
const editor = await loadEditorPlugin();
|
|
@@ -3087,7 +3087,7 @@ async function createEditor(dom, camera) {
|
|
|
3087
3087
|
originalLine: false,
|
|
3088
3088
|
modelData: false,
|
|
3089
3089
|
detailsPoint: false,
|
|
3090
|
-
orbitControls
|
|
3090
|
+
orbitControls,
|
|
3091
3091
|
camera
|
|
3092
3092
|
})).usePlugin(editor.Editor);
|
|
3093
3093
|
const domContainer = dxfSystem.findComponentByType(rp.components.DomContainer);
|
package/src/index2.js
CHANGED
|
@@ -478,7 +478,7 @@ class DomContainer extends Component {
|
|
|
478
478
|
position: "absolute",
|
|
479
479
|
left: 0,
|
|
480
480
|
top: 0,
|
|
481
|
-
zIndex: 9,
|
|
481
|
+
// zIndex: 9,
|
|
482
482
|
width: "100%",
|
|
483
483
|
height: "100%"
|
|
484
484
|
});
|
|
@@ -486,7 +486,7 @@ class DomContainer extends Component {
|
|
|
486
486
|
position: "absolute",
|
|
487
487
|
left: 0,
|
|
488
488
|
top: 0,
|
|
489
|
-
zIndex: 10,
|
|
489
|
+
// zIndex: 10,
|
|
490
490
|
width: "100%",
|
|
491
491
|
height: "100%"
|
|
492
492
|
});
|
|
@@ -622,16 +622,72 @@ class DomEventRegister extends Component {
|
|
|
622
622
|
static name = "DomEventRegister";
|
|
623
623
|
cancelDefaultBehaviorList = [];
|
|
624
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
|
+
}
|
|
625
633
|
/**
|
|
626
|
-
*
|
|
627
|
-
* @param parent
|
|
634
|
+
* 组件被添加到父组件上时调用
|
|
628
635
|
*/
|
|
629
|
-
onAddFromParent(
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
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);
|
|
633
688
|
document.body.tabIndex = 1;
|
|
634
689
|
const onKeyup = (e) => {
|
|
690
|
+
if (!this.isMouseEnter) return;
|
|
635
691
|
const key = e.key.toLocaleLowerCase();
|
|
636
692
|
variable.set("currentKeyUp", key);
|
|
637
693
|
for (let i = 0; i < this.cancelDefaultBehaviorList.length; i++) {
|
|
@@ -641,6 +697,7 @@ class DomEventRegister extends Component {
|
|
|
641
697
|
};
|
|
642
698
|
document.body.addEventListener("keyup", onKeyup);
|
|
643
699
|
const onKeydown = (e) => {
|
|
700
|
+
if (!this.isMouseEnter) return;
|
|
644
701
|
const key = e.key.toLocaleLowerCase();
|
|
645
702
|
variable.set("currentKeyDown", key);
|
|
646
703
|
for (let i = 0; i < this.cancelDefaultBehaviorList.length; i++) {
|
|
@@ -649,43 +706,46 @@ class DomEventRegister extends Component {
|
|
|
649
706
|
}
|
|
650
707
|
};
|
|
651
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);
|
|
652
713
|
this.addEventRecord("destory", () => {
|
|
653
714
|
document.body.removeEventListener("keyup", onKeyup);
|
|
654
715
|
document.body.removeEventListener("keydown", onKeydown);
|
|
716
|
+
document.body.removeEventListener("focus", onFocus);
|
|
717
|
+
document.body.removeEventListener("blur", onBlur);
|
|
655
718
|
});
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
variable.set("focus", true);
|
|
667
|
-
});
|
|
668
|
-
domElement.addEventListener("blur", () => {
|
|
669
|
-
variable.set("focus", false);
|
|
670
|
-
});
|
|
671
|
-
this.dragMoveHelper(domElement, (_0, x, y) => variable.set("pointerMove", { x, y }), { x: 0, y: 0 });
|
|
672
|
-
domElement.addEventListener("mousemove", (e) => {
|
|
673
|
-
this.pointer.set(e.offsetX, e.offsetY);
|
|
674
|
-
this.dispatchEvent({
|
|
675
|
-
type: "mousemove",
|
|
676
|
-
x: e.offsetX,
|
|
677
|
-
y: e.offsetY,
|
|
678
|
-
moveX: e.movementX,
|
|
679
|
-
moveY: e.movementY
|
|
680
|
-
});
|
|
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);
|
|
681
729
|
});
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
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
|
+
}
|
|
689
749
|
});
|
|
690
750
|
}
|
|
691
751
|
/**
|
package/src/index3.js
CHANGED
|
@@ -1436,7 +1436,6 @@ class RenderManager extends Component {
|
|
|
1436
1436
|
actionHistory = /* @__PURE__ */ new Set();
|
|
1437
1437
|
onAddFromParent() {
|
|
1438
1438
|
const dxfLineModel = this.dxfLineModel;
|
|
1439
|
-
this.reset();
|
|
1440
1439
|
this.editor.container.add(this.container);
|
|
1441
1440
|
this.editor.container.add(dxfLineModel.dxfModelGroup);
|
|
1442
1441
|
dxfLineModel.dxfLineModel.material = new THREE.LineBasicMaterial({
|
|
@@ -1450,6 +1449,7 @@ class RenderManager extends Component {
|
|
|
1450
1449
|
});
|
|
1451
1450
|
this.variable.addEventListener("dxfVisible", (e) => dxfLineModel.dxfModelGroup.visible = e.value);
|
|
1452
1451
|
this.dxf.addEventListener("createGroup", () => this.reset());
|
|
1452
|
+
this.reset();
|
|
1453
1453
|
}
|
|
1454
1454
|
updatedMode = null;
|
|
1455
1455
|
/** 重新设置数据
|
|
@@ -1463,6 +1463,7 @@ class RenderManager extends Component {
|
|
|
1463
1463
|
}
|
|
1464
1464
|
this.pointVirtualGrid = new PointVirtualGrid();
|
|
1465
1465
|
const box = this.dxf.box.clone().expansion(Math.max(this.dxf.box.width, this.dxf.box.height) * 2);
|
|
1466
|
+
if (box.width === 0 || box.height === 0) box.set(-200, -200, 200, 200);
|
|
1466
1467
|
this.quadtree = new Quadtree(box);
|
|
1467
1468
|
this.lines.length = 0;
|
|
1468
1469
|
this.dxf.lineSegments.forEach((line) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Vector2 } from 'three';
|
|
2
|
-
import { Component
|
|
2
|
+
import { Component } from '../../../../ComponentManager';
|
|
3
3
|
export declare class DomEventRegister extends Component<{
|
|
4
4
|
mousemove: {
|
|
5
5
|
x: number;
|
|
@@ -15,11 +15,29 @@ export declare class DomEventRegister extends Component<{
|
|
|
15
15
|
static name: string;
|
|
16
16
|
cancelDefaultBehaviorList: ((e: KeyboardEvent) => boolean)[];
|
|
17
17
|
pointer: Vector2;
|
|
18
|
+
private _isMouseEnter;
|
|
19
|
+
set isMouseEnter(isMouseEnter: boolean);
|
|
20
|
+
get isMouseEnter(): boolean;
|
|
18
21
|
/**
|
|
19
|
-
*
|
|
20
|
-
|
|
22
|
+
* 组件被添加到父组件上时调用
|
|
23
|
+
*/
|
|
24
|
+
onAddFromParent(): void;
|
|
25
|
+
/**
|
|
26
|
+
* 初始化鼠标事件代理(判断鼠标是否在domElement上)
|
|
27
|
+
*/
|
|
28
|
+
initMouseMoveEventProxy(): void;
|
|
29
|
+
/**
|
|
30
|
+
* 初始化键盘事件
|
|
31
|
+
*/
|
|
32
|
+
initKeyEvent(): void;
|
|
33
|
+
/**
|
|
34
|
+
* 初始化滚轮事件
|
|
35
|
+
*/
|
|
36
|
+
initWheelEvent(): void;
|
|
37
|
+
/**
|
|
38
|
+
* 根据domElement的cursor自动设置body的cursor
|
|
21
39
|
*/
|
|
22
|
-
|
|
40
|
+
autoBodyCursor(): void;
|
|
23
41
|
/**
|
|
24
42
|
*
|
|
25
43
|
* @param callBack
|
|
@@ -17,7 +17,7 @@ export interface RendererDescription {
|
|
|
17
17
|
};
|
|
18
18
|
resizeObserver?: HTMLElement | null;
|
|
19
19
|
scene?: THREE.Scene;
|
|
20
|
-
camera?: THREE.PerspectiveCamera | THREE.OrthographicCamera;
|
|
20
|
+
camera?: THREE.PerspectiveCamera | THREE.OrthographicCamera | THREE.Camera;
|
|
21
21
|
}
|
|
22
22
|
export declare class Renderer extends Component<{
|
|
23
23
|
resize: {
|
|
@@ -7,7 +7,7 @@ type Option = {
|
|
|
7
7
|
modelData?: boolean;
|
|
8
8
|
detailsPoint?: boolean;
|
|
9
9
|
orbitControls?: boolean;
|
|
10
|
-
camera?: THREE.
|
|
10
|
+
camera?: THREE.Camera;
|
|
11
11
|
};
|
|
12
12
|
declare function RenderPlugin_(dxfSystem: DxfSystem, option?: Option): void;
|
|
13
13
|
declare const RenderPlugin: typeof RenderPlugin_ & {
|