build-dxf 0.0.10 → 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/package.json +14 -5
- package/src/App.vue.d.ts +2 -0
- package/src/build.d.ts +3 -0
- package/src/build.js +10 -8
- package/src/components/Card.vue.d.ts +9 -0
- package/src/index.js +3 -2
- package/src/index2.js +6 -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 -605
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Component, ComponentManager } from '../../../../ComponentManager';
|
|
2
|
+
import { Dxf } from '../../../components/Dxf';
|
|
3
|
+
import { Renderer } from './Renderer';
|
|
4
|
+
import { Variable } from '../../../components/Variable';
|
|
5
|
+
import { WhiteModel } from '../../ModelDataPlugin/components';
|
|
6
|
+
import * as THREE from "three";
|
|
7
|
+
export declare class DetailsPointRender extends Component {
|
|
8
|
+
static name: string;
|
|
9
|
+
Dxf: Dxf | null;
|
|
10
|
+
Renderer: Renderer | null;
|
|
11
|
+
WhiteModel: WhiteModel | null;
|
|
12
|
+
Variable: Variable | null;
|
|
13
|
+
desPointGroup: THREE.Group<THREE.Object3DEventMap>;
|
|
14
|
+
rayLineGroup: THREE.Group<THREE.Object3DEventMap>;
|
|
15
|
+
data: any[];
|
|
16
|
+
onAddFromParent(parent: ComponentManager): void;
|
|
17
|
+
/**
|
|
18
|
+
* 更新模型
|
|
19
|
+
*/
|
|
20
|
+
updateModel(): void;
|
|
21
|
+
createDesPoint(): void;
|
|
22
|
+
createRayline(): void;
|
|
23
|
+
private _desBoxInfo;
|
|
24
|
+
/**
|
|
25
|
+
* 显示详情div盒子
|
|
26
|
+
* @param point
|
|
27
|
+
* @param div
|
|
28
|
+
* @param param2
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
showDesBox(point: THREE.Vector3, div: HTMLDivElement, { message, position }: any): void;
|
|
32
|
+
/**
|
|
33
|
+
* 隐藏详情盒子
|
|
34
|
+
*/
|
|
35
|
+
hideDesBox(): void;
|
|
36
|
+
private orbitControlsTarget;
|
|
37
|
+
private fov;
|
|
38
|
+
/**
|
|
39
|
+
* 查看详情点
|
|
40
|
+
* @param point
|
|
41
|
+
* @param position
|
|
42
|
+
*/
|
|
43
|
+
onLook(point: THREE.Vector3, position: THREE.Vector3): void;
|
|
44
|
+
/**
|
|
45
|
+
* 取消查看详情点
|
|
46
|
+
*/
|
|
47
|
+
cancelLook(): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Component, ComponentManager } from '../../../../ComponentManager';
|
|
2
|
+
export declare class DomEventRegister extends Component {
|
|
3
|
+
static name: string;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param parent
|
|
7
|
+
*/
|
|
8
|
+
onAddFromParent(parent: ComponentManager): void;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param el
|
|
12
|
+
* @param callBack
|
|
13
|
+
* @param offset
|
|
14
|
+
* @param condition
|
|
15
|
+
*/
|
|
16
|
+
dragMoveHelper(el: HTMLElement, callBack: (offset: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
}, mx: number, my: number) => void, offset?: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
}, condition?: () => boolean): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Component, ComponentManager } from '../../../../ComponentManager';
|
|
2
|
+
import { Point } from '../../../../Quadtree/Point';
|
|
3
|
+
export interface PointGroup {
|
|
4
|
+
points: Point[];
|
|
5
|
+
indices: number[];
|
|
6
|
+
rectIndices: number[];
|
|
7
|
+
}
|
|
8
|
+
export declare class ModelDataRender extends Component {
|
|
9
|
+
static name: string;
|
|
10
|
+
onAddFromParent(parent: ComponentManager): void;
|
|
11
|
+
dxf(parent: ComponentManager): void;
|
|
12
|
+
whiteModel(parent: ComponentManager): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Component, ComponentManager } from '../../../../ComponentManager';
|
|
2
|
+
import { Dxf } from '../../../components/Dxf';
|
|
3
|
+
import { Renderer } from './Renderer';
|
|
4
|
+
import * as THREE from "three";
|
|
5
|
+
export declare class OriginalLineRender extends Component {
|
|
6
|
+
static name: string;
|
|
7
|
+
Dxf: Dxf | null;
|
|
8
|
+
Renderer: Renderer | null;
|
|
9
|
+
originalLineMode: THREE.LineSegments<THREE.BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>, THREE.Material | THREE.Material[], THREE.Object3DEventMap>;
|
|
10
|
+
appendLineMode: THREE.LineSegments<THREE.BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>, THREE.Material | THREE.Material[], THREE.Object3DEventMap>;
|
|
11
|
+
textGroup: THREE.Group<THREE.Object3DEventMap>;
|
|
12
|
+
pointGroup: THREE.Group<THREE.Object3DEventMap>;
|
|
13
|
+
distanceGroup: THREE.Group<THREE.Object3DEventMap>;
|
|
14
|
+
onAddFromParent(parent: ComponentManager): void;
|
|
15
|
+
updateMode(data: any): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { CSS3DRenderer, CSS3DObject, CSS3DSprite } from 'three/addons/renderers/CSS3DRenderer.js';
|
|
2
|
+
import { CSS2DRenderer, CSS2DObject } from 'three/addons/renderers/CSS2DRenderer.js';
|
|
3
|
+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
4
|
+
import { Component } from '../../../../ComponentManager';
|
|
5
|
+
import { Point } from '../../../../Quadtree/Point';
|
|
6
|
+
import * as THREE from "three";
|
|
7
|
+
export interface RendererDescription {
|
|
8
|
+
canvas: HTMLCanvasElement;
|
|
9
|
+
orbitControls?: {
|
|
10
|
+
enableDamping?: boolean;
|
|
11
|
+
dampingFactor?: number;
|
|
12
|
+
domElement: HTMLElement;
|
|
13
|
+
};
|
|
14
|
+
htmlRenderer?: {
|
|
15
|
+
'2d'?: HTMLElement;
|
|
16
|
+
'3d'?: HTMLElement;
|
|
17
|
+
};
|
|
18
|
+
resizeObserver?: HTMLElement | null;
|
|
19
|
+
scene?: THREE.Scene;
|
|
20
|
+
camera?: THREE.PerspectiveCamera | THREE.OrthographicCamera;
|
|
21
|
+
}
|
|
22
|
+
export declare class Renderer extends Component {
|
|
23
|
+
static name: string;
|
|
24
|
+
static CSS2DObject: typeof CSS2DObject;
|
|
25
|
+
static CSS3DObject: typeof CSS3DObject;
|
|
26
|
+
static CSS3DSprite: typeof CSS3DSprite;
|
|
27
|
+
static Group: typeof THREE.Group;
|
|
28
|
+
static Object3D: typeof THREE.Object3D;
|
|
29
|
+
static Mesh: typeof THREE.Mesh;
|
|
30
|
+
static Line: typeof THREE.Line;
|
|
31
|
+
static LineSegments: typeof THREE.LineSegments;
|
|
32
|
+
static Points: typeof THREE.Points;
|
|
33
|
+
scene: THREE.Scene;
|
|
34
|
+
camera: THREE.PerspectiveCamera | THREE.OrthographicCamera;
|
|
35
|
+
renderer: THREE.WebGLRenderer;
|
|
36
|
+
orbitControls?: OrbitControls;
|
|
37
|
+
private resizeObserver?;
|
|
38
|
+
private description;
|
|
39
|
+
html2DRenderer?: CSS2DRenderer;
|
|
40
|
+
html3DRenderer?: CSS3DRenderer;
|
|
41
|
+
container: THREE.Group<THREE.Object3DEventMap>;
|
|
42
|
+
onUpdate?: () => void;
|
|
43
|
+
onResize?: (width: number, height: number) => void;
|
|
44
|
+
private tweenTaskList;
|
|
45
|
+
constructor(description: RendererDescription);
|
|
46
|
+
/**
|
|
47
|
+
* 世界坐标转屏幕坐标
|
|
48
|
+
* @param worldPosition
|
|
49
|
+
* @param camera
|
|
50
|
+
* @param renderer
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
worldToScreenPosition(worldPosition: THREE.Vector3): THREE.Vector2;
|
|
54
|
+
cameraPositionRecord: [THREE.Vector3, THREE.Quaternion][];
|
|
55
|
+
/**
|
|
56
|
+
* 相机
|
|
57
|
+
* @param position
|
|
58
|
+
* @param lookAt
|
|
59
|
+
* @param onEnd
|
|
60
|
+
*/
|
|
61
|
+
cameraTo(position: THREE.Vector3, lookAt: THREE.Vector3, onEnd?: any): void;
|
|
62
|
+
cameraBack(): void;
|
|
63
|
+
/**
|
|
64
|
+
* 创建点
|
|
65
|
+
* @param pos
|
|
66
|
+
*/
|
|
67
|
+
createPointMesh(pos?: Point | THREE.Vector3, size?: number, parameters?: THREE.MeshBasicMaterialParameters, parent?: THREE.Object3D): void;
|
|
68
|
+
/**
|
|
69
|
+
* 创建文本
|
|
70
|
+
* @param text
|
|
71
|
+
* @param pos
|
|
72
|
+
* @param style
|
|
73
|
+
*/
|
|
74
|
+
createText(text: any, pos?: Point | THREE.Vector3, style?: any, parent?: THREE.Object3D): void;
|
|
75
|
+
/**
|
|
76
|
+
* 创建几何缓冲区
|
|
77
|
+
* @param map
|
|
78
|
+
* @param count
|
|
79
|
+
*/
|
|
80
|
+
createLineSegments(map: Record<string, number[]>, count: number, parameters?: THREE.LineBasicMaterialParameters, parent?: THREE.Object3D): THREE.LineSegments<THREE.BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>, THREE.LineBasicMaterial, THREE.Object3DEventMap>;
|
|
81
|
+
destroy(): void;
|
|
82
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OriginalDataItem } from '../../../components/Dxf';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
lines?: OriginalDataItem[];
|
|
4
|
+
detailsPoint?: {
|
|
5
|
+
position: {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
z: number;
|
|
9
|
+
};
|
|
10
|
+
direction: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
z: number;
|
|
14
|
+
};
|
|
15
|
+
desc: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
19
|
+
elRef: HTMLDivElement;
|
|
20
|
+
}, HTMLDivElement>;
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
export declare class Lines extends THREE.LineSegments {
|
|
3
|
+
geometry: THREE.BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>;
|
|
4
|
+
points: THREE.Vector3[];
|
|
5
|
+
pointsObject3D: THREE.Points;
|
|
6
|
+
constructor(points?: THREE.Vector3[], color?: number);
|
|
7
|
+
addPoint(...points: THREE.Vector3[]): void;
|
|
8
|
+
setPoint(...points: THREE.Vector3[]): void;
|
|
9
|
+
private _timer;
|
|
10
|
+
private updateGeometry;
|
|
11
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Box2 } from '../Quadtree/Box2';
|
|
2
|
+
import { Point } from '../Quadtree/Point';
|
|
3
|
+
import { Rectangle } from '../Quadtree/Rectangle';
|
|
4
|
+
export declare class PointVirtualGrid<T = Record<string, any>> {
|
|
5
|
+
map: Map<string, Set<{
|
|
6
|
+
point: Point;
|
|
7
|
+
userData?: T;
|
|
8
|
+
}>>;
|
|
9
|
+
gridSize: number;
|
|
10
|
+
constructor(gridSize?: number);
|
|
11
|
+
/**
|
|
12
|
+
* 插入
|
|
13
|
+
* @param point
|
|
14
|
+
* @param userData
|
|
15
|
+
*/
|
|
16
|
+
insert(point: Point, userData?: T): void;
|
|
17
|
+
/**
|
|
18
|
+
* 批量加入
|
|
19
|
+
* @param points
|
|
20
|
+
*/
|
|
21
|
+
insertBatch(points: Array<{
|
|
22
|
+
point: Point;
|
|
23
|
+
userData?: T;
|
|
24
|
+
}>): void;
|
|
25
|
+
/**
|
|
26
|
+
* 获取通过坐标,获取唯一网格索引
|
|
27
|
+
* @param point
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
getGridId(point: Point): string;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param gridId
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
decodeGridId(gridId: string): Point;
|
|
37
|
+
/**
|
|
38
|
+
* 查询与矩形相交的点
|
|
39
|
+
* @param rectangle 矩形
|
|
40
|
+
* @returns 相交的节点数组
|
|
41
|
+
*/
|
|
42
|
+
queryRect(rectangle: Rectangle): void;
|
|
43
|
+
/**
|
|
44
|
+
* 查询与圆形区域相交的点
|
|
45
|
+
* @param pos 圆心
|
|
46
|
+
* @param radius 半径
|
|
47
|
+
* @returns 相交的节点数组
|
|
48
|
+
*/
|
|
49
|
+
queryCircle(pos: Point, radius: number): {
|
|
50
|
+
point: Point;
|
|
51
|
+
userData?: T;
|
|
52
|
+
}[];
|
|
53
|
+
/**
|
|
54
|
+
* 查询与包围盒相交的点
|
|
55
|
+
* @param box2 包围盒
|
|
56
|
+
* @returns 相交的节点数组
|
|
57
|
+
*/
|
|
58
|
+
queryBox(box2: Box2): {
|
|
59
|
+
point: Point;
|
|
60
|
+
userData?: T;
|
|
61
|
+
}[];
|
|
62
|
+
/**
|
|
63
|
+
* 查找相同点
|
|
64
|
+
* @param point
|
|
65
|
+
*/
|
|
66
|
+
queryPoint(point: Point): {
|
|
67
|
+
point: Point;
|
|
68
|
+
userData?: T;
|
|
69
|
+
}[];
|
|
70
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { LineSegment } from './LineSegment';
|
|
2
|
+
import { Point } from './Point';
|
|
3
|
+
import { Rectangle } from './Rectangle';
|
|
4
|
+
export declare class Box2 {
|
|
5
|
+
minX: number;
|
|
6
|
+
maxX: number;
|
|
7
|
+
minY: number;
|
|
8
|
+
maxY: number;
|
|
9
|
+
get points(): Point[];
|
|
10
|
+
get width(): number;
|
|
11
|
+
get height(): number;
|
|
12
|
+
get center(): Point;
|
|
13
|
+
constructor(minX?: number, maxX?: number, minY?: number, maxY?: number);
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param z
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
getPaths3D(z?: number): number[];
|
|
20
|
+
/**
|
|
21
|
+
* 判断线段是与包围盒相交
|
|
22
|
+
* @description Liang-Barsky算法的变种
|
|
23
|
+
* @param line
|
|
24
|
+
*/
|
|
25
|
+
intersectLineSegment(line: LineSegment): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* 判断线段是在包围盒内
|
|
28
|
+
* @param line
|
|
29
|
+
*/
|
|
30
|
+
containsLineSegment(line: LineSegment): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 判断矩形与包围盒相交
|
|
33
|
+
* @param rectangle
|
|
34
|
+
*/
|
|
35
|
+
intersectRectangle(rectangle: Rectangle): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 判断矩形是在包围盒内
|
|
38
|
+
* @param rectangle
|
|
39
|
+
*/
|
|
40
|
+
containsRectangle(rectangle: Rectangle): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 判断包围盒与包围盒相交
|
|
43
|
+
* @param box
|
|
44
|
+
*/
|
|
45
|
+
intersectBox(box: Box2): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* 判断包围盒是在包围盒内
|
|
48
|
+
* @param box
|
|
49
|
+
*/
|
|
50
|
+
containsBox(box: Box2): boolean;
|
|
51
|
+
/** 判断点是在包围盒内
|
|
52
|
+
* @param point
|
|
53
|
+
*/
|
|
54
|
+
containsPoint(point: Point): boolean;
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param minX
|
|
58
|
+
* @param minY
|
|
59
|
+
* @param maxX
|
|
60
|
+
* @param maxY
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
set(minX: number, minY: number, maxX: number, maxY: number): this;
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param maxWidth
|
|
67
|
+
* @param maxHeight
|
|
68
|
+
* @param mode
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
scaleSize(maxWidth: number, maxHeight: number, mode?: 'min' | 'max'): number;
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @param scalar
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
multiplyScalar(scalar: number): this;
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
clone(): Box2;
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @param points
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
static fromByPoints(...points: Point[]): Box2;
|
|
89
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Point } from './Point';
|
|
2
|
+
/**
|
|
3
|
+
* 非轴对称线段
|
|
4
|
+
*/
|
|
5
|
+
export declare class LineSegment<T = Record<string, any>> {
|
|
6
|
+
points: Point[];
|
|
7
|
+
userData?: T;
|
|
8
|
+
get center(): Point;
|
|
9
|
+
get start(): Point;
|
|
10
|
+
get end(): Point;
|
|
11
|
+
constructor(p1?: Point, p2?: Point);
|
|
12
|
+
/**
|
|
13
|
+
* 计算线段的长度
|
|
14
|
+
* @returns 线段的长度
|
|
15
|
+
*/
|
|
16
|
+
getLength(): number;
|
|
17
|
+
/**
|
|
18
|
+
* 获取方向
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
direction(): Point;
|
|
22
|
+
/**
|
|
23
|
+
* 计算一条线段在另一条直线上的投影,并裁剪超出目标线段的部分
|
|
24
|
+
* @param line 要投影的线段
|
|
25
|
+
* @returns 投影并裁剪后的线段
|
|
26
|
+
*/
|
|
27
|
+
projectLineSegment(line: LineSegment): LineSegment;
|
|
28
|
+
clone(): LineSegment<Record<string, any>>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export declare class Point {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
get X(): number;
|
|
5
|
+
get Y(): number;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param x
|
|
9
|
+
* @param y
|
|
10
|
+
*/
|
|
11
|
+
constructor(x?: number, y?: number);
|
|
12
|
+
set(x: number, y: number): this;
|
|
13
|
+
setX(x: number): this;
|
|
14
|
+
setY(y: number): this;
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param point
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
equal(point: Point): boolean;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param arr
|
|
24
|
+
*/
|
|
25
|
+
setByArray(arr: number[]): this;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
toArray(): [number, number];
|
|
30
|
+
/**
|
|
31
|
+
* multiplyScalar
|
|
32
|
+
* @param scalar
|
|
33
|
+
*/
|
|
34
|
+
mutiplyScalar(scalar: number): this;
|
|
35
|
+
multiplyScalar(scalar: number): this;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param scalar
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
divisionScalar(scalar: number): this;
|
|
42
|
+
/**
|
|
43
|
+
* 减法
|
|
44
|
+
* @description 将当前点的坐标减去指定点的坐标
|
|
45
|
+
* @param point
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
division(point: Point): this;
|
|
49
|
+
/**
|
|
50
|
+
* 加法
|
|
51
|
+
* @description 将当前点的坐标加上指定点的坐标
|
|
52
|
+
* @param point
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
add(point: Point): this;
|
|
56
|
+
/**
|
|
57
|
+
* 保留小数位数
|
|
58
|
+
* @param count
|
|
59
|
+
*/
|
|
60
|
+
fixed(count: number): this;
|
|
61
|
+
/**
|
|
62
|
+
* 归一化
|
|
63
|
+
* @description 将当前点的坐标归一化为单位向量
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
normalize(): this;
|
|
67
|
+
/**
|
|
68
|
+
* 获取单位法向量
|
|
69
|
+
* @description 计算当前点到指定点的方向向量,并返回逆时针旋转90度后的单位法向量
|
|
70
|
+
* @param point
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
normal(point: Point): Point;
|
|
74
|
+
/**
|
|
75
|
+
* 获取由传入的点到该点的单位方向向量
|
|
76
|
+
* @description 计算当前点到指定点的方向向量,并返回单位方向
|
|
77
|
+
* @param point
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
direction(point: Point): Point;
|
|
81
|
+
/**
|
|
82
|
+
* 计算模长
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
magnitude(): number;
|
|
86
|
+
/**
|
|
87
|
+
* 计算点点积
|
|
88
|
+
* @param point
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
dot(point: Point): number;
|
|
92
|
+
/** 计算两个向量夹角
|
|
93
|
+
* @description 公式:a · b = |a| × |b| × cosθ
|
|
94
|
+
* @param point
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
angleBetween(point: Point): number;
|
|
98
|
+
/** 获取向量长度
|
|
99
|
+
*/
|
|
100
|
+
length(): number;
|
|
101
|
+
/**
|
|
102
|
+
* 获取两个点长度
|
|
103
|
+
* @param point
|
|
104
|
+
*/
|
|
105
|
+
distance(point: Point): number;
|
|
106
|
+
/**
|
|
107
|
+
* 克隆
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
clone(): Point;
|
|
111
|
+
static from(arr: any): Point;
|
|
112
|
+
static zero(): Point;
|
|
113
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Box2 } from './Box2';
|
|
2
|
+
import { LineSegment } from './LineSegment';
|
|
3
|
+
import { Point } from './Point';
|
|
4
|
+
import { Rectangle } from './Rectangle';
|
|
5
|
+
export interface QuadtreeNode<T = any> {
|
|
6
|
+
line: LineSegment;
|
|
7
|
+
userData: T;
|
|
8
|
+
}
|
|
9
|
+
export declare class Quadtree<T = any> {
|
|
10
|
+
bounds: Box2;
|
|
11
|
+
capacity: number;
|
|
12
|
+
maxDepth: number;
|
|
13
|
+
depth: number;
|
|
14
|
+
isLeaf: boolean;
|
|
15
|
+
children: Quadtree[] | null;
|
|
16
|
+
nodes: QuadtreeNode<T>[];
|
|
17
|
+
color: number[];
|
|
18
|
+
constructor(bounds: Box2, capacity?: number, maxDepth?: number, depth?: number);
|
|
19
|
+
/**
|
|
20
|
+
* 插入线段节点
|
|
21
|
+
* @param node 线段节点
|
|
22
|
+
*/
|
|
23
|
+
insert(node: QuadtreeNode<T>): void;
|
|
24
|
+
/**
|
|
25
|
+
* 获取线段所属的象限
|
|
26
|
+
* @param line 线段
|
|
27
|
+
* @returns 象限索引(0:西北,1:东北,2:西南,3:东南)或-1(跨多个象限)
|
|
28
|
+
*/
|
|
29
|
+
private getQuadrant;
|
|
30
|
+
/**
|
|
31
|
+
* 细分当前节点为四个子节点
|
|
32
|
+
*/
|
|
33
|
+
private subdivide;
|
|
34
|
+
/**
|
|
35
|
+
* 查询与包围盒相交的线段节点
|
|
36
|
+
* @param box2 包围盒
|
|
37
|
+
* @returns 相交的节点数组
|
|
38
|
+
*/
|
|
39
|
+
queryBox(box2: Box2): QuadtreeNode<T>[];
|
|
40
|
+
/**
|
|
41
|
+
* 查询与圆形区域相交的线段节点
|
|
42
|
+
* @param pos 圆心
|
|
43
|
+
* @param radius 半径
|
|
44
|
+
* @returns 相交的节点数组
|
|
45
|
+
*/
|
|
46
|
+
queryCircle(pos: Point, radius: number): QuadtreeNode<T>[];
|
|
47
|
+
/**
|
|
48
|
+
* 查询与矩形相交的线段节点
|
|
49
|
+
* @param rectangle 矩形
|
|
50
|
+
* @returns 相交的节点数组
|
|
51
|
+
*/
|
|
52
|
+
queryRect(rectangle: Rectangle): QuadtreeNode<T>[];
|
|
53
|
+
/**
|
|
54
|
+
* 包围盒转换为数组
|
|
55
|
+
* @param array
|
|
56
|
+
* @param colors
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
boundsToArray(array?: number[], colors?: number[], recursion?: boolean): number[];
|
|
60
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Box2 } from './Box2';
|
|
2
|
+
import { LineSegment } from './LineSegment';
|
|
3
|
+
import { Point } from './Point';
|
|
4
|
+
/**
|
|
5
|
+
* 非轴对称矩形
|
|
6
|
+
*/
|
|
7
|
+
export declare class Rectangle {
|
|
8
|
+
points: Point[];
|
|
9
|
+
get path(): number[];
|
|
10
|
+
constructor(points: Point[]);
|
|
11
|
+
/**
|
|
12
|
+
* 判断线段是否与矩形相交
|
|
13
|
+
* @param line 线段
|
|
14
|
+
* @returns 是否与矩形相交
|
|
15
|
+
*/
|
|
16
|
+
intersectLineSegment(line: LineSegment): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 判断线段是否完全位于矩形内部
|
|
19
|
+
* @param line 线段
|
|
20
|
+
* @returns 是否完全在矩形内部
|
|
21
|
+
*/
|
|
22
|
+
containsLineSegment(line: LineSegment): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 判断点是否完全位于矩形内部
|
|
25
|
+
* @param point
|
|
26
|
+
*/
|
|
27
|
+
containsPoint(point: Point): boolean;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
toBox(): Box2;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param line
|
|
36
|
+
* @param width
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
static fromByLineSegment(line: LineSegment, width?: number, horizontal?: boolean, hScale?: number): Rectangle;
|
|
40
|
+
}
|