@soonspacejs/plugin-tiles 2.14.34 → 2.14.35
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/dist/index.d.ts +3 -0
- package/dist/index.esm.js +831 -270
- package/dist/plot/GroundDecalManager.d.ts +115 -0
- package/dist/plot/plugins/arrow.d.ts +25 -0
- package/dist/plot/plugins/base.d.ts +32 -0
- package/dist/plot/plugins/circle.d.ts +13 -0
- package/dist/plot/plugins/index.d.ts +10 -0
- package/dist/plot/plugins/line.d.ts +12 -0
- package/dist/plot/plugins/point.d.ts +14 -0
- package/dist/plot/plugins/polygon.d.ts +12 -0
- package/dist/plot/plugins/rectangle.d.ts +13 -0
- package/dist/plot/plugins/sector.d.ts +13 -0
- package/dist/plot/plugins/text.d.ts +14 -0
- package/dist/plot/plugins/types.d.ts +108 -0
- package/dist/plot/plugins/utils/ArrowUtils.d.ts +129 -0
- package/dist/plot/plugins/utils/colorUtils.d.ts +51 -0
- package/dist/plot/plugins/utils/coordUtils.d.ts +48 -0
- package/dist/terrain-tiles-renderer/TerrainTilesRenderer.d.ts +3 -0
- package/dist/terrain-tiles-renderer/types.d.ts +2 -1
- package/package.json +7 -4
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { PlotOverlay } from 'um-3d-tiles-renderer/three/plugins';
|
|
2
|
+
import { ImageOverlayPlugin } from 'um-3d-tiles-renderer/plugins';
|
|
3
|
+
import { GisPlotBase } from './plugins/base';
|
|
4
|
+
import { GisPlotArrowSnapshot, GisPlotSnapshot, LonLatPoint, PlotAddOptions } from './plugins/types';
|
|
5
|
+
import { default as SoonSpace } from 'soonspacejs';
|
|
6
|
+
/** 构造 {@link GroundDecalManager} 时的选项 */
|
|
7
|
+
export type GroundDecalManagerOptions = {
|
|
8
|
+
/** SoonSpace 实例(必传) */
|
|
9
|
+
ssp: SoonSpace;
|
|
10
|
+
/** 传入后会在首次有图形时自动将 PlotOverlay 注册到该插件 */
|
|
11
|
+
imageOverlayPlugin?: ImageOverlayPlugin;
|
|
12
|
+
};
|
|
13
|
+
/** {@link GroundDecalManager.getItem} / {@link GroundDecalManager.getItemDeep} 的联合返回类型 */
|
|
14
|
+
export type GisPlotItemSnapshot = GisPlotSnapshot | GisPlotArrowSnapshot;
|
|
15
|
+
/**
|
|
16
|
+
* 标绘样式补丁:与 {@link GisPlotBase.update} 一致,允许在基类字段之外带扩展键。
|
|
17
|
+
*/
|
|
18
|
+
export type GisPlotStylePatch = Partial<Parameters<GisPlotBase['update']>[0]> & Record<string, unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* {@link GroundDecalManager.setCenter} 的中心点(度)。
|
|
21
|
+
*/
|
|
22
|
+
export type CenterLonLat = {
|
|
23
|
+
lon?: number;
|
|
24
|
+
lat?: number;
|
|
25
|
+
};
|
|
26
|
+
export declare class GroundDecalManager {
|
|
27
|
+
/** 标绘 id → 实例;与 `PlotOverlay.imageSource.shapes` 共用同一引用 */
|
|
28
|
+
private readonly _items;
|
|
29
|
+
/** 标绘 id */
|
|
30
|
+
readonly id: string;
|
|
31
|
+
/** 标绘 overlay */
|
|
32
|
+
private readonly _overlay;
|
|
33
|
+
/** SoonSpace 实例 */
|
|
34
|
+
readonly ssp: SoonSpace;
|
|
35
|
+
/** 传入的 ImageOverlayPlugin,用于在有图形时自动注册 overlay */
|
|
36
|
+
private _imageOverlayPlugin?;
|
|
37
|
+
/** overlay 是否已注册到 ImageOverlayPlugin */
|
|
38
|
+
private _overlayAttached;
|
|
39
|
+
/** 合并同一帧内多次 `_markDirty`,值为 `requestAnimationFrame` 句柄 */
|
|
40
|
+
private _redrawTimer;
|
|
41
|
+
constructor(options: GroundDecalManagerOptions);
|
|
42
|
+
/**
|
|
43
|
+
* 内部使用的 `PlotOverlay` 实例。
|
|
44
|
+
* 注册到 `ImageOverlayPlugin` 的 `overlays` 数组中,顺序靠后者通常绘制在上层。
|
|
45
|
+
*/
|
|
46
|
+
get overlay(): PlotOverlay;
|
|
47
|
+
/**
|
|
48
|
+
* 绑定 / 更换 ImageOverlayPlugin(切换地形重建插件后调用)。
|
|
49
|
+
* 如果当前已有图形,会在下一帧自动重新注册 overlay。
|
|
50
|
+
*/
|
|
51
|
+
setImageOverlayPlugin(plugin: ImageOverlayPlugin): void;
|
|
52
|
+
/**
|
|
53
|
+
* 添加标绘:由 `options.type` 决定实例化哪一类 `GisPlot*`(与各类 `*Options` 对应)。
|
|
54
|
+
*/
|
|
55
|
+
addPlot(options: PlotAddOptions): string;
|
|
56
|
+
/** 按 id 移除标绘;存在并删除成功时触发重绘 */
|
|
57
|
+
remove(id: string): void;
|
|
58
|
+
/** 清空全部标绘 */
|
|
59
|
+
clear(): void;
|
|
60
|
+
/**
|
|
61
|
+
* 读取标绘快照(**浅拷贝**:`options` 为新对象,但 `points` 与内部仍为同一数组引用)。
|
|
62
|
+
* 若需完全独立副本,请用 {@link getItemDeep}。
|
|
63
|
+
*/
|
|
64
|
+
getItem(id: string): GisPlotItemSnapshot | null;
|
|
65
|
+
/**
|
|
66
|
+
* 深拷贝快照:`points` 等嵌套数组被复制,修改返回值不会影响内部状态。
|
|
67
|
+
* 箭头类型额外深拷贝 `generatedCoords`。
|
|
68
|
+
*/
|
|
69
|
+
getItemDeep(id: string): GisPlotItemSnapshot | null;
|
|
70
|
+
/**
|
|
71
|
+
* 合并更新样式与几何字段(调用对应 `GisPlot*.update`)。
|
|
72
|
+
* `patch` 形状需与该 id 下图元类型兼容。
|
|
73
|
+
*/
|
|
74
|
+
setStyle(id: string, patch: GisPlotStylePatch): void;
|
|
75
|
+
/**
|
|
76
|
+
* 将 **第一个顶点** 设为新的经纬度中心(适用于点、矩形中心、扇心、文字锚点等单中心语义)。
|
|
77
|
+
*/
|
|
78
|
+
setCenter(id: string, center: CenterLonLat): void;
|
|
79
|
+
/** 整体替换顶点列表(每项为 `[lon, lat]`) */
|
|
80
|
+
setCoords(id: string, coords: LonLatPoint[]): void;
|
|
81
|
+
/** 修改指定下标顶点;`coord` 分量可为 `undefined` 表示不改该分量 */
|
|
82
|
+
setCoord(id: string, index: number, coord: Partial<LonLatPoint> | [number?, number?]): void;
|
|
83
|
+
/** 在 `index` 处插入一个顶点(可插在末尾,`index` 越界时钳位) */
|
|
84
|
+
insertCoord(id: string, index: number, coord: LonLatPoint): void;
|
|
85
|
+
/**
|
|
86
|
+
* 删除指定下标顶点。
|
|
87
|
+
* 多边形至少保留 3 点,其余类型至少 2 点(与 `shape.category` 联动)。
|
|
88
|
+
*/
|
|
89
|
+
removeCoord(id: string, index: number): void;
|
|
90
|
+
/** 对所有顶点做经纬度平移(度) */
|
|
91
|
+
translateCoords(id: string, dLon: number, dLat: number): void;
|
|
92
|
+
/** 仅对 `category === 'text'` 的项更新 `options.content` */
|
|
93
|
+
setText(id: string, text: string): void;
|
|
94
|
+
/** 设置整个 overlay 不透明度(0–1,具体语义以 `PlotOverlay` 为准) */
|
|
95
|
+
setGlobalOpacity(opacity: number): void;
|
|
96
|
+
getCoordCount(id: string): number;
|
|
97
|
+
/**
|
|
98
|
+
* 在经纬度平面上找离 `(lon, lat)` 最近的顶点下标(平方距离最小);
|
|
99
|
+
* 无顶点时返回 `-1`。
|
|
100
|
+
*/
|
|
101
|
+
findNearestCoord(id: string, lon: number, lat: number): number;
|
|
102
|
+
render: () => void;
|
|
103
|
+
/**
|
|
104
|
+
* 释放 overlay 内部 RTT / 纹理等资源。
|
|
105
|
+
* `PlotImageSource` 的运行时实现含 `dispose`,类型声明可能未列出,故做断言。
|
|
106
|
+
*/
|
|
107
|
+
dispose(): void;
|
|
108
|
+
/**
|
|
109
|
+
* 标记需要在下一帧重绘瓦片标绘层;同一帧内多次调用只会调度一次。
|
|
110
|
+
* 首次有图形且尚未挂载时,先将 PlotOverlay 注册到 ImageOverlayPlugin(此时 shapes 已有数据,
|
|
111
|
+
* `init()` → `hasContent` 能正确返回 true)。
|
|
112
|
+
*/
|
|
113
|
+
private _markDirty;
|
|
114
|
+
}
|
|
115
|
+
export type { PlotAddOptions, } from './plugins/types';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LonLat } from './utils/ArrowUtils';
|
|
2
|
+
import { GisPlotBase } from './base';
|
|
3
|
+
import { GisPlotArrowSnapshot, PlotArrowOptions } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* 箭头标绘(面类)→ {@link PlotArrowOptions}
|
|
6
|
+
*
|
|
7
|
+
* CPU 端由 `./utils/ArrowUtils` 生成闭合多边形 → `generatedCoords`,复用 polygon type 2 渲染。
|
|
8
|
+
* 与折线端点箭头样式(`PlotArrowStyle`)不同。
|
|
9
|
+
*/
|
|
10
|
+
export declare class GisPlotArrow extends GisPlotBase {
|
|
11
|
+
readonly category: "arrow";
|
|
12
|
+
options: PlotArrowOptions;
|
|
13
|
+
/** `generateCoords()` 填充的闭合多边形顶点 */
|
|
14
|
+
generatedCoords: LonLat[];
|
|
15
|
+
constructor(options: PlotArrowOptions);
|
|
16
|
+
update(patch: Partial<PlotArrowOptions>): void;
|
|
17
|
+
/**
|
|
18
|
+
* 按 `arrowType` 与控制点生成闭合多边形顶点(供 GroundDecalManager / PlotOverlay 重建几何)。
|
|
19
|
+
*/
|
|
20
|
+
generateCoords(): LonLat[];
|
|
21
|
+
/** 浅拷贝:`options`、`generatedCoords` 与内部共享引用(顶点数组仍与 `options.points` 规则一致)。 */
|
|
22
|
+
getSnapshot(): GisPlotArrowSnapshot;
|
|
23
|
+
/** 深拷贝:`options.points` 与 `generatedCoords` 均为新数组。 */
|
|
24
|
+
getSnapshotDeep(): GisPlotArrowSnapshot;
|
|
25
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GisPlotBaseOptions, GisPlotCategory, GisPlotSnapshot, LonLatPoint } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* GIS 标绘对象基类。
|
|
4
|
+
*
|
|
5
|
+
* 数据结构对齐 {@link GisPlotBaseOptions}:`points` 为 `[[lon, lat], ...]`。
|
|
6
|
+
* 子类在 `options` 中扩展各自字段(如 `size`、`radius`、`arrowType` 等)。
|
|
7
|
+
*/
|
|
8
|
+
export declare class GisPlotBase {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
category: GisPlotCategory;
|
|
11
|
+
options: GisPlotBaseOptions;
|
|
12
|
+
constructor(options: GisPlotBaseOptions);
|
|
13
|
+
/**
|
|
14
|
+
* 合并更新 `options`(不可变风格:整表替换为新对象)。
|
|
15
|
+
* 子类应覆盖为 `Partial<具体Options>`,以便类型提示包含各类型专有字段。
|
|
16
|
+
*/
|
|
17
|
+
update(patch: Partial<GisPlotBaseOptions> & Record<string, unknown>): void;
|
|
18
|
+
/**
|
|
19
|
+
* 浅拷贝快照:`options` 为一层展开新对象,`points` 与内部仍为同一数组引用。
|
|
20
|
+
* {@link GroundDecalManager.getItem} 默认使用此方法。
|
|
21
|
+
*/
|
|
22
|
+
getSnapshot(): GisPlotSnapshot;
|
|
23
|
+
/**
|
|
24
|
+
* 深拷贝快照:`points` 中每个顶点为新数组,修改返回值不会影响标绘内部状态。
|
|
25
|
+
* 需独立副本时请用 {@link GroundDecalManager.getItemDeep} 或本方法。
|
|
26
|
+
*/
|
|
27
|
+
getSnapshotDeep(): GisPlotSnapshot;
|
|
28
|
+
/** 用于计算 ENU 参考中心的坐标点 */
|
|
29
|
+
getCenterPoints(): LonLatPoint[];
|
|
30
|
+
/** 用于计算最大空间范围的坐标点(子类可覆盖以扩展半径等) */
|
|
31
|
+
getExtentPoints(): LonLatPoint[];
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GisPlotBase } from './base';
|
|
2
|
+
import { LonLatPoint, PlotCircleOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 圆标绘 → {@link PlotCircleOptions}
|
|
5
|
+
* `points[0]` 为圆心;shader type 1。
|
|
6
|
+
*/
|
|
7
|
+
export declare class GisPlotCircle extends GisPlotBase {
|
|
8
|
+
readonly category: "circle";
|
|
9
|
+
options: PlotCircleOptions;
|
|
10
|
+
constructor(options: PlotCircleOptions);
|
|
11
|
+
update(patch: Partial<PlotCircleOptions>): void;
|
|
12
|
+
getExtentPoints(): LonLatPoint[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './base';
|
|
3
|
+
export * from './point';
|
|
4
|
+
export * from './line';
|
|
5
|
+
export * from './polygon';
|
|
6
|
+
export * from './rectangle';
|
|
7
|
+
export * from './sector';
|
|
8
|
+
export * from './arrow';
|
|
9
|
+
export * from './text';
|
|
10
|
+
export * from './circle';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GisPlotBase } from './base';
|
|
2
|
+
import { PlotLineOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 折线标绘 → {@link PlotLineOptions}
|
|
5
|
+
* `options.points` 为折线顶点;shader type 3。
|
|
6
|
+
*/
|
|
7
|
+
export declare class GisPlotLine extends GisPlotBase {
|
|
8
|
+
readonly category: "line";
|
|
9
|
+
options: PlotLineOptions;
|
|
10
|
+
constructor(options: PlotLineOptions);
|
|
11
|
+
update(patch: Partial<PlotLineOptions>): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GisPlotBase } from './base';
|
|
2
|
+
import { LonLatPoint, PlotPointOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 点标绘 → {@link PlotPointOptions}
|
|
5
|
+
* `options.points[0]` 为点的中心;shader type 6。
|
|
6
|
+
*/
|
|
7
|
+
export declare class GisPlotPoint extends GisPlotBase {
|
|
8
|
+
readonly category: "point";
|
|
9
|
+
options: PlotPointOptions;
|
|
10
|
+
constructor(options: PlotPointOptions);
|
|
11
|
+
update(patch: Partial<PlotPointOptions>): void;
|
|
12
|
+
getCenterPoints(): LonLatPoint[];
|
|
13
|
+
getExtentPoints(): LonLatPoint[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GisPlotBase } from './base';
|
|
2
|
+
import { PlotPolygonOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 多边形标绘 → {@link PlotPolygonOptions}
|
|
5
|
+
* 至少 3 个顶点;shader type 2。
|
|
6
|
+
*/
|
|
7
|
+
export declare class GisPlotPolygon extends GisPlotBase {
|
|
8
|
+
readonly category: "polygon";
|
|
9
|
+
options: PlotPolygonOptions;
|
|
10
|
+
constructor(options: PlotPolygonOptions);
|
|
11
|
+
update(patch: Partial<PlotPolygonOptions>): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GisPlotBase } from './base';
|
|
2
|
+
import { LonLatPoint, PlotRectangleOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 矩形标绘 → {@link PlotRectangleOptions}
|
|
5
|
+
* `points[0]` 为矩形中心;`width`/`height` 为米;shader type 0(sdBox)。
|
|
6
|
+
*/
|
|
7
|
+
export declare class GisPlotRectangle extends GisPlotBase {
|
|
8
|
+
readonly category: "rectangle";
|
|
9
|
+
options: PlotRectangleOptions;
|
|
10
|
+
constructor(options: PlotRectangleOptions);
|
|
11
|
+
update(patch: Partial<PlotRectangleOptions>): void;
|
|
12
|
+
getExtentPoints(): LonLatPoint[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GisPlotBase } from './base';
|
|
2
|
+
import { LonLatPoint, PlotSectorOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 扇形标绘 → {@link PlotSectorOptions}
|
|
5
|
+
* `points[0]` 为扇心;shader type 5。
|
|
6
|
+
*/
|
|
7
|
+
export declare class GisPlotSector extends GisPlotBase {
|
|
8
|
+
readonly category: "sector";
|
|
9
|
+
options: PlotSectorOptions;
|
|
10
|
+
constructor(options: PlotSectorOptions);
|
|
11
|
+
update(patch: Partial<PlotSectorOptions>): void;
|
|
12
|
+
getExtentPoints(): LonLatPoint[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GisPlotBase } from './base';
|
|
2
|
+
import { LonLatPoint, PlotTextOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 文本标绘 → {@link PlotTextOptions}
|
|
5
|
+
* `points[0]` 为标签锚点;shader type 4(label atlas)。
|
|
6
|
+
*/
|
|
7
|
+
export declare class GisPlotText extends GisPlotBase {
|
|
8
|
+
readonly category: "text";
|
|
9
|
+
options: PlotTextOptions;
|
|
10
|
+
constructor(options: PlotTextOptions);
|
|
11
|
+
update(patch: Partial<PlotTextOptions>): void;
|
|
12
|
+
getCenterPoints(): LonLatPoint[];
|
|
13
|
+
getExtentPoints(): LonLatPoint[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/** 经纬度顶点:[经度°, 纬度°](与 RTT / shader 中 lon/lat 一致) */
|
|
2
|
+
export type LonLatPoint = [number, number];
|
|
3
|
+
/** 标绘类别 */
|
|
4
|
+
export type GisPlotCategory = 'point' | 'line' | 'polygon' | 'rectangle' | 'sector' | 'arrow' | 'text' | 'circle';
|
|
5
|
+
/**
|
|
6
|
+
* 标绘公共基类型。
|
|
7
|
+
* stroke* / fill* 不透明度为 **0–100** 整数百分比(与 GroundDecalManager / shader 一致)。
|
|
8
|
+
*/
|
|
9
|
+
export type GisPlotBaseOptions = {
|
|
10
|
+
/** 图形的顶点坐标 [[lon, lat], ...] */
|
|
11
|
+
points: LonLatPoint[];
|
|
12
|
+
strokeColor: string;
|
|
13
|
+
strokeWidth: number;
|
|
14
|
+
strokeOpacity: number;
|
|
15
|
+
fillColor: string;
|
|
16
|
+
fillOpacity: number;
|
|
17
|
+
visible: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** {@link GisPlotBase.getSnapshot} / {@link GisPlotBase.getSnapshotDeep} 返回值 */
|
|
20
|
+
export type GisPlotSnapshot<T extends GisPlotBaseOptions = GisPlotBaseOptions> = {
|
|
21
|
+
type: GisPlotCategory;
|
|
22
|
+
options: T;
|
|
23
|
+
};
|
|
24
|
+
/** 点标绘:样式(圆/方)、大小(米) */
|
|
25
|
+
export type PlotPointOptions = GisPlotBaseOptions & {
|
|
26
|
+
pointStyle: 'circle' | 'square';
|
|
27
|
+
size: number;
|
|
28
|
+
};
|
|
29
|
+
/** 线标绘:折线顶点 + 可选端点箭头(SDF) */
|
|
30
|
+
export type PlotLineStrokeStyle = 'solid' | 'dashed' | 'dotted';
|
|
31
|
+
export type PlotEndpointStyle = 'round' | 'square';
|
|
32
|
+
export type PlotArrowStyle = 'simple' | 'filled' | 'open' | 'double' | 'diamond' | 'bar';
|
|
33
|
+
export type PlotLineOptions = GisPlotBaseOptions & {
|
|
34
|
+
strokeStyle?: PlotLineStrokeStyle;
|
|
35
|
+
endpointStyle?: PlotEndpointStyle;
|
|
36
|
+
showArrow?: boolean;
|
|
37
|
+
startArrowStyle?: PlotArrowStyle | null;
|
|
38
|
+
endArrowStyle?: PlotArrowStyle | null;
|
|
39
|
+
/** 线端箭头尺度(与示例 GroundDecalManager / shader 一致) */
|
|
40
|
+
arrowSize?: number;
|
|
41
|
+
};
|
|
42
|
+
export type PlotStrokeStyle = 'solid' | 'dashed';
|
|
43
|
+
export type PlotFillStyle = 'solid' | 'diagonal' | 'grid';
|
|
44
|
+
/** 多边形标绘 */
|
|
45
|
+
export type PlotPolygonOptions = GisPlotBaseOptions & {
|
|
46
|
+
strokeStyle?: PlotStrokeStyle;
|
|
47
|
+
fillStyle?: PlotFillStyle;
|
|
48
|
+
};
|
|
49
|
+
/** 矩形:中心点 + 宽/高(米) */
|
|
50
|
+
export type PlotRectangleOptions = GisPlotBaseOptions & {
|
|
51
|
+
strokeStyle?: PlotStrokeStyle;
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
};
|
|
55
|
+
/** 扇形:中心 + 半径与角度(度) */
|
|
56
|
+
export type PlotSectorOptions = GisPlotBaseOptions & {
|
|
57
|
+
strokeStyle?: PlotStrokeStyle;
|
|
58
|
+
radius: number;
|
|
59
|
+
startAngle: number;
|
|
60
|
+
sectorAngle: number;
|
|
61
|
+
};
|
|
62
|
+
/** 圆:圆心 + 半径(米) */
|
|
63
|
+
export type PlotCircleOptions = GisPlotBaseOptions & {
|
|
64
|
+
strokeStyle?: PlotStrokeStyle;
|
|
65
|
+
radius: number;
|
|
66
|
+
};
|
|
67
|
+
/** 箭头:控制点生成多边形;`straight` 在 CPU 端退化为首尾两点的 fine 箭头 */
|
|
68
|
+
export type PlotArrowType = 'straight' | 'curved' | 'fine' | 'attack';
|
|
69
|
+
export type PlotArrowOptions = GisPlotBaseOptions & {
|
|
70
|
+
strokeStyle?: PlotStrokeStyle;
|
|
71
|
+
arrowType: PlotArrowType;
|
|
72
|
+
headSize: number;
|
|
73
|
+
};
|
|
74
|
+
/** 文本标绘 */
|
|
75
|
+
export type PlotTextAlign = 'left' | 'center' | 'right';
|
|
76
|
+
export type PlotTextOptions = GisPlotBaseOptions & {
|
|
77
|
+
content: string;
|
|
78
|
+
fontColor: string;
|
|
79
|
+
fontSize: number;
|
|
80
|
+
textAlign?: PlotTextAlign;
|
|
81
|
+
showBorder?: boolean;
|
|
82
|
+
offsetX?: number;
|
|
83
|
+
offsetY?: number;
|
|
84
|
+
};
|
|
85
|
+
/** 箭头快照:在 options 外附加 `generatedCoords` */
|
|
86
|
+
export type GisPlotArrowSnapshot = GisPlotSnapshot<PlotArrowOptions> & {
|
|
87
|
+
generatedCoords: LonLatPoint[];
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* `GroundDecalManager.addPlot` 入参:字段 `type` 与对应 `*Options` 组合,内部据此实例化 `GisPlot*`。
|
|
91
|
+
*/
|
|
92
|
+
export type PlotAddOptions = ({
|
|
93
|
+
type: 'point';
|
|
94
|
+
} & PlotPointOptions) | ({
|
|
95
|
+
type: 'line';
|
|
96
|
+
} & PlotLineOptions) | ({
|
|
97
|
+
type: 'polygon';
|
|
98
|
+
} & PlotPolygonOptions) | ({
|
|
99
|
+
type: 'rectangle';
|
|
100
|
+
} & PlotRectangleOptions) | ({
|
|
101
|
+
type: 'circle';
|
|
102
|
+
} & PlotCircleOptions) | ({
|
|
103
|
+
type: 'sector';
|
|
104
|
+
} & PlotSectorOptions) | ({
|
|
105
|
+
type: 'text';
|
|
106
|
+
} & PlotTextOptions) | ({
|
|
107
|
+
type: 'arrow';
|
|
108
|
+
} & PlotArrowOptions);
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ArrowUtils
|
|
3
|
+
*
|
|
4
|
+
* 箭头标绘图形生成工具库。
|
|
5
|
+
*
|
|
6
|
+
* 移植自 cesium-plot-js,将原始 Cesium `Cartesian3` 逻辑改为纯 2D **[经度, 纬度]**(度)计算。
|
|
7
|
+
* 各 `create*` 函数接收控制点,返回闭合多边形顶点序列,供 `GroundDecalManager.addArrowPlot()` 等以
|
|
8
|
+
* **面多边形**(如 type 2 / polygon SDF)渲染。
|
|
9
|
+
*
|
|
10
|
+
* **约定**
|
|
11
|
+
*
|
|
12
|
+
* - 坐标:`[longitude, latitude]`,单位 **度**。
|
|
13
|
+
* - 距离:在经纬度平面内按欧氏距离计算(**非**椭球大地线长或真实米制距离)。
|
|
14
|
+
*/
|
|
15
|
+
/** 经纬度对:索引 0 为经度(°),索引 1 为纬度(°)。 */
|
|
16
|
+
export type LonLat = [number, number];
|
|
17
|
+
/**
|
|
18
|
+
* 两点在经纬度平面上的欧氏距离。
|
|
19
|
+
*
|
|
20
|
+
* @param p1 - 起点
|
|
21
|
+
* @param p2 - 终点
|
|
22
|
+
*/
|
|
23
|
+
export declare function MathDistance(p1: LonLat, p2: LonLat): number;
|
|
24
|
+
/**
|
|
25
|
+
* 折线顶点依次相连的总长度。
|
|
26
|
+
*
|
|
27
|
+
* @param points - 至少两个点;单点或空数组时循环不执行,返回 `0`。
|
|
28
|
+
*/
|
|
29
|
+
export declare function wholeDistance(points: LonLat[]): number;
|
|
30
|
+
/**
|
|
31
|
+
* 作为箭头宽度尺度的基准长度:总折线长的 `0.99` 次幂。
|
|
32
|
+
*
|
|
33
|
+
* 幂次小于 1 使较长箭头的宽度增长略慢于线性,避免过长箭头翼展过大。
|
|
34
|
+
*
|
|
35
|
+
* @param points - 定义箭杆路径的控制点
|
|
36
|
+
*/
|
|
37
|
+
export declare function getBaseLength(points: LonLat[]): number;
|
|
38
|
+
/**
|
|
39
|
+
* 两点的中点。
|
|
40
|
+
*/
|
|
41
|
+
export declare function Mid(p1: LonLat, p2: LonLat): LonLat;
|
|
42
|
+
/**
|
|
43
|
+
* 从 `startPnt` 指向 `endPnt` 的方位角(类似地平经度),弧度,范围 **[0, 2π)**。
|
|
44
|
+
*
|
|
45
|
+
* @param startPnt - 起点
|
|
46
|
+
* @param endPnt - 终点(与起点重合时除零由调用方避免)
|
|
47
|
+
*/
|
|
48
|
+
export declare function getAzimuth(startPnt: LonLat, endPnt: LonLat): number;
|
|
49
|
+
/**
|
|
50
|
+
* 在点 `b` 处,由 `b→a` 与 `b→c` 两方向方位角之差,归一化到 **[0, 2π)**。
|
|
51
|
+
*/
|
|
52
|
+
export declare function getAngleOfThreePoints(a: LonLat, b: LonLat, c: LonLat): number;
|
|
53
|
+
/**
|
|
54
|
+
* 判断折线段 `p1 → p2 → p3` 在 `p2` 处是否为顺时针转向(2D 叉积符号)。
|
|
55
|
+
*/
|
|
56
|
+
export declare function isClockWise(p1: LonLat, p2: LonLat, p3: LonLat): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 从 `endPnt` 出发,沿 `startPnt → endPnt` 方向旋转 `angle`(弧度),再前进 `distance`(度制平面距离),得到第三点。
|
|
59
|
+
*
|
|
60
|
+
* `clockWise` 为 `true` 时向一侧偏转,为 `false` 时向另一侧偏转,用于箭头两翼、颈部等对称结构。
|
|
61
|
+
*/
|
|
62
|
+
export declare function getThirdPoint(startPnt: LonLat, endPnt: LonLat, angle: number, distance: number, clockWise: boolean): LonLat;
|
|
63
|
+
/**
|
|
64
|
+
* 在顶点 `p2` 处,`p1→p2` 与 `p3→p2` 两方向单位向量之和,用作角平分线法向(未单位化)。
|
|
65
|
+
*/
|
|
66
|
+
export declare function getNormal(p1: LonLat, p2: LonLat, p3: LonLat): LonLat;
|
|
67
|
+
/**
|
|
68
|
+
* 在 `p2` 处沿角平分线方向生成左右两条 Bézier 控制点;`t` 控制偏移与邻边长的比例。
|
|
69
|
+
*
|
|
70
|
+
* @param t - 弯曲强度系数,典型值与 `getCurvePoints` 中一致(如 `0.3`)
|
|
71
|
+
* @returns `[ rightControl, leftControl ]`(命名与原始 cesium-plot 一致)
|
|
72
|
+
*/
|
|
73
|
+
export declare function getBisectorNormals(t: number, p1: LonLat, p2: LonLat, p3: LonLat): [LonLat, LonLat];
|
|
74
|
+
/**
|
|
75
|
+
* 由折线控制点生成 **三次 Bézier 链** 上的密化点列。
|
|
76
|
+
*
|
|
77
|
+
* 1. 内部顶点:角平分线法向 → 左右控制点({@link getBisectorNormals})。
|
|
78
|
+
* 2. 首尾:镜像控制点({@link getLeftMostControlPoint} / {@link getRightMostControlPoint})。
|
|
79
|
+
* 3. 相邻控制点间用标准三次 Bézier 公式采样 {@link FITTING_COUNT} 段。
|
|
80
|
+
*
|
|
81
|
+
* @param t - 控制点偏移强度(如 `0.3`)
|
|
82
|
+
* @param controlPoints - 至少 **3** 个点
|
|
83
|
+
*/
|
|
84
|
+
export declare function getCurvePoints(t: number, controlPoints: LonLat[]): LonLat[];
|
|
85
|
+
/**
|
|
86
|
+
* 均匀二次 B 样条对折线点列做平滑,步长 `0.05`。
|
|
87
|
+
*
|
|
88
|
+
* 用于攻击箭头左右侧边,使折线变为平滑曲线;适合「贴近控制点但不强制插值」的造型。
|
|
89
|
+
*
|
|
90
|
+
* @param points - 至少 2 个点;≤2 时原样返回
|
|
91
|
+
*/
|
|
92
|
+
export declare function getQBSplinePoints(points: LonLat[]): LonLat[];
|
|
93
|
+
/**
|
|
94
|
+
* **直线箭头(线型)**:`p1 → p2` 的箭杆 + 末端约 **30°**(`π/6`)张角的翼。
|
|
95
|
+
*
|
|
96
|
+
* 返回 **5 个顶点** 的折线(非闭合):`p1, p2, leftWing, p2, rightWing`,用于 `createCurvedArrow` 两点退化等场景。
|
|
97
|
+
*
|
|
98
|
+
* @param headSize - 头部尺度;`>0` 时翼长取 `min(距离/5, headSize*0.01)` 等组合逻辑
|
|
99
|
+
*/
|
|
100
|
+
export declare function createStraightArrow(p1: LonLat, p2: LonLat, headSize: number): LonLat[];
|
|
101
|
+
/**
|
|
102
|
+
* **细箭头(填充多边形)**:两点定义箭杆方向,生成带尾翼、颈部、头部的 **8 顶点** 逆时针闭合多边形。
|
|
103
|
+
*
|
|
104
|
+
* 宽度相对 `getBaseLength([p1,p2])` 的比例:尾 **10%**、颈 **20%**、翼 **25%**;翼角约 **π/8.5**,颈角约 **π/13**。
|
|
105
|
+
*
|
|
106
|
+
* @param p1 - 尾部中心
|
|
107
|
+
* @param p2 - 箭头尖端
|
|
108
|
+
*/
|
|
109
|
+
export declare function createFineArrow(p1: LonLat, p2: LonLat): LonLat[];
|
|
110
|
+
/**
|
|
111
|
+
* **曲线箭头(填充多边形)**:3 个及以上控制点定义箭杆曲率,末端为三角箭头。
|
|
112
|
+
*
|
|
113
|
+
* 流程概要:`getCurvePoints` → 降采样 → 沿曲线法向左右偏移形成带宽度体部 → 末端 `getThirdPoint` 生成翼与颈 →
|
|
114
|
+
* 闭合顺序:左轮廓 → 头 → 右轮廓逆序。
|
|
115
|
+
*
|
|
116
|
+
* **2 点** 时退化为 {@link createFineArrow}。
|
|
117
|
+
*
|
|
118
|
+
* @param lnglatPoints - 控制点序列,至少 2 个
|
|
119
|
+
*/
|
|
120
|
+
export declare function createCurvedArrow(lnglatPoints: LonLat[]): LonLat[];
|
|
121
|
+
/**
|
|
122
|
+
* **攻击箭头(填充多边形)**:首两点定义尾部宽度,后续点为脊线控制点(至少 3 点)。
|
|
123
|
+
*
|
|
124
|
+
* - 尾宽:`distance(points[0], points[1])`;顺逆时针决定 `tailLeft` / `tailRight`。
|
|
125
|
+
* - 脊线:尾边中点接 `points[2..]`;体宽沿脊线由尾宽渐变到颈宽;侧边经 B 样条平滑并降采样。
|
|
126
|
+
*
|
|
127
|
+
* @param lnglatPoints - 至少 3 个点
|
|
128
|
+
*/
|
|
129
|
+
export declare function createAttackArrow(lnglatPoints: LonLat[]): LonLat[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module colorUtils
|
|
3
|
+
*
|
|
4
|
+
* 颜色与不透明度工具函数。
|
|
5
|
+
*
|
|
6
|
+
* 为 {@link GroundDecalManager} 及标绘渲染管线提供颜色字符串解析与不透明度兼容层。
|
|
7
|
+
* SDF shader 中颜色以归一化 RGBA `[0,1]` 传入,alpha 通道通常已合并 `fillOpacity` / `strokeOpacity`。
|
|
8
|
+
*/
|
|
9
|
+
/** 归一化 RGBA 四元组,各分量 ∈ [0, 1]。 */
|
|
10
|
+
export type NormalizedRGBA = readonly [number, number, number, number];
|
|
11
|
+
/**
|
|
12
|
+
* 可携带填充/描边不透明度或统一透明度的样式片段。
|
|
13
|
+
*
|
|
14
|
+
* - **store 格式(推荐)**:`fillOpacity` / `strokeOpacity` 为 **0–100** 的整数百分比。
|
|
15
|
+
* - **旧版**:`opacity` 为 **0–1** 浮点数,同时作用于 fill 与 stroke。
|
|
16
|
+
*/
|
|
17
|
+
export interface StyleOpacityInput {
|
|
18
|
+
fillOpacity?: number;
|
|
19
|
+
strokeOpacity?: number;
|
|
20
|
+
opacity?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 将颜色字符串解析为归一化 RGBA 数组 `[r, g, b, a]`,各分量 ∈ [0, 1]。
|
|
24
|
+
*
|
|
25
|
+
* **支持的输入格式**
|
|
26
|
+
*
|
|
27
|
+
* | 形式 | 说明 |
|
|
28
|
+
* |------|------|
|
|
29
|
+
* | `'#hex'` | 3 位或 6 位十六进制(如 `'#f00'`, `'#ff0000'`) |
|
|
30
|
+
* | `'rgb(r,g,b)'` | RGB 分量 0–255 |
|
|
31
|
+
* | `'rgba(r,g,b,a)'` | `a` ∈ [0, 1] |
|
|
32
|
+
* | `'transparent'` | 全透明 `[0,0,0,0]` |
|
|
33
|
+
* | `null` / `undefined` / 空字符串 | 全透明 `[0,0,0,0]` |
|
|
34
|
+
*
|
|
35
|
+
* 无法识别的字符串回退为 **不透明白** `[1,1,1,1]`。
|
|
36
|
+
*
|
|
37
|
+
* @param color - CSS 风格颜色字符串;空或透明则返回全透明。
|
|
38
|
+
* @returns 长度为 4 的归一化 RGBA 数组(新数组,可安全修改副本若需)。
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseColorToRGBA(color: string | null | undefined): number[];
|
|
41
|
+
/**
|
|
42
|
+
* 解析不透明度参数,兼容两种样式约定,并写入长度为 2 的输出数组。
|
|
43
|
+
*
|
|
44
|
+
* 1. **store 格式**:`fillOpacity` / `strokeOpacity` 为 0–100 整数 → 除以 100 得到 0–1。
|
|
45
|
+
* 2. **旧版**:仅提供 `opacity`(0–1)时,填充与描边共用该值。
|
|
46
|
+
* 3. 若某通道未指定,默认 **1**(完全不透明)。
|
|
47
|
+
*
|
|
48
|
+
* @param style - 图形样式对象(仅需不透明度相关字段)。
|
|
49
|
+
* @param base - 长度为 2 的数组;执行后 `base[0]` = 填充不透明度,`base[1]` = 描边不透明度,均为 0–1。
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveOpacity(style: StyleOpacityInput, base: [number, number]): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Vector3 } from 'three';
|
|
2
|
+
/** 角度(度)→ 弧度,与 `THREE.MathUtils.DEG2RAD` 一致。 */
|
|
3
|
+
export declare const DEG2RAD: number;
|
|
4
|
+
/**
|
|
5
|
+
* 标签 atlas 画布边长(像素)。
|
|
6
|
+
*
|
|
7
|
+
* 文字标签预渲染到 `LABEL_ATLAS × LABEL_ATLAS` 的 2D canvas,再上传为 `CanvasTexture` 供 shader 采样。
|
|
8
|
+
*/
|
|
9
|
+
export declare const LABEL_ATLAS = 2048;
|
|
10
|
+
/**
|
|
11
|
+
* 椭球体接口:至少实现由大地坐标(弧度)到 ECEF 的转换。
|
|
12
|
+
*
|
|
13
|
+
* 与 Three.js / 瓦片渲染器中椭球实现兼容:`getCartographicToPosition( latRad, lonRad, height, target )`。
|
|
14
|
+
*/
|
|
15
|
+
export interface EllipsoidLike {
|
|
16
|
+
/**
|
|
17
|
+
* @param latitude - 纬度(弧度)
|
|
18
|
+
* @param longitude - 经度(弧度)
|
|
19
|
+
* @param height - 椭球面以上高度(米),地表一般为 0
|
|
20
|
+
* @param result - 输出 ECEF 坐标(米)
|
|
21
|
+
*/
|
|
22
|
+
getCartographicToPosition(latitude: number, longitude: number, height: number, result: Vector3): Vector3;
|
|
23
|
+
}
|
|
24
|
+
/** ENU 平面上的东向、北向分量(米)。 */
|
|
25
|
+
export interface ENUMeters {
|
|
26
|
+
/** East(东向)分量,米。 */
|
|
27
|
+
e: number;
|
|
28
|
+
/** North(北向)分量,米。 */
|
|
29
|
+
n: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 将经纬度(度)转换为以给定 ENU 原点为参考的局部东-北坐标(米)。
|
|
33
|
+
*
|
|
34
|
+
* **步骤概要**
|
|
35
|
+
*
|
|
36
|
+
* 1. `(lonDeg, latDeg)` → ECEF(通过椭球 `getCartographicToPosition`)。
|
|
37
|
+
* 2. ECEF 减去参考点 ECEF,得位移向量。
|
|
38
|
+
* 3. 位移分别与 `east`、`north` 单位向量点积,得到 `e`、`n`(米)。
|
|
39
|
+
*
|
|
40
|
+
* @param lonDeg - 经度(度)
|
|
41
|
+
* @param latDeg - 纬度(度)
|
|
42
|
+
* @param ellipsoid - 椭球体(WGS84 等)
|
|
43
|
+
* @param east - ECEF 空间中东向单位向量(与 `north`、径向构成右手系)
|
|
44
|
+
* @param north - ECEF 空间中北向单位向量
|
|
45
|
+
* @param centerECEF - ENU 原点在 ECEF 下的位置(米)
|
|
46
|
+
* @returns 局部平面坐标 `{ e, n }`(米)
|
|
47
|
+
*/
|
|
48
|
+
export declare function lonLatToMeters(lonDeg: number, latDeg: number, ellipsoid: EllipsoidLike, east: Vector3, north: Vector3, centerECEF: Vector3): ENUMeters;
|
|
@@ -6,6 +6,7 @@ import { OverlayManager } from './OverlayManager';
|
|
|
6
6
|
import { ResourceManager } from './ResourceManager';
|
|
7
7
|
import { TerrainManager } from './TerrainManager';
|
|
8
8
|
import { ITerrainTilesRendererOptions, IGeoJSONOverlayOptions, ICesiumIonOverlayOptions, ITMSTilesOverlayOptions, IXYZTilesOverlayOptions, IWMSTilesOverlayOptions, IWMTSTilesOverlayOptions, IUrlTemplateOverlayOptions, AlphaClipMode, ITerrainConfig } from './types';
|
|
9
|
+
import { GroundDecalManager } from '../plot/GroundDecalManager';
|
|
9
10
|
/**
|
|
10
11
|
* TerrainTilesRenderer 地形渲染器
|
|
11
12
|
* 支持多种地形源和多个叠加层
|
|
@@ -28,6 +29,8 @@ export declare class TerrainTilesRenderer {
|
|
|
28
29
|
terrainManager: TerrainManager;
|
|
29
30
|
/** Overlay 管理器(管理实例) */
|
|
30
31
|
overlayManager: OverlayManager;
|
|
32
|
+
/** 标绘管理器(管理标绘实例) */
|
|
33
|
+
groundDecalManager?: GroundDecalManager;
|
|
31
34
|
/** 当前地形配置 */
|
|
32
35
|
private _currentTerrainConfig;
|
|
33
36
|
/** Alpha 裁剪模式 */
|