@yituengine/keymap 1.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.
Files changed (75) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +148 -0
  3. package/dist/engine.js +1 -0
  4. package/dist/types/core/Assets.d.ts +11 -0
  5. package/dist/types/core/Classification.d.ts +17 -0
  6. package/dist/types/core/Flatten.d.ts +74 -0
  7. package/dist/types/core/Status.d.ts +3 -0
  8. package/dist/types/core/pathAnim.d.ts +27 -0
  9. package/dist/types/core/transformFun.d.ts +16 -0
  10. package/dist/types/draw/baseDraw.d.ts +74 -0
  11. package/dist/types/draw/drawCircle.d.ts +44 -0
  12. package/dist/types/draw/drawPoint.d.ts +30 -0
  13. package/dist/types/draw/drawPolygon.d.ts +35 -0
  14. package/dist/types/draw/drawPolyline.d.ts +35 -0
  15. package/dist/types/draw/index.d.ts +17 -0
  16. package/dist/types/effect/cloud.d.ts +34 -0
  17. package/dist/types/effect/fog.d.ts +44 -0
  18. package/dist/types/effect/fogPro.d.ts +46 -0
  19. package/dist/types/effect/index.d.ts +32 -0
  20. package/dist/types/effect/lensflare.d.ts +38 -0
  21. package/dist/types/effect/rainy.d.ts +47 -0
  22. package/dist/types/effect/snowCover.d.ts +50 -0
  23. package/dist/types/effect/snowFall.d.ts +38 -0
  24. package/dist/types/event/index.d.ts +12 -0
  25. package/dist/types/event/menu.d.ts +110 -0
  26. package/dist/types/event/mousePick.d.ts +57 -0
  27. package/dist/types/graphic/baseGraphic.d.ts +131 -0
  28. package/dist/types/graphic/billboardGraphic.d.ts +75 -0
  29. package/dist/types/graphic/circleGraphic.d.ts +103 -0
  30. package/dist/types/graphic/customPopupGraphic.d.ts +75 -0
  31. package/dist/types/graphic/index.d.ts +32 -0
  32. package/dist/types/graphic/modelGraphic.d.ts +90 -0
  33. package/dist/types/graphic/polygonGraphic.d.ts +124 -0
  34. package/dist/types/graphic/polylineGraphic.d.ts +100 -0
  35. package/dist/types/graphic/popupGraphic.d.ts +85 -0
  36. package/dist/types/layer/graphicLayer.d.ts +96 -0
  37. package/dist/types/layer/heatmapLayer/heatmapRenderer.d.ts +39 -0
  38. package/dist/types/layer/heatmapLayer.d.ts +113 -0
  39. package/dist/types/layer/index.d.ts +14 -0
  40. package/dist/types/layer/tilesetLayer.d.ts +107 -0
  41. package/dist/types/main.d.ts +68 -0
  42. package/dist/types/map/defaultInteractions.d.ts +26 -0
  43. package/dist/types/map/index.d.ts +254 -0
  44. package/dist/types/material/LightingFlow.d.ts +63 -0
  45. package/dist/types/material/PolylineDashed.d.ts +68 -0
  46. package/dist/types/material/TextureFlow.d.ts +94 -0
  47. package/dist/types/material/Wave.d.ts +75 -0
  48. package/dist/types/material/index.d.ts +20 -0
  49. package/dist/types/measure/baseMeasure.d.ts +93 -0
  50. package/dist/types/measure/index.d.ts +18 -0
  51. package/dist/types/measure/measureArea.d.ts +46 -0
  52. package/dist/types/measure/measureCutFill.d.ts +69 -0
  53. package/dist/types/measure/measureDistance.d.ts +50 -0
  54. package/dist/types/measure/measureHeight.d.ts +47 -0
  55. package/dist/types/primitive/ClassificationPrimitive.d.ts +72 -0
  56. package/dist/types/primitive/Tube.d.ts +38 -0
  57. package/dist/types/primitive/Wall.d.ts +47 -0
  58. package/dist/types/primitive/basePrimitive.d.ts +42 -0
  59. package/dist/types/primitive/index.d.ts +16 -0
  60. package/dist/types/types/general.d.ts +94 -0
  61. package/dist/types/types/index.d.ts +2 -0
  62. package/dist/types/types/public.d.ts +11 -0
  63. package/dist/types/utils/CoordTransform.d.ts +26 -0
  64. package/dist/types/utils/controlPoint.d.ts +10 -0
  65. package/dist/types/utils/cutFillAnalysis.d.ts +38 -0
  66. package/dist/types/utils/graphic.d.ts +45 -0
  67. package/dist/types/utils/midPoint.d.ts +11 -0
  68. package/dist/types/utils/rightMenu.d.ts +1 -0
  69. package/dist/types/utils/tools.d.ts +38 -0
  70. package/docs/guide/draw-measure.md +97 -0
  71. package/docs/guide/graphic.md +136 -0
  72. package/docs/guide/index.md +29 -0
  73. package/docs/guide/menu.md +101 -0
  74. package/docs/guide/quick-start.md +74 -0
  75. package/package.json +58 -0
@@ -0,0 +1,14 @@
1
+ import GraphicLayer from './graphicLayer';
2
+ import HeatmapLayer from './heatmapLayer';
3
+ import TilesetLayer from './tilesetLayer';
4
+ export { default as GraphicLayer } from './graphicLayer';
5
+ export { default as HeatmapLayer } from './heatmapLayer';
6
+ export { default as TilesetLayer } from './tilesetLayer';
7
+ export type { HeatmapGradientStop, HeatmapLayerOptions, HeatmapPoint, HeatmapRenderUpdateOptions, HeatmapValueRange } from './heatmapLayer';
8
+ export type LayerType = GraphicLayer | HeatmapLayer | TilesetLayer;
9
+ declare const _default: {
10
+ GraphicLayer: typeof GraphicLayer;
11
+ HeatmapLayer: typeof HeatmapLayer;
12
+ TilesetLayer: typeof TilesetLayer;
13
+ };
14
+ export default _default;
@@ -0,0 +1,107 @@
1
+ import Flatten from '../core/Flatten';
2
+ import Classification from '../core/Classification';
3
+ import * as Cesium from 'cesium';
4
+ import KeyMap from '../map';
5
+ /** 3D Tiles 加载完成后的回调。 */
6
+ type readyCallback = (tileset: Cesium.Cesium3DTileset) => any;
7
+ /**
8
+ * 3D Tiles 图层。
9
+ *
10
+ * `TilesetLayer` 用于加载 Cesium 3D Tiles 数据,并提供定位、显隐、销毁、模型矩阵移动、
11
+ * `Flatten` 压平工具和 `Classification` 分层工具入口。
12
+ */
13
+ export default class TilesetLayer {
14
+ /** 图层唯一 id,同时会写入 Cesium3DTileset 的运行时 id。 */
15
+ id: string;
16
+ /** 图层名称,默认使用 `TilesetLayer_id`。 */
17
+ name: string;
18
+ /** 图层类型标识。 */
19
+ type: string;
20
+ /** 3D Tiles tileset.json 地址。 */
21
+ url: string;
22
+ /** 当前图层所属的 `KeyMap` 实例,初始化前为 `null`。 */
23
+ map: KeyMap | null;
24
+ /** 是否优先加载叶子节点,以更高精度优先展示模型。 */
25
+ preferLeaves: boolean;
26
+ /** 当前 tileset 的压平工具,加载完成后创建。 */
27
+ Flatten: Flatten | null;
28
+ /** 当前 tileset 的分类工具,加载完成后创建。 */
29
+ Classification: Classification | null;
30
+ /** Cesium 3D Tileset 原始实例,加载完成前为 `null`。 */
31
+ tileset: Cesium.Cesium3DTileset | null;
32
+ /** @internal */
33
+ private _position;
34
+ /** @internal */
35
+ private ready;
36
+ /**
37
+ * 创建 3D Tiles 图层。
38
+ *
39
+ * @param opt 图层配置。
40
+ * @param opt.id 自定义图层 id。
41
+ * @param opt.url 3D Tiles tileset.json 地址。
42
+ * @param opt.position 初始模型位置,会在加载完成后应用到 tileset 矩阵。
43
+ * @param opt.preferLeaves 是否优先加载叶子节点以提升模型细节。
44
+ */
45
+ constructor(opt: {
46
+ id?: string;
47
+ url: string;
48
+ position?: Cesium.Cartesian3;
49
+ preferLeaves?: boolean;
50
+ });
51
+ /**
52
+ * 初始化图层并异步加载 3D Tiles。
53
+ *
54
+ * 通常由 `map.addLayer(layer)` 调用。加载完成后会创建 `Flatten`、`Classification`,
55
+ * 应用初始位置,登记到 `KeyMap.Assets`,并执行通过 `readyPromise()` 注册的回调。
56
+ *
57
+ * @param map 当前地图实例。
58
+ */
59
+ init(map: KeyMap): Promise<void>;
60
+ /** 显示图层,并把图层重新登记到全局资产管理器。 */
61
+ show(): void;
62
+ /** 隐藏图层,并从全局资产管理器中 detach。 */
63
+ hide(): void;
64
+ /** 从地图中移除 tileset,并从全局资产管理器中 detach。 */
65
+ destroy(): void;
66
+ /**
67
+ * 将地图视角定位到当前 tileset。
68
+ *
69
+ * 如果 tileset 尚未加载完成,会把定位动作加入加载完成回调队列。
70
+ */
71
+ zoomTo(): void;
72
+ /**
73
+ * 注册 tileset 加载完成回调。
74
+ *
75
+ * 回调会在 `Cesium3DTileset.fromUrl()` 完成并加入场景后执行。
76
+ *
77
+ * @param cb 加载完成回调。
78
+ */
79
+ readyPromise(cb: readyCallback): void;
80
+ /**
81
+ * 移动 tileset 到指定位置。
82
+ *
83
+ * 如果 tileset 尚未加载完成,会把移动动作加入加载完成回调队列。
84
+ *
85
+ * @param position 新的模型位置。
86
+ */
87
+ moveTo(position: Cesium.Cartesian3): void;
88
+ /**
89
+ * 按米为单位对 tileset 进行局部偏移。
90
+ *
91
+ * `dx` 表示东西向偏移,`dy` 表示南北向偏移,`dz` 表示高度偏移。
92
+ *
93
+ * @param dx 东西向偏移距离,单位米。
94
+ * @param dy 南北向偏移距离,单位米。
95
+ * @param dz 高度偏移距离,单位米。
96
+ */
97
+ offset(dx: number, dy: number, dz: number): void;
98
+ /**
99
+ * tileset 位置。
100
+ *
101
+ * 赋值时会调用 `moveTo()`,等价于更新 tileset 模型矩阵。
102
+ */
103
+ set position(v: Cesium.Cartesian3);
104
+ /** 当前 tileset 记录的位置,未设置时为 `null`。 */
105
+ get position(): Cesium.Cartesian3 | null;
106
+ }
107
+ export {};
@@ -0,0 +1,68 @@
1
+ import KeyMap from './map';
2
+ export { default as KeyMap } from './map';
3
+ export * as material from './material';
4
+ export * as measure from './measure';
5
+ export * as graphic from './graphic';
6
+ export * as layer from './layer';
7
+ export * as effect from './effect';
8
+ export * as primitive from './primitive';
9
+ export * as draw from './draw';
10
+ export * as eventType from './event';
11
+ export * from './types/public';
12
+ /** 引擎版本号,与 package.json 保持一致;initMap 时会在控制台打印,便于确认运行时实际加载的引擎版本。 */
13
+ export declare const ENGINE_VERSION = "1.0.0";
14
+ export declare const initMap: (containerId: string, disablePopup?: () => boolean) => void | KeyMap;
15
+ declare const _default: {
16
+ initMap: (containerId: string, disablePopup?: () => boolean) => void | KeyMap;
17
+ material: {
18
+ LightingFlow: typeof import("./material").LightingFlow;
19
+ PolylineDashed: typeof import("./material").PolylineDashed;
20
+ TextureFlow: typeof import("./material").TextureFlow;
21
+ Wave: typeof import("./material").Wave;
22
+ };
23
+ measure: {
24
+ MeasureDistance: typeof import("./measure").MeasureDistance;
25
+ MeasureCutFill: typeof import("./measure").MeasureCutFill;
26
+ MeasureHeight: typeof import("./measure").MeasureHeight;
27
+ MeasureArea: typeof import("./measure").MeasureArea;
28
+ };
29
+ graphic: {
30
+ BillboardGraphic: typeof import("./graphic").BillboardGraphic;
31
+ ModelGraphic: typeof import("./graphic").ModelGraphic;
32
+ PolylineGraphic: typeof import("./graphic").PolylineGraphic;
33
+ PolygonGraphic: typeof import("./graphic").PolygonGraphic;
34
+ CircleGraphic: typeof import("./graphic").CircleGraphic;
35
+ PopupGraphic: typeof import("./graphic").PopupGraphic;
36
+ CustomPopupGraphic: typeof import("./graphic").CustomPopupGraphic;
37
+ };
38
+ layer: {
39
+ GraphicLayer: typeof import("./layer").GraphicLayer;
40
+ HeatmapLayer: typeof import("./layer").HeatmapLayer;
41
+ TilesetLayer: typeof import("./layer").TilesetLayer;
42
+ };
43
+ effect: {
44
+ FogEffect: typeof import("./effect").FogEffect;
45
+ FogProEffect: typeof import("./effect").FogProEffect;
46
+ RainyEffect: typeof import("./effect").RainyEffect;
47
+ SnowCoverEffect: typeof import("./effect").SnowCoverEffect;
48
+ SnowFallEffect: typeof import("./effect").SnowFallEffect;
49
+ LensFlareEffect: typeof import("./effect").LensFlareEffect;
50
+ CloudEffect: typeof import("./effect").CloudEffect;
51
+ };
52
+ primitive: {
53
+ TubePrimitive: typeof import("./primitive").TubePrimitive;
54
+ WallPrimitive: typeof import("./primitive").WallPrimitive;
55
+ };
56
+ draw: {
57
+ DrawPoint: typeof import("./draw").DrawPoint;
58
+ DrawPolyline: typeof import("./draw").DrawPolyline;
59
+ DrawCircle: typeof import("./draw").DrawCircle;
60
+ DrawPolygon: typeof import("./draw").DrawPolygon;
61
+ };
62
+ eventType: {
63
+ MousePick: typeof import("./event").MousePick;
64
+ Menu: typeof import("./event").Menu;
65
+ };
66
+ KeyMap: typeof KeyMap;
67
+ };
68
+ export default _default;
@@ -0,0 +1,26 @@
1
+ import type KeyMap from './';
2
+ import Menu from '../event/menu';
3
+ import MousePick from '../event/mousePick';
4
+ export default class DefaultInteractions {
5
+ private readonly map;
6
+ private readonly disablePopup?;
7
+ private editPointDragHandler;
8
+ private graphicHoverHandler;
9
+ globalMenu: Menu | null;
10
+ globalMousePick: MousePick | null;
11
+ private popupLayer;
12
+ private isDraggingControlPoint;
13
+ constructor(map: KeyMap, disablePopup?: (() => boolean) | undefined);
14
+ init(): void;
15
+ destroy(): void;
16
+ private setupEditPointDrag;
17
+ private finishEditPointDrag;
18
+ private setupGraphicHover;
19
+ private setupGlobalMenu;
20
+ private setupGlobalMousePick;
21
+ private addGraphicClickHandler;
22
+ private addPopupHandler;
23
+ private togglePopup;
24
+ private toggleCustomPopup;
25
+ private addClassificationHandler;
26
+ }
@@ -0,0 +1,254 @@
1
+ import * as Cesium from 'cesium';
2
+ import Assets from '../core/Assets';
3
+ import Status from '../core/Status';
4
+ import { GeojsonCoordinate } from '../types';
5
+ import type { LayerType } from '../layer';
6
+ import type { EventType } from '../event';
7
+ import DefaultInteractions from './defaultInteractions';
8
+ /**
9
+ * 创建 `KeyMap` 时使用的内部配置。
10
+ *
11
+ * 通常业务侧不需要直接构造该对象,而是通过 `initMap(containerId, disablePopup?)`
12
+ * 创建地图实例。
13
+ */
14
+ type KeyMapOptions = {
15
+ /** 已创建完成的 Cesium Viewer 实例。 */
16
+ viewer: Cesium.Viewer;
17
+ /** 返回 `true` 时,默认弹窗交互会被临时禁用。 */
18
+ disablePopup?: () => boolean;
19
+ };
20
+ /**
21
+ * 地图核心实例。
22
+ *
23
+ * `KeyMap` 是易图引擎的运行时入口,负责持有 Cesium Viewer、业务图层、资产索引、
24
+ * 事件实例和默认交互。业务项目通常通过 `initMap()` 获取实例,再使用它添加图层、
25
+ * 注册事件、控制视角或销毁地图。
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { initMap } from '@yituengine/keymap';
30
+ *
31
+ * const map = initMap('map');
32
+ * map?.flyTo({ position: [113.2644, 23.1291, 3000] });
33
+ * ```
34
+ */
35
+ export default class KeyMap {
36
+ /**
37
+ * Cesium Viewer 原始实例。
38
+ *
39
+ * 当 SDK 没有封装某个 Cesium 能力时,可以通过该属性访问底层 Viewer。
40
+ */
41
+ viewer: Cesium.Viewer;
42
+ /**
43
+ * 当前 Viewer 的相机实例。
44
+ *
45
+ * 可用于读取相机姿态,或直接调用 Cesium Camera 的视角控制能力。
46
+ */
47
+ camera: Cesium.Camera;
48
+ /**
49
+ * 当前 Viewer 的场景实例。
50
+ *
51
+ * 可用于访问 `globe`、`primitives`、`postProcessStages` 等 Cesium 场景对象。
52
+ */
53
+ scene: Cesium.Scene;
54
+ /**
55
+ * 当前地图上已添加的业务图层列表。
56
+ *
57
+ * 一般不建议业务侧直接修改该数组,应优先使用 `addLayer()` 和 `removeLayer()`。
58
+ */
59
+ layers: LayerType[];
60
+ /**
61
+ * 全局资产管理器。
62
+ *
63
+ * 图形、绘制结果、测量对象和部分 Primitive 会登记到这里,便于按 id 查询、删除或解绑。
64
+ */
65
+ Assets: Assets;
66
+ /**
67
+ * SDK 默认使用的 Cesium 数据源。
68
+ *
69
+ * 大部分 Entity 类型图形会添加到该数据源中,由 `KeyMap.destroy()` 统一清理。
70
+ */
71
+ dataSource: Cesium.CustomDataSource;
72
+ /**
73
+ * 已注册的事件实例列表。
74
+ *
75
+ * 例如 `Menu`、`MousePick` 会通过 `map.on(event)` 注册,并在销毁时统一清理。
76
+ */
77
+ Events: EventType[];
78
+ /**
79
+ * 地图运行状态对象。
80
+ *
81
+ * 默认交互、绘制和测量流程会读取或更新这里的状态,业务侧可用于判断当前交互状态。
82
+ */
83
+ Status: Status;
84
+ /**
85
+ * 当前激活的绘制或测量实例 id。
86
+ *
87
+ * 用于保证同一时间只存在一个激活实例,并支持 `Escape` 取消当前实例。
88
+ */
89
+ measureInstanceId: import("vue").Ref<string | null>;
90
+ /**
91
+ * 是否已经完成过每像素实际距离的初始化计算。
92
+ *
93
+ * 首次瓦片加载完成后会尝试初始化 `metersPerPixel`。
94
+ */
95
+ isMetersPerPixelInit: boolean;
96
+ /**
97
+ * 当前视图中每个屏幕像素对应的地表距离,单位为米。
98
+ *
99
+ * 该值会在相机变化或瓦片首次加载完成后更新,可用于比例尺、距离相关 UI 或屏幕尺寸换算。
100
+ */
101
+ metersPerPixel: import("vue").Ref<number>;
102
+ /** @internal */
103
+ private lastMaxCount;
104
+ /**
105
+ * 当前场景瓦片加载进度,范围为 `0` 到 `100`。
106
+ *
107
+ * 可用于业务侧显示地图加载进度条。没有待加载瓦片时值为 `100`。
108
+ */
109
+ tilesLoadingProgress: import("vue").Ref<number>;
110
+ /**
111
+ * 鼠标当前位置的经纬高。
112
+ *
113
+ * 鼠标在地球表面移动时更新,字段分别为经度 `longitude`、纬度 `latitude` 和高度 `height`。
114
+ */
115
+ mousePostion: {
116
+ longitude: number;
117
+ latitude: number;
118
+ height: number;
119
+ };
120
+ /** @internal */
121
+ private isDestroyed;
122
+ /** @internal */
123
+ private middleRotateIconHandler;
124
+ /**
125
+ * 默认交互管理器。
126
+ *
127
+ * 负责注册图形悬停、弹窗、右键菜单、编辑拖拽等 SDK 内置交互。
128
+ *
129
+ * @internal
130
+ */
131
+ defaultInteractions: DefaultInteractions;
132
+ /**
133
+ * 创建地图核心实例。
134
+ *
135
+ * 构造时会挂载默认数据源,注册鼠标位置、瓦片加载进度、每像素距离、中键旋转图标和默认交互。
136
+ * 业务侧通常不直接调用该构造函数,而是使用 `initMap()`。
137
+ *
138
+ * @param option KeyMap 初始化配置。
139
+ */
140
+ constructor(option: KeyMapOptions);
141
+ /**
142
+ * 添加一个可挂载到地图的对象。
143
+ *
144
+ * 传入对象需要实现 `add(map)` 方法。图层、部分 Primitive 或其他 SDK 资产可以通过该方法接入地图。
145
+ *
146
+ * @param data 需要添加到当前地图的对象。
147
+ */
148
+ add(data: {
149
+ add: (map: KeyMap) => void;
150
+ }): void;
151
+ /**
152
+ * 从地图中移除一个可销毁对象。
153
+ *
154
+ * 传入对象需要实现 `destroy(map)` 方法。对于图层和图形,更推荐使用它们自己的 `destroy()`
155
+ * 或 `map.removeLayer(layer)`,语义会更明确。
156
+ *
157
+ * @param data 需要从当前地图移除的对象。
158
+ */
159
+ remove(data: {
160
+ destroy: (map: KeyMap) => void;
161
+ }): void;
162
+ /**
163
+ * 将相机定位到指定对象。
164
+ *
165
+ * 传入对象需要实现 `zoomTo(map)` 方法。常用于对图层、图形或业务封装对象执行统一定位。
166
+ *
167
+ * @param data 需要定位的对象。
168
+ */
169
+ zoomTo(data: {
170
+ zoomTo: (map: KeyMap) => void;
171
+ }): void;
172
+ /**
173
+ * 注册事件对象。
174
+ *
175
+ * 事件对象需要实现 `register(map)` 方法。`Menu` 和 `MousePick` 等事件能力通过该方法接入地图。
176
+ *
177
+ * @param fn 需要注册的事件对象。
178
+ */
179
+ on(fn: {
180
+ register: (map: KeyMap) => void;
181
+ }): void;
182
+ /**
183
+ * 注销事件对象。
184
+ *
185
+ * 事件对象需要实现 `destroy()` 方法,用于移除 Cesium 事件监听、DOM 监听或其他资源。
186
+ *
187
+ * @param fn 需要注销的事件对象。
188
+ */
189
+ off(fn: {
190
+ destroy: () => void;
191
+ }): void;
192
+ /**
193
+ * 添加图层到地图。
194
+ *
195
+ * 调用后图层会持有当前 `KeyMap` 和 `Cesium.Viewer` 引用,并登记到 `layers` 列表。
196
+ *
197
+ * @param layer 要添加的图层实例。
198
+ */
199
+ addLayer(layer: LayerType): void;
200
+ /**
201
+ * 从地图中移除图层。
202
+ *
203
+ * 调用后会执行图层的 `destroy()`,图层内图形也会被同步清理。
204
+ *
205
+ * @param layer 要移除的图层实例。
206
+ */
207
+ removeLayer(layer: LayerType): void;
208
+ /**
209
+ * 激活绘制或测量实例。
210
+ *
211
+ * 如果已经存在其他激活实例,会先通过 `Assets.removeById()` 移除旧实例,保证绘制和测量互斥。
212
+ * 激活期间会监听 `Escape` 键,用于取消当前实例。
213
+ *
214
+ * @param id 当前绘制或测量实例 id。
215
+ * @internal
216
+ */
217
+ activateMeasureInstance(id: string): void;
218
+ /**
219
+ * 取消当前绘制或测量实例的激活状态。
220
+ *
221
+ * 只有传入 id 与当前激活实例一致时才会生效。
222
+ *
223
+ * @param id 当前绘制或测量实例 id。
224
+ * @internal
225
+ */
226
+ deactivateMeasureInstance(id: string): void;
227
+ /**
228
+ * 将相机飞行到指定经纬高位置。
229
+ *
230
+ * 默认视角朝北,并以 `-50` 度俯视目标点。
231
+ *
232
+ * @param opt 飞行参数。
233
+ * @param opt.position 目标经纬高,格式为 `[lng, lat, alt?]`。
234
+ * @param opt.duration 飞行时长,单位为秒,默认 `3`。
235
+ */
236
+ flyTo(opt: {
237
+ position: GeojsonCoordinate;
238
+ duration?: number;
239
+ }): void;
240
+ /**
241
+ * 销毁地图实例并释放资源。
242
+ *
243
+ * 该方法会清理默认交互、事件监听、图层、资产、默认数据源和 Cesium Viewer。
244
+ * 多次调用是安全的,后续调用会直接返回。
245
+ */
246
+ destroy(): void;
247
+ private destroyDefaultInteractions;
248
+ private updateMousePositon;
249
+ private cancelMeasureInstanceByEsc;
250
+ private updateTilesLoadingProgress;
251
+ private updateMetersPerPixel;
252
+ private changeMiddleRotateIcon;
253
+ }
254
+ export {};
@@ -0,0 +1,63 @@
1
+ import { EMaterialName } from '../types';
2
+ import * as Cesium from 'cesium';
3
+ /** `LightingFlow` 流光线材质传入 Cesium shader 的 uniforms。 */
4
+ export interface LightingFlowUniforms {
5
+ /** 流光带宽度。 */
6
+ uLineWidth: number;
7
+ /** 默认透明度底值。 */
8
+ uDefaultOpc: number;
9
+ /** 流光颜色。 */
10
+ uColor: Cesium.Color;
11
+ }
12
+ /**
13
+ * 线状流光材质。
14
+ *
15
+ * 实现 Cesium `MaterialProperty`,用于在线或面边界上生成沿纹理坐标移动的高亮流光效果。
16
+ */
17
+ export default class LightingFlow implements Cesium.MaterialProperty {
18
+ private static registered;
19
+ /** Cesium MaterialProperty 标识,当前材质会随 uniforms 变化。 */
20
+ readonly isConstant = false;
21
+ /** Cesium 材质类型名称。 */
22
+ name: EMaterialName;
23
+ /** 当前材质 uniforms 状态。 */
24
+ uniforms: LightingFlowUniforms;
25
+ /** uniforms 变化时通知 Cesium 重新取值。 */
26
+ definitionChanged: Cesium.Event<(...args: any[]) => void>;
27
+ /**
28
+ * 创建流光线材质。
29
+ *
30
+ * @param opt 材质配置。
31
+ * @param opt.lineWidth 流光带宽度,默认 `1`。
32
+ * @param opt.opacity 默认透明度底值,默认 `0`。
33
+ * @param opt.color 流光颜色,默认蓝色。
34
+ */
35
+ constructor(opt?: {
36
+ lineWidth?: number;
37
+ opacity?: number;
38
+ color?: Cesium.Color;
39
+ });
40
+ private static registerMaterial;
41
+ /** 流光带宽度。赋值时会触发 `definitionChanged`。 */
42
+ get uLineWidth(): number;
43
+ set uLineWidth(w: number);
44
+ /** 默认透明度底值。赋值时会触发 `definitionChanged`。 */
45
+ get uDefaultOpc(): number;
46
+ set uDefaultOpc(o: number);
47
+ /** 流光颜色。赋值时会触发 `definitionChanged`。 */
48
+ get uColor(): Cesium.Color;
49
+ set uColor(c: Cesium.Color);
50
+ /** 返回 Cesium 材质类型名称。 */
51
+ getType(_time: Cesium.JulianDate): EMaterialName;
52
+ /**
53
+ * 返回当前 uniforms 值。
54
+ *
55
+ * Cesium 渲染管线会在需要材质值时调用该方法。
56
+ *
57
+ * @param _time Cesium 当前时间。
58
+ * @param result 可复用的结果对象。
59
+ */
60
+ getValue(_time: Cesium.JulianDate, result?: LightingFlowUniforms): LightingFlowUniforms;
61
+ /** 比较另一个 Cesium Property 是否与当前材质等价。 */
62
+ equals(other?: Cesium.Property): boolean;
63
+ }
@@ -0,0 +1,68 @@
1
+ import { EMaterialName } from '../types';
2
+ import * as Cesium from 'cesium';
3
+ /** `PolylineDashed` 虚线材质传入 Cesium shader 的 uniforms。 */
4
+ export interface PolylineDashedUniforms {
5
+ /** 虚线密度,值越大线段重复越密。 */
6
+ uDensity: number;
7
+ /** 虚线间隔比例。 */
8
+ uSpacing: number;
9
+ /** 虚线颜色。 */
10
+ uColor: Cesium.Color;
11
+ }
12
+ /**
13
+ * 自适应虚线材质。
14
+ *
15
+ * 实现 Cesium `MaterialProperty`,会根据相机高度调整虚线密度,使不同视距下的虚线视觉更稳定。
16
+ */
17
+ export default class PolylineDashed implements Cesium.MaterialProperty {
18
+ private static registered;
19
+ /** Cesium MaterialProperty 标识,当前材质会随 uniforms 变化。 */
20
+ readonly isConstant = false;
21
+ /** 相机高度匹配档位,单位为千米。 */
22
+ distances: number[];
23
+ /** 当前材质 uniforms 状态。 */
24
+ uniforms: PolylineDashedUniforms;
25
+ /** uniforms 变化时通知 Cesium 重新取值。 */
26
+ definitionChanged: Cesium.Event<(...args: any[]) => void>;
27
+ /** 当前材质用于读取相机高度的 Viewer。 */
28
+ viewer: Cesium.Viewer;
29
+ /**
30
+ * 创建自适应虚线材质。
31
+ *
32
+ * @param opt 材质配置。
33
+ * @param opt.density 虚线密度,默认 `50`。
34
+ * @param opt.spacing 虚线间隔比例,默认 `0.5`。
35
+ * @param opt.color 虚线颜色 CSS 字符串。
36
+ * @param opt.viewer 当前 Cesium Viewer,用于根据相机高度动态匹配虚线密度。
37
+ */
38
+ constructor(opt: {
39
+ density: number;
40
+ spacing: number;
41
+ color: string;
42
+ viewer: Cesium.Viewer;
43
+ });
44
+ private static registerMaterial;
45
+ /** 虚线密度。赋值时会触发 `definitionChanged`。 */
46
+ get uDensity(): number;
47
+ set uDensity(d: number);
48
+ /** 虚线间隔比例。赋值时会触发 `definitionChanged`。 */
49
+ get uSpacing(): number;
50
+ set uSpacing(s: number);
51
+ /** 虚线颜色。赋值时会触发 `definitionChanged`。 */
52
+ get uColor(): Cesium.Color;
53
+ set uColor(c: Cesium.Color);
54
+ /** 返回 Cesium 材质类型名称。 */
55
+ getType(): EMaterialName;
56
+ /**
57
+ * 返回当前 uniforms 值。
58
+ *
59
+ * 该方法会根据当前相机高度动态放大 `uDensity`。
60
+ *
61
+ * @param _time Cesium 当前时间。
62
+ * @param result 可复用的结果对象。
63
+ */
64
+ getValue(_time: Cesium.JulianDate, result?: PolylineDashedUniforms): PolylineDashedUniforms;
65
+ /** 比较另一个 Cesium Property 是否与当前材质等价。 */
66
+ equals(other?: Cesium.Property): boolean;
67
+ private matchDistance;
68
+ }