dxfview 0.0.4 → 0.0.5-beta

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 (27) hide show
  1. package/dist/dxfview.esm.min.js +3 -3
  2. package/dist/types/core/canvas/SelectionBoxDrawable.d.ts +27 -0
  3. package/dist/types/core/dxf/DxfLoader.d.ts +1 -1
  4. package/dist/types/core/dxf/DxfUtils.d.ts +1 -0
  5. package/dist/types/core/dxf/dxfom-text.d.ts +3 -1
  6. package/dist/types/core/dxf-parser/ParseHelpers.d.ts +1 -0
  7. package/dist/types/core/font/FontManager.d.ts +2 -0
  8. package/dist/types/core/geometry-offset/Offset.d.ts +2 -2
  9. package/dist/types/core/helpers/OSnapHelper.d.ts +65 -2
  10. package/dist/types/core/input/InputManager.d.ts +2 -0
  11. package/dist/types/core/license/PublicKey.d.ts +1 -1
  12. package/dist/types/core/utils/DecimalPrecisionUtils.d.ts +4 -0
  13. package/dist/types/core/utils/MergeUtils.d.ts +1 -1
  14. package/dist/types/core/utils/utf8OrGBK.d.ts +4 -0
  15. package/dist/types/core/viewers/DxfViewer.d.ts +321 -176
  16. package/dist/types/plugins/annotation/AnnotationPlugin.d.ts +144 -2
  17. package/dist/types/plugins/annotation/AutoDrawAnnotation.d.ts +3 -4
  18. package/dist/types/plugins/annotation/BaseAnnotation.d.ts +42 -3
  19. package/dist/types/plugins/annotation/BaseAnnotationDrawable.d.ts +52 -2
  20. package/dist/types/plugins/annotation/FreeDrawAnnotation.d.ts +48 -14
  21. package/dist/types/plugins/annotation/RectAnnotation.d.ts +37 -10
  22. package/dist/types/plugins/annotation/RectDrawable.d.ts +13 -2
  23. package/dist/types/plugins/annotation/freeDrawDrawable.d.ts +1 -0
  24. package/dist/types/plugins/annotation/type.d.ts +1 -0
  25. package/dist/types/plugins/divide/DividePlugin.d.ts +10 -2
  26. package/dist/types/plugins/divide/FrameAnnotation.d.ts +1 -0
  27. package/package.json +92 -90
@@ -0,0 +1,27 @@
1
+ import * as THREE from "three";
2
+ import { Drawable } from "./Drawable";
3
+ declare type SelectionBoxOptions = {
4
+ lineColor?: number[];
5
+ lineWidth?: number;
6
+ dashed?: boolean;
7
+ dashPattern?: number[];
8
+ };
9
+ /**
10
+ * Lightweight drawable for visualizing a world-space selection box.
11
+ * Kept independent from annotation classes to avoid editing/snap overhead.
12
+ */
13
+ export declare class SelectionBoxDrawable extends Drawable {
14
+ private min;
15
+ private max;
16
+ private dashed;
17
+ private dashPattern;
18
+ constructor(id: string, min: THREE.Vector3, max: THREE.Vector3, options?: SelectionBoxOptions);
19
+ update(min: THREE.Vector3, max: THREE.Vector3): void;
20
+ getClassType(): string;
21
+ getVertexes(): THREE.Vector3[];
22
+ getBounds(): THREE.Box3;
23
+ isPointInPath(p: THREE.Vector3): boolean;
24
+ draw(ctx: CanvasRenderingContext2D, camera: THREE.Camera): void;
25
+ drawSelect(ctx: CanvasRenderingContext2D, camera: THREE.Camera): void;
26
+ }
27
+ export {};
@@ -215,7 +215,7 @@ export declare class DxfLoader extends THREE.Loader {
215
215
  private timer;
216
216
  private ignorePaperSpace;
217
217
  font?: FontManager;
218
- private encoding;
218
+ encoding: string;
219
219
  private overrideColor?;
220
220
  private overrideHatchPatternLineThickness?;
221
221
  angBase: number | IPoint;
@@ -21,6 +21,7 @@ export declare class DxfUtils {
21
21
  * While this takes some extra space, so, we'd like to add a flag here.
22
22
  */
23
23
  static merge(object: DxfObject, saveBatchInfo?: boolean): void;
24
+ private static attachBatchUserData;
24
25
  /**
25
26
  * Merges child objects of given object.
26
27
  * If objects' material are the same, they can be merged.
@@ -10,7 +10,9 @@ export interface DxfTextContentElement {
10
10
  }
11
11
  export declare const decodeDxfTextCharacterCodes: (text: string, mbcsEncoding?: string | TextDecoder) => string;
12
12
  export declare const decodeDxfTextUnicodeCodePoints: (text: string) => string;
13
- export declare const decodeDxfTextMbcsCharacterCodes: (text: string, encoding: string | TextDecoder) => string;
13
+ export declare const decodeDxfTextMifCharacterCode: (codePage: string, hexBytes: string, fallbackEncoding?: string | TextDecoder) => string | undefined;
14
+ export declare const decodeDxfTextMbcsCharacterCodes: (text: string, encoding?: string | TextDecoder) => string;
15
+ export declare const normalizeDxfTextSymbols: (text: string) => string;
14
16
  export declare const parseDxfTextContent: (text: string, options?: {
15
17
  readonly encoding?: string | TextDecoder;
16
18
  }) => DxfTextContentElement[];
@@ -34,3 +34,4 @@ export declare function checkCommonEntityProperties(entity: IEntity, curr: IGrou
34
34
  * @param {*} curr - the current group being parsed
35
35
  */
36
36
  export declare function checkCommonObjectProperties(object: IObject, curr: IGroup): boolean;
37
+ export declare function skipControlGroup(scanner: DxfBaseReader, curr: IGroup): IGroup;
@@ -39,6 +39,8 @@ export declare class FontManager {
39
39
  * @returns 字符的几何形状
40
40
  */
41
41
  getCharShape(char: string, fontName: string, size: number): THREE.BufferGeometry<THREE.NormalBufferAttributes> | TextGeometry | undefined;
42
+ private findFont;
43
+ private static normalizeFontName;
42
44
  /**
43
45
  * 获取未找到文本的默认形状
44
46
  * @param size 字体大小
@@ -32,11 +32,11 @@ export declare class Offset {
32
32
  /**
33
33
  * Decides by the sign if it's a padding or a margin
34
34
  */
35
- offset(dist: number): Pair | Ring | Polygon | MultiPolygon;
35
+ offset(dist: number): MultiPolygon | Polygon | Ring | Pair;
36
36
  private offsetSegment;
37
37
  private margin;
38
38
  private padding;
39
- offsetLine(dist: number): Pair | Ring | Polygon | MultiPolygon;
39
+ offsetLine(dist: number): MultiPolygon | Polygon | Ring | Pair;
40
40
  /**
41
41
  * Just offsets lines, no fill
42
42
  */
@@ -69,6 +69,10 @@ export declare enum OSnapType {
69
69
  interface OSnapInfo {
70
70
  point: THREE.Vector3;
71
71
  distance: number;
72
+ apertureDistance?: number;
73
+ screenDistance?: number;
74
+ sourceAnnotationId?: string;
75
+ ringPriority?: number;
72
76
  type: OSnapType;
73
77
  line?: ILine;
74
78
  }
@@ -79,6 +83,13 @@ export declare class OSnapHelper {
79
83
  protected activeOSnapType: OSnapType;
80
84
  protected snapToleranceInWorldCoord: number;
81
85
  protected intersectionLimit: number;
86
+ protected orthoModeEnabled: boolean;
87
+ protected endpointPriorityModeEnabled: boolean;
88
+ protected endpointPriorityBoost: number;
89
+ protected endpointPriorityPixelRadius: number;
90
+ private stickySnapPixelTolerance;
91
+ private stickySnapReleasePixelDistance;
92
+ private lastSnapInfo?;
82
93
  /**
83
94
  * OSnapType 的优先级,数值越小优先级越高。
84
95
  * 在多种捕捉结果出现时,依据优先级与距离选择最终的捕捉点。
@@ -105,6 +116,36 @@ export declare class OSnapHelper {
105
116
  getSnapTolerance(): number;
106
117
  setIntersectionLimit(val: number): void;
107
118
  getIntersectionLimit(): number;
119
+ /**
120
+ * 设置正交模式开关。
121
+ * 启用后,绘制的线条会被约束为水平或垂直方向。
122
+ * @param enabled 是否启用正交模式
123
+ */
124
+ setOrthoModeEnabled(enabled: boolean): void;
125
+ /**
126
+ * 获取正交模式是否启用。
127
+ */
128
+ isOrthoModeEnabled(): boolean;
129
+ /**
130
+ * 获取当前激活的捕捉类型。
131
+ * 用于判断是否应用正交约束(例如,垂足捕捉时不应用正交约束)。
132
+ */
133
+ getActiveOSnapType(): OSnapType;
134
+ /**
135
+ * 设置是否启用 CAD 式端点优先模式。
136
+ */
137
+ setEndpointPriorityModeEnabled(enabled: boolean): void;
138
+ /**
139
+ * 获取 CAD 式端点优先模式状态。
140
+ */
141
+ isEndpointPriorityModeEnabled(): boolean;
142
+ /**
143
+ * 应用正交约束:根据参考点将当前位置约束为水平或垂直方向(90° 的倍数:0°、90°、180°、270°)。
144
+ * @param currentPosition 当前鼠标位置(世界坐标)
145
+ * @param referencePosition 参考点位置(通常是上一个点击的位置)
146
+ * @returns 应用正交约束后的位置
147
+ */
148
+ applyOrthoConstraint(currentPosition: THREE.Vector3, referencePosition: THREE.Vector3): THREE.Vector3;
108
149
  /**
109
150
  * Gets osnap marker line color.
110
151
  * @returns rgb/rgba number array, each value is between 0 and 1. e.g. [0.92, 0.95, 0.96].
@@ -140,9 +181,10 @@ export declare class OSnapHelper {
140
181
  * @param intersections The raycaster intersections, must have been sorted by distance.
141
182
  * @param is3d If it is a 3d or 2d viewer.
142
183
  * @param lastMouseDownPosition Used in order to to get foot of perpendicular.
184
+ * @param mousePositionOverride Optional mouse world position (useful for 2d to avoid ray hit drift).
143
185
  * @returns Target snap point if any
144
186
  */
145
- handleSnap(rayCasterResult: THREE.Intersection[], is3d: boolean, lastMouseDownPosition?: THREE.Vector3): THREE.Vector3 | undefined;
187
+ handleSnap(rayCasterResult: THREE.Intersection[], is3d: boolean, lastMouseDownPosition?: THREE.Vector3, mousePositionOverride?: THREE.Vector3, mouseScreenPositionOverride?: THREE.Vector2): THREE.Vector3 | undefined;
146
188
  /**
147
189
  * Tries to find a proper snap point and display corresponding marker.
148
190
  * @param mousePosition Mouse position in world coordinate.
@@ -151,12 +193,33 @@ export declare class OSnapHelper {
151
193
  * @param lastMouseDownPosition Used in order to to get foot of perpendicular.
152
194
  * @returns Target snap point if any
153
195
  */
154
- protected getSnapPointAndUpdateMarker(mousePosition: THREE.Vector3, intersections: THREE.Intersection[], is3d: boolean, lastMouseDownPosition?: THREE.Vector3): THREE.Vector3 | undefined;
196
+ protected getSnapPointAndUpdateMarker(mousePosition: THREE.Vector3, intersections: THREE.Intersection[], is3d: boolean, lastMouseDownPosition?: THREE.Vector3, mouseScreenPosition?: THREE.Vector2): THREE.Vector3 | undefined;
155
197
  activateMarker(type: OSnapType, osnapInfo?: OSnapInfo): void;
156
198
  private getFootOfPerpendicular;
199
+ private getScreenDistance;
200
+ private isSameSnapCandidate;
201
+ private selectStickySnapCandidate;
202
+ private cloneSnapInfo;
203
+ /**
204
+ * CAD式捕捉排序:
205
+ * 1) 先按捕捉类型优先级;
206
+ * 2) 同一标注内的顶点捕捉优先外环(ringPriority更小);
207
+ * 3) 再按屏幕像素距离(CAD孔径语义);
208
+ * 4) 再按真实捕捉点距离(避免缩小时轻微移动导致跳点);
209
+ * 5) 最后用孔径中心距离做稳定 tie-break。
210
+ */
211
+ private compareSnapInfo;
212
+ private applyEndpointPriority;
157
213
  private getSnapInfo;
158
214
  private getOsnapInfoListFromMesh;
159
215
  private getOsnapInfoFromSegment;
216
+ private getLineRingPriority;
217
+ private applyLineSnapMetadata;
218
+ /**
219
+ * 根据 intersection.index 获取具体线段并计算捕捉信息
220
+ * 这是解决捕捉漏掉/偏差问题的核心方法
221
+ */
222
+ private getOsnapInfoFromIntersectionIndex;
160
223
  private getOsnapInfoListFromLine;
161
224
  private getOsnapInfoListFromPoint;
162
225
  /**
@@ -9,6 +9,7 @@ export interface IUIEvent {
9
9
  export interface IMouseEvent extends IUIEvent {
10
10
  readonly altKey: boolean;
11
11
  readonly ctrlKey: boolean;
12
+ readonly metaKey: boolean;
12
13
  readonly shiftKey: boolean;
13
14
  readonly button: number;
14
15
  readonly clientX: number;
@@ -32,6 +33,7 @@ export interface IWheelEvent extends IMouseEvent {
32
33
  export interface IKeyboardEvent extends IUIEvent {
33
34
  readonly altKey: boolean;
34
35
  readonly ctrlKey: boolean;
36
+ readonly metaKey: boolean;
35
37
  readonly shiftKey: boolean;
36
38
  readonly key: string;
37
39
  readonly code: string;
@@ -1 +1 @@
1
- export declare const DEFAULT_PUBLIC_KEY_HEX = "0xe93f27a3147a0e2f67b718dffbf7553981ec8d9bb8bf7d18a4ba1f491736ea78";
1
+ export declare const DEFAULT_PUBLIC_KEY_HEX = "0xe98c5ce23e9da75c9169a670637a1ff68e373ddbf7e98cb85efdfb8a6106bf33";
@@ -2,3 +2,7 @@
2
2
  * @internal
3
3
  */
4
4
  export declare const showPrecisionValue: (value: number, precistionType: number) => string;
5
+ /**
6
+ * @internal
7
+ */
8
+ export declare const showPrecisionValueAnnotation: (value: number, precistionType: number) => string;
@@ -445,7 +445,7 @@ export declare class MergeUtils {
445
445
  *
446
446
  * @returns 是否可以合并 - true表示两个对象兼容,可以合并
447
447
  */
448
- static areObjectsMergeable(o1: THREE.Object3D, o2: THREE.Object3D): any;
448
+ static areObjectsMergeable(o1: THREE.Object3D, o2: THREE.Object3D): boolean | undefined;
449
449
  /**
450
450
  * 检查网格是否为合并后的对象
451
451
  *
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 判断是否为utf-8
3
+ */
4
+ export declare function isUTF8(bytes: Uint8Array): boolean;