@maqiuyao/dxf-viewer 0.2.0 → 0.2.1
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.
|
@@ -2,7 +2,7 @@ import { CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
|
|
|
2
2
|
import { ProgressBar, Spinner } from '../components';
|
|
3
3
|
import { ViewerName } from './Constants';
|
|
4
4
|
import { Plugin } from './Plugin';
|
|
5
|
-
import { ViewerEvent } from './ViewerEvent';
|
|
5
|
+
import { ViewerEvent, MouseClickInfo } from './ViewerEvent';
|
|
6
6
|
import { BaseViewerConfig, CameraConfig, CameraProjection, ModelConfig, Viewpoint } from '../../core/Configs';
|
|
7
7
|
import { CameraManager } from '../../core/camera';
|
|
8
8
|
import { CanvasRender } from '../../core/canvas';
|
|
@@ -18,7 +18,7 @@ import { UndoManager } from '../../core/undo';
|
|
|
18
18
|
import { Event } from '../../core/utils';
|
|
19
19
|
import * as THREE from "three";
|
|
20
20
|
type ViewerEvents = {
|
|
21
|
-
[K in ViewerEvent]: any;
|
|
21
|
+
[K in ViewerEvent]: K extends ViewerEvent.MouseClick ? MouseClickInfo : any;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* Abstract base class for Viewer2d, Viewer3d, etc.
|
|
@@ -171,9 +171,40 @@ export declare class Viewer2d extends BaseViewer {
|
|
|
171
171
|
*/
|
|
172
172
|
private loadingDxfCount;
|
|
173
173
|
private textSearchHelper?;
|
|
174
|
+
/** 实体点击高亮的云线框叠加层 */
|
|
175
|
+
private clickHighlightList?;
|
|
176
|
+
/** 是否启用点击实体高亮,默认关闭 */
|
|
177
|
+
private _enableClickHighlight;
|
|
174
178
|
constructor(viewerCfg: Viewer2dConfig);
|
|
175
179
|
get camera(): THREE.OrthographicCamera;
|
|
176
180
|
private setupDefaultEvents;
|
|
181
|
+
/**
|
|
182
|
+
* 从拾取命中结果反查所属 DXF 实体的 userData 与对应 batch。
|
|
183
|
+
* 合并(deepMerge)后一个几何对象含多个 batch,每个 batch.userData 保存原实体元数据;
|
|
184
|
+
* 依据命中的索引/面游标定位 batch。返回的 batch 用于计算该实体的世界包围盒以高亮。
|
|
185
|
+
*/
|
|
186
|
+
private resolveEntityFromPick;
|
|
187
|
+
/**
|
|
188
|
+
* 计算命中实体(batch 或整个对象)的世界包围盒。
|
|
189
|
+
*/
|
|
190
|
+
private getEntityBoundingBox;
|
|
191
|
+
/**
|
|
192
|
+
* 用云线框高亮指定实体包围盒(替换上一个高亮)。
|
|
193
|
+
*/
|
|
194
|
+
private highlightEntityBox;
|
|
195
|
+
/**
|
|
196
|
+
* Gets if click-to-highlight entity is enabled. Default is false.
|
|
197
|
+
*/
|
|
198
|
+
get enableClickHighlight(): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Sets if click-to-highlight entity is enabled.
|
|
201
|
+
* When turned off, the current highlight (if any) is cleared.
|
|
202
|
+
*/
|
|
203
|
+
set enableClickHighlight(enable: boolean);
|
|
204
|
+
/**
|
|
205
|
+
* 清除实体点击高亮。
|
|
206
|
+
*/
|
|
207
|
+
clearClickHighlight(): void;
|
|
177
208
|
protected handleMouseClick(e: EventInfo): void;
|
|
178
209
|
private setDefaultBackground;
|
|
179
210
|
/**
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
import { Object3D, Vector2, Vector3 } from 'three';
|
|
2
|
+
import { EventInfo } from '../input-manager/InputManager';
|
|
3
|
+
/**
|
|
4
|
+
* 实体点击事件({@link ViewerEvent.MouseClick})的载荷。
|
|
5
|
+
* 点击图纸实体时携带命中信息;点击空白处时 entity/object/point/userData/handle 为 undefined。
|
|
6
|
+
*/
|
|
7
|
+
export interface MouseClickInfo {
|
|
8
|
+
/** 原始输入事件信息 */
|
|
9
|
+
event: EventInfo;
|
|
10
|
+
/** 点击位置(查看器容器内像素坐标) */
|
|
11
|
+
position: Vector2;
|
|
12
|
+
/** 点击位置对应的世界坐标 */
|
|
13
|
+
worldPosition: Vector3;
|
|
14
|
+
/** @deprecated 兼容旧字段,等价于 worldPosition */
|
|
15
|
+
pooo: Vector3;
|
|
16
|
+
/** 命中的实体对象;点击空白处为 undefined */
|
|
17
|
+
entity?: Object3D;
|
|
18
|
+
/** 命中对象(与 entity 一致,仅当解析出实体时非空) */
|
|
19
|
+
object?: Object3D;
|
|
20
|
+
/** 命中点(世界坐标) */
|
|
21
|
+
point?: Vector3;
|
|
22
|
+
/** 命中实体的元数据(handle / dxfType / layerName / textContent 等) */
|
|
23
|
+
userData?: Record<string, any>;
|
|
24
|
+
/** 命中实体的 DXF handle */
|
|
25
|
+
handle?: string;
|
|
26
|
+
}
|
|
1
27
|
/**
|
|
2
28
|
* Viewer events
|
|
3
29
|
* TODO: dxf event and bim event
|