dxfview 0.0.4-beta.21 → 0.0.4-beta.23
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.
|
@@ -26,6 +26,8 @@ import { FontManager } from "../../core/font";
|
|
|
26
26
|
import { EventInfo } from "../../core/input/InputManager";
|
|
27
27
|
import { MarkupManager, MarkupType } from "../../core/markup";
|
|
28
28
|
import { Model2d, ModelData2d } from "../../core/model";
|
|
29
|
+
import { // 几何体合并工具
|
|
30
|
+
Batch } from "../../core/utils";
|
|
29
31
|
import { BaseViewer, ViewerName } from "../../core/viewers/BaseViewer";
|
|
30
32
|
import { MeasurementData, MeasurementType } from "../../plugins/measure";
|
|
31
33
|
import type { MeasurementPlugin } from "../../plugins/measure";
|
|
@@ -50,10 +52,18 @@ export declare type MarkupData = DrawableData;
|
|
|
50
52
|
*
|
|
51
53
|
* @property {string} modelId - 模型唯一标识符,用于区分不同的DXF 文件
|
|
52
54
|
* @property {string} layerName - 图层名称,表示实体所在的图层
|
|
55
|
+
* @property {Batch} batch - 可选,合并前的原始实体批次信息(包含顶点范围、索引范围、用户数据等)
|
|
56
|
+
* @property {THREE.Object3D} mergedObject - 可选,合并后的 THREE.Object3D 对象(Mesh/Line/Points)
|
|
57
|
+
* @property {number} faceIndex - 可选,点击的面索引(仅 Mesh 类型)
|
|
58
|
+
* @property {number} lineIndex - 可选,点击的线索引(仅 Line/LineSegments 类型)
|
|
53
59
|
*/
|
|
54
60
|
export interface EntityData {
|
|
55
61
|
modelId: string;
|
|
56
62
|
layerName: string;
|
|
63
|
+
batch?: Batch;
|
|
64
|
+
mergedObject?: THREE.Object3D;
|
|
65
|
+
faceIndex?: number;
|
|
66
|
+
lineIndex?: number;
|
|
57
67
|
}
|
|
58
68
|
/**
|
|
59
69
|
* @interface DxfLayers
|
|
@@ -1255,6 +1265,98 @@ export declare class DxfViewer extends BaseViewer {
|
|
|
1255
1265
|
* @internal
|
|
1256
1266
|
*/
|
|
1257
1267
|
clearSelection(): void;
|
|
1268
|
+
/**
|
|
1269
|
+
* 通过屏幕坐标拾取合并前的单个实体信息
|
|
1270
|
+
*
|
|
1271
|
+
* 使用射线投射检测指定屏幕坐标处的实体,并通过 Batch 反查获取合并前的原始实体信息。
|
|
1272
|
+
*
|
|
1273
|
+
* @param screenX - 页面坐标 X(即 MouseEvent.clientX)
|
|
1274
|
+
* @param screenY - 页面坐标 Y(即 MouseEvent.clientY)
|
|
1275
|
+
* @returns 实体数据(包含 batch 信息),如果未命中则返回 undefined
|
|
1276
|
+
*/
|
|
1277
|
+
getEntityAtPoint(screenX: number, screenY: number): EntityData | undefined;
|
|
1278
|
+
/**
|
|
1279
|
+
* 通过世界坐标拾取合并前的单个实体信息
|
|
1280
|
+
*
|
|
1281
|
+
* @param worldPoint - 世界坐标点
|
|
1282
|
+
* @param radius - 搜索半径(世界坐标单位),默认使用当前 raycaster 阈值
|
|
1283
|
+
* @returns 实体数据(包含 batch 信息),如果未命中则返回 undefined
|
|
1284
|
+
*/
|
|
1285
|
+
getEntityAtWorldPoint(worldPoint: THREE.Vector3, radius?: number): EntityData | undefined;
|
|
1286
|
+
/**
|
|
1287
|
+
* 获取框选范围内的所有合并前实体信息
|
|
1288
|
+
*
|
|
1289
|
+
* 通过屏幕空间的矩形区域,提取该区域内所有合并前的原始实体(batch)信息。
|
|
1290
|
+
*
|
|
1291
|
+
* @param screenBox - 页面坐标的矩形区域 (Box2, 使用 MouseEvent.clientX/clientY 坐标系: min=左上, max=右下)
|
|
1292
|
+
* @returns 框选范围内所有实体的数据数组
|
|
1293
|
+
*/
|
|
1294
|
+
getEntitiesInScreenBox(screenBox: THREE.Box2): EntityData[];
|
|
1295
|
+
/**
|
|
1296
|
+
* 获取世界坐标 Box3 范围内的所有合并前实体信息
|
|
1297
|
+
*
|
|
1298
|
+
* @param worldBox - 世界坐标的包围盒
|
|
1299
|
+
* @returns 范围内所有实体的数据数组
|
|
1300
|
+
*/
|
|
1301
|
+
getEntitiesInWorldBox(worldBox: THREE.Box3): EntityData[];
|
|
1302
|
+
/**
|
|
1303
|
+
* 获取所有合并前的实体 batch 列表
|
|
1304
|
+
*
|
|
1305
|
+
* 遍历当前场景中所有可选择对象,收集所有 batch 信息。
|
|
1306
|
+
*
|
|
1307
|
+
* @returns 所有实体的数据数组
|
|
1308
|
+
*/
|
|
1309
|
+
getAllEntities(): EntityData[];
|
|
1310
|
+
/**
|
|
1311
|
+
* 根据 batch 信息提取该实体的顶点数据(世界坐标)
|
|
1312
|
+
*
|
|
1313
|
+
* @param mergedObject - 合并后的 THREE.Object3D
|
|
1314
|
+
* @param batch - 批次信息
|
|
1315
|
+
* @returns 顶点坐标数组
|
|
1316
|
+
*/
|
|
1317
|
+
getEntityVertices(mergedObject: THREE.Object3D, batch: Batch): THREE.Vector3[];
|
|
1318
|
+
/**
|
|
1319
|
+
* 根据 batch 信息计算该实体的包围盒
|
|
1320
|
+
*
|
|
1321
|
+
* @param mergedObject - 合并后的 THREE.Object3D
|
|
1322
|
+
* @param batch - 批次信息
|
|
1323
|
+
* @returns 包围盒
|
|
1324
|
+
*/
|
|
1325
|
+
getEntityBoundingBox(mergedObject: THREE.Object3D, batch: Batch): THREE.Box3;
|
|
1326
|
+
/**
|
|
1327
|
+
* 获取场景中可选择的对象列表
|
|
1328
|
+
* 从已加载模型的当前布局中获取有几何体的叶子对象
|
|
1329
|
+
*/
|
|
1330
|
+
private getSelectableSceneObjects;
|
|
1331
|
+
/**
|
|
1332
|
+
* 从 intersection 构建 EntityData
|
|
1333
|
+
*/
|
|
1334
|
+
private buildEntityDataFromIntersection;
|
|
1335
|
+
/**
|
|
1336
|
+
* 从非合并对象构建 EntityData
|
|
1337
|
+
*/
|
|
1338
|
+
private buildEntityDataFromObject;
|
|
1339
|
+
/**
|
|
1340
|
+
* 从 batch 信息构建 EntityData
|
|
1341
|
+
*/
|
|
1342
|
+
private buildEntityDataFromBatch;
|
|
1343
|
+
/**
|
|
1344
|
+
* 递归查找对象所属的模型 ID(向上遍历到场景根节点的直接子对象)
|
|
1345
|
+
*/
|
|
1346
|
+
private findModelIdByObject;
|
|
1347
|
+
/**
|
|
1348
|
+
* 计算 batch 的包围盒
|
|
1349
|
+
*/
|
|
1350
|
+
private computeBatchBoundingBox;
|
|
1351
|
+
/**
|
|
1352
|
+
* 从 NDC 坐标的矩形构建视锥体
|
|
1353
|
+
* 平面法线指向视锥体内部(THREE.Frustum 要求物体在所有平面的正半空间才算在视锥体内)
|
|
1354
|
+
*/
|
|
1355
|
+
private buildFrustumFromNDCBox;
|
|
1356
|
+
/**
|
|
1357
|
+
* 收集视锥体内的所有实体
|
|
1358
|
+
*/
|
|
1359
|
+
private collectEntitiesInFrustum;
|
|
1258
1360
|
/**
|
|
1259
1361
|
* 使相机飞向对象
|
|
1260
1362
|
*/
|
|
@@ -1308,7 +1410,7 @@ export declare class DxfViewer extends BaseViewer {
|
|
|
1308
1410
|
* viewer.zoomToBBox(box);
|
|
1309
1411
|
* ```
|
|
1310
1412
|
*/
|
|
1311
|
-
zoomToBBox(bbox: Box2): void;
|
|
1413
|
+
zoomToBBox(bbox: Box2, animate?: boolean): void;
|
|
1312
1414
|
/**
|
|
1313
1415
|
* @description {en} Zooms to view extent.
|
|
1314
1416
|
* @description {zh} 缩放到视图范图
|
|
@@ -2,6 +2,9 @@ import * as THREE from "three";
|
|
|
2
2
|
import { BaseAnnotationDrawable, AnnotationModeType, AnnotationData } from "./BaseAnnotationDrawable";
|
|
3
3
|
import type { BaseViewer } from "../../core/viewers";
|
|
4
4
|
import { Plugin } from "../../core/viewers/Plugin";
|
|
5
|
+
export interface AnnotationPluginOptions {
|
|
6
|
+
segmentLabelScaleWithZoom?: boolean;
|
|
7
|
+
}
|
|
5
8
|
export declare class AnnotationPlugin extends Plugin {
|
|
6
9
|
static DEFAULT_ID: string;
|
|
7
10
|
selectedDrawable: BaseAnnotationDrawable | undefined;
|
|
@@ -21,8 +24,9 @@ export declare class AnnotationPlugin extends Plugin {
|
|
|
21
24
|
private snapObjectsDirty;
|
|
22
25
|
private pendingSnapDrawableIds;
|
|
23
26
|
private snapLineMaterial?;
|
|
27
|
+
private segmentLabelScaleWithZoom;
|
|
24
28
|
private readonly partitionLabels;
|
|
25
|
-
constructor(viewer: BaseViewer);
|
|
29
|
+
constructor(viewer: BaseViewer, options?: AnnotationPluginOptions);
|
|
26
30
|
getDrawableList(): {
|
|
27
31
|
id: string;
|
|
28
32
|
position: THREE.Vector3;
|
|
@@ -90,6 +94,9 @@ export declare class AnnotationPlugin extends Plugin {
|
|
|
90
94
|
private initEvents;
|
|
91
95
|
protected get canvas(): HTMLCanvasElement;
|
|
92
96
|
protected get raycaster(): any;
|
|
97
|
+
setSegmentLabelScaleWithZoom(enabled: boolean): void;
|
|
98
|
+
getSegmentLabelScaleWithZoom(): boolean;
|
|
99
|
+
private applyDrawableRuntimeContext;
|
|
93
100
|
add(drawable: BaseAnnotationDrawable, needFireEvent?: boolean): void;
|
|
94
101
|
create(data: AnnotationData): BaseAnnotationDrawable;
|
|
95
102
|
remove(drawable: BaseAnnotationDrawable, needFireEvent?: boolean): void;
|
|
@@ -255,6 +262,7 @@ export declare class AnnotationPlugin extends Plugin {
|
|
|
255
262
|
* 在当前选中图形基础上启动复制预览
|
|
256
263
|
*/
|
|
257
264
|
startCopyForSelected(): void;
|
|
265
|
+
private shouldIgnoreSelectionWhileAnnotating;
|
|
258
266
|
/**
|
|
259
267
|
* 处理 DxfViewer 的统一点击事件,同步插件内部的选择状态
|
|
260
268
|
* 当用户在非激活状态下点击标注时,DxfViewer 会选择对应的 drawable 并触发此事件
|
|
@@ -65,6 +65,10 @@ export declare abstract class BaseAnnotationDrawable extends Drawable {
|
|
|
65
65
|
protected segmentLabelFontSize: number;
|
|
66
66
|
protected segmentLabelPaddingX: number;
|
|
67
67
|
protected segmentLabelPaddingY: number;
|
|
68
|
+
protected segmentLabelScaleWithZoom: boolean;
|
|
69
|
+
protected segmentLabelReferencePixelSizeInWorldCoord?: number;
|
|
70
|
+
protected segmentLabelAdaptiveBaseScale?: number;
|
|
71
|
+
protected segmentLabelAdaptiveBaseScaleSignature?: string;
|
|
68
72
|
protected annotationType?: AnnotationType;
|
|
69
73
|
protected titleText?: string;
|
|
70
74
|
protected annotationProperty?: AnnotationProperty;
|
|
@@ -74,6 +78,20 @@ export declare abstract class BaseAnnotationDrawable extends Drawable {
|
|
|
74
78
|
* 设置选中态填充颜色
|
|
75
79
|
*/
|
|
76
80
|
setSelectedFillColor(color: number[]): this;
|
|
81
|
+
setViewer(viewer?: BaseViewer): this;
|
|
82
|
+
setSegmentLabelScaleWithZoom(enabled: boolean): this;
|
|
83
|
+
captureSegmentLabelScaleReference(force?: boolean): this;
|
|
84
|
+
protected getSegmentLabelScaleFactor(): number;
|
|
85
|
+
private getSegmentLabelReferencePixelSize;
|
|
86
|
+
private isSegmentLabelRectOverlap;
|
|
87
|
+
private getSortedSegmentLabelEntries;
|
|
88
|
+
private measureSegmentLabelRect;
|
|
89
|
+
private layoutSegmentLabelEntries;
|
|
90
|
+
private estimateSegmentLabelAdaptiveBaseScale;
|
|
91
|
+
private buildSegmentLabelAdaptiveBaseScaleSignature;
|
|
92
|
+
private resolveSegmentLabelAdaptiveBaseScale;
|
|
93
|
+
private collectSegmentLabelEntries;
|
|
94
|
+
private prepareSegmentLabelEntries;
|
|
77
95
|
/**
|
|
78
96
|
* 开始拖拽顶点(仅外环 points)
|
|
79
97
|
*/
|
|
@@ -156,6 +174,10 @@ export declare abstract class BaseAnnotationDrawable extends Drawable {
|
|
|
156
174
|
* 停用射线检测器
|
|
157
175
|
*/
|
|
158
176
|
deactivateRaycaster(): void;
|
|
177
|
+
private static readonly AREA_SCALE_RATIO;
|
|
178
|
+
private static readonly MIN_LABEL_SCALE;
|
|
179
|
+
private static readonly SCREEN_HIDE_THRESHOLD;
|
|
180
|
+
private static readonly MIN_SCREEN_SEGMENT;
|
|
159
181
|
protected drawSegmentLengths(ctx: CanvasRenderingContext2D, camera: THREE.Camera): void;
|
|
160
182
|
private drawSegmentLengthLabel;
|
|
161
183
|
private drawRoundedRect;
|