rm-build-dxf 0.1.186

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.
Files changed (195) hide show
  1. package/README.md +6 -0
  2. package/package.json +50 -0
  3. package/src/App.vue.d.ts +2 -0
  4. package/src/DomEventRegister.js +1 -0
  5. package/src/api/getSocket.d.ts +1 -0
  6. package/src/api/index.d.ts +27 -0
  7. package/src/api/type.d.ts +46 -0
  8. package/src/build.js +1 -0
  9. package/src/components/DragContainer.vue.d.ts +48 -0
  10. package/src/components/NumberEditor.vue.d.ts +33 -0
  11. package/src/constants.d.ts +11 -0
  12. package/src/demo.d.ts +1 -0
  13. package/src/dxf-system/DxfSystem.d.ts +26 -0
  14. package/src/dxf-system/build.d.ts +94 -0
  15. package/src/dxf-system/components/CorrectionDxf.d.ts +44 -0
  16. package/src/dxf-system/components/Dxf.d.ts +96 -0
  17. package/src/dxf-system/components/ThreeVJia.d.ts +33 -0
  18. package/src/dxf-system/components/Variable.d.ts +41 -0
  19. package/src/dxf-system/index.d.ts +2 -0
  20. package/src/dxf-system/plugins/editor/Command/ClippingLine.d.ts +30 -0
  21. package/src/dxf-system/plugins/editor/Command/Command.d.ts +346 -0
  22. package/src/dxf-system/plugins/editor/Command/DefaultCommand.d.ts +56 -0
  23. package/src/dxf-system/plugins/editor/Command/DeleteSelectLine.d.ts +25 -0
  24. package/src/dxf-system/plugins/editor/Command/DrawBalconyRailing.d.ts +12 -0
  25. package/src/dxf-system/plugins/editor/Command/DrawBeam.d.ts +12 -0
  26. package/src/dxf-system/plugins/editor/Command/DrawDoorLine.d.ts +9 -0
  27. package/src/dxf-system/plugins/editor/Command/DrawHole.d.ts +67 -0
  28. package/src/dxf-system/plugins/editor/Command/DrawLine.d.ts +41 -0
  29. package/src/dxf-system/plugins/editor/Command/DrawPillar.d.ts +12 -0
  30. package/src/dxf-system/plugins/editor/Command/DrawWindow.d.ts +12 -0
  31. package/src/dxf-system/plugins/editor/Command/ManualDistance.d.ts +23 -0
  32. package/src/dxf-system/plugins/editor/Command/MergeLine.d.ts +33 -0
  33. package/src/dxf-system/plugins/editor/Command/PointDrag/index.d.ts +38 -0
  34. package/src/dxf-system/plugins/editor/Command/PointDrag/modifyDoor.d.ts +40 -0
  35. package/src/dxf-system/plugins/editor/Command/PointDrag/modifyLine.d.ts +34 -0
  36. package/src/dxf-system/plugins/editor/Command/PointDrag/modifyWindow.d.ts +25 -0
  37. package/src/dxf-system/plugins/editor/Command/PropertiesPanel.d.ts +33 -0
  38. package/src/dxf-system/plugins/editor/Command/RayDistance.d.ts +23 -0
  39. package/src/dxf-system/plugins/editor/Command/SelectAll.d.ts +30 -0
  40. package/src/dxf-system/plugins/editor/Command/TwoLineConnectionLine.d.ts +33 -0
  41. package/src/dxf-system/plugins/editor/Command/TwoPointConnection.d.ts +33 -0
  42. package/src/dxf-system/plugins/editor/Command/VerticalCorr.d.ts +66 -0
  43. package/src/dxf-system/plugins/editor/Command/VerticalCorrContinue.d.ts +35 -0
  44. package/src/dxf-system/plugins/editor/Command/ViewAngle.d.ts +21 -0
  45. package/src/dxf-system/plugins/editor/Editor.d.ts +56 -0
  46. package/src/dxf-system/plugins/editor/RenderManager.d.ts +101 -0
  47. package/src/dxf-system/plugins/editor/index.d.ts +9 -0
  48. package/src/dxf-system/plugins/editor/pages/EditorTool/EditorTool.vue.d.ts +7 -0
  49. package/src/dxf-system/plugins/editor/pages/EditorTool/EditorToolContent.vue.d.ts +7 -0
  50. package/src/dxf-system/plugins/editor/pages/PropertiesPanel.vue.d.ts +18 -0
  51. package/src/dxf-system/plugins/editor/pages/components/Button.vue.d.ts +17 -0
  52. package/src/dxf-system/plugins/editor/pages/components/Input.vue.d.ts +13 -0
  53. package/src/dxf-system/plugins/editor/pages/components/ToolToggle.vue.d.ts +20 -0
  54. package/src/dxf-system/plugins/editor/type.d.ts +11 -0
  55. package/src/dxf-system/plugins/editor/us-service/DragControlPoint.d.ts +48 -0
  56. package/src/dxf-system/plugins/editor/us-service/LineSelector.d.ts +44 -0
  57. package/src/dxf-system/plugins/editor/us-service/PointerFollowMove.d.ts +86 -0
  58. package/src/dxf-system/plugins/editor/us-service/SnapController.d.ts +32 -0
  59. package/src/dxf-system/plugins/editor/utils/Wall2D.d.ts +10 -0
  60. package/src/dxf-system/plugins/model3d/components/DxfLineModel.d.ts +14 -0
  61. package/src/dxf-system/plugins/model3d/components/WhiteModel.d.ts +61 -0
  62. package/src/dxf-system/plugins/model3d/components/index.d.ts +2 -0
  63. package/src/dxf-system/plugins/model3d/index.d.ts +11 -0
  64. package/src/dxf-system/plugins/renderer/components/DomContainer.d.ts +13 -0
  65. package/src/dxf-system/plugins/renderer/components/DomEventRegister.d.ts +116 -0
  66. package/src/dxf-system/plugins/renderer/components/EventInput.d.ts +74 -0
  67. package/src/dxf-system/plugins/renderer/components/ModelDataRender.d.ts +13 -0
  68. package/src/dxf-system/plugins/renderer/components/Renderer.d.ts +100 -0
  69. package/src/dxf-system/plugins/renderer/components/index.d.ts +5 -0
  70. package/src/dxf-system/plugins/renderer/index.d.ts +13 -0
  71. package/src/dxf-system/type.d.ts +218 -0
  72. package/src/dxf-system/utils/BayWindowHelper.d.ts +58 -0
  73. package/src/dxf-system/utils/BoundExt.d.ts +51 -0
  74. package/src/dxf-system/utils/DoorFind.d.ts +44 -0
  75. package/src/dxf-system/utils/DoubleWallFinder.d.ts +24 -0
  76. package/src/dxf-system/utils/HeightQuery.d.ts +12 -0
  77. package/src/dxf-system/utils/LineGroupType.d.ts +125 -0
  78. package/src/dxf-system/utils/LoadModel.d.ts +7 -0
  79. package/src/dxf-system/utils/RunJianPipeline.d.ts +92 -0
  80. package/src/dxf-system/utils/SceneAutoGenerat.d.ts +42 -0
  81. package/src/dxf-system/utils/ThreeVJiaPipeline.d.ts +154 -0
  82. package/src/dxf-system/utils/WallGroupManager.d.ts +27 -0
  83. package/src/dxf-system/utils/WallHole.d.ts +134 -0
  84. package/src/dxf-system/utils/WallHoleDrawData.d.ts +31 -0
  85. package/src/dxf-system/utils/ZHouseMockData.d.ts +127 -0
  86. package/src/dxf-system/utils/cad/DxfDataPlugin.d.ts +20 -0
  87. package/src/dxf-system/utils/cad/DxfDrawPlugin.d.ts +13 -0
  88. package/src/dxf-system/utils/cad/draw-data.d.ts +43 -0
  89. package/src/dxf-system/utils/cad/draw-dxf-image.d.ts +2 -0
  90. package/src/dxf-system/utils/cad/draw-dxf-string.d.ts +3 -0
  91. package/src/dxf-system/utils/cad/index.d.ts +143 -0
  92. package/src/dxf-system/utils/clipping-double-wall.d.ts +7 -0
  93. package/src/dxf-system/utils/draw-helper.d.ts +6 -0
  94. package/src/dxf-system/utils/find-discrete.d.ts +26 -0
  95. package/src/dxf-system/utils/find-rooms.d.ts +16 -0
  96. package/src/dxf-system/utils/get-win-draw-data.d.ts +18 -0
  97. package/src/dxf-system/utils/index.d.ts +8 -0
  98. package/src/dxf-system/utils/line-pipeline/builtin/axis-align-corr.d.ts +16 -0
  99. package/src/dxf-system/utils/line-pipeline/builtin/beam-support-line.d.ts +3 -0
  100. package/src/dxf-system/utils/line-pipeline/builtin/bound-ext.d.ts +8 -0
  101. package/src/dxf-system/utils/line-pipeline/builtin/build-group/bay-window.d.ts +7 -0
  102. package/src/dxf-system/utils/line-pipeline/builtin/build-group/double-wall.d.ts +6 -0
  103. package/src/dxf-system/utils/line-pipeline/builtin/build-group/index.d.ts +7 -0
  104. package/src/dxf-system/utils/line-pipeline/builtin/door-space-handle.d.ts +5 -0
  105. package/src/dxf-system/utils/line-pipeline/builtin/door-to-hole.d.ts +9 -0
  106. package/src/dxf-system/utils/line-pipeline/builtin/double-wall-alignment.d.ts +7 -0
  107. package/src/dxf-system/utils/line-pipeline/builtin/index.d.ts +39 -0
  108. package/src/dxf-system/utils/line-pipeline/builtin/init.d.ts +8 -0
  109. package/src/dxf-system/utils/line-pipeline/builtin/remove-room-sundries.d.ts +3 -0
  110. package/src/dxf-system/utils/line-pipeline/builtin/remove-short-double-wall.d.ts +6 -0
  111. package/src/dxf-system/utils/line-pipeline/builtin/wall-height-handle.d.ts +8 -0
  112. package/src/dxf-system/utils/line-pipeline/index.d.ts +22 -0
  113. package/src/dxf-system/utils/remove-dangline.d.ts +7 -0
  114. package/src/dxf-system/utils/tools.d.ts +91 -0
  115. package/src/index.css +1 -0
  116. package/src/index.js +1 -0
  117. package/src/index2.js +1 -0
  118. package/src/index3.js +1 -0
  119. package/src/main.d.ts +0 -0
  120. package/src/pages/CubeView.vue.d.ts +4 -0
  121. package/src/pages/DxfPreview.vue.d.ts +9 -0
  122. package/src/pages/Editor.vue.d.ts +8 -0
  123. package/src/pages/ExportGLB.vue.d.ts +2 -0
  124. package/src/pages/ImagePreview.vue.d.ts +9 -0
  125. package/src/pages/ModelView.vue.d.ts +11 -0
  126. package/src/pages/Setting.vue.d.ts +6 -0
  127. package/src/pages/Todo.vue.d.ts +2 -0
  128. package/src/pages/WallView.vue.d.ts +9 -0
  129. package/src/pages/WindowManager.vue.d.ts +2 -0
  130. package/src/pages/buildJson.vue.d.ts +4 -0
  131. package/src/pages/modelCarrier/index.vue.d.ts +4 -0
  132. package/src/router/index.d.ts +2 -0
  133. package/src/utils/EventDispatcher.d.ts +18 -0
  134. package/src/utils/algorithms/AlignToParallelSegments.d.ts +25 -0
  135. package/src/utils/algorithms/AxisAlignCorr.d.ts +38 -0
  136. package/src/utils/algorithms/Box2.d.ts +96 -0
  137. package/src/utils/algorithms/CheckPointCloudContinuity.d.ts +63 -0
  138. package/src/utils/algorithms/ConstraintSystem.d.ts +17 -0
  139. package/src/utils/algorithms/ConvexHullGraham.d.ts +16 -0
  140. package/src/utils/algorithms/Debouncing.d.ts +10 -0
  141. package/src/utils/algorithms/LineIndexGenerator.d.ts +12 -0
  142. package/src/utils/algorithms/LineQueryer.d.ts +42 -0
  143. package/src/utils/algorithms/LineSegment.d.ts +258 -0
  144. package/src/utils/algorithms/LineSegmentSpatialHash.d.ts +86 -0
  145. package/src/utils/algorithms/LineSegmentUtils.d.ts +185 -0
  146. package/src/utils/algorithms/Map.d.ts +38 -0
  147. package/src/utils/algorithms/MaxiCircles.d.ts +15 -0
  148. package/src/utils/algorithms/MiniCircles.d.ts +57 -0
  149. package/src/utils/algorithms/OBB.d.ts +30 -0
  150. package/src/utils/algorithms/PCSparseOctree.d.ts +56 -0
  151. package/src/utils/algorithms/Pipeline.d.ts +20 -0
  152. package/src/utils/algorithms/Point.d.ts +271 -0
  153. package/src/utils/algorithms/PointSpatialHash.d.ts +149 -0
  154. package/src/utils/algorithms/PointUtils.d.ts +47 -0
  155. package/src/utils/algorithms/Polygon.d.ts +164 -0
  156. package/src/utils/algorithms/PolygonUtils.d.ts +9 -0
  157. package/src/utils/algorithms/Quadtree.d.ts +89 -0
  158. package/src/utils/algorithms/Rectangle.d.ts +62 -0
  159. package/src/utils/algorithms/UndirectedGraph.d.ts +124 -0
  160. package/src/utils/algorithms/UnionFindSet.d.ts +12 -0
  161. package/src/utils/algorithms/ccw.d.ts +2 -0
  162. package/src/utils/algorithms/lazy.d.ts +14 -0
  163. package/src/utils/algorithms/precision.d.ts +3 -0
  164. package/src/utils/algorithms/stepElimination.d.ts +6 -0
  165. package/src/utils/algorithms/uuid.d.ts +1 -0
  166. package/src/utils/command/CommandFlow.d.ts +45 -0
  167. package/src/utils/command/CommandSystem.d.ts +96 -0
  168. package/src/utils/command/index.d.ts +2 -0
  169. package/src/utils/decorators/measure-time.d.ts +5 -0
  170. package/src/utils/ecs/Component.d.ts +18 -0
  171. package/src/utils/ecs/Container.d.ts +47 -0
  172. package/src/utils/ecs/index.d.ts +4 -0
  173. package/src/utils/geometry-manager/GeometryManager.d.ts +2 -0
  174. package/src/utils/index.d.ts +25 -0
  175. package/src/utils/modelScenario/bayWindow.d.ts +35 -0
  176. package/src/utils/modelScenario/scenario.d.ts +92 -0
  177. package/src/utils/three-object-3d/ExtrudeMesh.d.ts +11 -0
  178. package/src/utils/three-object-3d/LineAlignmentGuide.d.ts +20 -0
  179. package/src/utils/three-object-3d/Lines.d.ts +25 -0
  180. package/src/utils/three-object-3d/Lines2.d.ts +22 -0
  181. package/src/utils/three-object-3d/Shape2D.d.ts +61 -0
  182. package/src/utils/tools/GCHandle.d.ts +12 -0
  183. package/src/utils/tools/Gltf.d.ts +7 -0
  184. package/src/utils/tools/SnapLine.d.ts +19 -0
  185. package/src/utils/tools/StorageHelper.d.ts +8 -0
  186. package/src/utils/tools/clone-user-data.d.ts +7 -0
  187. package/src/utils/tools/create-html.d.ts +9 -0
  188. package/src/utils/tools/create-promise.d.ts +5 -0
  189. package/src/utils/tools/createVueApp.d.ts +1 -0
  190. package/src/utils/tools/download.d.ts +1 -0
  191. package/src/utils/tools/get-json.d.ts +5 -0
  192. package/src/utils/tools/include.d.ts +1 -0
  193. package/src/utils/tools/is-mobile.d.ts +2 -0
  194. package/src/utils/tools/repetitive-task.d.ts +1 -0
  195. package/src/utils/tools/selectLocal-file.d.ts +7 -0
@@ -0,0 +1,56 @@
1
+ import { Octant, PointData } from 'sparse-octree';
2
+ import { OBB } from './OBB';
3
+ import * as THREE from 'three';
4
+ export declare class PCSparseOctree<T> {
5
+ private octree;
6
+ bound: THREE.Box3;
7
+ constructor(bound: THREE.Box3);
8
+ /** 插入点 + 数据
9
+ * @param point
10
+ * @param data
11
+ */
12
+ insert(point: THREE.Vector3, data: T): void;
13
+ /** 批量插入(推荐大批量时用)
14
+ * @param points
15
+ * @param datas
16
+ */
17
+ insertBatch(points: THREE.Vector3[], datas: T[]): void;
18
+ /** 查找所有在 oBB 内的盒子
19
+ * @param queryOBB
20
+ * @returns
21
+ */
22
+ findNodeInOBB(queryOBB: OBB): Octant<PointData<T>>[];
23
+ /** 查找所有在 oBB 内的点(带数据)
24
+ * @param queryOBB
25
+ * @returns
26
+ */
27
+ findPointsInOBB(queryOBB: OBB): Array<{
28
+ point: THREE.Vector3;
29
+ data: T;
30
+ }>;
31
+ /** 通过半径查找
32
+ * @param position
33
+ * @param radius
34
+ * @param skipSelf
35
+ * @returns
36
+ */
37
+ findPointsByCircle(position: THREE.Vector3, radius: number, skipSelf?: boolean): import('sparse-octree').PointContainer<T>[];
38
+ /** 查找最近的点
39
+ * @param position
40
+ * @param maxDistance
41
+ * @param skipSelf
42
+ * @returns
43
+ */
44
+ findNearestPoint(position: THREE.Vector3, maxDistance: number, skipSelf?: boolean): import('sparse-octree').PointContainer<T> | null;
45
+ /** 批量查询
46
+ * @param obbList
47
+ * @returns
48
+ */
49
+ findPointsInOBBBatch(obbList: OBB[]): {
50
+ point: THREE.Vector3;
51
+ data: T;
52
+ }[][];
53
+ static fromPoints(points: THREE.Vector3[]): PCSparseOctree<{
54
+ index: number;
55
+ }>;
56
+ }
@@ -0,0 +1,20 @@
1
+ export interface HandlerContext<T = any, C = any> {
2
+ type: string;
3
+ data: T;
4
+ cache: C;
5
+ stopped?: boolean;
6
+ }
7
+ type HandleFunc<T, C> = (ctx: HandlerContext<T, C>) => void | T;
8
+ type Type<S extends string = string> = S | S[];
9
+ export interface Handler<T = any, C = any, S extends string = string> {
10
+ type: Type<S>;
11
+ handle: HandleFunc<T, C>;
12
+ }
13
+ export declare class Pipeline<T = any, C = any, S extends string = string> {
14
+ private map;
15
+ use(handler: Handler<T, C, S>): this;
16
+ use(type: Type<S>, func: HandleFunc<T, C>): this;
17
+ run(type: S, data: T, cache?: C): T;
18
+ clear(): void;
19
+ }
20
+ export {};
@@ -0,0 +1,271 @@
1
+ import { Vector3 } from 'three';
2
+ import { LineSegment } from './LineSegment';
3
+ export type PointType = Point | {
4
+ x: number;
5
+ y: number;
6
+ } | [number, number];
7
+ export declare class Point<T = Record<string, any>> {
8
+ private _x;
9
+ private _y;
10
+ private _version;
11
+ get version(): number;
12
+ get X(): number;
13
+ get Y(): number;
14
+ get x(): number;
15
+ get y(): number;
16
+ set x(x: number);
17
+ set y(y: number);
18
+ userData: T;
19
+ currentData: Record<string | number | symbol, any>;
20
+ /**
21
+ *
22
+ * @param x
23
+ * @param y
24
+ */
25
+ constructor(x?: number, y?: number);
26
+ private _set;
27
+ set(x: number, y: number): this;
28
+ setByDirect(direct: Point, origin: Point, width: number): void;
29
+ setX(x: number): this;
30
+ setY(y: number): this;
31
+ /**
32
+ *
33
+ * @param point
34
+ * @returns
35
+ */
36
+ equal(point: Point, eps?: number): boolean;
37
+ /**
38
+ *
39
+ * @param arr
40
+ */
41
+ setByArray(arr: number[]): this;
42
+ /** 乘法
43
+ * @param scalar
44
+ * @returns
45
+ */
46
+ multiply(point: Point): this;
47
+ /** 乘以一个标量
48
+ * @param scalar
49
+ * @returns
50
+ */
51
+ multiplyScalar(scalar: number): this;
52
+ /** 除法
53
+ * @param scalar
54
+ * @returns
55
+ */
56
+ division(point: Point): this;
57
+ /** 除一个标量
58
+ * @param scalar
59
+ * @returns
60
+ */
61
+ divisionScalar(scalar: number): this;
62
+ /**
63
+ * 减法
64
+ * @description 将当前点的坐标减去指定点的坐标
65
+ * @param point
66
+ * @returns
67
+ */
68
+ subtract(point: Point): this;
69
+ /**
70
+ * 减一个标量
71
+ * @description 将当前点的坐标减去指定点的坐标
72
+ * @param point
73
+ * @returns
74
+ */
75
+ subtractScalar(value: number): this;
76
+ /**
77
+ * 加法
78
+ * @description 将当前点的坐标加上指定点的坐标
79
+ * @param point
80
+ * @returns
81
+ */
82
+ add(point: Point): this;
83
+ /** 加一个标量
84
+ * @description 将当前点的坐标加上指定点的坐标
85
+ * @param point
86
+ * @returns
87
+ */
88
+ addScalar(value: number): this;
89
+ /**
90
+ * 加法(不可变)
91
+ * @description 返回当前点与指定点相加后的新点,不修改当前点
92
+ * @param point
93
+ * @param out 输出对象,用于复用对象减少 GC
94
+ * @returns 相加后的点
95
+ */
96
+ added(point: Point, out?: Point<Record<string, any>>): Point<Record<string, any>>;
97
+ /**
98
+ * 减法(不可变)
99
+ * @description 返回当前点减去指定点后的新点,不修改当前点
100
+ * @param point
101
+ * @param out 输出对象,用于复用对象减少 GC
102
+ * @returns 相减后的点
103
+ */
104
+ subtracted(point: Point, out?: Point<Record<string, any>>): Point<Record<string, any>>;
105
+ /** 转为整型
106
+ * @returns
107
+ */
108
+ parseInt(): this;
109
+ /**
110
+ * 绕point旋转angle
111
+ * @param point
112
+ * @param angle 旋转角度,单位为弧度
113
+ */
114
+ rotate(point: {
115
+ x: number;
116
+ y: number;
117
+ }, angle: number): this;
118
+ /**
119
+ * 旋转(不可变)
120
+ * @description 返回当前点绕指定中心旋转后的新点,不修改当前点
121
+ * @param center 旋转中心
122
+ * @param angle 旋转角度(弧度)
123
+ * @param out 输出对象,用于复用对象减少 GC
124
+ * @returns 旋转后的点
125
+ */
126
+ rotated(center: {
127
+ x: number;
128
+ y: number;
129
+ }, angle: number, out?: Point<Record<string, any>>): Point<Record<string, any>>;
130
+ /**
131
+ * 保留小数位数
132
+ * @param count
133
+ */
134
+ precision(count: number): this;
135
+ /** 保留四位小数
136
+ * @returns
137
+ */
138
+ precision4(): this;
139
+ /**
140
+ * 归一化
141
+ * @description 将当前点的坐标归一化为单位向量
142
+ * @returns
143
+ */
144
+ normalize(): this;
145
+ /**
146
+ * 归一化(不可变)
147
+ * @description 返回当前向量归一化后的新点,不修改当前点
148
+ * @param out 输出对象,用于复用对象减少 GC
149
+ * @returns 单位向量
150
+ */
151
+ normalized(out?: Point<Record<string, any>>): Point<Record<string, any>>;
152
+ /**
153
+ * 获取单位左法向量
154
+ * @description 计算当前点到指定点的方向向量,并返回逆时针旋转90度后的单位法向量
155
+ * @param point
156
+ * @returns
157
+ */
158
+ leftNormal(point: Point, out?: Point<Record<string, any>>): Point<Record<string, any>>;
159
+ /**
160
+ * 获取由传入的点到该点的单位方向向量
161
+ * @description 计算当前点到指定点的方向向量,并返回单位方向
162
+ * @param point
163
+ * @returns
164
+ */
165
+ directionFrom(point: Point, out?: Point<Record<string, any>>): Point<Record<string, any>>;
166
+ /** 展开为线
167
+ * @param direction
168
+ * @param length
169
+ */
170
+ expandAsLine<T = any>(direction: Point, length: number, userData?: T, line?: LineSegment<T>): LineSegment<T>;
171
+ /**
172
+ * 计算模长
173
+ * @returns
174
+ */
175
+ magnitude(): number;
176
+ /**
177
+ * 计算点点积
178
+ * @param point
179
+ * @returns
180
+ */
181
+ dot(point: Point): number;
182
+ /** 求两个点叉积
183
+ * @description 如果叉积大于 0,a 到 b 为逆时针方向。
184
+ * @description 如果叉积小于 0,a 到 b 为顺时针方向。
185
+ * @param point
186
+ * @returns
187
+ */
188
+ cross(point: Point): number;
189
+ /** 计算两个向量夹角
190
+ * @description 公式:a · b = |a| × |b| × cosθ
191
+ * @description 结果为0(0度),两个向量方向一致,结果为3.1415926(180度, PI),两个向量方向相反
192
+ * @deprecated 已弃用,请使用angle
193
+ * @param point
194
+ * @returns
195
+ */
196
+ angleBetween(point: Point, type?: 'radian' | 'cos' | 'angle', angle?: "180" | "360"): number;
197
+ /**
198
+ * @param point
199
+ * @deprecated 已弃用,请使用angle
200
+ * @returns
201
+ */
202
+ angleBetween2(point: Point): number;
203
+ /** 获取夹角
204
+ * @param point
205
+ * @param opt
206
+ * @returns
207
+ */
208
+ angle(point: Point, opt?: {
209
+ unit?: 'radian' | 'degree' | 'cos';
210
+ range?: '180' | '360';
211
+ }): number;
212
+ /** 获取向量长度
213
+ */
214
+ length(): number;
215
+ /**
216
+ * 获取两个点长度
217
+ * @param point
218
+ */
219
+ distance(point: {
220
+ x: number;
221
+ y: number;
222
+ }): number;
223
+ /**
224
+ * @param point
225
+ * @returns
226
+ */
227
+ distanceSquared(point: {
228
+ x: number;
229
+ y: number;
230
+ }): number;
231
+ hashCode(fixed?: number): string;
232
+ encode(): bigint;
233
+ /**
234
+ * 克隆
235
+ * @returns
236
+ */
237
+ clone(out?: Point<Record<string, any>>): Point<Record<string, any>>;
238
+ /**
239
+ * 克隆
240
+ * @returns
241
+ */
242
+ copy(p: PointType): this;
243
+ /** 转为数组
244
+ */
245
+ toArray(): [number, number];
246
+ /** 转为json
247
+ * @param z
248
+ * @returns
249
+ */
250
+ toJson(z?: number): {
251
+ x: number;
252
+ y: number;
253
+ z: number;
254
+ };
255
+ toJson2D(): {
256
+ x: number;
257
+ y: number;
258
+ };
259
+ toVector3(z?: number): Vector3;
260
+ /** 创建
261
+ * @param arr
262
+ * @returns
263
+ */
264
+ static from(arr: any): Point<Record<string, any>>;
265
+ /** 通过列表批量创建
266
+ * @param arr
267
+ * @returns
268
+ */
269
+ static fromByList(arr: any[]): Point<Record<string, any>>[];
270
+ static zero(): Point<Record<string, any>>;
271
+ }
@@ -0,0 +1,149 @@
1
+ import { Box2 } from './Box2';
2
+ import { Point } from './Point';
3
+ import { Polygon } from './Polygon';
4
+ import { Rectangle } from './Rectangle';
5
+ import { LineSegment } from './LineSegment';
6
+ type Target<T> = {
7
+ point: Point;
8
+ userData?: T;
9
+ };
10
+ type NodeSet<T> = Set<Target<T>>;
11
+ export type PvgTarget<T> = Target<T>;
12
+ export type ResultList<T = any> = Array<Target<T>>;
13
+ export type CircleResult<T = any> = {
14
+ point: Point;
15
+ distanceSq: number;
16
+ userData?: T;
17
+ };
18
+ export declare class PointSpatialHash<T = Record<string, any>> {
19
+ map: Map<string, NodeSet<T>>;
20
+ gridSize: number;
21
+ id: symbol;
22
+ constructor(gridSize?: number);
23
+ /**
24
+ * 插入
25
+ * @param point
26
+ * @param userData
27
+ */
28
+ insert(point: Point, userData?: T): this;
29
+ /**
30
+ * 批量加入
31
+ * @param points
32
+ */
33
+ insertBatch(points: Array<{
34
+ point: Point;
35
+ userData?: T;
36
+ }>): void;
37
+ /** 移除点
38
+ * @param point
39
+ */
40
+ remove(point: Point): this;
41
+ /** 移除点
42
+ * @param points
43
+ */
44
+ removes(points: Point[]): this;
45
+ update(point: Point): boolean;
46
+ updates(point: Point[]): void;
47
+ /**
48
+ * 获取通过坐标,获取唯一网格索引
49
+ * @param point
50
+ * @returns
51
+ */
52
+ getGridIdByPoint(point: Point): string;
53
+ getGridId(i: number, j: number): string;
54
+ /**
55
+ * 清空所有数据
56
+ */
57
+ clear(): void;
58
+ /** 遍历网格
59
+ * @param minI
60
+ * @param maxI
61
+ * @param minJ
62
+ * @param maxJ
63
+ * @param callback
64
+ */
65
+ private forEachGrid;
66
+ /**
67
+ * 查询与矩形相交的点
68
+ * @param rectangle 矩形
69
+ * @returns 相交的节点数组
70
+ */
71
+ queryRect(rectangle: Rectangle): {
72
+ point: Point;
73
+ userData?: T;
74
+ }[];
75
+ /**
76
+ * 查询与圆形区域相交的点
77
+ * @param pos 圆心
78
+ * @param radius 半径
79
+ * @returns 相交的节点数组
80
+ */
81
+ queryCircle(pos: Point, radius: number, excludeOneself?: boolean): ResultList<T>;
82
+ /**
83
+ * 查询与包围盒相交的点
84
+ * @param box2 包围盒
85
+ * @returns 相交的节点数组
86
+ */
87
+ queryBox(box2: Box2): {
88
+ point: Point;
89
+ userData?: T;
90
+ }[];
91
+ /**
92
+ * 查找相同点
93
+ * @param point
94
+ */
95
+ queryPoint(point: Point, excludeOneself?: boolean): ResultList<T>;
96
+ /** 批量查询点
97
+ * @param points
98
+ * @param excludeOneself
99
+ * @returns
100
+ */
101
+ queryPoints(points: Point[], excludeOneself?: boolean): ResultList<T>;
102
+ /** 获取多边形内的点
103
+ * @param polygon
104
+ */
105
+ queryPolygon(polygon: Polygon, position?: "inside" | "on" | "all"): {
106
+ point: Point;
107
+ userData?: T;
108
+ }[];
109
+ /**
110
+ * 查找点自己
111
+ * @param point
112
+ */
113
+ queryPointSelf(point: Point): {
114
+ point: Point;
115
+ userData: T;
116
+ } | null;
117
+ /** 通过点,从近到远按圈层搜索
118
+ * 同一圈内不保证距离顺序
119
+ * 返回第一个满足条件的圈层
120
+ */
121
+ searchByRing(point: Point, fn: (circle: CircleResult<T>[], circleNum: number) => boolean, maxRing?: number): CircleResult<T>[] | null;
122
+ /**
123
+ * @param point
124
+ * @param excludeSelf
125
+ * @returns
126
+ */
127
+ findNearest(point: Point, excludeSelf?: boolean): CircleResult<T> | null;
128
+ /**
129
+ * @param point
130
+ */
131
+ isFreePoint(point: Point): boolean;
132
+ /** 查找游离的点
133
+ */
134
+ getFreePoint(): Target<T>[];
135
+ /** 查找第一个游离的点
136
+ */
137
+ getFreePointFirst(): Target<T> | undefined;
138
+ /** 通过点快速创建
139
+ * @param lines
140
+ * @returns
141
+ */
142
+ static from(points: Point[], gridSize?: number): PointSpatialHash<number>;
143
+ /** 通过线段快速创建
144
+ * @param lines
145
+ * @returns
146
+ */
147
+ static fromByLines<T = any>(lines: LineSegment<T>[]): PointSpatialHash<LineSegment<T>>;
148
+ }
149
+ export {};
@@ -0,0 +1,47 @@
1
+ import { LineSegment } from './LineSegment';
2
+ import { Point } from './Point';
3
+ export declare class PointUtils {
4
+ private static _globalPoint;
5
+ static get globalPoint(): Point<Record<string, any>>;
6
+ static getCenter(points: Point[]): Point<Record<string, any>>;
7
+ /** 值网格化
8
+ * @param points
9
+ * @param tolerance
10
+ */
11
+ static quantize(points: Point[], tolerance?: number): Point<Record<string, any>>[];
12
+ /**保留小数位数
13
+ * @param points
14
+ */
15
+ static precision(points: Point[], count: number): Point<Record<string, any>>[];
16
+ /**保留四位小数位数
17
+ * @param points
18
+ */
19
+ static precision4(points: Point[]): Point<Record<string, any>>[];
20
+ /** 点吸附
21
+ * @param points
22
+ * @param tolerance
23
+ * @returns
24
+ */
25
+ static adsorb(points: Point[], tolerance?: number, mode?: "average" | "first"): Point<Record<string, any>>[];
26
+ private static _baseNormalLine;
27
+ private static get baseNormalLine();
28
+ /** 点的线段方向约束
29
+ * @description 点只能在线段方向和法线方向的轴上
30
+ * @param point
31
+ * @param startPoint
32
+ * @param baseLine
33
+ * @param baseNormalLine
34
+ * @returns
35
+ */
36
+ static constrainPointToAxis(point: Point, baseLine: LineSegment, normalStartPoint?: Point | null, baseNormalLine?: LineSegment): Point<Record<string, any>>;
37
+ /** 导出为数组
38
+ * @param points
39
+ * @returns
40
+ */
41
+ static toArray(points: Point[]): Float32Array<ArrayBuffer>;
42
+ /** 导出为数组
43
+ * @param points
44
+ * @returns
45
+ */
46
+ static fromArray(array: Array<number> | Float32Array): Point<Record<string, any>>[];
47
+ }
@@ -0,0 +1,164 @@
1
+ import { Box2 } from './Box2';
2
+ import { LineSegment } from './LineSegment';
3
+ import { Point } from './Point';
4
+ import { Rectangle } from './Rectangle';
5
+ type BooleanOpType = "Union" | "Intersection" | "Difference" | "Xor";
6
+ type FillType = "EvenOdd" | "NonZero" | "Positive" | "Negative";
7
+ type BooleanOpOption = {
8
+ type: BooleanOpType;
9
+ scale: number;
10
+ subjectFillType?: FillType;
11
+ clipFillType?: FillType;
12
+ };
13
+ export declare class Polygon<T = any> extends Array<Point<T>> {
14
+ [Symbol.iterator](): ArrayIterator<Point<T>>;
15
+ constructor(points?: Point<T>[]);
16
+ set(points?: Point<T>[]): void;
17
+ /**
18
+ * 获取多边形几何中心(面积质心)
19
+ * @description 使用多边形面积质心公式计算
20
+ * @description 适用于闭合简单多边形(顺时针或逆时针均可)
21
+ * @description 如果面积为 0,则退化为顶点平均中心
22
+ * @param out 输出对象,用于减少 GC
23
+ * @returns
24
+ */
25
+ getCenter(out?: Point<Record<string, any>>): Point<Record<string, any>>;
26
+ /** 计算二维包围盒
27
+ * @returns
28
+ */
29
+ getBox2(): Box2;
30
+ /** 获取最小包围矩形
31
+ * @param polygon
32
+ * @returns
33
+ */
34
+ getMinimumBoundingRectangle(polygon?: Polygon<any>): Polygon<any> | null;
35
+ /** 计算面积
36
+ * @param signed 是否保留方向
37
+ * @returns
38
+ */
39
+ area(signed?: boolean): number;
40
+ /** 有向面积
41
+ * @returns
42
+ */
43
+ signedArea(): number;
44
+ closedLoop(): boolean;
45
+ /** 闭合路径向路径外膨胀width
46
+ * @param width
47
+ */
48
+ closedExpansion(width: number, scale?: number): this | null;
49
+ /** 通过线段分割
50
+ * @param line
51
+ * @returns
52
+ */
53
+ clipByLine(line: LineSegment): Polygon<Record<string, any>>[];
54
+ /**
55
+ * 获取点相对于多边形的位置
56
+ * @param point
57
+ * @returns 'on' 边上,'inside' 内部,'outside' 外部
58
+ */
59
+ getPointSideOfLine(point: Point): "on" | "outside" | "inside";
60
+ /** 获取最长路径长度
61
+ * @returns
62
+ */
63
+ getMaxLengthInfo(): {
64
+ start: Point<any>;
65
+ end: Point<any>;
66
+ length: number;
67
+ };
68
+ /** 获取最小路径长度
69
+ * @returns
70
+ */
71
+ getMinLengthInfo(): {
72
+ start: Point<any>;
73
+ end: Point<any>;
74
+ length: number;
75
+ };
76
+ /** 点在多边形上:包括路径和内部
77
+ * @param point
78
+ * @returns
79
+ */
80
+ pointIn(point: Point): boolean;
81
+ /** 点在多边形内部,不包括路径上
82
+ * @param point
83
+ * @returns
84
+ */
85
+ pointWithin(point: Point): boolean;
86
+ /** 缩放
87
+ * @param scale
88
+ */
89
+ scale(scale?: number): this;
90
+ round(): this;
91
+ /**
92
+ * @param polygon
93
+ */
94
+ union(polygons: Polygon | Polygon[], scale?: number): boolean;
95
+ /** 差集
96
+ * @param polygon
97
+ */
98
+ difference(polygons: Polygon | Polygon[], scale?: number): boolean;
99
+ /** 包围盒检测
100
+ * @param box
101
+ * @returns
102
+ */
103
+ intersectsBox(box: Box2): boolean;
104
+ /** 转为线段
105
+ * @param closed
106
+ * @returns
107
+ */
108
+ toLines(closed?: boolean): LineSegment<Record<string, any>>[];
109
+ /** 转为矩形
110
+ * @param out
111
+ */
112
+ toRectangle(out?: Rectangle): Rectangle | undefined;
113
+ toArrays(): [number, number][];
114
+ close(): this;
115
+ clone(): Polygon<Record<string, any>>;
116
+ /** 通过线段创建, 默认路径只有一条
117
+ * @param lines
118
+ * @returns
119
+ */
120
+ static fromByLines(lines: LineSegment[]): Polygon<Record<string, any>>;
121
+ /** 通过线段创建, 默认路径只有一条
122
+ * @param lines
123
+ * @returns
124
+ */
125
+ static fromByLines2(lines: LineSegment[], skipGroup?: boolean): Polygon<any>;
126
+ /** 通过线段创建,返回所有路径
127
+ * @description 处理线路拓扑,使线路有序链接,形成长路径
128
+ * @param lines
129
+ */
130
+ static multipleFromByLines(lines: LineSegment[]): Polygon<any>[];
131
+ /** 通过线段路径创建
132
+ * @description 通过线段路径创建, 请确保线段路径正确无误
133
+ * @param lines
134
+ * @param polygon
135
+ * @returns
136
+ */
137
+ static fromByLinePath(lines: LineSegment[], polygon?: Polygon<any>): Polygon<any>;
138
+ /**
139
+ * @param poly
140
+ */
141
+ static ensureCCW(poly: Polygon): void;
142
+ /** 布尔运算
143
+ * @param subject
144
+ * @param polygons
145
+ * @param scale 数据缩放
146
+ * @returns
147
+ */
148
+ static booleanOp(subject: Polygon | Polygon[], clips: Polygon | Polygon[], opt: BooleanOpOption): Polygon<Record<string, any>>[];
149
+ /** 路径偏移
150
+ * @param poly
151
+ * @param option
152
+ * @returns
153
+ */
154
+ static offset(poly: Polygon, option: {
155
+ offsetHalfWidth: number;
156
+ joinType?: JoinType;
157
+ endType?: EndType;
158
+ type?: string;
159
+ scale?: number;
160
+ }): Polygon<Record<string, any>>;
161
+ }
162
+ type JoinType = "jtMiter" | "jtSquare" | "jtRound";
163
+ type EndType = "etOpenSquare" | "etOpenButt" | "etOpenRound";
164
+ export {};