@vsleem-realsee-viewer/shared 1.1.3 → 2.0.0

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Coordinate 坐标系类
4
4
 
5
- 该类设计适用于建筑信息模型(BIM)、地理信息系统(GIS)等需要复杂空间关系管理的场景。
5
+ 该类设计适用于建筑信息模型(Bim)、地理信息系统(GIS)等需要复杂空间关系管理的场景。
6
6
 
7
7
  ## 属性说明
8
8
 
@@ -50,7 +50,7 @@
50
50
  | `fromMapping` | `() => Promise<ProjectionModel \| undefined>` | 查询当前坐标系被哪些源坐标系映射 |
51
51
  | `findRoot` | `(mapped?: boolean) => Coordinate` | 递归查找根坐标系,可选是否只查找有映射关系的 |
52
52
  | `findChildModel` | `(type?: number \| number[], mapped?: boolean) => Coordinate \| undefined` | 查找符合条件的子模型坐标系 |
53
- | `findLatestModel` | `(type?: number \| number[], excludeNodes?: Coordinate[]) => Coordinate \| undefined` | 使用广度优先搜索查找最近的模型坐标系 |
53
+ | `findClosestModel` | `(type?: number \| number[], excludeNodes?: Coordinate[]) => Coordinate \| undefined` | 使用广度优先搜索查找最近的模型坐标系 |
54
54
  | `findParentSpace` | `() => Coordinate \| undefined` | 向上查找最近的父级空间坐标系 |
55
55
  | `findParentSpaceNames` | `(level?: number) => string[]` | 获取指定层级数的父空间名称列表 |
56
56
  | `findCsGroup` | `() => Coordinate[]` | 查找当前坐标系所在的分组 |
@@ -63,7 +63,7 @@
63
63
 
64
64
  # DataSource 数据源类
65
65
 
66
- 该类类用于管理 BIM、GIS、数字孪生的层级结构与空间关系
66
+ 该类类用于管理 Bim、GIS、数字孪生的层级结构与空间关系
67
67
 
68
68
  ## 静态方法说明
69
69
 
@@ -124,8 +124,8 @@
124
124
  | `constructor` | `(options?: Partial<RelativeMap>) => RelativeMap` | 初始化相对映射关系,支持部分属性配置 |
125
125
  | `addRelativeMap` | `(r1: RelativeMap, r2: RelativeMap) => RelativeMap` | 合并两个坐标变换(先应用r1后应用r2) |
126
126
  | `inverseRelativeMap` | `(r: RelativeMap) => RelativeMap` | 计算坐标变换的逆变换 |
127
- | `JSONParse` | `(r?: string) => RelativeMap \| undefined` | 从JSON字符串解析为RelativeMap对象 |
128
- | `JSONStringify` | `(r?: RelativeMap) => string \| undefined` | 将RelativeMap对象序列化为JSON字符串 |
127
+ | `toParse` | `(r?: string) => RelativeMap \| undefined` | 从JSON字符串解析为RelativeMap对象 |
128
+ | `toStringify` | `(r?: RelativeMap) => string \| undefined` | 将RelativeMap对象序列化为JSON字符串 |
129
129
 
130
130
  # Point 点坐标类
131
131
 
@@ -151,18 +151,18 @@
151
151
 
152
152
  ## 方法说明
153
153
 
154
- | 方法 | 类型 | 说明 |
155
- | --------------- | ------------------------------------------------------------------------------------------------ | ---------------------- |
156
- | `constructor` | `(options?: Partial<Point>) => Point` | 初始化点坐标 |
157
- | `dist` | `(p1: Point, p2: Point) => number` | 计算两点间三维距离 |
158
- | `distXZ` | `(p1: Point, p2: Point) => number` | 计算两点在XZ平面的距离 |
159
- | `distXY` | `(p1: Point, p2: Point) => number` | 计算两点在XY平面的距离 |
160
- | `toRadians` | `(degrees: number) => number` | 角度转弧度 |
161
- | `toDegrees` | `(radians: number) => number` | 弧度转角度 |
162
- | `angleXZ` | `(pa: Point, pb: Point, pc: Point) => number` | 计算三点在XZ平面的夹角 |
163
- | `JSONParse` | `(point?: string) => Point \| undefined` | 从字符串解析点坐标 |
164
- | `JSONStringify` | `(point?: Point) => string` | 将点坐标序列化为字符串 |
165
- | `projection` | `(r: RelativeMap, srcCoordinate?: Coordinate, dstCoordinate?: Coordinate) => Point \| undefined` | 坐标投影转换 |
166
- | `project` | `(r: RelativeMap) => Point \| undefined` | 基础坐标投影 |
167
- | `projectXZ` | `(r: RelativeMap) => Point` | XZ平面坐标投影 |
168
- | `projectXY` | `(r: RelativeMap) => Point` | XY平面坐标投影 |
154
+ | 方法 | 类型 | 说明 |
155
+ | ------------- | ------------------------------------------------------------------------------------------------ | ---------------------- |
156
+ | `constructor` | `(options?: Partial<Point>) => Point` | 初始化点坐标 |
157
+ | `dist` | `(p1: Point, p2: Point) => number` | 计算两点间三维距离 |
158
+ | `distXZ` | `(p1: Point, p2: Point) => number` | 计算两点在XZ平面的距离 |
159
+ | `distXY` | `(p1: Point, p2: Point) => number` | 计算两点在XY平面的距离 |
160
+ | `toRadians` | `(degrees: number) => number` | 角度转弧度 |
161
+ | `toDegrees` | `(radians: number) => number` | 弧度转角度 |
162
+ | `angleXZ` | `(pa: Point, pb: Point, pc: Point) => number` | 计算三点在XZ平面的夹角 |
163
+ | `toParse` | `(point?: string) => Point \| undefined` | 从字符串解析点坐标 |
164
+ | `toStringify` | `(point?: Point) => string` | 将点坐标序列化为字符串 |
165
+ | `projection` | `(r: RelativeMap, srcCoordinate?: Coordinate, dstCoordinate?: Coordinate) => Point \| undefined` | 坐标投影转换 |
166
+ | `project` | `(r: RelativeMap) => Point \| undefined` | 基础坐标投影 |
167
+ | `projectXZ` | `(r: RelativeMap) => Point` | XZ平面坐标投影 |
168
+ | `projectXY` | `(r: RelativeMap) => Point` | XY平面坐标投影 |
package/dist/index.d.ts CHANGED
@@ -35,12 +35,16 @@ export declare class AppError extends Error {
35
35
  * 业务错误码枚举(扩展无返回值错误)
36
36
  */
37
37
  export declare enum AppErrorCode {
38
- GEO_POINT_NO_PLANE = 9000,
39
- POINT_AND_GIS_NO_MAPPING = 9010,
40
- POINT_NO_PLANE = 9011,
41
- RELATIVE_MAP_MAPPING_SAME = 9020,
42
- RELATIVE_NO_PLANE = 9021,
43
- RELATIVE_JSON_ERROR = 9022
38
+ GeoPointNoPlane = 9000,
39
+ PointUnmappedGIS = 9010,
40
+ PointNoXYZ = 9011,
41
+ PointNoPlane = 9012,
42
+ RelativePlaneUnmatch = 9020,
43
+ RelativeNoPlane = 9021,
44
+ RelativeJsonError = 9022,
45
+ RequestCodeError = 9030,
46
+ RequestResultError = 9031,
47
+ RequestUnknownError = 9032
44
48
  }
45
49
 
46
50
  export declare enum AppObsType {
@@ -270,6 +274,11 @@ export declare class CanvasRegionElement implements BaseElement {
270
274
  draw(ctx: CanvasRenderingContext2D, core: CanvasElement): void;
271
275
  }
272
276
 
277
+ /**
278
+ * 深度拷贝
279
+ * @param value 拷贝的值
280
+ * @returns
281
+ */
273
282
  declare function cloneDeep<T>(value: T): T;
274
283
 
275
284
  export declare class Coordinate {
@@ -296,6 +305,7 @@ export declare class Coordinate {
296
305
  get spaceList(): Coordinate[];
297
306
  get modelList(): Coordinate[];
298
307
  get fullName(): string;
308
+ setOptions(options?: Partial<Coordinate>): void;
299
309
  addChild(child: Partial<Coordinate> | Partial<Coordinate>[]): Promise<void>;
300
310
  removeChild(child: Partial<Coordinate> | Partial<Coordinate>[]): Promise<void>;
301
311
  updateChild(child: Partial<Coordinate> | Partial<Coordinate>[]): Promise<void>;
@@ -321,7 +331,7 @@ export declare class Coordinate {
321
331
  * @param excludeNodes //排除的坐标系
322
332
  * @returns
323
333
  */
324
- findLatestModel(type?: number | number[], excludeNodes?: Coordinate[]): Coordinate | undefined;
334
+ findClosestModel(type?: number | number[], excludeNodes?: Coordinate[]): Coordinate | undefined;
325
335
  /**
326
336
  *向上寻找到子节点的空间坐标系
327
337
  * @returns
@@ -368,6 +378,26 @@ export declare class Coordinate {
368
378
  * @returns
369
379
  */
370
380
  getRelativeMaps(): RelativeMap[];
381
+ /**
382
+ * 过滤树对象,排除指定条件的节点
383
+ * @param tree 要过滤的树对象
384
+ * @param excludeIds 要排除的ID数组 (可选)
385
+ * @param excludeTypes 要排除的模型Type数组 (可选)
386
+ * @returns
387
+ */
388
+ static filterCoordinateTree(node: Coordinate, excludeModelTypes?: number[], excludeIds?: number[]): Coordinate | undefined;
389
+ /**
390
+ * 获取共同的空间坐标系
391
+ * @param coordinateList 空间或模型坐标系集合
392
+ * @returns
393
+ */
394
+ static getCommonCoordinate(coordinateList: Coordinate[]): Coordinate | undefined;
395
+ /**
396
+ * 检查并列第一行是否相同,否则就返回
397
+ * @param coordinateList 二维坐标系集合
398
+ * @returns
399
+ */
400
+ private static checkSameCoordinate;
371
401
  }
372
402
 
373
403
  export declare enum CoordinateLevel {
@@ -400,7 +430,7 @@ export declare type CoordinateModel = {
400
430
 
401
431
  export declare enum CoordinateModelType {
402
432
  CADModel = 5,//cad图片模型
403
- BimfaceModel = 6,//bimface模型
433
+ BIMModel = 6,//bim模型
404
434
  ForgeModel = 7,//forge模型
405
435
  ThreeDModel = 8,//3d模型
406
436
  SkyMapModel = 9,//天地图模型
@@ -480,10 +510,37 @@ export declare class DataSource {
480
510
  static filterSpaceTree(tree: Coordinate[]): Coordinate[];
481
511
  }
482
512
 
513
+ /**
514
+ * 防抖函数
515
+ * @param func
516
+ * @param wait
517
+ * @param immediate
518
+ * @returns
519
+ */
483
520
  declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number, immediate?: boolean): T & {
484
521
  cancel: () => void;
485
522
  };
486
523
 
524
+ /**
525
+ * 深度合并对象,会修改目标对象
526
+ * @param target 目标对象(会被修改)
527
+ * @param sources 源对象(可以有多个)
528
+ * @returns 合并后的目标对象
529
+ */
530
+ declare function deepMerge<T extends object>(target: T, ...sources: Partial<T>[]): T;
531
+
532
+ /**
533
+ * 深度合并多个对象,深层只合并Object对象,允许undefined覆盖属性值
534
+ * @param target 目标对象(会被修改)
535
+ * @param sources 多个源对象(可能包含undefined/null)
536
+ * @returns 合并后的目标对象
537
+ */
538
+ declare function deepMergeProps<T extends object>(target: T, ...sources: Array<DeepPartial<T> | null | undefined>): T;
539
+
540
+ declare type DeepPartial<T> = {
541
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
542
+ };
543
+
487
544
  declare function error(message: string): void;
488
545
 
489
546
  export declare class GeoPoint {
@@ -594,6 +651,10 @@ declare type MappingRecord = {
594
651
  srcCsId: number;
595
652
  };
596
653
 
654
+ /**
655
+ * 点类,表示二维或三维空间中的点
656
+ * 支持直角坐标系(x,y,z)和地理坐标系(经度,纬度,高度)
657
+ */
597
658
  export declare class Point {
598
659
  x: number;
599
660
  y: number;
@@ -609,24 +670,87 @@ export declare class Point {
609
670
  hasAngle: boolean;
610
671
  plane: string;
611
672
  constructor(options?: Partial<Point>);
673
+ /**
674
+ * 计算两点之间的三维距离
675
+ * @param p1 点1
676
+ * @param p2 点2
677
+ * @returns 距离值
678
+ */
612
679
  static dist(p1: Point, p2: Point): number;
680
+ /**
681
+ * 计算两点在XZ平面上的距离
682
+ * @param p1 点1
683
+ * @param p2 点2
684
+ * @returns 距离值
685
+ */
613
686
  static distXZ(p1: Point, p2: Point): number;
687
+ /**
688
+ * 计算两点在XY平面上的距离
689
+ * @param p1 点1
690
+ * @param p2 点2
691
+ * @returns 距离值
692
+ */
614
693
  static distXY(p1: Point, p2: Point): number;
694
+ /**
695
+ * 角度转弧度
696
+ * @param degrees 角度值
697
+ * @returns 弧度值
698
+ */
615
699
  static toRadians(degrees: number): number;
700
+ /**
701
+ * 弧度转角度
702
+ * @param radians 弧度值
703
+ * @returns 角度值
704
+ */
616
705
  static toDegrees(radians: number): number;
706
+ /**
707
+ * 计算三点在XZ平面上的夹角 (以pb为顶点)
708
+ * @param pa 点A
709
+ * @param pb 点B (顶点)
710
+ * @param pc 点C
711
+ * @returns 夹角角度 (0-180度)
712
+ */
617
713
  static angleXZ(pa: Point, pb: Point, pc: Point): number;
618
- static JSONParse(point?: string): Point | undefined;
619
- static JSONStringify(point?: Point): string;
620
714
  /**
621
- * 点的投射
622
- * @param r //映射关系
623
- * @param srcCoordinate 源坐标系
715
+ * 从字符串解析点坐标 ("x,y,z")
716
+ * @param point 坐标字符串
717
+ * @returns Point对象
718
+ */
719
+ static toParse(point?: string): Point | undefined;
720
+ /**
721
+ * 将点坐标序列化为字符串 ("x,y,z")
722
+ * @param point 点对象
723
+ * @returns 坐标字符串
724
+ */
725
+ static toStringify(point?: Point): string;
726
+ /**
727
+ * 坐标投影转换
728
+ * @param r 映射关系
729
+ * @param srcCoordinate 源坐标系
624
730
  * @param dstCoordinate 目标坐标系
731
+ * @returns 转换后的点
732
+ * @throws AppError 当转换失败时抛出异常
625
733
  */
626
734
  projection(r: RelativeMap, srcCoordinate?: Coordinate, dstCoordinate?: Coordinate): Point | undefined;
627
- project(r: RelativeMap): Point | undefined;
628
- projectXZ(r: RelativeMap): Point;
629
- projectXY(r: RelativeMap): Point;
735
+ /**
736
+ * 基础投影转换
737
+ * @param r 映射关系
738
+ * @returns 转换后的点
739
+ * @throws AppError 当没有坐标或平面无效时抛出异常
740
+ */
741
+ private project;
742
+ /**
743
+ * XZ平面投影转换
744
+ * @param r 映射关系
745
+ * @returns 转换后的点
746
+ */
747
+ private projectXZ;
748
+ /**
749
+ * XY平面投影转换
750
+ * @param r 映射关系
751
+ * @returns 转换后的点
752
+ */
753
+ private projectXY;
630
754
  }
631
755
 
632
756
  export declare class Position {
@@ -634,8 +758,8 @@ export declare class Position {
634
758
  pitch: number;
635
759
  roll: number;
636
760
  constructor(options?: Partial<Position>);
637
- static JSONParse(position?: string): Position | undefined;
638
- static JSONStringify(position?: Position): string;
761
+ static toParse(position?: string): Position | undefined;
762
+ static toStringify(position?: Position): string;
639
763
  }
640
764
 
641
765
  export declare type ProjectionModel = {
@@ -677,8 +801,8 @@ export declare class RelativeMap {
677
801
  * @returns 逆映射
678
802
  */
679
803
  static inverseRelativeMap(r: RelativeMap): RelativeMap;
680
- static JSONParse(r?: string): RelativeMap | undefined;
681
- static JSONStringify(r?: RelativeMap): string | undefined;
804
+ static toParse(r?: string): RelativeMap | undefined;
805
+ static toStringify(r?: RelativeMap): string | undefined;
682
806
  }
683
807
 
684
808
  /**
@@ -753,6 +877,13 @@ declare function saveCoordinate(data: CoordinateModel[], options?: RequestOption
753
877
  */
754
878
  declare function setRequestGlobalConfig(config: Partial<AppSetting>): void;
755
879
 
880
+ /**
881
+ * 节流函数
882
+ * @param func
883
+ * @param limit
884
+ * @param immediate
885
+ * @returns
886
+ */
756
887
  declare function throttle<T extends (...args: any[]) => void>(func: T, limit: number, immediate?: boolean): T & {
757
888
  cancel: () => void;
758
889
  };
@@ -811,6 +942,8 @@ declare namespace utils {
811
942
  cloneDeep,
812
943
  debounce,
813
944
  throttle,
945
+ deepMerge,
946
+ deepMergeProps,
814
947
  loadScript,
815
948
  getImageTransform,
816
949
  toCanvasCoord,
@@ -821,6 +954,15 @@ declare namespace utils {
821
954
  }
822
955
  export { utils }
823
956
 
957
+ export declare class Vector3 {
958
+ x: number;
959
+ y: number;
960
+ z: number;
961
+ constructor(options?: Partial<Vector3>);
962
+ static toParse(position?: string): Vector3 | undefined;
963
+ static toStringify(position?: Vector3): string;
964
+ }
965
+
824
966
  declare function warn(message: string): void;
825
967
 
826
968
  export { }