dxfview 0.0.2

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 (258) hide show
  1. package/README.md +1 -0
  2. package/dist/dxfview.esm.min.js +7 -0
  3. package/dist/types/components/dxf-layout-bar/DxfLayoutBar.d.ts +26 -0
  4. package/dist/types/components/dxf-layout-bar/index.d.ts +1 -0
  5. package/dist/types/components/pop-panel/PopPanel.d.ts +14 -0
  6. package/dist/types/components/pop-panel/index.d.ts +1 -0
  7. package/dist/types/components/progress-bar/ProgressBar.d.ts +34 -0
  8. package/dist/types/components/progress-bar/index.d.ts +1 -0
  9. package/dist/types/components/settings/ProjectSettingsDef.d.ts +44 -0
  10. package/dist/types/components/settings/index.d.ts +1 -0
  11. package/dist/types/components/tool-tip/Tooltip.d.ts +20 -0
  12. package/dist/types/components/tool-tip/index.d.ts +1 -0
  13. package/dist/types/core/Configs.d.ts +238 -0
  14. package/dist/types/core/Constants.d.ts +164 -0
  15. package/dist/types/core/Units.d.ts +16 -0
  16. package/dist/types/core/VersionManager.d.ts +3 -0
  17. package/dist/types/core/camera-controls/CameraControls.d.ts +773 -0
  18. package/dist/types/core/camera-controls/Constants.d.ts +2 -0
  19. package/dist/types/core/camera-controls/EventDispatcher.d.ts +41 -0
  20. package/dist/types/core/camera-controls/index.d.ts +2 -0
  21. package/dist/types/core/camera-controls/types.d.ts +112 -0
  22. package/dist/types/core/camera-controls/utils/extractClientCoordFromEvent.d.ts +3 -0
  23. package/dist/types/core/camera-controls/utils/math-utils.d.ts +11 -0
  24. package/dist/types/core/camera-controls/utils/notSupportedInOrthographicCamera.d.ts +2 -0
  25. package/dist/types/core/canvas/CanvasRender.d.ts +52 -0
  26. package/dist/types/core/canvas/Constants.d.ts +28 -0
  27. package/dist/types/core/canvas/Drawable.d.ts +87 -0
  28. package/dist/types/core/canvas/DrawableList.d.ts +29 -0
  29. package/dist/types/core/canvas/index.d.ts +4 -0
  30. package/dist/types/core/compare/BaseDxfCompareHelper.d.ts +104 -0
  31. package/dist/types/core/compare/CompareDrawable.d.ts +17 -0
  32. package/dist/types/core/compare/DxfCompareHelper.d.ts +69 -0
  33. package/dist/types/core/compare/DxfCompareMarkupManager.d.ts +11 -0
  34. package/dist/types/core/compare/index.d.ts +4 -0
  35. package/dist/types/core/controls/CameraControlsEx.d.ts +34 -0
  36. package/dist/types/core/controls/index.d.ts +1 -0
  37. package/dist/types/core/dxf/DxfCompare.d.ts +151 -0
  38. package/dist/types/core/dxf/DxfConstants.d.ts +15 -0
  39. package/dist/types/core/dxf/DxfLoader.d.ts +526 -0
  40. package/dist/types/core/dxf/DxfObject.d.ts +32 -0
  41. package/dist/types/core/dxf/DxfUtils.d.ts +79 -0
  42. package/dist/types/core/dxf/HatchPatternShaders.d.ts +12 -0
  43. package/dist/types/core/dxf/LinePatternShaders.d.ts +12 -0
  44. package/dist/types/core/dxf/bspline.d.ts +8 -0
  45. package/dist/types/core/dxf/dxfom-mtext.d.ts +46 -0
  46. package/dist/types/core/dxf/dxfom-text.d.ts +16 -0
  47. package/dist/types/core/dxf/index.d.ts +10 -0
  48. package/dist/types/core/dxf/round10.d.ts +2 -0
  49. package/dist/types/core/dxf-parser/AutoCadColorIndex.d.ts +8 -0
  50. package/dist/types/core/dxf-parser/DxfBaseReader.d.ts +12 -0
  51. package/dist/types/core/dxf-parser/DxfBinaryReader.d.ts +14 -0
  52. package/dist/types/core/dxf-parser/DxfParser.d.ts +327 -0
  53. package/dist/types/core/dxf-parser/DxfTextReader.d.ts +31 -0
  54. package/dist/types/core/dxf-parser/ParseHelpers.d.ts +36 -0
  55. package/dist/types/core/dxf-parser/entities/3dface.d.ts +11 -0
  56. package/dist/types/core/dxf-parser/entities/arc.d.ts +16 -0
  57. package/dist/types/core/dxf-parser/entities/attdef.d.ts +31 -0
  58. package/dist/types/core/dxf-parser/entities/attrib.d.ts +31 -0
  59. package/dist/types/core/dxf-parser/entities/circle.d.ts +13 -0
  60. package/dist/types/core/dxf-parser/entities/dimension.d.ts +22 -0
  61. package/dist/types/core/dxf-parser/entities/ellipse.d.ts +15 -0
  62. package/dist/types/core/dxf-parser/entities/geomtry.d.ts +40 -0
  63. package/dist/types/core/dxf-parser/entities/hatch.d.ts +108 -0
  64. package/dist/types/core/dxf-parser/entities/image.d.ts +37 -0
  65. package/dist/types/core/dxf-parser/entities/insert.d.ts +20 -0
  66. package/dist/types/core/dxf-parser/entities/leader.d.ts +23 -0
  67. package/dist/types/core/dxf-parser/entities/line.d.ts +10 -0
  68. package/dist/types/core/dxf-parser/entities/lwpolyline.d.ts +21 -0
  69. package/dist/types/core/dxf-parser/entities/mleader.d.ts +101 -0
  70. package/dist/types/core/dxf-parser/entities/mtext.d.ts +18 -0
  71. package/dist/types/core/dxf-parser/entities/ole2frame.d.ts +20 -0
  72. package/dist/types/core/dxf-parser/entities/point.d.ts +11 -0
  73. package/dist/types/core/dxf-parser/entities/polyline.d.ts +20 -0
  74. package/dist/types/core/dxf-parser/entities/ray.d.ts +10 -0
  75. package/dist/types/core/dxf-parser/entities/region.d.ts +10 -0
  76. package/dist/types/core/dxf-parser/entities/seqend.d.ts +8 -0
  77. package/dist/types/core/dxf-parser/entities/solid.d.ts +10 -0
  78. package/dist/types/core/dxf-parser/entities/spline.d.ts +23 -0
  79. package/dist/types/core/dxf-parser/entities/table.d.ts +42 -0
  80. package/dist/types/core/dxf-parser/entities/text.d.ts +18 -0
  81. package/dist/types/core/dxf-parser/entities/vertex.d.ts +20 -0
  82. package/dist/types/core/dxf-parser/entities/viewport.d.ts +46 -0
  83. package/dist/types/core/dxf-parser/entities/xline.d.ts +10 -0
  84. package/dist/types/core/dxf-parser/index.d.ts +27 -0
  85. package/dist/types/core/dxf-parser/objects/common.d.ts +15 -0
  86. package/dist/types/core/dxf-parser/objects/dictionary.d.ts +19 -0
  87. package/dist/types/core/dxf-parser/objects/imagedef.d.ts +24 -0
  88. package/dist/types/core/dxf-parser/objects/layout.d.ts +29 -0
  89. package/dist/types/core/dxf-parser/objects/sortentstable.d.ts +12 -0
  90. package/dist/types/core/dxf-parser/objects/spatialfilter.d.ts +22 -0
  91. package/dist/types/core/dxf-parser/objects/xrecord.d.ts +11 -0
  92. package/dist/types/core/font/BaseFont.d.ts +88 -0
  93. package/dist/types/core/font/FontManager.d.ts +107 -0
  94. package/dist/types/core/font/MeshFont.d.ts +44 -0
  95. package/dist/types/core/font/ShxFont.d.ts +108 -0
  96. package/dist/types/core/font/index.d.ts +1 -0
  97. package/dist/types/core/font/shx/ExtraLettersTemplate.d.ts +1 -0
  98. package/dist/types/core/font/shx/Shx.constants.d.ts +11 -0
  99. package/dist/types/core/font/shx/ShxParser.d.ts +18 -0
  100. package/dist/types/core/font/shx/TextShape.d.ts +24 -0
  101. package/dist/types/core/font/shx/gbk/index.d.ts +4 -0
  102. package/dist/types/core/font/shx/index.d.ts +1 -0
  103. package/dist/types/core/font/shx/util/BitConverter.d.ts +18 -0
  104. package/dist/types/core/geometry-offset/Edge.d.ts +27 -0
  105. package/dist/types/core/geometry-offset/Offset.d.ts +46 -0
  106. package/dist/types/core/geometry-offset/index.d.ts +1 -0
  107. package/dist/types/core/helpers/BinaryReader.d.ts +24 -0
  108. package/dist/types/core/helpers/BoxSelectHelper.d.ts +44 -0
  109. package/dist/types/core/helpers/LoadingHelper.d.ts +46 -0
  110. package/dist/types/core/helpers/MobileTouchHelperDrawable.d.ts +26 -0
  111. package/dist/types/core/helpers/OSnapHelper.d.ts +167 -0
  112. package/dist/types/core/helpers/ObjectPixelSizeHelper.d.ts +13 -0
  113. package/dist/types/core/helpers/PickMarkupHelper.d.ts +29 -0
  114. package/dist/types/core/helpers/RafHelper.d.ts +18 -0
  115. package/dist/types/core/helpers/ZoomToRectHelper.d.ts +17 -0
  116. package/dist/types/core/helpers/index.d.ts +9 -0
  117. package/dist/types/core/index.d.ts +18 -0
  118. package/dist/types/core/indexeddb/AnnotationTable.d.ts +14 -0
  119. package/dist/types/core/indexeddb/BaseTable.d.ts +36 -0
  120. package/dist/types/core/indexeddb/DxfDataTable.d.ts +22 -0
  121. package/dist/types/core/indexeddb/FontDataTable.d.ts +32 -0
  122. package/dist/types/core/indexeddb/IndexedDbManager.d.ts +29 -0
  123. package/dist/types/core/indexeddb/ViewpointTable.d.ts +14 -0
  124. package/dist/types/core/indexeddb/index.d.ts +6 -0
  125. package/dist/types/core/input/InputManager.d.ts +161 -0
  126. package/dist/types/core/input/index.d.ts +1 -0
  127. package/dist/types/core/license/AutoConfig.d.ts +17 -0
  128. package/dist/types/core/license/LicenseManager.d.ts +107 -0
  129. package/dist/types/core/license/PublicKey.d.ts +1 -0
  130. package/dist/types/core/license/index.d.ts +1 -0
  131. package/dist/types/core/markup/ArrowMarkup.d.ts +14 -0
  132. package/dist/types/core/markup/BaseMarkup.d.ts +28 -0
  133. package/dist/types/core/markup/CircleMarkup.d.ts +12 -0
  134. package/dist/types/core/markup/CloudLineMarkup.d.ts +10 -0
  135. package/dist/types/core/markup/CloudRectMarkup.d.ts +11 -0
  136. package/dist/types/core/markup/CloudRectWithTextMarkup.d.ts +43 -0
  137. package/dist/types/core/markup/Constants.d.ts +17 -0
  138. package/dist/types/core/markup/DotMarkup.d.ts +9 -0
  139. package/dist/types/core/markup/EllipseMarkup.d.ts +12 -0
  140. package/dist/types/core/markup/LeaderLineMarkup.d.ts +25 -0
  141. package/dist/types/core/markup/MarkupManager.d.ts +91 -0
  142. package/dist/types/core/markup/PolylineMarkup.d.ts +11 -0
  143. package/dist/types/core/markup/RectMarkup.d.ts +10 -0
  144. package/dist/types/core/markup/TextMarkup.d.ts +40 -0
  145. package/dist/types/core/markup/XMarkup.d.ts +10 -0
  146. package/dist/types/core/markup/index.d.ts +13 -0
  147. package/dist/types/core/model/Constants.d.ts +51 -0
  148. package/dist/types/core/model/Model.d.ts +18 -0
  149. package/dist/types/core/model/Model2d.d.ts +115 -0
  150. package/dist/types/core/model/index.d.ts +3 -0
  151. package/dist/types/core/patches/Constants.d.ts +4 -0
  152. package/dist/types/core/patches/Line.d.ts +2 -0
  153. package/dist/types/core/patches/Mesh.d.ts +2 -0
  154. package/dist/types/core/patches/Points.d.ts +2 -0
  155. package/dist/types/core/patches/index.d.ts +4 -0
  156. package/dist/types/core/undo-redo/AddAnnotationCommand.d.ts +11 -0
  157. package/dist/types/core/undo-redo/AddMarkupCommand.d.ts +10 -0
  158. package/dist/types/core/undo-redo/AddMeasurementCommand.d.ts +9 -0
  159. package/dist/types/core/undo-redo/Command.d.ts +6 -0
  160. package/dist/types/core/undo-redo/RemoveAnnotationCommand.d.ts +11 -0
  161. package/dist/types/core/undo-redo/RemoveMarkupCommand.d.ts +10 -0
  162. package/dist/types/core/undo-redo/RemoveMeasurementCommand.d.ts +9 -0
  163. package/dist/types/core/undo-redo/UndoRedoManager.d.ts +21 -0
  164. package/dist/types/core/undo-redo/UpdateMarkupCommand.d.ts +11 -0
  165. package/dist/types/core/undo-redo/index.d.ts +9 -0
  166. package/dist/types/core/utils/CSS2DObjectUtils.d.ts +14 -0
  167. package/dist/types/core/utils/ColorUtils.d.ts +21 -0
  168. package/dist/types/core/utils/CommonUtils.d.ts +125 -0
  169. package/dist/types/core/utils/CoordinateUtils.d.ts +81 -0
  170. package/dist/types/core/utils/DecimalPrecisionUtils.d.ts +4 -0
  171. package/dist/types/core/utils/DeviceUtils.d.ts +15 -0
  172. package/dist/types/core/utils/EdgeUtils.d.ts +14 -0
  173. package/dist/types/core/utils/Event.d.ts +33 -0
  174. package/dist/types/core/utils/FpsUtils.d.ts +13 -0
  175. package/dist/types/core/utils/GeometryUtils.d.ts +111 -0
  176. package/dist/types/core/utils/Locale.d.ts +190 -0
  177. package/dist/types/core/utils/LogUtils.d.ts +7 -0
  178. package/dist/types/core/utils/MaterialUtils.d.ts +40 -0
  179. package/dist/types/core/utils/MathUtils.d.ts +59 -0
  180. package/dist/types/core/utils/MergeUtils.d.ts +638 -0
  181. package/dist/types/core/utils/ObjectUtils.d.ts +87 -0
  182. package/dist/types/core/utils/PolygonUtils.d.ts +8 -0
  183. package/dist/types/core/utils/SVGObjectUtils.d.ts +16 -0
  184. package/dist/types/core/utils/SceneUtils.d.ts +26 -0
  185. package/dist/types/core/utils/SectionUtils.d.ts +11 -0
  186. package/dist/types/core/utils/UnitConversionUtils.d.ts +31 -0
  187. package/dist/types/core/utils/index.d.ts +21 -0
  188. package/dist/types/core/viewers/BaseViewer.d.ts +265 -0
  189. package/dist/types/core/viewers/DxfViewer.d.ts +1372 -0
  190. package/dist/types/core/viewers/Plugin.d.ts +29 -0
  191. package/dist/types/core/viewers/ViewerEvent.d.ts +178 -0
  192. package/dist/types/core/viewers/index.d.ts +4 -0
  193. package/dist/types/export.doc.d.ts +10 -0
  194. package/dist/types/fetch-polyfill.d.ts +2 -0
  195. package/dist/types/index.d.ts +8 -0
  196. package/dist/types/plugins/annotation/AnnotationPlugin.d.ts +139 -0
  197. package/dist/types/plugins/annotation/AutoDrawAnnotation.d.ts +63 -0
  198. package/dist/types/plugins/annotation/BaseAnnotation.d.ts +113 -0
  199. package/dist/types/plugins/annotation/BaseAnnotationDrawable.d.ts +139 -0
  200. package/dist/types/plugins/annotation/CopyAnnotation.d.ts +36 -0
  201. package/dist/types/plugins/annotation/CopyDrawable.d.ts +26 -0
  202. package/dist/types/plugins/annotation/FreeDrawAnnotation.d.ts +59 -0
  203. package/dist/types/plugins/annotation/RectAnnotation.d.ts +53 -0
  204. package/dist/types/plugins/annotation/RectDrawable.d.ts +42 -0
  205. package/dist/types/plugins/annotation/ShapeFinder.d.ts +51 -0
  206. package/dist/types/plugins/annotation/freeDrawDrawable.d.ts +21 -0
  207. package/dist/types/plugins/annotation/index.d.ts +8 -0
  208. package/dist/types/plugins/annotation/type.d.ts +182 -0
  209. package/dist/types/plugins/axis-gizmo/AxisGizmoPlugin.d.ts +49 -0
  210. package/dist/types/plugins/axis-gizmo/CoordinateAxes.d.ts +12 -0
  211. package/dist/types/plugins/axis-gizmo/index.d.ts +1 -0
  212. package/dist/types/plugins/bottom-bar/BottomBarPlugin.d.ts +44 -0
  213. package/dist/types/plugins/bottom-bar/index.d.ts +1 -0
  214. package/dist/types/plugins/divide/CoverLayerManager.d.ts +44 -0
  215. package/dist/types/plugins/divide/DivGeometryUtils.d.ts +66 -0
  216. package/dist/types/plugins/divide/DividePlugin.d.ts +181 -0
  217. package/dist/types/plugins/divide/FrameAnnotation.d.ts +142 -0
  218. package/dist/types/plugins/divide/FrameDrawable.d.ts +75 -0
  219. package/dist/types/plugins/divide/index.d.ts +6 -0
  220. package/dist/types/plugins/divide/types.d.ts +38 -0
  221. package/dist/types/plugins/hotpoint/HotpointPlugin.d.ts +93 -0
  222. package/dist/types/plugins/hotpoint/index.d.ts +1 -0
  223. package/dist/types/plugins/index.d.ts +12 -0
  224. package/dist/types/plugins/layer-manager/LayerManagerPlugin.d.ts +59 -0
  225. package/dist/types/plugins/layer-manager/index.d.ts +1 -0
  226. package/dist/types/plugins/local-model-uploader/IUploader.d.ts +10 -0
  227. package/dist/types/plugins/local-model-uploader/LocalDxfUploader.d.ts +19 -0
  228. package/dist/types/plugins/local-model-uploader/index.d.ts +1 -0
  229. package/dist/types/plugins/measure/AngleMeasureDrawable.d.ts +12 -0
  230. package/dist/types/plugins/measure/AngleMeasurement.d.ts +16 -0
  231. package/dist/types/plugins/measure/AreaMeasureDrawable.d.ts +14 -0
  232. package/dist/types/plugins/measure/AreaMeasurement.d.ts +31 -0
  233. package/dist/types/plugins/measure/BaseMeasureDrawable.d.ts +35 -0
  234. package/dist/types/plugins/measure/BaseMeasurement.d.ts +127 -0
  235. package/dist/types/plugins/measure/CoordinateMeasureDrawable.d.ts +10 -0
  236. package/dist/types/plugins/measure/CoordinateMeasurement.d.ts +15 -0
  237. package/dist/types/plugins/measure/DistanceMeasureDrawable.d.ts +15 -0
  238. package/dist/types/plugins/measure/DistanceMeasurement.d.ts +28 -0
  239. package/dist/types/plugins/measure/MeasurementPlugin.d.ts +131 -0
  240. package/dist/types/plugins/measure/index.d.ts +3 -0
  241. package/dist/types/plugins/overview-map/ImageDrawable.d.ts +41 -0
  242. package/dist/types/plugins/overview-map/LineDrawable.d.ts +20 -0
  243. package/dist/types/plugins/overview-map/OverviewMapDrawable.d.ts +24 -0
  244. package/dist/types/plugins/overview-map/OverviewMapPlugin.d.ts +156 -0
  245. package/dist/types/plugins/overview-map/TextDrawable.d.ts +50 -0
  246. package/dist/types/plugins/overview-map/index.d.ts +5 -0
  247. package/dist/types/plugins/screenshot/ScreenshotPlugin.d.ts +88 -0
  248. package/dist/types/plugins/screenshot/index.d.ts +1 -0
  249. package/dist/types/plugins/stats/StatsPlugin.d.ts +20 -0
  250. package/dist/types/plugins/stats/index.d.ts +1 -0
  251. package/dist/types/plugins/toolbars/DxfViewerToolbarPlugin.d.ts +67 -0
  252. package/dist/types/plugins/toolbars/MarkupToolbar.d.ts +33 -0
  253. package/dist/types/plugins/toolbars/Toolbar.config.d.ts +5 -0
  254. package/dist/types/plugins/toolbars/Toolbar.constants.d.ts +96 -0
  255. package/dist/types/plugins/toolbars/Toolbar.d.ts +102 -0
  256. package/dist/types/plugins/toolbars/index.d.ts +5 -0
  257. package/dist/types/version.d.ts +2 -0
  258. package/package.json +90 -0
@@ -0,0 +1,638 @@
1
+ /**
2
+ * MergeUtils - 几何体合并工具类
3
+ *
4
+ * 此文件提供了完整的Three.js几何体合并功能,主要用于优化渲染性能。
5
+ * 通过将多个具有相同材质和属性的几何体合并为单个几何体,可以减少Draw Call数量。
6
+ *
7
+ * 主要功能:
8
+ * - 网格(Mesh)几何体合并
9
+ * - 线段(Line)几何体合并
10
+ * - 点云(Points)几何体合并
11
+ * - 批处理信息保存和查询
12
+ * - 合并对象的撤销和恢复
13
+ *
14
+ * 核心优化策略:
15
+ * 1. 仅合并具有相同材质和属性的对象
16
+ * 2. 保持原始对象的变换矩阵信息
17
+ * 3. 支持批处理信息的保存,用于后续查询和操作
18
+ * 4. 提供完整的合并统计信息
19
+ */
20
+ import * as THREE from "three";
21
+ /**
22
+ * Batch接口 - 合并批次信息
23
+ *
24
+ * 此接口定义了合并后几何体中每个批次的信息结构。
25
+ * 当多个几何体被合并为一个时,每个原始几何体在合并后的几何体中占据一个批次。
26
+ * 通过批次信息,可以精确定位原始几何体在合并几何体中的位置和范围。
27
+ *
28
+ * 应用场景:
29
+ * 1. 鼠标交互时确定点击的是哪个原始对象
30
+ * 2. 局部更新时确定需要更新的顶点范围
31
+ * 3. 统计和调试时追踪每个批次的信息
32
+ * 4. 撤销合并操作时恢复原始对象的几何数据
33
+ *
34
+ * @internal 内部使用,不对外暴露
35
+ */
36
+ export interface Batch {
37
+ /**
38
+ * 批次ID - 唯一标识符
39
+ * 用于区分合并几何体中的不同批次,每个批次对应一个原始几何体
40
+ * 从0开始递增,方便索引和查找
41
+ */
42
+ batchId: number;
43
+ /**
44
+ * 原始对象名称 - 可选
45
+ * 保存原始几何体的名称信息,用于调试和追踪
46
+ * 如果原始对象没有名称,此字段可能为空
47
+ */
48
+ name?: string;
49
+ /**
50
+ * 原始对象ID - 可选
51
+ * 保存原始几何体的唯一标识符,如elementId等
52
+ * 用于业务逻辑中的对象识别和关联
53
+ */
54
+ id?: string;
55
+ /**
56
+ * 位置起始索引
57
+ * 在合并后的顶点数组中,此批次顶点的起始位置
58
+ * 用于确定此批次在合并几何体中的顶点范围
59
+ */
60
+ positionStart: number;
61
+ /**
62
+ * 位置数量
63
+ * 此批次包含的顶点数量
64
+ * 从positionStart开始,连续的positionCount个顶点属于此批次
65
+ */
66
+ positionCount: number;
67
+ /**
68
+ * 索引起始位置
69
+ * 在合并后的索引数组中,此批次的索引起始位置
70
+ * 对于有索引的几何体,此字段非常重要
71
+ */
72
+ indexStart: number;
73
+ /**
74
+ * 索引数量
75
+ * 此批次包含的索引数量
76
+ * 从indexStart开始,连续的indexCount个索引属于此批次
77
+ */
78
+ indexCount: number;
79
+ /**
80
+ * 包围球 - 可选
81
+ * 此批次的几何包围球,用于快速的碰撞检测和视锥剔除
82
+ * 只有线段(Line)类型的批次才会计算此信息,以节省内存
83
+ */
84
+ boundingSphere?: THREE.Sphere;
85
+ /**
86
+ * 用户数据 - 可选
87
+ * 保存原始几何体的userData信息
88
+ * 包含了原始对象的自定义属性,如layerName等
89
+ * 注意:为了节省内存,只有在需要时才会保存此信息
90
+ */
91
+ userData?: object;
92
+ }
93
+ /**
94
+ * MergeUtils类 - 几何体合并工具类
95
+ *
96
+ * 此类提供了完整的Three.js几何体合并功能,是DXF查看器的核心优化工具。
97
+ * 通过智能合并具有相同材质和属性的几何体,可以显著提升渲染性能。
98
+ *
99
+ * 主要特性:
100
+ * 1. 支持Mesh、Line、Points三种几何体类型的合并
101
+ * 2. 智能检测可合并对象,基于材质、几何属性、图层等条件
102
+ * 3. 保持原始对象的变换矩阵和用户数据
103
+ * 4. 提供详细的批处理信息,用于后续查询和交互
104
+ * 5. 完整的合并统计信息,便于性能监控和调试
105
+ *
106
+ * 使用建议:
107
+ * - 在大量几何体加载完成后调用deepMerge进行合并
108
+ * - 对于动态更新的场景,考虑使用mergeInner进行轻量级合并
109
+ * - 定期调用resetMergeInfo重置统计信息
110
+ *
111
+ * @internal 内部工具类,不直接对外暴露
112
+ */
113
+ export declare class MergeUtils {
114
+ /**
115
+ * 合并统计信息
116
+ * 记录每次合并操作的详细统计数据,用于性能监控和调试
117
+ * 所有字段都会在每次合并操作后更新
118
+ */
119
+ static mergeInfo: {
120
+ /**
121
+ * 被移除的对象数量
122
+ * 统计被合并掉的原始对象总数
123
+ * 这些对象被合并到新的几何体中,原始对象被销毁
124
+ */
125
+ removedObjects: number;
126
+ /**
127
+ * 合并后的网格数量
128
+ * 统计成功合并的网格(Mesh)几何体数量
129
+ * 每个合并后的网格可能包含多个原始网格的数据
130
+ */
131
+ mergedMeshes: number;
132
+ /**
133
+ * 合并后的线段数量
134
+ * 统计成功合并的线段(Line)几何体数量
135
+ * 线段合并相对复杂,需要处理索引和线段模式
136
+ */
137
+ mergedLines: number;
138
+ /**
139
+ * 合并后的点云数量
140
+ * 统计成功合并的点云(Points)几何体数量
141
+ * 点云合并通常用于粒子系统或散点数据
142
+ */
143
+ mergedPoints: number;
144
+ /**
145
+ * 合并的未知类型对象数量
146
+ * 统计合并的非标准类型对象数量
147
+ * 通常这些对象类型不影响主要渲染性能
148
+ */
149
+ mergedUnknownTypeObjects: number;
150
+ /**
151
+ * 合并操作耗时
152
+ * 记录整个合并过程的总耗时,单位为毫秒
153
+ * 用于性能分析和优化
154
+ */
155
+ elapsedTime: number;
156
+ };
157
+ /**
158
+ * 重置合并统计信息
159
+ *
160
+ * 将所有统计字段重置为0,用于开始新的合并统计周期
161
+ * 建议在每次批量合并操作前调用此方法
162
+ *
163
+ * 使用场景:
164
+ * 1. 开始新的模型加载和合并流程前
165
+ * 2. 性能测试时需要独立的统计数据
166
+ * 3. 调试时需要清除之前的统计信息
167
+ */
168
+ static resetMergeInfo(): void;
169
+ /**
170
+ * 尝试处理可合并对象
171
+ *
172
+ * 此方法是合并算法的核心,负责检查两个对象是否可以合并。
173
+ * 如果可以合并,则将它们分组到同一个批次中。
174
+ * 该方法采用性能优化的策略,避免重复比较已经确认可合并的对象。
175
+ *
176
+ * 合并条件检查顺序:
177
+ * 1. 边界检查 - 确保索引有效
178
+ * 2. 对象类型检查 - 确保有几何体且为BufferGeometry
179
+ * 3. 合并条件检查 - 材质、几何属性、对象属性等
180
+ * 4. 批次管理 - 创建新批次或加入现有批次
181
+ *
182
+ * @private 私有方法,仅供内部调用
183
+ *
184
+ * @param object 父对象或对象数组 - 可以是THREE.Object3D或其子对象数组
185
+ * @param i 第一个对象的索引 - 在对象数组中的位置
186
+ * @param k 第二个对象的索引 - 在对象数组中的位置,用于比较
187
+ * @param dict 可合并对象字典 - 存储已分组的可合并对象索引
188
+ * 键为第一个对象的索引,值为包含该组所有索引的对象
189
+ * @param nonMergeIndexes 非合并索引数组 - 存储暂时找不到合并伙伴的对象索引
190
+ * 用于优化性能,避免重复检查
191
+ *
192
+ * @returns 是否找到可合并对象 - true表示成功找到并处理,false表示未找到
193
+ */
194
+ private static tryHandleMergeableObjects;
195
+ /**
196
+ * 深度合并对象数组
197
+ *
198
+ * 这是MergeUtils的核心方法,负责将一组Three.js对象进行智能合并。
199
+ * 该方法采用深度合并策略,将具有相同材质和属性的几何体合并为单个几何体,
200
+ * 从而显著减少Draw Call数量,提升渲染性能。
201
+ *
202
+ * 合并策略:
203
+ * 1. 仅处理叶子节点的对象,不处理有子对象的容器对象
204
+ * 2. 基于材质相等性和几何属性兼容性进行合并
205
+ * 3. 保持原始对象的变换矩阵和用户数据
206
+ * 4. 支持批处理信息的保存,便于后续查询和交互
207
+ *
208
+ * 性能优化:
209
+ * - 使用字典结构缓存已分组的对象,避免重复比较
210
+ * - 从后往前遍历以提高缓存命中率
211
+ * - 支持非合并索引数组,减少不必要的比较
212
+ * - 详细的日志记录,便于性能分析
213
+ *
214
+ * 使用建议:
215
+ * - 在大量几何体加载完成后调用此方法
216
+ * - 对于实时更新的场景,可以考虑减少批处理信息保存
217
+ * - 注意合并后的对象会从原父对象移除并添加到levelObject
218
+ *
219
+ * @param objects 要合并的对象数组 - 必须是THREE.Object3D的实例
220
+ * @param levelObject 目标父对象 - 可选,合并后的对象会被添加到此对象中
221
+ * @param bRemovedAndAddedAfterMerge 是否自动移除和添加 - 默认为true,控制是否自动处理父子关系
222
+ * @param bRemoveEmptyObjectsAfterMerge 是否移除空对象 - 默认为true,清理合并后的空容器对象
223
+ * @param saveBatchInfo 是否保存批处理信息 - 默认为true,用于后续查询原始对象信息
224
+ *
225
+ * @returns 合并结果对象
226
+ * - added: 新增的对象数组(合并后的对象)
227
+ * - removed: 被移除的对象数组(被合并掉的原始对象)
228
+ */
229
+ static deepMerge(objects: THREE.Object3D[], levelObject?: THREE.Object3D | undefined, bRemovedAndAddedAfterMerge?: boolean, bRemoveEmptyObjectsAfterMerge?: boolean, saveBatchInfo?: boolean): {
230
+ added: THREE.Object3D[];
231
+ removed: THREE.Object3D[];
232
+ };
233
+ /**
234
+ * 应用变换矩阵到几何体
235
+ *
236
+ * 在合并过程中,由于几何体会被移动到新的父对象下,需要正确应用其祖先对象的变换矩阵。
237
+ * 此方法遍历对象的祖先链,累积所有变换矩阵,然后应用到几何体上。
238
+ *
239
+ * 对象层级结构示例:
240
+ * ```
241
+ * - root object (根对象)
242
+ * - merged objects group (合并对象组)
243
+ * - merged object 1 (合并后的对象1)
244
+ * - merged object 2 (合并后的对象2)
245
+ * ```
246
+ *
247
+ * 矩阵应用原理:
248
+ * 1. 从当前对象开始,向上遍历所有祖先对象
249
+ * 2. 累积每个祖先对象的变换矩阵(从下往上累乘)
250
+ * 3. 将累积的变换矩阵应用到几何体的顶点上
251
+ * 4. 优化:如果累积矩阵为单位矩阵,则无需应用变换
252
+ *
253
+ * 性能优化:
254
+ * - 使用预分配的临时矩阵对象,避免频繁创建
255
+ * - 提前检查是否为单位矩阵,跳过不必要的计算
256
+ * - 支持可选的levelObject参数,控制遍历的终止条件
257
+ *
258
+ * @private 私有方法,仅供内部合并过程调用
259
+ *
260
+ * @param copyGeometry 要应用的几何体副本 - 必须是已经克隆的几何体,不能修改原始几何体
261
+ * @param object 当前对象 - 需要计算其相对于levelObject的变换矩阵
262
+ * @param levelObject 目标层级对象 - 可选,矩阵累积的终止对象,默认为场景根对象
263
+ *
264
+ * @returns 应用变换后的几何体 - 如果应用了变换则返回新几何体,否则返回原几何体
265
+ */
266
+ private static applyMatrix;
267
+ /**
268
+ * 合并线段几何体
269
+ *
270
+ * 专门用于合并线段(Line)和线段组(LineSegments)的几何体方法。
271
+ * 线段合并相对复杂,因为需要处理不同的线段模式和索引结构。
272
+ *
273
+ * 线段类型说明:
274
+ * - LineSegments: 每两个顶点构成一条线段 (0-1, 2-3, 4-5...)
275
+ * - Line: 所有顶点依次连接形成连续线段 (0-1-2-3-4...)
276
+ *
277
+ * 合并策略:
278
+ * 1. 对于非虚线材质:直接使用Three.js的标准合并方法
279
+ * 2. 对于虚线材质:需要特殊处理,将Line转换为LineSegments
280
+ *
281
+ * 索引重建逻辑:
282
+ * - LineSegments模式:保持原始索引结构,直接累加顶点偏移
283
+ * - Line模式:需要重建索引,将连续线段转换为独立线段
284
+ * - 无索引模式:遍历所有顶点,动态生成索引
285
+ *
286
+ * 批处理信息更新:
287
+ * - 保存每个批次的索引范围和顶点范围
288
+ * - 支持后续通过索引查询原始批次信息
289
+ *
290
+ * @param geometries 要合并的几何体数组 - 所有几何体必须有相同的属性结构
291
+ * @param saveBatchInfo 是否保存批处理信息 - 用于后续查询和交互
292
+ * @param isDashedMaterial 是否为虚线材质 - 虚线材质需要特殊处理
293
+ * @param batches 批次信息数组 - 可选,用于保存批处理详细信息
294
+ *
295
+ * @returns 合并后的几何体 - 如果合并失败返回undefined
296
+ */
297
+ static mergeLineGeometries(geometries: THREE.BufferGeometry[], saveBatchInfo: boolean, isDashedMaterial: boolean, batches?: Batch[]): THREE.BufferGeometry | undefined;
298
+ /**
299
+ * 将线段几何体转换为线段组并合并
300
+ *
301
+ * 专门处理虚线材质的线段合并方法。
302
+ * 当使用虚线材质(LineDashedMaterial或ShaderMaterial)时,
303
+ * 需要将普通的Line转换为LineSegments格式才能正确显示虚线效果。
304
+ *
305
+ * 转换原理:
306
+ * 原始Line: 顶点序列 [0,1,2,3,4] -> 连接为 0-1-2-3-4
307
+ * 转换为LineSegments: 顶点序列 [0,1,0,2,1,2,2,3,3,4] -> 连接为 0-1,0-2,1-2,2-3,3-4
308
+ *
309
+ * 处理步骤:
310
+ * 1. 检查所有几何体的属性兼容性
311
+ * 2. 转换有索引的几何体为非索引格式
312
+ * 3. 收集所有几何体的顶点属性
313
+ * 4. 为每个几何体生成对应的顶点和索引数据
314
+ * 5. 合并所有属性为单个几何体
315
+ * 6. 更新批处理信息
316
+ *
317
+ * 性能优化:
318
+ * - 预分配数组空间,避免动态扩容
319
+ * - 批量处理顶点属性,提高内存访问效率
320
+ * - 只在需要时计算批处理信息
321
+ *
322
+ * @private 私有方法,仅供线段合并过程调用
323
+ *
324
+ * @param geometries 要合并的几何体数组 - 所有几何体必须有相同的属性结构
325
+ * @param saveBatchInfo 是否保存批处理信息 - 用于后续查询和交互
326
+ * @param batches 批次信息数组 - 用于保存批处理详细信息
327
+ *
328
+ * @returns 合并后的几何体 - 如果合并失败返回undefined
329
+ */
330
+ private static mergeBufferGeometriesWithLinesToLineSegments;
331
+ /**
332
+ * 合并线段顶点属性(转换为线段组格式)
333
+ *
334
+ * 处理虚线材质时,将Line格式的顶点属性转换为LineSegments格式。
335
+ * 这个方法是线段合并过程中的核心属性处理逻辑。
336
+ *
337
+ * 属性转换规则:
338
+ * 1. LineSegments模式:顶点属性保持不变
339
+ * 2. Line模式:每个连续线段需要复制顶点属性
340
+ *
341
+ * 转换示例:
342
+ * 原始Line顶点: [A, B, C, D] (属性值: [a1, b1, c1, d1])
343
+ * 转换为LineSegments: [A, B, A, C, B, C, C, D] (属性值: [a1, b1, a1, c1, b1, c1, c1, d1])
344
+ *
345
+ * 处理步骤:
346
+ * 1. 验证所有属性的类型和大小一致性
347
+ * 2. 计算合并后的总数组长度
348
+ * 3. 逐个处理每个几何体的属性
349
+ * 4. 根据线段模式进行属性复制或直接使用
350
+ * 5. 返回合并后的BufferAttribute
351
+ *
352
+ * 性能优化:
353
+ * - 预计算数组长度,避免动态扩容
354
+ * - 使用TypedArray进行高效的内存操作
355
+ * - 批量处理所有属性,减少函数调用开销
356
+ *
357
+ * @private 私有方法,仅供属性合并过程调用
358
+ *
359
+ * @param attributes 要合并的属性数组 - 每个元素对应一个几何体的同名属性
360
+ * @param isLineSegmentsArray 线段模式标记数组 - 标识每个几何体是否为LineSegments模式
361
+ *
362
+ * @returns 合并后的BufferAttribute - 如果合并失败返回undefined
363
+ */
364
+ private static mergeBufferAttributesWithLinesToLineSegments;
365
+ /**
366
+ * 从数组中移除指定数字
367
+ *
368
+ * 从后往前遍历数组,查找并移除第一个匹配的元素。
369
+ * 使用从后往前遍历的方式可以避免移除元素时索引变化导致的bug。
370
+ *
371
+ * 使用场景:
372
+ * - 从非合并索引数组中移除已找到合并伙伴的索引
373
+ * - 清理临时数组中的过期数据
374
+ *
375
+ * 性能优化:
376
+ * - 从数组末尾开始遍历,通常能更快找到要删除的元素
377
+ * - 只删除第一个匹配的元素,避免意外删除多个相同值
378
+ * - 使用splice方法一次性完成删除操作
379
+ *
380
+ * @private 私有方法,仅供内部数组操作使用
381
+ *
382
+ * @param arr 要操作的数字数组 - 会被原地修改
383
+ * @param toBeDeleted 要删除的数字值 - 只删除第一个匹配的元素
384
+ */
385
+ private static removeFromArray;
386
+ /**
387
+ * 检查两个几何体是否可以合并
388
+ *
389
+ * 验证两个几何体是否具有相同的结构和属性,从而可以安全合并。
390
+ * 这是合并前的关键检查,确保合并后的几何体具有一致的属性结构。
391
+ *
392
+ * 检查条件:
393
+ * 1. 类型检查:两个几何体都必须是BufferGeometry
394
+ * 2. 实例类型排除:不支持InstancedBufferGeometry(实例化几何体)
395
+ * 3. 索引一致性:要么都有索引,要么都没有索引
396
+ * 4. 属性完整性:具有相同的属性集合
397
+ * 5. 属性存在性:每个属性在两个几何体中都存在
398
+ *
399
+ * 不支持InstancedBufferGeometry的原因:
400
+ * - 实例化几何体有特殊的实例变换矩阵
401
+ * - 合并后实例信息会丢失,导致渲染错误
402
+ * - 需要特殊的实例合并逻辑,超出了标准合并的范围
403
+ *
404
+ * 性能优化:
405
+ * - 提前进行简单的null检查
406
+ * - 使用Set进行属性比较,提高查找效率
407
+ * - 详细的错误日志,便于调试
408
+ *
409
+ * @param g1 第一个几何体 - 要比较的几何体对象
410
+ * @param g2 第二个几何体 - 要比较的几何体对象
411
+ *
412
+ * @returns 是否可以合并 - true表示两个几何体兼容,可以合并
413
+ */
414
+ static areGeometriesMergeable(g1: THREE.BufferGeometry, g2: THREE.BufferGeometry): boolean;
415
+ /**
416
+ * 检查两个对象是否可以合并
417
+ *
418
+ * 验证两个Three.js对象是否满足合并条件,确保合并后的对象具有一致的行为。
419
+ * 这是对象级别的重要检查,基于多个维度进行兼容性验证。
420
+ *
421
+ * 检查条件:
422
+ * 1. 图层掩码(layer.mask):必须相同,确保对象在同一渲染层
423
+ * 2. 渲染顺序(renderOrder):必须相同,保持渲染顺序一致性
424
+ * 3. 可见性(visible):必须相同,确保可见性行为一致
425
+ * 4. 图层名称(layerName):如果存在,必须相同(DXF文件专用)
426
+ * 5. 对象类型:要么完全相同,要么都是同一绘制类型(Mesh/Line/Points)
427
+ *
428
+ * 图层掩码重要性:
429
+ * - 控制对象在哪些渲染层中可见
430
+ * - 合并不同掩码的对象会导致渲染错误
431
+ * - 必须严格检查,确保合并安全
432
+ *
433
+ * 图层名称在DXF中的作用:
434
+ * - DXF文件中的对象按图层组织
435
+ * - 相同图层的对象通常具有相同的材质和属性
436
+ * - 合并不同图层的对象可能会破坏DXF的图层结构
437
+ *
438
+ * 类型兼容性:
439
+ * - 严格类型匹配:两个Mesh对象可以合并
440
+ * - 绘制类型匹配:一个Mesh和一个Mesh可以合并
441
+ * - 混合类型不匹配:Mesh和Line不能合并
442
+ *
443
+ * @param o1 第一个对象 - 要比较的Three.js对象
444
+ * @param o2 第二个对象 - 要比较的Three.js对象
445
+ *
446
+ * @returns 是否可以合并 - true表示两个对象兼容,可以合并
447
+ */
448
+ static areObjectsMergeable(o1: THREE.Object3D, o2: THREE.Object3D): any;
449
+ /**
450
+ * 检查网格是否为合并后的对象
451
+ *
452
+ * 通过检查网格的userData中是否存在batches属性来判断是否为合并对象。
453
+ * 合并后的对象会在userData中保存批次信息,用于后续查询和操作。
454
+ *
455
+ * 合并对象的特征:
456
+ * - userData.batches存在且为数组
457
+ * - 每个batch包含原始对象的几何信息
458
+ * - 可以支持按批次进行局部操作
459
+ *
460
+ * 使用场景:
461
+ * 1. 鼠标交互时判断是否需要特殊处理
462
+ * 2. 性能优化时跳过已合并的对象
463
+ * 3. 调试时识别合并状态
464
+ * 4. 撤销操作时判断是否需要拆分
465
+ *
466
+ * 注意事项:
467
+ * - 只有通过MergeUtils合并的对象才会设置batches信息
468
+ * - 手动创建的网格不会有此标记
469
+ * - 如果保存批处理信息时设置为false,此方法会返回false
470
+ *
471
+ * @param mesh 要检查的网格对象 - THREE.Mesh实例
472
+ *
473
+ * @returns 是否为合并对象 - true表示此网格是合并后的对象
474
+ */
475
+ static isMergedMesh(mesh: THREE.Mesh): boolean;
476
+ /**
477
+ * 检查面索引是否属于指定批次
478
+ *
479
+ * 验证给定的面索引是否位于合并几何体中指定批次的范围内。
480
+ * 用于鼠标交互、选择等场景,确定点击的面属于哪个原始对象。
481
+ *
482
+ * 支持两种索引模式:
483
+ * 1. BoundsTree模式:BVH加速结构改变了原始索引,使用顶点索引判断
484
+ * 2. 标准索引模式:使用面索引范围直接判断
485
+ * 3. 无索引模式:使用顶点索引范围判断
486
+ *
487
+ * 判断逻辑:
488
+ * - BoundsTree模式:检查顶点索引是否在批次的顶点范围内
489
+ * - 有索引模式:检查面索引是否在批次的索引范围内
490
+ * - 无索引模式:将面索引转换为顶点索引后进行范围检查
491
+ *
492
+ * 使用场景:
493
+ * 1. 鼠标点击时确定点击的是哪个原始对象的面
494
+ * 2. 面选择工具中高亮显示特定批次
495
+ * 3. 局部更新时确定需要重新计算的面范围
496
+ * 4. 统计特定批次的面数量
497
+ *
498
+ * @param geometry 合并后的几何体 - 包含批次的几何体对象
499
+ * @param batch 批次信息 - 要检查的批次对象
500
+ * @param faceIndex 面索引 - 要检查的面在几何体中的索引
501
+ *
502
+ * @returns 是否属于批次 - true表示该面属于指定的批次
503
+ */
504
+ static isFaceIndexInBatch(geometry: THREE.BufferGeometry, batch: Batch, faceIndex: number): boolean;
505
+ /**
506
+ * 根据面索引获取批次信息
507
+ *
508
+ * 遍历合并网格的所有批次,查找包含指定面索引的批次。
509
+ * 这是鼠标交互和选择功能的核心方法,用于确定用户操作的是哪个原始对象。
510
+ *
511
+ * 查找过程:
512
+ * 1. 验证输入参数的有效性
513
+ * 2. 检查网格是否包含批次信息
514
+ * 3. 遍历所有批次,使用isFaceIndexInBatch方法检查每个批次
515
+ * 4. 返回第一个匹配的批次或undefined
516
+ *
517
+ * 错误处理:
518
+ * - 无效的面索引(负数)会记录错误日志并返回undefined
519
+ * - 没有批次信息的网格会返回undefined
520
+ * - 没有找到匹配批次的面索引也会返回undefined
521
+ *
522
+ * 性能优化:
523
+ * - 提前进行边界检查,避免无效计算
524
+ * - 使用高效的范围检查算法
525
+ * - 支持BoundsTree等加速结构
526
+ *
527
+ * 使用场景:
528
+ * 1. 鼠标点击事件中确定点击的原始对象
529
+ * 2. 面选择工具中获取选中面的原始信息
530
+ * 3. 局部材质更新时确定影响范围
531
+ * 4. 统计和分析特定批次的几何信息
532
+ *
533
+ * @param mesh 合并后的网格对象 - 包含批次信息的网格
534
+ * @param faceIndex 面索引 - 要查找的面在几何体中的索引
535
+ *
536
+ * @returns 批次信息 - 如果找到匹配的批次则返回Batch对象,否则返回undefined
537
+ */
538
+ static getBatchByFaceIndex(mesh: THREE.Mesh, faceIndex: number): Batch | undefined;
539
+ /**
540
+ * 根据线段索引获取批次信息
541
+ *
542
+ * 专门用于线段对象的批次查询方法。
543
+ * 根据给定的索引查找包含该索引的批次,用于线段的选择和交互。
544
+ *
545
+ * 索引类型说明:
546
+ * - 有索引的线段:index直接对应顶点索引
547
+ * - 无索引的线段:index对应顶点数组中的位置
548
+ *
549
+ * 查找逻辑:
550
+ * 1. 验证索引的有效性(不能为负数)
551
+ * 2. 检查线段对象是否包含批次信息
552
+ * 3. 根据索引类型选择合适的比较方法
553
+ * 4. 遍历批次列表查找匹配的批次
554
+ *
555
+ * 性能优化:
556
+ * - 提前进行边界检查
557
+ * - 支持两种索引模式的自适应处理
558
+ * - 高效的范围查找算法
559
+ *
560
+ * 使用场景:
561
+ * 1. 线段选择工具中确定选中的线段属于哪个批次
562
+ * 2. 鼠标悬停在线段上时显示批次信息
563
+ * 3. 线段编辑时确定编辑范围
564
+ * 4. 线段属性统计和分析
565
+ *
566
+ * @param line 合并后的线段对象 - 包含批次信息的线段
567
+ * @param index 线段索引 - 要查找的索引值
568
+ *
569
+ * @returns 批次信息 - 如果找到匹配的批次则返回Batch对象,否则返回undefined
570
+ */
571
+ static getBatchByLineIndex(line: THREE.Line, index: number): Batch | undefined;
572
+ /**
573
+ * 根据面索引获取批次ID
574
+ *
575
+ * 通过面索引快速获取对应的批次ID,这是getBatchByFaceIndex方法的简化版本。
576
+ * 主要用于需要批次ID而不需要完整批次信息的场景。
577
+ *
578
+ * 实现原理:
579
+ * 1. 调用getBatchByFaceIndex获取完整的批次信息
580
+ * 2. 如果找到批次则返回其batchId
581
+ * 3. 如果没有找到则返回-1表示无效
582
+ *
583
+ * 性能优化:
584
+ * - 重用现有的批次查找逻辑
585
+ * - 避免重复的遍历操作
586
+ * - 提供统一的错误处理
587
+ *
588
+ * 使用场景:
589
+ * 1. 快速判断面是否属于有效批次
590
+ * 2. 批次ID用于哈希表或数组索引
591
+ * 3. 性能敏感的查找操作
592
+ * 4. 批次统计和分组
593
+ *
594
+ * 注意事项:
595
+ * - 返回-1表示无效批次,需要检查错误情况
596
+ * - 依赖于getBatchByFaceIndex的实现
597
+ * - 对于无效输入会返回-1
598
+ *
599
+ * @param mesh 合并后的网格对象 - 包含批次信息的网格
600
+ * @param faceIndex 面索引 - 要查找的面在几何体中的索引
601
+ *
602
+ * @returns 批次ID - 有效的批次ID(>=0)或-1(无效)
603
+ */
604
+ static getBatchIdByFaceIndex(mesh: THREE.Mesh, faceIndex: number): number;
605
+ /**
606
+ * 根据批次ID获取批次信息
607
+ *
608
+ * 通过批次ID直接查找对应的批次对象。
609
+ * 这是最直接高效的批次查找方法,适合已知批次ID的场景。
610
+ *
611
+ * 查找过程:
612
+ * 1. 验证网格是否包含批次信息
613
+ * 2. 遍历批次数组查找匹配的batchId
614
+ * 3. 返回找到的批次对象或undefined
615
+ *
616
+ * 性能优化:
617
+ * - O(n)时间复杂度,n为批次数量
618
+ * - 对于大量批次的场景可以考虑建立ID到批次的映射表
619
+ * - 提前进行有效性检查
620
+ *
621
+ * 使用场景:
622
+ * 1. 已知批次ID需要获取详细信息
623
+ * 2. 批次管理和维护操作
624
+ * 3. 跨组件的批次信息传递
625
+ * 4. 批次数据缓存和更新
626
+ *
627
+ * 注意事项:
628
+ * - 批次ID从0开始连续分配
629
+ * - 如果批次不存在会返回undefined
630
+ * - 非合并对象也会返回undefined
631
+ *
632
+ * @param mesh 合并后的网格对象 - 包含批次信息的网格
633
+ * @param batchId 批次ID - 要查找的批次唯一标识符
634
+ *
635
+ * @returns 批次信息 - 如果找到则返回Batch对象,否则返回undefined
636
+ */
637
+ static getBatchByBatchId(mesh: THREE.Mesh, batchId: number): Batch | undefined;
638
+ }