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.
- package/README.md +1 -0
- package/dist/dxfview.esm.min.js +7 -0
- package/dist/types/components/dxf-layout-bar/DxfLayoutBar.d.ts +26 -0
- package/dist/types/components/dxf-layout-bar/index.d.ts +1 -0
- package/dist/types/components/pop-panel/PopPanel.d.ts +14 -0
- package/dist/types/components/pop-panel/index.d.ts +1 -0
- package/dist/types/components/progress-bar/ProgressBar.d.ts +34 -0
- package/dist/types/components/progress-bar/index.d.ts +1 -0
- package/dist/types/components/settings/ProjectSettingsDef.d.ts +44 -0
- package/dist/types/components/settings/index.d.ts +1 -0
- package/dist/types/components/tool-tip/Tooltip.d.ts +20 -0
- package/dist/types/components/tool-tip/index.d.ts +1 -0
- package/dist/types/core/Configs.d.ts +238 -0
- package/dist/types/core/Constants.d.ts +164 -0
- package/dist/types/core/Units.d.ts +16 -0
- package/dist/types/core/VersionManager.d.ts +3 -0
- package/dist/types/core/camera-controls/CameraControls.d.ts +773 -0
- package/dist/types/core/camera-controls/Constants.d.ts +2 -0
- package/dist/types/core/camera-controls/EventDispatcher.d.ts +41 -0
- package/dist/types/core/camera-controls/index.d.ts +2 -0
- package/dist/types/core/camera-controls/types.d.ts +112 -0
- package/dist/types/core/camera-controls/utils/extractClientCoordFromEvent.d.ts +3 -0
- package/dist/types/core/camera-controls/utils/math-utils.d.ts +11 -0
- package/dist/types/core/camera-controls/utils/notSupportedInOrthographicCamera.d.ts +2 -0
- package/dist/types/core/canvas/CanvasRender.d.ts +52 -0
- package/dist/types/core/canvas/Constants.d.ts +28 -0
- package/dist/types/core/canvas/Drawable.d.ts +87 -0
- package/dist/types/core/canvas/DrawableList.d.ts +29 -0
- package/dist/types/core/canvas/index.d.ts +4 -0
- package/dist/types/core/compare/BaseDxfCompareHelper.d.ts +104 -0
- package/dist/types/core/compare/CompareDrawable.d.ts +17 -0
- package/dist/types/core/compare/DxfCompareHelper.d.ts +69 -0
- package/dist/types/core/compare/DxfCompareMarkupManager.d.ts +11 -0
- package/dist/types/core/compare/index.d.ts +4 -0
- package/dist/types/core/controls/CameraControlsEx.d.ts +34 -0
- package/dist/types/core/controls/index.d.ts +1 -0
- package/dist/types/core/dxf/DxfCompare.d.ts +151 -0
- package/dist/types/core/dxf/DxfConstants.d.ts +15 -0
- package/dist/types/core/dxf/DxfLoader.d.ts +526 -0
- package/dist/types/core/dxf/DxfObject.d.ts +32 -0
- package/dist/types/core/dxf/DxfUtils.d.ts +79 -0
- package/dist/types/core/dxf/HatchPatternShaders.d.ts +12 -0
- package/dist/types/core/dxf/LinePatternShaders.d.ts +12 -0
- package/dist/types/core/dxf/bspline.d.ts +8 -0
- package/dist/types/core/dxf/dxfom-mtext.d.ts +46 -0
- package/dist/types/core/dxf/dxfom-text.d.ts +16 -0
- package/dist/types/core/dxf/index.d.ts +10 -0
- package/dist/types/core/dxf/round10.d.ts +2 -0
- package/dist/types/core/dxf-parser/AutoCadColorIndex.d.ts +8 -0
- package/dist/types/core/dxf-parser/DxfBaseReader.d.ts +12 -0
- package/dist/types/core/dxf-parser/DxfBinaryReader.d.ts +14 -0
- package/dist/types/core/dxf-parser/DxfParser.d.ts +327 -0
- package/dist/types/core/dxf-parser/DxfTextReader.d.ts +31 -0
- package/dist/types/core/dxf-parser/ParseHelpers.d.ts +36 -0
- package/dist/types/core/dxf-parser/entities/3dface.d.ts +11 -0
- package/dist/types/core/dxf-parser/entities/arc.d.ts +16 -0
- package/dist/types/core/dxf-parser/entities/attdef.d.ts +31 -0
- package/dist/types/core/dxf-parser/entities/attrib.d.ts +31 -0
- package/dist/types/core/dxf-parser/entities/circle.d.ts +13 -0
- package/dist/types/core/dxf-parser/entities/dimension.d.ts +22 -0
- package/dist/types/core/dxf-parser/entities/ellipse.d.ts +15 -0
- package/dist/types/core/dxf-parser/entities/geomtry.d.ts +40 -0
- package/dist/types/core/dxf-parser/entities/hatch.d.ts +108 -0
- package/dist/types/core/dxf-parser/entities/image.d.ts +37 -0
- package/dist/types/core/dxf-parser/entities/insert.d.ts +20 -0
- package/dist/types/core/dxf-parser/entities/leader.d.ts +23 -0
- package/dist/types/core/dxf-parser/entities/line.d.ts +10 -0
- package/dist/types/core/dxf-parser/entities/lwpolyline.d.ts +21 -0
- package/dist/types/core/dxf-parser/entities/mleader.d.ts +101 -0
- package/dist/types/core/dxf-parser/entities/mtext.d.ts +18 -0
- package/dist/types/core/dxf-parser/entities/ole2frame.d.ts +20 -0
- package/dist/types/core/dxf-parser/entities/point.d.ts +11 -0
- package/dist/types/core/dxf-parser/entities/polyline.d.ts +20 -0
- package/dist/types/core/dxf-parser/entities/ray.d.ts +10 -0
- package/dist/types/core/dxf-parser/entities/region.d.ts +10 -0
- package/dist/types/core/dxf-parser/entities/seqend.d.ts +8 -0
- package/dist/types/core/dxf-parser/entities/solid.d.ts +10 -0
- package/dist/types/core/dxf-parser/entities/spline.d.ts +23 -0
- package/dist/types/core/dxf-parser/entities/table.d.ts +42 -0
- package/dist/types/core/dxf-parser/entities/text.d.ts +18 -0
- package/dist/types/core/dxf-parser/entities/vertex.d.ts +20 -0
- package/dist/types/core/dxf-parser/entities/viewport.d.ts +46 -0
- package/dist/types/core/dxf-parser/entities/xline.d.ts +10 -0
- package/dist/types/core/dxf-parser/index.d.ts +27 -0
- package/dist/types/core/dxf-parser/objects/common.d.ts +15 -0
- package/dist/types/core/dxf-parser/objects/dictionary.d.ts +19 -0
- package/dist/types/core/dxf-parser/objects/imagedef.d.ts +24 -0
- package/dist/types/core/dxf-parser/objects/layout.d.ts +29 -0
- package/dist/types/core/dxf-parser/objects/sortentstable.d.ts +12 -0
- package/dist/types/core/dxf-parser/objects/spatialfilter.d.ts +22 -0
- package/dist/types/core/dxf-parser/objects/xrecord.d.ts +11 -0
- package/dist/types/core/font/BaseFont.d.ts +88 -0
- package/dist/types/core/font/FontManager.d.ts +107 -0
- package/dist/types/core/font/MeshFont.d.ts +44 -0
- package/dist/types/core/font/ShxFont.d.ts +108 -0
- package/dist/types/core/font/index.d.ts +1 -0
- package/dist/types/core/font/shx/ExtraLettersTemplate.d.ts +1 -0
- package/dist/types/core/font/shx/Shx.constants.d.ts +11 -0
- package/dist/types/core/font/shx/ShxParser.d.ts +18 -0
- package/dist/types/core/font/shx/TextShape.d.ts +24 -0
- package/dist/types/core/font/shx/gbk/index.d.ts +4 -0
- package/dist/types/core/font/shx/index.d.ts +1 -0
- package/dist/types/core/font/shx/util/BitConverter.d.ts +18 -0
- package/dist/types/core/geometry-offset/Edge.d.ts +27 -0
- package/dist/types/core/geometry-offset/Offset.d.ts +46 -0
- package/dist/types/core/geometry-offset/index.d.ts +1 -0
- package/dist/types/core/helpers/BinaryReader.d.ts +24 -0
- package/dist/types/core/helpers/BoxSelectHelper.d.ts +44 -0
- package/dist/types/core/helpers/LoadingHelper.d.ts +46 -0
- package/dist/types/core/helpers/MobileTouchHelperDrawable.d.ts +26 -0
- package/dist/types/core/helpers/OSnapHelper.d.ts +167 -0
- package/dist/types/core/helpers/ObjectPixelSizeHelper.d.ts +13 -0
- package/dist/types/core/helpers/PickMarkupHelper.d.ts +29 -0
- package/dist/types/core/helpers/RafHelper.d.ts +18 -0
- package/dist/types/core/helpers/ZoomToRectHelper.d.ts +17 -0
- package/dist/types/core/helpers/index.d.ts +9 -0
- package/dist/types/core/index.d.ts +18 -0
- package/dist/types/core/indexeddb/AnnotationTable.d.ts +14 -0
- package/dist/types/core/indexeddb/BaseTable.d.ts +36 -0
- package/dist/types/core/indexeddb/DxfDataTable.d.ts +22 -0
- package/dist/types/core/indexeddb/FontDataTable.d.ts +32 -0
- package/dist/types/core/indexeddb/IndexedDbManager.d.ts +29 -0
- package/dist/types/core/indexeddb/ViewpointTable.d.ts +14 -0
- package/dist/types/core/indexeddb/index.d.ts +6 -0
- package/dist/types/core/input/InputManager.d.ts +161 -0
- package/dist/types/core/input/index.d.ts +1 -0
- package/dist/types/core/license/AutoConfig.d.ts +17 -0
- package/dist/types/core/license/LicenseManager.d.ts +107 -0
- package/dist/types/core/license/PublicKey.d.ts +1 -0
- package/dist/types/core/license/index.d.ts +1 -0
- package/dist/types/core/markup/ArrowMarkup.d.ts +14 -0
- package/dist/types/core/markup/BaseMarkup.d.ts +28 -0
- package/dist/types/core/markup/CircleMarkup.d.ts +12 -0
- package/dist/types/core/markup/CloudLineMarkup.d.ts +10 -0
- package/dist/types/core/markup/CloudRectMarkup.d.ts +11 -0
- package/dist/types/core/markup/CloudRectWithTextMarkup.d.ts +43 -0
- package/dist/types/core/markup/Constants.d.ts +17 -0
- package/dist/types/core/markup/DotMarkup.d.ts +9 -0
- package/dist/types/core/markup/EllipseMarkup.d.ts +12 -0
- package/dist/types/core/markup/LeaderLineMarkup.d.ts +25 -0
- package/dist/types/core/markup/MarkupManager.d.ts +91 -0
- package/dist/types/core/markup/PolylineMarkup.d.ts +11 -0
- package/dist/types/core/markup/RectMarkup.d.ts +10 -0
- package/dist/types/core/markup/TextMarkup.d.ts +40 -0
- package/dist/types/core/markup/XMarkup.d.ts +10 -0
- package/dist/types/core/markup/index.d.ts +13 -0
- package/dist/types/core/model/Constants.d.ts +51 -0
- package/dist/types/core/model/Model.d.ts +18 -0
- package/dist/types/core/model/Model2d.d.ts +115 -0
- package/dist/types/core/model/index.d.ts +3 -0
- package/dist/types/core/patches/Constants.d.ts +4 -0
- package/dist/types/core/patches/Line.d.ts +2 -0
- package/dist/types/core/patches/Mesh.d.ts +2 -0
- package/dist/types/core/patches/Points.d.ts +2 -0
- package/dist/types/core/patches/index.d.ts +4 -0
- package/dist/types/core/undo-redo/AddAnnotationCommand.d.ts +11 -0
- package/dist/types/core/undo-redo/AddMarkupCommand.d.ts +10 -0
- package/dist/types/core/undo-redo/AddMeasurementCommand.d.ts +9 -0
- package/dist/types/core/undo-redo/Command.d.ts +6 -0
- package/dist/types/core/undo-redo/RemoveAnnotationCommand.d.ts +11 -0
- package/dist/types/core/undo-redo/RemoveMarkupCommand.d.ts +10 -0
- package/dist/types/core/undo-redo/RemoveMeasurementCommand.d.ts +9 -0
- package/dist/types/core/undo-redo/UndoRedoManager.d.ts +21 -0
- package/dist/types/core/undo-redo/UpdateMarkupCommand.d.ts +11 -0
- package/dist/types/core/undo-redo/index.d.ts +9 -0
- package/dist/types/core/utils/CSS2DObjectUtils.d.ts +14 -0
- package/dist/types/core/utils/ColorUtils.d.ts +21 -0
- package/dist/types/core/utils/CommonUtils.d.ts +125 -0
- package/dist/types/core/utils/CoordinateUtils.d.ts +81 -0
- package/dist/types/core/utils/DecimalPrecisionUtils.d.ts +4 -0
- package/dist/types/core/utils/DeviceUtils.d.ts +15 -0
- package/dist/types/core/utils/EdgeUtils.d.ts +14 -0
- package/dist/types/core/utils/Event.d.ts +33 -0
- package/dist/types/core/utils/FpsUtils.d.ts +13 -0
- package/dist/types/core/utils/GeometryUtils.d.ts +111 -0
- package/dist/types/core/utils/Locale.d.ts +190 -0
- package/dist/types/core/utils/LogUtils.d.ts +7 -0
- package/dist/types/core/utils/MaterialUtils.d.ts +40 -0
- package/dist/types/core/utils/MathUtils.d.ts +59 -0
- package/dist/types/core/utils/MergeUtils.d.ts +638 -0
- package/dist/types/core/utils/ObjectUtils.d.ts +87 -0
- package/dist/types/core/utils/PolygonUtils.d.ts +8 -0
- package/dist/types/core/utils/SVGObjectUtils.d.ts +16 -0
- package/dist/types/core/utils/SceneUtils.d.ts +26 -0
- package/dist/types/core/utils/SectionUtils.d.ts +11 -0
- package/dist/types/core/utils/UnitConversionUtils.d.ts +31 -0
- package/dist/types/core/utils/index.d.ts +21 -0
- package/dist/types/core/viewers/BaseViewer.d.ts +265 -0
- package/dist/types/core/viewers/DxfViewer.d.ts +1372 -0
- package/dist/types/core/viewers/Plugin.d.ts +29 -0
- package/dist/types/core/viewers/ViewerEvent.d.ts +178 -0
- package/dist/types/core/viewers/index.d.ts +4 -0
- package/dist/types/export.doc.d.ts +10 -0
- package/dist/types/fetch-polyfill.d.ts +2 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/plugins/annotation/AnnotationPlugin.d.ts +139 -0
- package/dist/types/plugins/annotation/AutoDrawAnnotation.d.ts +63 -0
- package/dist/types/plugins/annotation/BaseAnnotation.d.ts +113 -0
- package/dist/types/plugins/annotation/BaseAnnotationDrawable.d.ts +139 -0
- package/dist/types/plugins/annotation/CopyAnnotation.d.ts +36 -0
- package/dist/types/plugins/annotation/CopyDrawable.d.ts +26 -0
- package/dist/types/plugins/annotation/FreeDrawAnnotation.d.ts +59 -0
- package/dist/types/plugins/annotation/RectAnnotation.d.ts +53 -0
- package/dist/types/plugins/annotation/RectDrawable.d.ts +42 -0
- package/dist/types/plugins/annotation/ShapeFinder.d.ts +51 -0
- package/dist/types/plugins/annotation/freeDrawDrawable.d.ts +21 -0
- package/dist/types/plugins/annotation/index.d.ts +8 -0
- package/dist/types/plugins/annotation/type.d.ts +182 -0
- package/dist/types/plugins/axis-gizmo/AxisGizmoPlugin.d.ts +49 -0
- package/dist/types/plugins/axis-gizmo/CoordinateAxes.d.ts +12 -0
- package/dist/types/plugins/axis-gizmo/index.d.ts +1 -0
- package/dist/types/plugins/bottom-bar/BottomBarPlugin.d.ts +44 -0
- package/dist/types/plugins/bottom-bar/index.d.ts +1 -0
- package/dist/types/plugins/divide/CoverLayerManager.d.ts +44 -0
- package/dist/types/plugins/divide/DivGeometryUtils.d.ts +66 -0
- package/dist/types/plugins/divide/DividePlugin.d.ts +181 -0
- package/dist/types/plugins/divide/FrameAnnotation.d.ts +142 -0
- package/dist/types/plugins/divide/FrameDrawable.d.ts +75 -0
- package/dist/types/plugins/divide/index.d.ts +6 -0
- package/dist/types/plugins/divide/types.d.ts +38 -0
- package/dist/types/plugins/hotpoint/HotpointPlugin.d.ts +93 -0
- package/dist/types/plugins/hotpoint/index.d.ts +1 -0
- package/dist/types/plugins/index.d.ts +12 -0
- package/dist/types/plugins/layer-manager/LayerManagerPlugin.d.ts +59 -0
- package/dist/types/plugins/layer-manager/index.d.ts +1 -0
- package/dist/types/plugins/local-model-uploader/IUploader.d.ts +10 -0
- package/dist/types/plugins/local-model-uploader/LocalDxfUploader.d.ts +19 -0
- package/dist/types/plugins/local-model-uploader/index.d.ts +1 -0
- package/dist/types/plugins/measure/AngleMeasureDrawable.d.ts +12 -0
- package/dist/types/plugins/measure/AngleMeasurement.d.ts +16 -0
- package/dist/types/plugins/measure/AreaMeasureDrawable.d.ts +14 -0
- package/dist/types/plugins/measure/AreaMeasurement.d.ts +31 -0
- package/dist/types/plugins/measure/BaseMeasureDrawable.d.ts +35 -0
- package/dist/types/plugins/measure/BaseMeasurement.d.ts +127 -0
- package/dist/types/plugins/measure/CoordinateMeasureDrawable.d.ts +10 -0
- package/dist/types/plugins/measure/CoordinateMeasurement.d.ts +15 -0
- package/dist/types/plugins/measure/DistanceMeasureDrawable.d.ts +15 -0
- package/dist/types/plugins/measure/DistanceMeasurement.d.ts +28 -0
- package/dist/types/plugins/measure/MeasurementPlugin.d.ts +131 -0
- package/dist/types/plugins/measure/index.d.ts +3 -0
- package/dist/types/plugins/overview-map/ImageDrawable.d.ts +41 -0
- package/dist/types/plugins/overview-map/LineDrawable.d.ts +20 -0
- package/dist/types/plugins/overview-map/OverviewMapDrawable.d.ts +24 -0
- package/dist/types/plugins/overview-map/OverviewMapPlugin.d.ts +156 -0
- package/dist/types/plugins/overview-map/TextDrawable.d.ts +50 -0
- package/dist/types/plugins/overview-map/index.d.ts +5 -0
- package/dist/types/plugins/screenshot/ScreenshotPlugin.d.ts +88 -0
- package/dist/types/plugins/screenshot/index.d.ts +1 -0
- package/dist/types/plugins/stats/StatsPlugin.d.ts +20 -0
- package/dist/types/plugins/stats/index.d.ts +1 -0
- package/dist/types/plugins/toolbars/DxfViewerToolbarPlugin.d.ts +67 -0
- package/dist/types/plugins/toolbars/MarkupToolbar.d.ts +33 -0
- package/dist/types/plugins/toolbars/Toolbar.config.d.ts +5 -0
- package/dist/types/plugins/toolbars/Toolbar.constants.d.ts +96 -0
- package/dist/types/plugins/toolbars/Toolbar.d.ts +102 -0
- package/dist/types/plugins/toolbars/index.d.ts +5 -0
- package/dist/types/version.d.ts +2 -0
- package/package.json +90 -0
|
@@ -0,0 +1,1372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview DxfViewer 类 - DXF/DWG 文件的 3D 查看器核心组件
|
|
3
|
+
*
|
|
4
|
+
* 这个文件实现了 DxfViewer 类,该类继承自 BaseViewer,专门用于渲染和交互 DXF/DWG 格式的工程图纸。
|
|
5
|
+
* 主要功能包括:
|
|
6
|
+
* - 3D 场景渲染和相机控制
|
|
7
|
+
* - 图层管理和可见性控制
|
|
8
|
+
* - 实体选择和交互
|
|
9
|
+
* - 标注和测量功能
|
|
10
|
+
* - 布局视图切换
|
|
11
|
+
* - 标记和注释系统
|
|
12
|
+
*
|
|
13
|
+
* @author DxfViewer Team
|
|
14
|
+
* @version 1.0.0
|
|
15
|
+
*/
|
|
16
|
+
import * as THREE from "three";
|
|
17
|
+
import { CSS2DRenderer } from "three/examples/jsm/renderers/CSS2DRenderer.js";
|
|
18
|
+
import { DxfModelConfig, DxfViewerConfig } from "../../core/Configs";
|
|
19
|
+
import { Box2, // 矩阵自动更新设置
|
|
20
|
+
Vector2 } from "../../core/Constants";
|
|
21
|
+
import { Drawable, DrawableData } from "../../core/canvas";
|
|
22
|
+
import { // DXF 实体
|
|
23
|
+
DxfLayer } from "../../core/dxf";
|
|
24
|
+
import { ILayoutObject } from "../../core/dxf-parser";
|
|
25
|
+
import { FontManager } from "../../core/font";
|
|
26
|
+
import { EventInfo } from "../../core/input/InputManager";
|
|
27
|
+
import { MarkupManager, MarkupType } from "../../core/markup";
|
|
28
|
+
import { Model2d, ModelData2d } from "../../core/model";
|
|
29
|
+
import { BaseViewer, ViewerName } from "../../core/viewers/BaseViewer";
|
|
30
|
+
import { MeasurementData, MeasurementType } from "../../plugins/measure";
|
|
31
|
+
import type { MeasurementPlugin } from "../../plugins/measure";
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {DrawableData} MarkupData
|
|
34
|
+
* @description DxfViewer 的标记数据类型
|
|
35
|
+
*
|
|
36
|
+
* 标记数据包含额外的布局信息,例如布局名称。
|
|
37
|
+
* DxfViewer 不维护模型和标记数据之间的关系,业务逻辑应该知道
|
|
38
|
+
* 一组标记数据属于哪个模型。
|
|
39
|
+
*
|
|
40
|
+
* 这个类型继承自 DrawableData,扩展了基础的可绘制数据结构,
|
|
41
|
+
* 用于支持 DXF 查看器的标记功能,如注释、测量等。
|
|
42
|
+
*/
|
|
43
|
+
export declare type MarkupData = DrawableData;
|
|
44
|
+
/**
|
|
45
|
+
* @interface EntityData
|
|
46
|
+
* @description 实体数据接口
|
|
47
|
+
*
|
|
48
|
+
* 这个接口定义了 DXF 实体的数据结构,包含实体所属的模型和图层信息。
|
|
49
|
+
* 用于在查看器中唯一标识和定位一个实体对象。
|
|
50
|
+
*
|
|
51
|
+
* @property {string} modelId - 模型唯一标识符,用于区分不同的 DXF 文件
|
|
52
|
+
* @property {string} layerName - 图层名称,表示实体所在的图层
|
|
53
|
+
*/
|
|
54
|
+
export interface EntityData {
|
|
55
|
+
modelId: string;
|
|
56
|
+
layerName: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @interface DxfLayers
|
|
60
|
+
* @description DXF/DWG 图层组接口
|
|
61
|
+
*
|
|
62
|
+
* 这个接口定义了一个图纸的所有图层集合,包含图层名称到图层对象的映射。
|
|
63
|
+
* 用于管理和组织 DXF 文件中的图层信息,支持图层的显示/隐藏、颜色设置等操作。
|
|
64
|
+
*
|
|
65
|
+
* @property {string} modelId - 模型唯一标识符,对应具体的 DXF 文件
|
|
66
|
+
* @property {Record<string, DxfLayer>} layers - 图层映射表,键为图层名称,值为图层对象
|
|
67
|
+
*/
|
|
68
|
+
export interface DxfLayers {
|
|
69
|
+
modelId: string;
|
|
70
|
+
layers: Record<string, DxfLayer>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @interface PdfLayers
|
|
74
|
+
* @description PDF 图层组接口
|
|
75
|
+
*
|
|
76
|
+
* 这个接口定义了一个 PDF 文件的所有图层集合,虽然主要用于 DXF 查看器,
|
|
77
|
+
* 但也支持 PDF 文件的图层管理功能。
|
|
78
|
+
*
|
|
79
|
+
* @property {string} modelId - 模型唯一标识符
|
|
80
|
+
* @property {Record<string, PdfLayer>} layers - PDF 图层映射表,键为图层名称,值为图层对象
|
|
81
|
+
*/
|
|
82
|
+
export interface PdfLayers {
|
|
83
|
+
modelId: string;
|
|
84
|
+
layers: Record<string, PdfLayer>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @interface PdfLayer
|
|
88
|
+
* @description PDF 图层接口
|
|
89
|
+
*
|
|
90
|
+
* 这个接口定义了单个 PDF 图层的属性和状态信息。
|
|
91
|
+
* 用于控制 PDF 图层的显示和交互行为。
|
|
92
|
+
*
|
|
93
|
+
* @property {string} name - 图层名称,用于标识和显示
|
|
94
|
+
* @property {string} id - 图层唯一标识符
|
|
95
|
+
* @property {string} index - 图层索引,用于排序和定位
|
|
96
|
+
* @property {boolean} visible - 图层是否可见,控制显示状态
|
|
97
|
+
*/
|
|
98
|
+
export interface PdfLayer {
|
|
99
|
+
name: string;
|
|
100
|
+
id: string;
|
|
101
|
+
index: string;
|
|
102
|
+
visible: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @interface PdfData
|
|
106
|
+
* @description PDF 数据接口
|
|
107
|
+
*
|
|
108
|
+
* 这个接口定义了 PDF 文件的数据结构,虽然主要用于 DXF 查看器,
|
|
109
|
+
* 但也支持 PDF 文件的渲染和交互功能。
|
|
110
|
+
*
|
|
111
|
+
* @property {THREE.Object3D} threejsObject - 整个 DXF/PDF 文件的根 Three.js 对象
|
|
112
|
+
* @property {Record<string, PdfLayer>} layers - 图层映射表,包含所有图层信息
|
|
113
|
+
* @property {Record<string, THREE.Object3D[]>} layersAndThreejsObjects 可选 - 按图层名称组织的 Three.js 对象数组
|
|
114
|
+
* @property {number} loadedEntityCount - 已创建/加载的实体数量,主要用于日志记录,不是精确值
|
|
115
|
+
*/
|
|
116
|
+
export interface PdfData {
|
|
117
|
+
threejsObject: THREE.Object3D;
|
|
118
|
+
layers: Record<string, PdfLayer>;
|
|
119
|
+
layersAndThreejsObjects?: Record<string, THREE.Object3D[]>;
|
|
120
|
+
loadedEntityCount: number;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Threejs 对象按以下树状视图组织:
|
|
124
|
+
*
|
|
125
|
+
* - modelLevelObject1 (THREE.Group, name = <modelId>)
|
|
126
|
+
* - layoutLevelObject1 (THREE.Group, name = <布局名称>, 用于控制布局可见性)
|
|
127
|
+
* - entityLevelObject1 (THREE.Point/Line/Mesh/Group)
|
|
128
|
+
*
|
|
129
|
+
* - 图层 threejs 对象
|
|
130
|
+
* {
|
|
131
|
+
* layerName:[threejsObject1,threejsObject2,threejsObject3,...] (THREE.Point/Line/Mesh)
|
|
132
|
+
* }
|
|
133
|
+
*/
|
|
134
|
+
/**
|
|
135
|
+
* @class DxfViewer
|
|
136
|
+
* @description DXF/DWG 文件查看器类 - 专业的工程图纸 3D 查看器
|
|
137
|
+
*
|
|
138
|
+
* "dwg"是"drawing"的缩写,是AutoCAD保存的文件格式。
|
|
139
|
+
* "dxf"是数据交换格式,可以从dwg文件转换而来。
|
|
140
|
+
* 我们无法直接读取dwg文件,需要先通过ODA转换为dxf格式。
|
|
141
|
+
*
|
|
142
|
+
* 支持的DXF版本:AutoCAD 2018。同时支持二进制和ASCII格式。
|
|
143
|
+
*
|
|
144
|
+
* JSON编码:UTF-8编码,无BOM
|
|
145
|
+
*
|
|
146
|
+
* 坐标系统:右手坐标系,Y轴向上
|
|
147
|
+
*
|
|
148
|
+
* 关于单位:
|
|
149
|
+
* - 距离单位遵循主DXF文件的单位
|
|
150
|
+
* - 面积单位遵循主DXF文件的单位
|
|
151
|
+
* - 角度单位为"度",逆时针方向
|
|
152
|
+
* - 时间单位为"秒"
|
|
153
|
+
*
|
|
154
|
+
* 颜色:使用rgb/rgba,值范围0-1
|
|
155
|
+
*
|
|
156
|
+
* 关于DxfViewer中的测量:
|
|
157
|
+
* - 测量由DxfViewer生成
|
|
158
|
+
* - 测量数据应该由用户存储,以便稍后恢复到DxfViewer中
|
|
159
|
+
* - DxfViewer管理测量数据,可以创建、删除、隐藏等
|
|
160
|
+
* - DxfViewer不维护测量与布局之间的关系
|
|
161
|
+
*
|
|
162
|
+
* 关于DxfViewer中的标记:
|
|
163
|
+
* 标记与测量非常相似
|
|
164
|
+
*
|
|
165
|
+
* 关于DxfViewer中的热点:
|
|
166
|
+
* - 热点由用户创建和存储
|
|
167
|
+
* - 热点可以添加到DxfViewer中,也可以从中移除
|
|
168
|
+
* - 调用者应该设置在当前DxfViewer会话中唯一的热点ID
|
|
169
|
+
* - DxfViewer不会隐藏热点,用户可以自己操作
|
|
170
|
+
* - DxfViewer不维护热点与布局之间的关系
|
|
171
|
+
*
|
|
172
|
+
* 关于布局:
|
|
173
|
+
* - 每个布局都有自己的主视图
|
|
174
|
+
* - 切换到另一个布局时,会清除所有测量、标记和热点
|
|
175
|
+
* - 切换到另一个布局时,会停用任何正在进行的操作,如测量、标记等
|
|
176
|
+
*
|
|
177
|
+
* 关于叠加:
|
|
178
|
+
* - 只要浏览器有足够的内存、CPU/GPU等,就支持添加任意数量的模型
|
|
179
|
+
* - 第一个模型称为"主模型",其他的称为"叠加模型"
|
|
180
|
+
* - 忽略叠加模型的图纸空间
|
|
181
|
+
* - 如果叠加模型的单位与主模型不同,应该转换为主模型的单位
|
|
182
|
+
* - 在getLayers()中会添加modelId作为前缀
|
|
183
|
+
*
|
|
184
|
+
* 关于比较:
|
|
185
|
+
* - 只比较"模型"空间
|
|
186
|
+
* - 比较具有相同句柄和类型的实体
|
|
187
|
+
* - 比较实体的几何形状、位置、缩放等
|
|
188
|
+
* - 忽略图层的可见性、冻结设置
|
|
189
|
+
* - 忽略实体的属性,如线型、线宽、填充图案、字体、颜色等
|
|
190
|
+
* - 忽略块引用的空间过滤器(xclip)
|
|
191
|
+
* - 忽略与图层相关的操作,如将实体移动到另一个图层、更改图层颜色等
|
|
192
|
+
* - 默认情况下,"添加"的实体以绿色渲染,"删除"的实体以红色渲染,"修改"的实体由两部分组成,一个"删除"和一个"添加"
|
|
193
|
+
*
|
|
194
|
+
* 关于撤销/重做:
|
|
195
|
+
* - 支持测量和标记操作的撤销/重做。例如:创建/删除/移动标记
|
|
196
|
+
* - 设置/移除一批测量或标记将被视为一个操作
|
|
197
|
+
* - 切换到另一个布局会清除所有撤销/重做历史记录
|
|
198
|
+
*
|
|
199
|
+
* 关于对象捕捉(OSnap):
|
|
200
|
+
* - 支持捕捉到线的端点和中点
|
|
201
|
+
* - 支持捕捉到两条线的交点
|
|
202
|
+
* - 支持捕捉到垂直于线的垂足
|
|
203
|
+
* - 支持捕捉到线上的任意点
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ``` typescript
|
|
207
|
+
* const viewerCfg = {
|
|
208
|
+
* containerId: "myCanvas",
|
|
209
|
+
* enableSpinner: true,
|
|
210
|
+
* enableLayoutBar: true,
|
|
211
|
+
* };
|
|
212
|
+
* const modelCfg = {
|
|
213
|
+
* modelId: "id_0",
|
|
214
|
+
* name: "sample",
|
|
215
|
+
* src: "http://www.abc.com/sample.dxf",
|
|
216
|
+
* }
|
|
217
|
+
* const fontFiles = ["http://www.abc.com/hztxt.shx", "http://www.abc.com/simplex.shx"];
|
|
218
|
+
*
|
|
219
|
+
* const viewer = new DxfViewer(viewerCfg);
|
|
220
|
+
* await viewer.setFont(fontFiles);
|
|
221
|
+
* await viewer.loadModelAsync(modelCfg);
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
export declare class DxfViewer extends BaseViewer {
|
|
225
|
+
/**
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
name: ViewerName;
|
|
229
|
+
private readonly CAMERA_Z_POSITION;
|
|
230
|
+
private readonly CAMERA_MIN_ZOOM;
|
|
231
|
+
private timer;
|
|
232
|
+
/** @protected CSS2D渲染器 - 用于在场景中渲染HTML标签 */
|
|
233
|
+
protected css2dRenderer?: CSS2DRenderer;
|
|
234
|
+
/** @protected 字体管理器 - 处理文本渲染 */
|
|
235
|
+
protected fontManager?: FontManager;
|
|
236
|
+
/** @protected 是否启用选择功能 */
|
|
237
|
+
protected enableSelection?: boolean;
|
|
238
|
+
/** @protected 当前选中的对象 */
|
|
239
|
+
protected selectedObject?: THREE.Object3D | Drawable;
|
|
240
|
+
/**
|
|
241
|
+
* 已加载的模型列表
|
|
242
|
+
* 记录的"键"是modelId或src
|
|
243
|
+
* @internal
|
|
244
|
+
*/
|
|
245
|
+
loadedModels: Model2d[];
|
|
246
|
+
/**
|
|
247
|
+
* 主模型ID - 指示主模型,应该是第一个加载的模型
|
|
248
|
+
* @internal
|
|
249
|
+
*/
|
|
250
|
+
masterModelId: string;
|
|
251
|
+
/** @private DXF布局栏组件 */
|
|
252
|
+
private dxfLayoutBar?;
|
|
253
|
+
/** @private Three.js加载管理器 */
|
|
254
|
+
private loadingManager?;
|
|
255
|
+
/** @private 射线投射器 - 用于对象拾取和交互 */
|
|
256
|
+
private raycaster?;
|
|
257
|
+
/** @private 相机更新定时器 */
|
|
258
|
+
private cameraUpdateInterval?;
|
|
259
|
+
/** @protected 是否选中状态 - TODO: 与selectedObject重复? */
|
|
260
|
+
protected selected: boolean;
|
|
261
|
+
/** @private 标记管理器 - 管理活动布局的标记 */
|
|
262
|
+
private markupManager?;
|
|
263
|
+
/** @private 缩放至矩形区域辅助工具 */
|
|
264
|
+
private zoomToRectHelper?;
|
|
265
|
+
/**
|
|
266
|
+
* @private 请求动画帧辅助工具 - 用于提升渲染性能
|
|
267
|
+
* 启用此功能后,只在必要时渲染,例如相机位置改变、模型加载等
|
|
268
|
+
* 通过将raf设置为undefined可以禁用此功能
|
|
269
|
+
*/
|
|
270
|
+
private raf?;
|
|
271
|
+
/** @private 时钟对象 - 用于时间相关的计算 */
|
|
272
|
+
private clock;
|
|
273
|
+
/** @protected 渲染启用状态 - 与RafHelper配合使用 */
|
|
274
|
+
protected renderEnabled: boolean;
|
|
275
|
+
/** @private 超时符号 - 与RafHelper配合使用 */
|
|
276
|
+
private timeoutSymbol?;
|
|
277
|
+
/** @private 是否启用隐藏视觉上过小对象的功能 */
|
|
278
|
+
private enableHideVisuallySmallObjects;
|
|
279
|
+
/** @private 已排序的可隐藏对象 - 键为布局名称,visibleMinZoom表示当相机缩放大于此值时对象可见 */
|
|
280
|
+
private sortedHidableObjects;
|
|
281
|
+
/** @private 上次相机缩放值 - 初始为无穷大,用于隐藏小对象 */
|
|
282
|
+
private lastCameraZoom;
|
|
283
|
+
/** @private 上一帧编号 - 用于确定场景是否已渲染,从而决定在捕捉时是否更新可射线投射对象 */
|
|
284
|
+
private lastFrame;
|
|
285
|
+
/** @private 当前活动布局名称 */
|
|
286
|
+
private activeLayoutName;
|
|
287
|
+
/** @private 布局信息映射表 - 不同布局包含不同的数据,例如边界框、测量结果等 */
|
|
288
|
+
private layoutInfos;
|
|
289
|
+
/** @private 单位系统 */
|
|
290
|
+
private units;
|
|
291
|
+
/** @private 可射线投射对象缓存 - 用于提升性能 */
|
|
292
|
+
private raycastableObjects;
|
|
293
|
+
/** @private FPS工具 - 用于性能监控 */
|
|
294
|
+
private fpsUtils;
|
|
295
|
+
/** @private 正在拖拽的标注可绘制对象 */
|
|
296
|
+
private draggingAnnotationDrawable?;
|
|
297
|
+
/** @private 正在拖拽的顶点索引 */
|
|
298
|
+
private draggingVertexIndex?;
|
|
299
|
+
/**
|
|
300
|
+
* DxfViewer构造函数
|
|
301
|
+
*
|
|
302
|
+
* 初始化DXF查看器的核心功能,包括Three.js场景、DOM元素、
|
|
303
|
+
* 输入管理器、事件系统、相机控制器等。
|
|
304
|
+
*
|
|
305
|
+
* @param viewerCfg - 查看器配置参数,包含容器ID、功能开关等设置
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* const viewer = new DxfViewer({
|
|
310
|
+
* containerId: "viewer-container",
|
|
311
|
+
* enableSpinner: true,
|
|
312
|
+
* enableLayoutBar: true,
|
|
313
|
+
* enableSelection: true
|
|
314
|
+
* });
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
constructor(viewerCfg: DxfViewerConfig);
|
|
318
|
+
/**
|
|
319
|
+
* 初始化查看器所需的所有组件和功能
|
|
320
|
+
*
|
|
321
|
+
* 这个方法按照特定的顺序初始化查看器的各个子系统:
|
|
322
|
+
* 1. Three.js 核心组件(场景、相机、渲染器)
|
|
323
|
+
* 2. DOM 元素和UI组件
|
|
324
|
+
* 3. 输入管理器(鼠标、键盘事件处理)
|
|
325
|
+
* 4. 事件系统(自定义事件监听)
|
|
326
|
+
* 5. 相机控制器(视角控制和交互)
|
|
327
|
+
* 6. 其他辅助组件
|
|
328
|
+
*
|
|
329
|
+
* @internal 内部方法,不应由外部直接调用
|
|
330
|
+
*/
|
|
331
|
+
protected init(): void;
|
|
332
|
+
private initInputManager;
|
|
333
|
+
/**
|
|
334
|
+
* 交互模式:
|
|
335
|
+
* select 模式:左键点击选择,鼠标中键拖拽平移;鼠标样式为默认;
|
|
336
|
+
* move 模式:左键拖拽平移(与中键一致),鼠标样式为 pan/grab
|
|
337
|
+
*/
|
|
338
|
+
private currentInteractionMode;
|
|
339
|
+
/**
|
|
340
|
+
* 切换用户交互模式
|
|
341
|
+
*
|
|
342
|
+
* DxfViewer支持两种主要的交互模式:
|
|
343
|
+
* - "select"模式:用于选择和查看对象,左键点击选择对象
|
|
344
|
+
* - "move"模式:用于快速平移视图,左键拖拽即可平移
|
|
345
|
+
*
|
|
346
|
+
* 两种模式的鼠标行为:
|
|
347
|
+
* select模式:
|
|
348
|
+
* - 左键:选择对象
|
|
349
|
+
* - 中键:拖拽平移视图
|
|
350
|
+
* - 鼠标样式:默认样式
|
|
351
|
+
*
|
|
352
|
+
* move模式:
|
|
353
|
+
* - 左键:拖拽平移视图(与中键行为一致)
|
|
354
|
+
* - 鼠标样式:抓取样式(pan/grab)
|
|
355
|
+
*
|
|
356
|
+
* @param mode - 要设置的交互模式 ("select" | "move")
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* // 切换到移动模式,方便快速浏览
|
|
361
|
+
* viewer.setInteractionMode("move");
|
|
362
|
+
*
|
|
363
|
+
* // 切换到选择模式,进行对象交互
|
|
364
|
+
* viewer.setInteractionMode("select");
|
|
365
|
+
* ```
|
|
366
|
+
*/
|
|
367
|
+
setInteractionMode(mode: "select" | "move"): void;
|
|
368
|
+
/**
|
|
369
|
+
* 初始化Three.js核心组件
|
|
370
|
+
* 包括场景、渲染器和相机
|
|
371
|
+
*/
|
|
372
|
+
private initThree;
|
|
373
|
+
/**
|
|
374
|
+
* 初始化DOM相关组件
|
|
375
|
+
* 包括加载指示器、CSS2D渲染器、进度条和布局栏
|
|
376
|
+
*/
|
|
377
|
+
private initDom;
|
|
378
|
+
/**
|
|
379
|
+
* 初始化Three.js场景
|
|
380
|
+
* 设置背景色和矩阵更新策略
|
|
381
|
+
*/
|
|
382
|
+
private initScene;
|
|
383
|
+
/**
|
|
384
|
+
* 初始化WebGL渲染器
|
|
385
|
+
* 配置渲染参数并设置到DOM中
|
|
386
|
+
*/
|
|
387
|
+
private initRenderer;
|
|
388
|
+
/**
|
|
389
|
+
* 初始化CSS2D渲染器
|
|
390
|
+
* 用于渲染HTML标签和标注
|
|
391
|
+
*/
|
|
392
|
+
protected initCSS2DRenderer(): void;
|
|
393
|
+
/**
|
|
394
|
+
* 初始化正交相机
|
|
395
|
+
* 设置相机位置、缩放和投影矩阵
|
|
396
|
+
*/
|
|
397
|
+
private initCamera;
|
|
398
|
+
/**
|
|
399
|
+
* 初始化相机控制器
|
|
400
|
+
* 设置鼠标和触摸交互行为
|
|
401
|
+
* @internal
|
|
402
|
+
*/
|
|
403
|
+
protected initControls(): void;
|
|
404
|
+
/**
|
|
405
|
+
* 窗口大小改变时的回调函数
|
|
406
|
+
*/
|
|
407
|
+
private onResize;
|
|
408
|
+
/**
|
|
409
|
+
* 相机控制改变时的回调函数
|
|
410
|
+
* @param viewer - DxfViewer实例
|
|
411
|
+
*/
|
|
412
|
+
protected onControlsChange(viewer: DxfViewer): () => void;
|
|
413
|
+
/**
|
|
414
|
+
* 初始化鼠标/指针事件
|
|
415
|
+
* 处理各种交互事件如点击、拖拽、键盘快捷键等
|
|
416
|
+
*/
|
|
417
|
+
private initEvents;
|
|
418
|
+
protected initOthers(): void;
|
|
419
|
+
private initLoadingProgressBar;
|
|
420
|
+
/**
|
|
421
|
+
* 显示布局栏
|
|
422
|
+
* @internal
|
|
423
|
+
*/
|
|
424
|
+
showLayoutBar(): void;
|
|
425
|
+
/**
|
|
426
|
+
* 隐藏布局栏
|
|
427
|
+
* @internal
|
|
428
|
+
*/
|
|
429
|
+
hideLayoutBar(): void;
|
|
430
|
+
protected animate(): void;
|
|
431
|
+
/**
|
|
432
|
+
* 启用渲染以提升性能
|
|
433
|
+
*
|
|
434
|
+
* 为获得更好的性能,应该只在必要时进行渲染。通常在以下情况应该启用渲染:
|
|
435
|
+
* - 对象被添加到场景、从场景移除,或对象的position、scale、rotation、opacity、material等属性发生变化
|
|
436
|
+
* - 对象被选择或取消选择
|
|
437
|
+
* - 相机发生变化
|
|
438
|
+
* - 渲染区域大小发生变化
|
|
439
|
+
*
|
|
440
|
+
* 这个方法会设置一个超时,在指定的时间后自动禁用渲染,从而避免不必要的渲染开销。
|
|
441
|
+
*
|
|
442
|
+
* @param time - 渲染启用持续时间(毫秒),默认为1000ms
|
|
443
|
+
* @internal 内部方法,主要由框架内部调用
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```typescript
|
|
447
|
+
* // 手动启用渲染,持续2秒
|
|
448
|
+
* viewer.enableRender(2000);
|
|
449
|
+
*
|
|
450
|
+
* // 使用默认时间启用渲染
|
|
451
|
+
* viewer.enableRender();
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
enableRender: (time?: number) => void;
|
|
455
|
+
/**
|
|
456
|
+
* 获取当前的FPS(每秒帧数)值
|
|
457
|
+
*
|
|
458
|
+
* 返回当前查看器的实时渲染帧率,用于性能监控和调试。
|
|
459
|
+
* FPS值反映了渲染性能的高低,数值越高表示性能越好。
|
|
460
|
+
*
|
|
461
|
+
* @returns 当前的FPS值
|
|
462
|
+
* @internal 内部方法,主要用于性能监控
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```typescript
|
|
466
|
+
* const fps = viewer.getFps();
|
|
467
|
+
* console.log(`Current FPS: ${fps}`);
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
getFps(): number;
|
|
471
|
+
/**
|
|
472
|
+
* 判断是否为3D查看器
|
|
473
|
+
*
|
|
474
|
+
* DxfViewer是2D查看器,专门用于渲染DXF/DWG格式的工程图纸。
|
|
475
|
+
* 这个方法返回false,表示当前查看器不支持3D渲染。
|
|
476
|
+
*
|
|
477
|
+
* @returns 总是返回false,因为DxfViewer是2D查看器
|
|
478
|
+
* @internal 内部方法,用于框架内部的查看器类型判断
|
|
479
|
+
*/
|
|
480
|
+
is3d(): boolean;
|
|
481
|
+
/**
|
|
482
|
+
* 销毁 DxfViewer 实例
|
|
483
|
+
*
|
|
484
|
+
* 彻底清理和释放 DxfViewer 占用的所有资源,包括:
|
|
485
|
+
* - 停止所有异步任务和动画循环
|
|
486
|
+
* - 销毁UI组件(布局栏、标记管理器等)
|
|
487
|
+
* - 清理Three.js资源(渲染器、几何体、材质等)
|
|
488
|
+
* - 移除事件监听器
|
|
489
|
+
* - 释放内存和GPU资源
|
|
490
|
+
*
|
|
491
|
+
* 注意:销毁顺序很重要,例如测量功能依赖于渲染器,
|
|
492
|
+
* 必须在销毁渲染器之前先销毁测量功能。
|
|
493
|
+
*
|
|
494
|
+
* 调用此方法后,DxfViewer实例将不可用,所有相关资源都会被释放。
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```typescript
|
|
498
|
+
* // 销毁查看器实例
|
|
499
|
+
* viewer.destroy();
|
|
500
|
+
*
|
|
501
|
+
* // 此时viewer实例已不可用,不应再使用
|
|
502
|
+
* ```
|
|
503
|
+
*/
|
|
504
|
+
destroy(): void;
|
|
505
|
+
/**
|
|
506
|
+
* 用于指示有多少个DXF文件正在加载
|
|
507
|
+
*/
|
|
508
|
+
private loadingDxfCount;
|
|
509
|
+
/**
|
|
510
|
+
* 异步加载DXF文件
|
|
511
|
+
*
|
|
512
|
+
* 加载DXF/DWG格式的工程图纸文件,支持主模型和叠加模型的概念:
|
|
513
|
+
*
|
|
514
|
+
* **主模型 vs 叠加模型:**
|
|
515
|
+
* - 第一个加载的文件将被视为"主模型"
|
|
516
|
+
* - 后续加载的文件称为"叠加模型"
|
|
517
|
+
*
|
|
518
|
+
* **加载内容差异:**
|
|
519
|
+
* - **主模型**:加载所有内容,包括模型空间和图纸空间
|
|
520
|
+
* - **叠加模型**:仅加载模型空间,且只能叠加到主模型的模型空间上
|
|
521
|
+
*
|
|
522
|
+
* **功能特性:**
|
|
523
|
+
* - 支持进度回调,实时显示加载进度
|
|
524
|
+
* - 支持本地缓存以提升性能
|
|
525
|
+
* - 支持模型合并优化
|
|
526
|
+
* - 支持编码设置(处理不同字符集的DXF文件)
|
|
527
|
+
* - 支持颜色覆盖(统一修改模型颜色)
|
|
528
|
+
* - 自动处理图纸空间的忽略逻辑
|
|
529
|
+
*
|
|
530
|
+
* @param modelCfg - 要加载的模型配置
|
|
531
|
+
* @param onProgress - 加载进度回调函数,可选
|
|
532
|
+
*
|
|
533
|
+
* @returns Promise<void> - 当模型加载完成时resolve
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* ```typescript
|
|
537
|
+
* // 基本用法
|
|
538
|
+
* const viewerCfg = {
|
|
539
|
+
* containerId: "myCanvas",
|
|
540
|
+
* enableSpinner: true,
|
|
541
|
+
* enableLayoutBar: true,
|
|
542
|
+
* };
|
|
543
|
+
*
|
|
544
|
+
* const modelCfg = {
|
|
545
|
+
* modelId: "primary_model",
|
|
546
|
+
* name: "主模型",
|
|
547
|
+
* src: "http://example.com/primary.dxf",
|
|
548
|
+
* merge: true, // 启用模型合并优化
|
|
549
|
+
* encoding: "utf-8", // 文件编码
|
|
550
|
+
* ignorePaperSpace: false, // 不忽略图纸空间(仅对主模型有效)
|
|
551
|
+
* };
|
|
552
|
+
*
|
|
553
|
+
* const viewer = new DxfViewer(viewerCfg);
|
|
554
|
+
*
|
|
555
|
+
* try {
|
|
556
|
+
* await viewer.loadModelAsync(modelCfg, (event) => {
|
|
557
|
+
* const progress = (event.loaded * 100) / event.total;
|
|
558
|
+
* console.log(`加载进度: ${progress.toFixed(1)}%`);
|
|
559
|
+
*
|
|
560
|
+
* // 可以在这里更新UI进度条
|
|
561
|
+
* updateProgressBar(progress);
|
|
562
|
+
* });
|
|
563
|
+
*
|
|
564
|
+
* console.log("模型加载完成!");
|
|
565
|
+
*
|
|
566
|
+
* // 现在可以加载叠加模型
|
|
567
|
+
* const overlayCfg = {
|
|
568
|
+
* modelId: "overlay_model",
|
|
569
|
+
* name: "叠加模型",
|
|
570
|
+
* src: "http://example.com/overlay.dxf",
|
|
571
|
+
* merge: true,
|
|
572
|
+
* };
|
|
573
|
+
*
|
|
574
|
+
* await viewer.loadModelAsync(overlayCfg, (event) => {
|
|
575
|
+
* const progress = (event.loaded * 100) / event.total;
|
|
576
|
+
* console.log(`叠加模型加载进度: ${progress.toFixed(1)}%`);
|
|
577
|
+
* });
|
|
578
|
+
*
|
|
579
|
+
* } catch (error) {
|
|
580
|
+
* console.error("模型加载失败:", error);
|
|
581
|
+
* }
|
|
582
|
+
* ```
|
|
583
|
+
*
|
|
584
|
+
* @example
|
|
585
|
+
* ```typescript
|
|
586
|
+
* // 加载多个模型的示例
|
|
587
|
+
* const models = [
|
|
588
|
+
* { modelId: "floor1", name: "一层平面图", src: "floor1.dxf" },
|
|
589
|
+
* { modelId: "floor2", name: "二层平面图", src: "floor2.dxf" },
|
|
590
|
+
* { modelId: "structure", name: "结构图", src: "structure.dxf" },
|
|
591
|
+
* ];
|
|
592
|
+
*
|
|
593
|
+
* for (const model of models) {
|
|
594
|
+
* await viewer.loadModelAsync(model, (event) => {
|
|
595
|
+
* console.log(`${model.name} 加载进度: ${(event.loaded * 100 / event.total).toFixed(1)}%`);
|
|
596
|
+
* });
|
|
597
|
+
* }
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
600
|
+
loadModelAsync(modelCfg: DxfModelConfig, onProgress?: (event: ProgressEvent) => void): Promise<void>;
|
|
601
|
+
/**
|
|
602
|
+
* 卸载DXF模型
|
|
603
|
+
*
|
|
604
|
+
* 从查看器中移除指定的DXF模型,清理相关资源。
|
|
605
|
+
* 这个方法目前还没有实现,是为未来版本预留的功能。
|
|
606
|
+
*
|
|
607
|
+
* @param modelId 可选 - 要卸载的模型ID。如果不提供,则可能卸载所有模型
|
|
608
|
+
* @internal 内部方法,暂未实现
|
|
609
|
+
* @throws {Error} 抛出"Not implemented yet!"错误,表示功能尚未实现
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```typescript
|
|
613
|
+
* // 未来版本中的使用方式
|
|
614
|
+
* viewer.unloadDxf("model_001");
|
|
615
|
+
* ```
|
|
616
|
+
*/
|
|
617
|
+
unloadDxf(): void;
|
|
618
|
+
/**
|
|
619
|
+
* 将模型数据添加到查看器
|
|
620
|
+
*
|
|
621
|
+
* 这个方法负责将加载的DXF模型正式集成到Three.js场景中,
|
|
622
|
+
* 设置必要的属性和状态,确保模型能够正确渲染和交互。
|
|
623
|
+
*
|
|
624
|
+
* @param modelData - 2D模型数据,包含模型ID和DXF数据
|
|
625
|
+
* @returns 返回创建的Model2d实例
|
|
626
|
+
* @description 将模型数据添加到查看器中进行渲染和管理
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* ```typescript
|
|
630
|
+
* const modelData = {
|
|
631
|
+
* modelId: "my_model",
|
|
632
|
+
* dxfData: loadedDxfData
|
|
633
|
+
* };
|
|
634
|
+
* const model = viewer.addModel(modelData);
|
|
635
|
+
* ```
|
|
636
|
+
*/
|
|
637
|
+
addModel(modelData: ModelData2d): Model2d | undefined;
|
|
638
|
+
/**
|
|
639
|
+
* 获取已加载实体数量
|
|
640
|
+
* @internal
|
|
641
|
+
* @returns {number}
|
|
642
|
+
*/
|
|
643
|
+
getEntitiesCount(): number;
|
|
644
|
+
/**
|
|
645
|
+
* 获取已加载的dxf模型id数组
|
|
646
|
+
*/
|
|
647
|
+
protected getLoadedDxfModelIds(): string[];
|
|
648
|
+
/**
|
|
649
|
+
* @description {en} Gets layout names of the master model.
|
|
650
|
+
* @description {zh} 获取主模型的布局名称。
|
|
651
|
+
* @returns
|
|
652
|
+
* - {en} Layout names of the master model.
|
|
653
|
+
* - {zh} 主模型的布局名称。
|
|
654
|
+
* @example
|
|
655
|
+
* ```typescript
|
|
656
|
+
* const layoutNames = dxfViewer.getLayoutNames();
|
|
657
|
+
* console.log(layoutNames); // ['Model', 'Layout1', 'Layout2']
|
|
658
|
+
* ```
|
|
659
|
+
*/
|
|
660
|
+
getLayoutNames(): string[];
|
|
661
|
+
/**
|
|
662
|
+
* 获取布局。
|
|
663
|
+
* 仅返回主模型的布局。
|
|
664
|
+
*/
|
|
665
|
+
protected getLayouts(): ILayoutObject[];
|
|
666
|
+
private handleOverlayDxf;
|
|
667
|
+
/**
|
|
668
|
+
* @description {en} Activates a layout.
|
|
669
|
+
* @description {zh} 激活布局。
|
|
670
|
+
* @param layoutName
|
|
671
|
+
* - {en} The name of the layout to be activated.
|
|
672
|
+
* - {zh} 要激活的布局名称。
|
|
673
|
+
* @example
|
|
674
|
+
* ```typescript
|
|
675
|
+
* viewer.activateLayout('Layout1');
|
|
676
|
+
* ```
|
|
677
|
+
*/
|
|
678
|
+
activateLayout(layoutName: string): void;
|
|
679
|
+
private cancelAllOperations;
|
|
680
|
+
/**
|
|
681
|
+
* @description {en} Gets active layout.
|
|
682
|
+
* @description {zh} 获取当前布局。
|
|
683
|
+
* @returns
|
|
684
|
+
* - {en} Active layout name or undefined.
|
|
685
|
+
* - {zh} 当前激活的布局名称或undefined。
|
|
686
|
+
* @example
|
|
687
|
+
* ``` typescript
|
|
688
|
+
* const activeLayout = viewer.getActiveLayoutName();
|
|
689
|
+
* console.log(activeLayout);
|
|
690
|
+
* ```
|
|
691
|
+
*/
|
|
692
|
+
getActiveLayoutName(): string | undefined;
|
|
693
|
+
/**
|
|
694
|
+
* @description {en} Gets dxf layers.
|
|
695
|
+
* @description {zh} 获取dxf图层。
|
|
696
|
+
* @returns
|
|
697
|
+
* - {en} Dxf layers.
|
|
698
|
+
* - {zh} dxf图层。
|
|
699
|
+
* @example
|
|
700
|
+
* ``` typescript
|
|
701
|
+
* const dxfLayers = viewer.getLayers();
|
|
702
|
+
* for (let i = 0; i < dxfLayers.length; ++i) {
|
|
703
|
+
* const layers = dxfLayers[i].layers;
|
|
704
|
+
* const layerNames = Object.keys(layers).sort();
|
|
705
|
+
* console.log(layerNames);
|
|
706
|
+
* }
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
getLayers(): (DxfLayers | PdfLayers)[];
|
|
710
|
+
/**
|
|
711
|
+
* 设置模型(即dxf文件)的可见性。
|
|
712
|
+
* @throws 如果modelId不存在则抛出异常。
|
|
713
|
+
* @internal
|
|
714
|
+
*/
|
|
715
|
+
setModelVisibility(modelId: string, visible: boolean): void;
|
|
716
|
+
/**
|
|
717
|
+
* @description {en} Sets layer's visibility.
|
|
718
|
+
* @description {zh} 设置图层的可见性。
|
|
719
|
+
* @param layerName
|
|
720
|
+
* - {en} Layer's name to show or hide.
|
|
721
|
+
* - {zh} 要显示或隐藏的图层名称。
|
|
722
|
+
* @param visible
|
|
723
|
+
* - {en} Layer's target visibility.
|
|
724
|
+
* - {zh} 图层的目标可见性。
|
|
725
|
+
* @param modelId
|
|
726
|
+
* - {en} Useful when more than one model is loaded, if not specified, will use the master model.
|
|
727
|
+
* - {zh} 当加载了多个模型时有用,如果未指定,将使用主模型。
|
|
728
|
+
* @throws Error
|
|
729
|
+
* - {en}: Throws exception if given modelId doesn't exist.
|
|
730
|
+
* - {zh} 如果给定的modelId不存在,则抛出异常。
|
|
731
|
+
* @example
|
|
732
|
+
* ``` typescript
|
|
733
|
+
* // Hides layer "0"
|
|
734
|
+
* viewer.setLayerVisibility("0", false);
|
|
735
|
+
* ```
|
|
736
|
+
*/
|
|
737
|
+
setLayerVisibility(layerName: string, visible: boolean, modelId?: string): void;
|
|
738
|
+
/**
|
|
739
|
+
* 设置图层的不透明度
|
|
740
|
+
* @internal
|
|
741
|
+
*/
|
|
742
|
+
setLayerOpacity(layerName: string, opacity: number, modelId?: string): void;
|
|
743
|
+
/**
|
|
744
|
+
* 设置图层的颜色
|
|
745
|
+
* @throws 如果图层不存在则抛出异常。
|
|
746
|
+
* @internal
|
|
747
|
+
*/
|
|
748
|
+
setLayerColor(layerName: string, color: number, modelId?: string): void;
|
|
749
|
+
/**
|
|
750
|
+
* 重置图层的颜色。
|
|
751
|
+
* @internal
|
|
752
|
+
*/
|
|
753
|
+
resetLayerColor(layerName: string, modelId?: string): void;
|
|
754
|
+
/**
|
|
755
|
+
* @description {en} Sets font.
|
|
756
|
+
* This needs to be called before loading a dxf, it won't affect any loaded text.
|
|
757
|
+
* It accepts shx or typeface formats. For typeface, it only support passing in 1 font file in the array for now.
|
|
758
|
+
* @description {zh} 设置字体。
|
|
759
|
+
* 需要在加载dxf之前调用,不会影响已加载的文字。
|
|
760
|
+
* 支持shx或typeface格式。对于typeface,目前只支持传入1个字体文件。
|
|
761
|
+
* @param urls
|
|
762
|
+
* - {en} font file urls.
|
|
763
|
+
* - {zh} 字体文件链接。
|
|
764
|
+
* @example
|
|
765
|
+
* ```typescript
|
|
766
|
+
* viewer.setFont(["https://example.com/xxx.shx"]);
|
|
767
|
+
* ```
|
|
768
|
+
*/
|
|
769
|
+
setFont(urls: string[]): Promise<void>;
|
|
770
|
+
getFont(): FontManager | undefined;
|
|
771
|
+
/**
|
|
772
|
+
* 设置加载管理器。
|
|
773
|
+
* @internal
|
|
774
|
+
* 需要在加载dxf之前调用,用于加载本地外部链接。
|
|
775
|
+
* @param manager
|
|
776
|
+
*/
|
|
777
|
+
setLoadingManager(manager: THREE.LoadingManager): void;
|
|
778
|
+
/**
|
|
779
|
+
* 设置显示长度单位。
|
|
780
|
+
* @internal 尚未实现!
|
|
781
|
+
* @default 毫米
|
|
782
|
+
*/
|
|
783
|
+
setDisplayLengthUnits(): void;
|
|
784
|
+
/**
|
|
785
|
+
* 设置显示面积单位
|
|
786
|
+
* @internal 尚未实现!
|
|
787
|
+
* @default 米
|
|
788
|
+
*/
|
|
789
|
+
setDisplayAreaUnits(): void;
|
|
790
|
+
/**
|
|
791
|
+
* 设置显示小数位数
|
|
792
|
+
* @internal 尚未实现!
|
|
793
|
+
* @default 2
|
|
794
|
+
*/
|
|
795
|
+
setDisplayPrecision(): void;
|
|
796
|
+
/**
|
|
797
|
+
* @description {en} Gets current view extent.
|
|
798
|
+
* This is useful for user to save this value as a viewpoint, and jump to this viewpoint next time.
|
|
799
|
+
* @description {zh} 获取当前视图范围。
|
|
800
|
+
* 用户可使用该接口获取当前视口范围,并在适当的场景下跳转到该视口范围。
|
|
801
|
+
* @example
|
|
802
|
+
* ``` typescript
|
|
803
|
+
* const box = viewer.getCurrentViewExtent();
|
|
804
|
+
* console.log("Current view extent:", box);
|
|
805
|
+
* ```
|
|
806
|
+
*/
|
|
807
|
+
getCurrentViewExtent(): Box2;
|
|
808
|
+
/**
|
|
809
|
+
* @description Compatible with older versions, use MeasurePlugin instead
|
|
810
|
+
* @internal
|
|
811
|
+
* @deprecated use MeasurePlugin instead
|
|
812
|
+
*/
|
|
813
|
+
get measurePlugin(): MeasurementPlugin | undefined;
|
|
814
|
+
/**
|
|
815
|
+
* @description {en} Activates one of "Distance", "Area" or "Angle" measurement
|
|
816
|
+
* @description {zh} 激活"距离", "面积" 或者 "角度"测量
|
|
817
|
+
* @param type
|
|
818
|
+
* - "Distance", "Area" or "Angle"
|
|
819
|
+
* @example
|
|
820
|
+
* ``` typescript
|
|
821
|
+
* viewer.activateMeasurement(MeasurementType.Distance);
|
|
822
|
+
* ```
|
|
823
|
+
* @deprecated use MeasurePlugin instead
|
|
824
|
+
*/
|
|
825
|
+
activateMeasurement(type: MeasurementType): void;
|
|
826
|
+
/**
|
|
827
|
+
* @description {en} Deactivates measurement.
|
|
828
|
+
* @description {zh} 退出测量。
|
|
829
|
+
* @example
|
|
830
|
+
* ``` typescript
|
|
831
|
+
* viewer.deactivateMeasurement();
|
|
832
|
+
* ```
|
|
833
|
+
* @deprecated use MeasurePlugin instead
|
|
834
|
+
*/
|
|
835
|
+
deactivateMeasurement(): void;
|
|
836
|
+
/**
|
|
837
|
+
* @description {en} Gets active measurement type.
|
|
838
|
+
* @description {zh} 获取当前激活的测量类型。
|
|
839
|
+
* @returns
|
|
840
|
+
* - "Distance", "Area" or "Angle" or undefined
|
|
841
|
+
* @example
|
|
842
|
+
* ``` typescript
|
|
843
|
+
* const measurementType = viewer.getActiveMeasurementType();
|
|
844
|
+
* console.log(measurementType);
|
|
845
|
+
* ```
|
|
846
|
+
* @deprecated use MeasurePlugin instead
|
|
847
|
+
*/
|
|
848
|
+
getActiveMeasurementType(): MeasurementType | undefined;
|
|
849
|
+
/**
|
|
850
|
+
* @description {en} Gets all measurements.
|
|
851
|
+
* @description {zh} 获取所有测量数据。
|
|
852
|
+
* @returns
|
|
853
|
+
* - {en} measurement data array.
|
|
854
|
+
* - {zh} 测量数据数组。
|
|
855
|
+
* @example
|
|
856
|
+
* ``` typescript
|
|
857
|
+
* const measurementData = viewer.getMeasurements();
|
|
858
|
+
* console.log(measurementData);
|
|
859
|
+
* ```
|
|
860
|
+
* @deprecated use MeasurePlugin instead
|
|
861
|
+
*/
|
|
862
|
+
getMeasurements(): MeasurementData[];
|
|
863
|
+
/**
|
|
864
|
+
* @description {en} Cancels current measurement. This won't deactivate measurement, rather, you can start a new measurement.
|
|
865
|
+
* @description {zh} 取消当前的测量绘制。这并不会退出测量,用户可以开始一个新的测量。
|
|
866
|
+
* @deprecated use MeasurePlugin instead
|
|
867
|
+
*/
|
|
868
|
+
cancelMeasurement(): void;
|
|
869
|
+
/**
|
|
870
|
+
* @description {en} Sets measurement data.
|
|
871
|
+
* @description {zh} 设置测量数据。
|
|
872
|
+
* @param measurementData
|
|
873
|
+
* - {en} measurement data array.
|
|
874
|
+
* - {zh} 测量数据数组。
|
|
875
|
+
* @example
|
|
876
|
+
* ``` typescript
|
|
877
|
+
* const measurementData = [{
|
|
878
|
+
* type: "Distance",
|
|
879
|
+
* id: "c6ea70a3-ddb0-4dd0-87c8-bd2491936428",
|
|
880
|
+
* points: [[0, 1000], [5000, 1000]],
|
|
881
|
+
* }];
|
|
882
|
+
* viewer.setMeasurements(measurementData);
|
|
883
|
+
* ```
|
|
884
|
+
* @deprecated use MeasurePlugin instead
|
|
885
|
+
*/
|
|
886
|
+
setMeasurements(measurementData: MeasurementData[]): void;
|
|
887
|
+
/**
|
|
888
|
+
* Selects a measurement by id
|
|
889
|
+
* @internal
|
|
890
|
+
* @deprecated use MeasurePlugin instead
|
|
891
|
+
*/
|
|
892
|
+
selectMeasurement(id: string): void;
|
|
893
|
+
/**
|
|
894
|
+
* Unselects a measurement.
|
|
895
|
+
* @internal
|
|
896
|
+
* @deprecated use MeasurePlugin instead
|
|
897
|
+
*/
|
|
898
|
+
unselectMeasurement(): void;
|
|
899
|
+
/**
|
|
900
|
+
* @description {en} Removes a measurement by id.
|
|
901
|
+
* @description {zh} 根据id删除测量数据。
|
|
902
|
+
* @param id
|
|
903
|
+
* - {en} Measurement data id.
|
|
904
|
+
* - {zh} 测量数据id。
|
|
905
|
+
* @example
|
|
906
|
+
* ``` typescript
|
|
907
|
+
* const id = "c6ea70a3-ddb0-4dd0-87c8-bd2491936428";
|
|
908
|
+
* viewer.removeMeasurement(id);
|
|
909
|
+
* ```
|
|
910
|
+
* @deprecated use MeasurePlugin instead
|
|
911
|
+
*/
|
|
912
|
+
removeMeasurement(id: string): void;
|
|
913
|
+
/**
|
|
914
|
+
* Sets a measurement's visibility.
|
|
915
|
+
* Note that, the markup should belong to active layout. You shouldn't update a markup of an inactive layout.
|
|
916
|
+
* @internal
|
|
917
|
+
* @deprecated use MeasurePlugin instead
|
|
918
|
+
*/
|
|
919
|
+
setMeasurementVisibility(id: string, visible: boolean): boolean;
|
|
920
|
+
/**
|
|
921
|
+
* @description {en} Clears measurement results.
|
|
922
|
+
* @description {zh} 清除测量结果。
|
|
923
|
+
* @example
|
|
924
|
+
* ``` typescript
|
|
925
|
+
* viewer.clearMeasurements();
|
|
926
|
+
* ```
|
|
927
|
+
* @deprecated use MeasurePlugin instead
|
|
928
|
+
*/
|
|
929
|
+
clearMeasurements(): void;
|
|
930
|
+
/** markup start **/
|
|
931
|
+
/**
|
|
932
|
+
* @internal
|
|
933
|
+
*/
|
|
934
|
+
getMarkupManager(): MarkupManager | undefined;
|
|
935
|
+
/**
|
|
936
|
+
* @description {en} Activates markup feature.
|
|
937
|
+
* @description {zh} 激活标注功能。
|
|
938
|
+
* @param type
|
|
939
|
+
* - {en} markup type.
|
|
940
|
+
* - {zh} 标注类型。
|
|
941
|
+
* @example
|
|
942
|
+
* ``` typescript
|
|
943
|
+
* const markupType = MarkupType.Arrow;
|
|
944
|
+
* viewer.activateMarkup(markupType);
|
|
945
|
+
* ```
|
|
946
|
+
* @deprecated
|
|
947
|
+
*/
|
|
948
|
+
activateMarkup(type: MarkupType): void;
|
|
949
|
+
/**
|
|
950
|
+
* @description {en} Deactivates markup feature.
|
|
951
|
+
* @description {zh} 退出标注功能。
|
|
952
|
+
* @example
|
|
953
|
+
* ``` typescript
|
|
954
|
+
* viewer.deactivateMarkup();
|
|
955
|
+
* ```
|
|
956
|
+
*/
|
|
957
|
+
deactivateMarkup(): void;
|
|
958
|
+
/**
|
|
959
|
+
* @description {en} Gets active markup type.
|
|
960
|
+
* @description {zh} 获取激活的标注类型。
|
|
961
|
+
* @returns
|
|
962
|
+
* - {en} markup type.
|
|
963
|
+
* - {zh} 标注类型。
|
|
964
|
+
* @example
|
|
965
|
+
* ``` typescript
|
|
966
|
+
* const markupType = viewer.getActiveMarkupType();
|
|
967
|
+
* console.log(markupType);
|
|
968
|
+
* ```
|
|
969
|
+
*/
|
|
970
|
+
getActiveMarkupType(): MarkupType | undefined;
|
|
971
|
+
/**
|
|
972
|
+
* Set markup stroke color
|
|
973
|
+
* @internal
|
|
974
|
+
*/
|
|
975
|
+
setMarkupLineColor(r: number, g: number, b: number, a: number): void;
|
|
976
|
+
/**
|
|
977
|
+
* @internal
|
|
978
|
+
*/
|
|
979
|
+
getMarkupLineColor(): number[] | undefined;
|
|
980
|
+
/**
|
|
981
|
+
* Set markup fill color
|
|
982
|
+
* @internal
|
|
983
|
+
*/
|
|
984
|
+
setMarkupFillColor(r: number, g: number, b: number, a: number): void;
|
|
985
|
+
/**
|
|
986
|
+
* @internal
|
|
987
|
+
*/
|
|
988
|
+
getMarkupFillColor(): number[] | undefined;
|
|
989
|
+
/**
|
|
990
|
+
* Set markup stroke line width
|
|
991
|
+
* @internal
|
|
992
|
+
*/
|
|
993
|
+
setMarkupLineWidth(lineWidth: number): void;
|
|
994
|
+
/**
|
|
995
|
+
* @internal
|
|
996
|
+
*/
|
|
997
|
+
getMarkupLineWidth(): number | undefined;
|
|
998
|
+
/**
|
|
999
|
+
* Set markup font size
|
|
1000
|
+
* @internal
|
|
1001
|
+
*/
|
|
1002
|
+
setMarkupFontSize(fontSize: number): void;
|
|
1003
|
+
/**
|
|
1004
|
+
* @internal
|
|
1005
|
+
*/
|
|
1006
|
+
getMarkupFontSize(): number | undefined;
|
|
1007
|
+
/**
|
|
1008
|
+
* @description {en} Gets all markups.
|
|
1009
|
+
* @description {zh} 获取所有标注数据。
|
|
1010
|
+
* @returns
|
|
1011
|
+
* - {en} markup data array.
|
|
1012
|
+
* - {zh} 标注数据数组。
|
|
1013
|
+
* @example
|
|
1014
|
+
* ``` typescript
|
|
1015
|
+
* const markupData = viewer.getMarkups();
|
|
1016
|
+
* console.log(markupData);
|
|
1017
|
+
* ```
|
|
1018
|
+
*/
|
|
1019
|
+
getMarkups(): MarkupData[];
|
|
1020
|
+
/**
|
|
1021
|
+
* @description {en} Adds markups to active layout.
|
|
1022
|
+
* @description {zh} 添加标注到当前布局。
|
|
1023
|
+
* @param markupDataArray
|
|
1024
|
+
* - {en} markup data array.
|
|
1025
|
+
* - {zh} 标注数据数组。
|
|
1026
|
+
* @example
|
|
1027
|
+
* ``` typescript
|
|
1028
|
+
* const markupData = [{
|
|
1029
|
+
* type: "ArrowMarkup",
|
|
1030
|
+
* id: "c6ea70a3-ddb0-4dd0-87c8-bd2491936428",
|
|
1031
|
+
* lineWidth: 2,
|
|
1032
|
+
* strokeStyle: "#ff0000",
|
|
1033
|
+
* fillStyle: "#ff000030",
|
|
1034
|
+
* points: [[0, 0], [1000, 1000]],
|
|
1035
|
+
* }];
|
|
1036
|
+
* viewer.setMarkups(markupData);
|
|
1037
|
+
* ```
|
|
1038
|
+
*/
|
|
1039
|
+
setMarkups(markupDataArray: MarkupData[]): void;
|
|
1040
|
+
/**
|
|
1041
|
+
* Sets a markup's visibility by id.
|
|
1042
|
+
* Note that, the markup should belong to active layout. You shouldn't update a markup of an inactive layout.
|
|
1043
|
+
* @internal
|
|
1044
|
+
*/
|
|
1045
|
+
setMarkupVisibility(id: string, visible: boolean): boolean;
|
|
1046
|
+
/**
|
|
1047
|
+
* @description {en} Updates a markup.
|
|
1048
|
+
* @description {zh} 更新标注。
|
|
1049
|
+
* @param {MarkupData} markup
|
|
1050
|
+
* - {en} markup data.
|
|
1051
|
+
* - {zh} 标注数据。
|
|
1052
|
+
* @returns
|
|
1053
|
+
* - {en} Whether update successfully, true means success, false means failure.
|
|
1054
|
+
* - {zh} 是否更新成功,true表示成功,false表示失败。
|
|
1055
|
+
* @example
|
|
1056
|
+
* ``` typescript
|
|
1057
|
+
* const markupData = {
|
|
1058
|
+
* type: "ArrowMarkup",
|
|
1059
|
+
* id: "c6ea70a3-ddb0-4dd0-87c8-bd2491936428",
|
|
1060
|
+
* lineWidth: 3,
|
|
1061
|
+
* strokeStyle: "#ff0000",
|
|
1062
|
+
* fillStyle: "#ff000030",
|
|
1063
|
+
* points: [[0, 0], [1000, 1000]],
|
|
1064
|
+
* };
|
|
1065
|
+
* viewer.updateMarkup(markupData);
|
|
1066
|
+
*/
|
|
1067
|
+
updateMarkup(markup: MarkupData): boolean;
|
|
1068
|
+
/**
|
|
1069
|
+
* @description {en} Removes a markup by markup id.
|
|
1070
|
+
* @description {zh} 根据标注id删除标注。
|
|
1071
|
+
* @param {string} id
|
|
1072
|
+
* - {en} markup id.
|
|
1073
|
+
* - {zh} 标注id。
|
|
1074
|
+
* @returns
|
|
1075
|
+
* - {en} Whether remove successfully, true means success, false means failure.
|
|
1076
|
+
* - {zh} 是否删除成功,true表示成功,false表示失败。
|
|
1077
|
+
* @example
|
|
1078
|
+
* ``` typescript
|
|
1079
|
+
* const markupId = "c6ea70a3-ddb0-4dd0-87c8-bd2491936428";
|
|
1080
|
+
* viewer.removeMarkup(markupId);
|
|
1081
|
+
* ```
|
|
1082
|
+
*/
|
|
1083
|
+
removeMarkup(id: string): boolean;
|
|
1084
|
+
/**
|
|
1085
|
+
* @description {en} Clears markups.
|
|
1086
|
+
* @description {zh} 清除所有标注。
|
|
1087
|
+
* @example
|
|
1088
|
+
* ``` typescript
|
|
1089
|
+
* viewer.clearMarkups();
|
|
1090
|
+
* ```
|
|
1091
|
+
*/
|
|
1092
|
+
clearMarkups(): void;
|
|
1093
|
+
/** markup end **/
|
|
1094
|
+
/**
|
|
1095
|
+
* Gets mouse hit result in world coordinate
|
|
1096
|
+
* @example
|
|
1097
|
+
* ``` typescript
|
|
1098
|
+
* document.addEventListener("click", (event) => {
|
|
1099
|
+
* const result = viewer.getHitResult(event);
|
|
1100
|
+
* const loc = result?.location;
|
|
1101
|
+
* if (loc) {
|
|
1102
|
+
* console.log(`Clicked at x: ${loc[0]}, y: ${loc[1]}`);
|
|
1103
|
+
* }
|
|
1104
|
+
* });
|
|
1105
|
+
* ```
|
|
1106
|
+
* @internal
|
|
1107
|
+
*/
|
|
1108
|
+
getHitResult(event: MouseEvent | PointerEvent | EventInfo): Vector2 | undefined;
|
|
1109
|
+
/**
|
|
1110
|
+
* Gets hit result by Normalized Device Coordinates.
|
|
1111
|
+
* Lower left coordinate: (-1, -1)
|
|
1112
|
+
* Upper right coordinate: (1, 1)
|
|
1113
|
+
*/
|
|
1114
|
+
protected getHitResultByNdcCoordinate(coord: Vector2): Vector2 | undefined;
|
|
1115
|
+
/**
|
|
1116
|
+
* @description {en} Asks user to select a box area, and zooms to it.
|
|
1117
|
+
* @description {zh} 询问用户选择一个框选区域,然后缩放到该区域。
|
|
1118
|
+
* @example
|
|
1119
|
+
* ``` typescript
|
|
1120
|
+
* viewer.zoomToRect();
|
|
1121
|
+
* ```
|
|
1122
|
+
*/
|
|
1123
|
+
zoomToRect(): void;
|
|
1124
|
+
/**
|
|
1125
|
+
* @internal
|
|
1126
|
+
*/
|
|
1127
|
+
deactivateZoomRect(): void;
|
|
1128
|
+
private getLayoutByName;
|
|
1129
|
+
private getActiveLayoutInfo;
|
|
1130
|
+
private getMsTransformMatrix;
|
|
1131
|
+
private getLayoutExtentEx;
|
|
1132
|
+
/**
|
|
1133
|
+
* Shows objects for given layout, and hide any other layouts.
|
|
1134
|
+
*/
|
|
1135
|
+
private showLayoutObjects;
|
|
1136
|
+
private getLayoutViewports;
|
|
1137
|
+
private setMaterialUniforms;
|
|
1138
|
+
/**
|
|
1139
|
+
* Checks if a layer is frozen for viewport (VP Freeze)
|
|
1140
|
+
*/
|
|
1141
|
+
private isLayerFrozenForViewport;
|
|
1142
|
+
private getFilteredViewports;
|
|
1143
|
+
private generateObjectsByViewport;
|
|
1144
|
+
private findSpatialFilter;
|
|
1145
|
+
private getAnyMaterial;
|
|
1146
|
+
private addSpatialFilterSection;
|
|
1147
|
+
private getObjectsByBoundingBox;
|
|
1148
|
+
private getDxfUnits;
|
|
1149
|
+
private generateSectionsBySpatialFilter;
|
|
1150
|
+
/**
|
|
1151
|
+
* @description {en} resize viewer
|
|
1152
|
+
* @description {zh} 重置视图大小
|
|
1153
|
+
* @param {number} width
|
|
1154
|
+
* - {en} width of viewer
|
|
1155
|
+
* - {zh} 视图宽度。
|
|
1156
|
+
* @param {number} height
|
|
1157
|
+
* - {en} height of viewer
|
|
1158
|
+
* - {zh} 视图高度。
|
|
1159
|
+
* @example
|
|
1160
|
+
* ```typescript
|
|
1161
|
+
* const width = 800;
|
|
1162
|
+
* const height = 600;
|
|
1163
|
+
* viewer.resize(width, height);
|
|
1164
|
+
* ```
|
|
1165
|
+
*/
|
|
1166
|
+
protected resize(width: number, height: number): void;
|
|
1167
|
+
/**
|
|
1168
|
+
* @internal
|
|
1169
|
+
*/
|
|
1170
|
+
getRaycaster(): THREE.Raycaster | undefined;
|
|
1171
|
+
/**
|
|
1172
|
+
* Gets the corresponding viewport by judging that the point is in the viewport
|
|
1173
|
+
*/
|
|
1174
|
+
private getViewportByPoint;
|
|
1175
|
+
/**
|
|
1176
|
+
* Gets raycast-able objects by mouseEvent.
|
|
1177
|
+
* @internal
|
|
1178
|
+
*/
|
|
1179
|
+
getRaycastableObjectsByMouse(event?: EventInfo): THREE.Object3D<THREE.Event>[];
|
|
1180
|
+
/**
|
|
1181
|
+
* 根据给定的鼠标位置获取相交对象
|
|
1182
|
+
*
|
|
1183
|
+
* 使用射线投射技术检测鼠标位置与场景中的3D对象的相交情况。
|
|
1184
|
+
* 这个方法是对象选择和交互的基础,用于确定用户点击了哪个对象。
|
|
1185
|
+
*
|
|
1186
|
+
* @param event - 鼠标事件信息,可选。如果不传入,则使用(0, 0)作为射线投射起点
|
|
1187
|
+
* @returns 相交对象的数组,按距离排序(最近的在前)
|
|
1188
|
+
* @private 内部方法,仅供框架内部使用
|
|
1189
|
+
*/
|
|
1190
|
+
private getIntersections;
|
|
1191
|
+
/**
|
|
1192
|
+
* 重写:事件级缓存的射线相交
|
|
1193
|
+
*/
|
|
1194
|
+
intersectObjectsCached(event: EventInfo, objects: THREE.Object3D[], recursive: boolean, cacheKey: string): THREE.Intersection<THREE.Object3D<THREE.Event>>[];
|
|
1195
|
+
/**
|
|
1196
|
+
* 处理鼠标点击事件
|
|
1197
|
+
*
|
|
1198
|
+
* 处理用户的鼠标点击交互,包括对象选择、取消选择等操作。
|
|
1199
|
+
* 这个方法会检查各种状态(如测量模式、标注模式等)以避免冲突。
|
|
1200
|
+
*
|
|
1201
|
+
* @param event - 鼠标事件信息,包含点击位置、按钮状态等
|
|
1202
|
+
* @private 内部方法,由事件系统调用
|
|
1203
|
+
*/
|
|
1204
|
+
private handleMouseClick;
|
|
1205
|
+
/**
|
|
1206
|
+
* 处理标注顶点拖拽开始
|
|
1207
|
+
*/
|
|
1208
|
+
private handleAnnotationVertexDragStart;
|
|
1209
|
+
/**
|
|
1210
|
+
* 处理标注顶点拖拽移动
|
|
1211
|
+
*/
|
|
1212
|
+
private handleAnnotationVertexDragMove;
|
|
1213
|
+
/**
|
|
1214
|
+
* 处理标注顶点拖拽结束
|
|
1215
|
+
*/
|
|
1216
|
+
private handleAnnotationVertexDragEnd;
|
|
1217
|
+
private selectDrawableByEvent;
|
|
1218
|
+
/**
|
|
1219
|
+
* 检查对象是否为标注 drawable(鸭子类型检查)
|
|
1220
|
+
*/
|
|
1221
|
+
private isAnnotationDrawable;
|
|
1222
|
+
/**
|
|
1223
|
+
* 从多个重叠的 drawable 中选择最小的区域
|
|
1224
|
+
* 优先级:1. 面积最小的封闭图形 2. 长度最短的线条 3. 第一个
|
|
1225
|
+
*/
|
|
1226
|
+
private selectSmallestDrawable;
|
|
1227
|
+
/**
|
|
1228
|
+
* 判断 drawable 是否为封闭图形
|
|
1229
|
+
*/
|
|
1230
|
+
private isClosedShape;
|
|
1231
|
+
/**
|
|
1232
|
+
* 选择面积最小的封闭图形
|
|
1233
|
+
*/
|
|
1234
|
+
private selectSmallestClosedShape;
|
|
1235
|
+
/**
|
|
1236
|
+
* 计算图形面积
|
|
1237
|
+
*/
|
|
1238
|
+
private calculateShapeArea;
|
|
1239
|
+
/**
|
|
1240
|
+
* 选择最短的线条
|
|
1241
|
+
*/
|
|
1242
|
+
private selectShortestLine;
|
|
1243
|
+
/**
|
|
1244
|
+
* 计算线条长度
|
|
1245
|
+
*/
|
|
1246
|
+
private calculateLineLength;
|
|
1247
|
+
/**
|
|
1248
|
+
* 选择或取消选择一个对象。
|
|
1249
|
+
* depthTest 默认关闭。当对象相互覆盖时,高亮效果会更加明显。
|
|
1250
|
+
*/
|
|
1251
|
+
protected selectObject(object?: THREE.Object3D, depthTest?: boolean): void;
|
|
1252
|
+
/**
|
|
1253
|
+
* Clears the current selection
|
|
1254
|
+
* @internal
|
|
1255
|
+
*/
|
|
1256
|
+
clearSelection(): void;
|
|
1257
|
+
/**
|
|
1258
|
+
* 使相机飞向对象
|
|
1259
|
+
*/
|
|
1260
|
+
protected flyToObjects(objects: THREE.Object3D[]): void;
|
|
1261
|
+
/**
|
|
1262
|
+
* 使相机飞向一个对象
|
|
1263
|
+
*/
|
|
1264
|
+
protected flyToObject(object: THREE.Object3D): void;
|
|
1265
|
+
/**
|
|
1266
|
+
* 如果有当前选中对象,飞向它
|
|
1267
|
+
*/
|
|
1268
|
+
protected flyToSelectedObject(): void;
|
|
1269
|
+
/**
|
|
1270
|
+
* 飞向随机对象(通过 alt + r)。
|
|
1271
|
+
* 当数据错误或程序有bug时很有用,
|
|
1272
|
+
* 这时我们在场景中看不到任何东西!
|
|
1273
|
+
*/
|
|
1274
|
+
protected flyToRandomObject(): void;
|
|
1275
|
+
/**
|
|
1276
|
+
* Makes camera fly to target position with given lookAt position
|
|
1277
|
+
* @param position camera's target position
|
|
1278
|
+
* @param lookAt camera's new lookAt position
|
|
1279
|
+
* @param targetCameraZoom camera's target zoom value
|
|
1280
|
+
* @internal
|
|
1281
|
+
*/
|
|
1282
|
+
flyTo(position: THREE.Vector3, lookAt: THREE.Vector3, targetCameraZoom?: number, animate?: boolean): void;
|
|
1283
|
+
/**
|
|
1284
|
+
* 将相机移动到目标位置
|
|
1285
|
+
* @param position 2d位置
|
|
1286
|
+
* @internal
|
|
1287
|
+
*/
|
|
1288
|
+
goTo(position: Vector2, targetCameraZoom?: number, animate?: boolean): void;
|
|
1289
|
+
/**
|
|
1290
|
+
* @description {en} Moves camera to home view.
|
|
1291
|
+
* @description {zh} 移动相机到主视图.
|
|
1292
|
+
* @example
|
|
1293
|
+
* ``` typescript
|
|
1294
|
+
* viewer.goToHomeView();
|
|
1295
|
+
* ```
|
|
1296
|
+
*/
|
|
1297
|
+
goToHomeView(): void;
|
|
1298
|
+
/**
|
|
1299
|
+
* @description {en} Zooms to specific bounding box.
|
|
1300
|
+
* @description {zh} 缩放到指定的包围盒.
|
|
1301
|
+
* @param bbox
|
|
1302
|
+
* - {en} 2d bounding box
|
|
1303
|
+
* - {zh} 2d 包围盒。
|
|
1304
|
+
* @example
|
|
1305
|
+
* ``` typescript
|
|
1306
|
+
* const box = { min: { x: 0, y: 0 }, max: { x: 10000, y: 10000} };
|
|
1307
|
+
* viewer.zoomToBBox(box);
|
|
1308
|
+
* ```
|
|
1309
|
+
*/
|
|
1310
|
+
zoomToBBox(bbox: Box2): void;
|
|
1311
|
+
/**
|
|
1312
|
+
* @description {en} Zooms to view extent.
|
|
1313
|
+
* @description {zh} 缩放到视图范围.
|
|
1314
|
+
* @example
|
|
1315
|
+
* ``` typescript
|
|
1316
|
+
* viewer.zoomToExtent();
|
|
1317
|
+
* ```
|
|
1318
|
+
*/
|
|
1319
|
+
zoomToExtent(): void;
|
|
1320
|
+
/**
|
|
1321
|
+
* @description {en} Sets background color.
|
|
1322
|
+
* @description {zh} 设置背景颜色。
|
|
1323
|
+
* @param r
|
|
1324
|
+
* - {en} Red channel value between 0 and 1.
|
|
1325
|
+
* - {zh} 红色通道值,介于 0 和 1 之间。
|
|
1326
|
+
* @param g
|
|
1327
|
+
* - {en} Green channel value between 0 and 1.
|
|
1328
|
+
* - {zh} 绿色通道值,介于 0 和 1 之间。
|
|
1329
|
+
* @param b
|
|
1330
|
+
* - {en} Blue channel value between 0 and 1.
|
|
1331
|
+
* -{zh} 蓝色通道值,介于 0 和 1 之间。
|
|
1332
|
+
* @example
|
|
1333
|
+
* ``` typescript
|
|
1334
|
+
* // {en} Sets background to gray
|
|
1335
|
+
* // {zh} 设置背景为灰色
|
|
1336
|
+
* viewer.setBackgroundColor(0.5, 0.5, 0.5);
|
|
1337
|
+
* ```
|
|
1338
|
+
*/
|
|
1339
|
+
setBackgroundColor(r: number, g: number, b: number): void;
|
|
1340
|
+
/**
|
|
1341
|
+
* Gets LayoutInfo by layoutName. It creats LayoutInfo if doesn't exist.
|
|
1342
|
+
*/
|
|
1343
|
+
private getLayoutInfo;
|
|
1344
|
+
/**
|
|
1345
|
+
* 创建一个比包围盒大得多的地面平面。
|
|
1346
|
+
*/
|
|
1347
|
+
private updateGroundPlane;
|
|
1348
|
+
/**
|
|
1349
|
+
* Compute bounding box of loaded models for active layout
|
|
1350
|
+
* @internal
|
|
1351
|
+
*/
|
|
1352
|
+
computeBoundingBox(): THREE.Box3;
|
|
1353
|
+
/**
|
|
1354
|
+
* Checks if an expected zoom value is valid, and adjust its value if necessary.
|
|
1355
|
+
*/
|
|
1356
|
+
private checkAndGetLimitedCameraZoom;
|
|
1357
|
+
private getVisiblePixelSize;
|
|
1358
|
+
private setLayoutHidableObjectArray;
|
|
1359
|
+
private statObjects;
|
|
1360
|
+
/**
|
|
1361
|
+
* Updates hidable objects' visibility once camera.zoom changed.
|
|
1362
|
+
*/
|
|
1363
|
+
private updateHidableObjectsVisibility;
|
|
1364
|
+
/**
|
|
1365
|
+
* Updates raycaster threshold to a proper value, so user can easily pick points and lines
|
|
1366
|
+
*/
|
|
1367
|
+
private updateRaycasterThreshold;
|
|
1368
|
+
/**
|
|
1369
|
+
* Updates camera zoom value for shader materials, which are created in DxfLoader
|
|
1370
|
+
*/
|
|
1371
|
+
private updateCameraZoomUniform;
|
|
1372
|
+
}
|