@soonspacejs/plugin-tiles 2.15.8 → 2.15.10

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.
@@ -1,115 +1,166 @@
1
- /** 经纬度顶点:[经度°, 纬度°](与 RTT / shader 中 lon/lat 一致) */
1
+ /** 经纬度顶点:[经度°, 纬度°],单位度。 */
2
2
  export type LonLatPoint = [number, number];
3
- /** 标绘类别 */
3
+ /** 标绘类别枚举,与 8 个 GisPlot* 子类一一对应;也是桥接器 switch(category) 的分支依据。 */
4
4
  export type GisPlotCategory = 'point' | 'line' | 'polygon' | 'rectangle' | 'sector' | 'arrow' | 'text' | 'circle';
5
5
  /**
6
- * 标绘公共基类型。
7
- * stroke* / fill* 不透明度为 **0–100** 整数百分比(与 GroundDecalManager / shader 一致)。
6
+ * 标绘公共基类型。所有 GisPlot*Options 都继承自它。
7
+ *
8
+ * 关键口径:
9
+ * - strokeOpacity / fillOpacity 为 0..100 整数百分比(非 0..1)。
10
+ * - strokeColor / fillColor 为 CSS 颜色字符串。
11
+ * - points 元素顺序固定为 [lon, lat]。
8
12
  */
9
13
  export type GisPlotBaseOptions = {
10
- /** 图形的顶点坐标 [[lon, lat], ...] */
14
+ /** 图形顶点列表 [[lon, lat], ...] */
11
15
  points: LonLatPoint[];
16
+ /** 描边色(CSS 字符串) */
12
17
  strokeColor: string;
18
+ /** 描边宽(米) */
13
19
  strokeWidth: number;
20
+ /** 描边不透明度:0..100 整数百分比 */
14
21
  strokeOpacity: number;
22
+ /** 填充色(CSS 字符串) */
15
23
  fillColor: string;
24
+ /** 填充不透明度:0..100 整数百分比 */
16
25
  fillOpacity: number;
26
+ /** 可见性 */
17
27
  visible: boolean;
18
28
  };
19
- /** {@link GisPlotBase.getSnapshot} / {@link GisPlotBase.getSnapshotDeep} 返回值 */
29
+ /**
30
+ * 通用浅快照结构:{ type, options }。type 即 category。
31
+ * {@link GisPlotBase.getSnapshot} / {@link GisPlotBase.getSnapshotDeep} 的返回结构。
32
+ */
20
33
  export type GisPlotSnapshot<T extends GisPlotBaseOptions = GisPlotBaseOptions> = {
21
34
  type: GisPlotCategory;
22
35
  options: T;
23
36
  };
24
- /** 点标绘:样式(圆/方)、大小(米) */
37
+ /**
38
+ * 箭头专用快照:在 { type, options } 之外额外带 generatedCoords(闭合多边形顶点)。
39
+ * 管理器 getItem 的返回联合类型 GisPlotItemSnapshot = GisPlotSnapshot | GisPlotArrowSnapshot 由此而来。
40
+ */
41
+ export type GisPlotArrowSnapshot = GisPlotSnapshot<PlotArrowOptions> & {
42
+ generatedCoords: LonLatPoint[];
43
+ };
44
+ /** 点标绘形状:'circle' = 圆点,'square' = 方点。 */
45
+ export type PlotPointStyle = 'circle' | 'square';
46
+ /**
47
+ * 点标绘选项。points[0] 为点中心;size 在 cesium-to-three 侧:
48
+ * circle 解释为直径、square 解释为边长。
49
+ */
25
50
  export type PlotPointOptions = GisPlotBaseOptions & {
26
- pointStyle: 'circle' | 'square';
51
+ /** 点形状:'circle' / 'square' */
52
+ pointStyle: PlotPointStyle;
53
+ /** 尺寸(米):circle 为直径、square 为边长 */
27
54
  size: number;
28
55
  };
29
- /** 线标绘:折线顶点 + 可选端点箭头(SDF) */
30
- export type PlotLineStrokeStyle = 'solid' | 'dashed' | 'dotted';
31
- export type PlotEndpointStyle = 'round' | 'square';
32
56
  /**
33
- * 折线端点箭头(仅四种;原 `filled` 已更名为 `filledArrow`)
34
- * - `filledArrow` — 三角箭头
35
- * - `filledDiamond` — 菱形
36
- * - `filledCircle` — 实心圆
37
- * - `bar` — 竖条 / 小段
57
+ * 折线描边样式:实线 / 虚线。cesium-to-three 贴地折线着色器只支持 solid / dash 两态。
58
+ */
59
+ export type PlotLineStrokeStyle = 'solid' | 'dashed';
60
+ /**
61
+ * 折线端点箭头样式:实心箭头 / 空心(不填充)箭头。
62
+ * cesium-to-three 折线只有 solid / open 两态:
63
+ * - 'filledArrow' → arrowStyle='solid'
64
+ * - 'unfilledArrow' → arrowStyle='open'
65
+ */
66
+ export type PlotArrowStyle = 'filledArrow' | 'unfilledArrow';
67
+ /**
68
+ * 折线标绘选项。showArrow / startArrowStyle / endArrowStyle 是端点装饰相关
69
+ * 的可选字段;strokeStyle 控制实线 / 虚线。
38
70
  */
39
- export type PlotArrowStyle = 'filledArrow' | 'filledDiamond' | 'filledCircle' | 'bar';
40
71
  export type PlotLineOptions = GisPlotBaseOptions & {
41
72
  strokeStyle?: PlotLineStrokeStyle;
42
- endpointStyle?: PlotEndpointStyle;
43
73
  showArrow?: boolean;
74
+ /** 起点箭头样式;null / 缺省表示无 */
44
75
  startArrowStyle?: PlotArrowStyle | null;
76
+ /** 终点箭头样式;null / 缺省表示无 */
45
77
  endArrowStyle?: PlotArrowStyle | null;
46
78
  };
47
- export type PlotStrokeStyle = 'solid' | 'dashed';
48
- export type PlotFillStyle = 'solid' | 'diagonal' | 'grid';
49
- /** 多边形标绘 */
50
- export type PlotPolygonOptions = GisPlotBaseOptions & {
51
- strokeStyle?: PlotStrokeStyle;
52
- fillStyle?: PlotFillStyle;
53
- };
54
- /** 矩形:4 个角点 [[lon,lat], ...] 按顺时针或逆时针顺序 */
55
- export type PlotRectangleOptions = GisPlotBaseOptions & {
56
- strokeStyle?: PlotStrokeStyle;
57
- };
58
- /** 扇形:中心 + 半径与角度(度) */
79
+ /** 多边形标绘选项:≥3 顶点 */
80
+ export type PlotPolygonOptions = GisPlotBaseOptions;
81
+ /** 矩形标绘选项:points 为 4 个角点(顺 / 逆时针) */
82
+ export type PlotRectangleOptions = GisPlotBaseOptions;
83
+ /** 扇形标绘选项:points[0] 为扇心;startAngle / sectorAngle 单位为度 */
59
84
  export type PlotSectorOptions = GisPlotBaseOptions & {
60
- strokeStyle?: PlotStrokeStyle;
85
+ /** 半径(米) */
61
86
  radius: number;
87
+ /** 起始角(度) */
62
88
  startAngle: number;
89
+ /** 张开角(度) */
63
90
  sectorAngle: number;
64
91
  };
65
- /** 圆:圆心 + 半径(米) */
92
+ /** 圆形标绘选项:points[0] 为圆心 */
66
93
  export type PlotCircleOptions = GisPlotBaseOptions & {
67
- strokeStyle?: PlotStrokeStyle;
94
+ /** 半径(米) */
68
95
  radius: number;
69
96
  };
70
- /** 箭头:控制点生成多边形;`straight` 在 CPU 端退化为首尾两点的 fine 箭头 */
71
- export type PlotArrowType = 'straight' | 'curved' | 'fine' | 'attack';
97
+ /**
98
+ * 箭头类型,与 cesium-to-three arrow SDK 的 5 个生成函数一一对应:
99
+ * - 'fine' → createFineArrow 细箭头(2 控制点:起 / 止)
100
+ * - 'assaultDirection' → createAssaultDirectionArrow 突击方向箭头(2 控制点:起 / 止)
101
+ * - 'attack' → createAttackArrow 攻击箭头(≥3 控制点:前 2 = 尾边、后 N-2 = 脊线,最后一个为 tip)
102
+ * - 'swallowtailAttack' → createSwallowtailAttackArrow 燕尾攻击箭头(同 attack 控制点约定)
103
+ * - 'curved' → createCurvedArrow 曲线箭头(≥2 控制点,全部作为脊线)
104
+ */
105
+ export type PlotArrowType = 'fine' | 'assaultDirection' | 'attack' | 'swallowtailAttack' | 'curved';
106
+ /**
107
+ * 箭头标绘选项。points 为控制点;不同 arrowType 对 points 的解释见 PlotArrowType。
108
+ */
72
109
  export type PlotArrowOptions = GisPlotBaseOptions & {
73
- strokeStyle?: PlotStrokeStyle;
74
110
  arrowType: PlotArrowType;
75
- headSize: number;
76
111
  };
77
- /** 文本标绘 */
112
+ /** 文本水平对齐(框内) */
78
113
  export type PlotTextAlign = 'left' | 'center' | 'right';
114
+ /** 文本垂直对齐(框内) */
79
115
  export type PlotTextVerticalAlign = 'top' | 'middle' | 'bottom';
116
+ /** 文本框相对锚点的水平对齐 */
80
117
  export type PlotTextAnchorX = 'left' | 'center' | 'right';
118
+ /** 文本框相对锚点的垂直对齐 */
81
119
  export type PlotTextAnchorY = 'top' | 'middle' | 'bottom';
120
+ /** 文本排版方向:横排 / 竖排(自右向左 / 自左向右) */
82
121
  export type PlotTextLayoutDirection = 'horizontal' | 'vertical-rl' | 'vertical-lr';
83
122
  /**
84
- * Text box plot options.
85
- * `points[0]` is the textbox anchor point in lon / lat degrees.
86
- * `textAlign` / `verticalAlign` control content alignment inside the box.
87
- * `anchorX` / `anchorY` control where the box sits relative to the anchor point.
123
+ * 文本标绘选项。points[0] 为文本框锚点;
124
+ * textAlign / verticalAlign 控制框内对齐;
125
+ * anchorX / anchorY 控制框相对锚点位置。
88
126
  */
89
127
  export type PlotTextOptions = GisPlotBaseOptions & {
128
+ /** 文本内容;\n 在横排是换行、竖排是换列 */
90
129
  content: string;
130
+ /** 字色(CSS 字符串) */
91
131
  fontColor: string;
132
+ /** 字号(纹素像素,> 0) */
92
133
  fontSize: number;
134
+ /** 缩放倍率(米/像素) */
93
135
  scale?: number;
136
+ /** 文字在框内水平对齐,默认 'left' */
94
137
  textAlign?: PlotTextAlign;
138
+ /** 文字在框内垂直对齐,默认 'middle' */
95
139
  verticalAlign?: PlotTextVerticalAlign;
140
+ /** 框相对锚点水平对齐,默认 'center' */
96
141
  anchorX?: PlotTextAnchorX;
142
+ /** 框相对锚点垂直对齐,默认 'middle' */
97
143
  anchorY?: PlotTextAnchorY;
144
+ /** 固定框宽(纹素像素);不传则按内容自适应 */
98
145
  boxWidth?: number;
146
+ /** 固定框高(纹素像素);不传则按内容自适应 */
99
147
  boxHeight?: number;
100
- padding?: number;
148
+ /** 内边距:单值或 [top, right, bottom, left](纹素像素) */
149
+ padding?: number | [number, number, number, number];
150
+ /** 排版方向,默认 'horizontal' */
101
151
  layoutDirection?: PlotTextLayoutDirection;
152
+ /** 地平面内旋转,度,北向顺时针为正,默认 0 */
102
153
  rotation?: number;
154
+ /** X 方向偏移(米) */
103
155
  offsetX?: number;
156
+ /** Y 方向偏移(米) */
104
157
  offsetY?: number;
158
+ /** 是否显示框边框 */
105
159
  showBorder?: boolean;
106
160
  };
107
- /** 箭头快照:在 options 外附加 `generatedCoords` */
108
- export type GisPlotArrowSnapshot = GisPlotSnapshot<PlotArrowOptions> & {
109
- generatedCoords: LonLatPoint[];
110
- };
111
161
  /**
112
- * `GroundDecalManager.addPlot` 入参:字段 `type` 与对应 `*Options` 组合,内部据此实例化 `GisPlot*`。
162
+ * 工厂入参:管理器 addPlot 的唯一入参类型。判别联合(discriminated union)。
163
+ * 管理器据此 switch(type) 实例化对应子类。
113
164
  */
114
165
  export type PlotAddOptions = ({
115
166
  type: 'point';
@@ -1,129 +1,46 @@
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 为纬度(°)。 */
1
+ /** 经纬度顶点:[lon°, lat°] */
16
2
  export type LonLat = [number, number];
17
- /**
18
- * 两点在经纬度平面上的欧氏距离。
19
- *
20
- * @param p1 - 起点
21
- * @param p2 - 终点
22
- */
3
+ /** 每段三次 Bézier 采样段数(getCurvePoints 用) */
4
+ export declare const FITTING_COUNT = 100;
5
+ /** 角平分线法向量长度阈值,小于视为共线 */
6
+ export declare const ZERO_TOLERANCE = 0.0001;
7
+ /** 经纬度平面欧氏距离(把度当作平面坐标) */
23
8
  export declare function MathDistance(p1: LonLat, p2: LonLat): number;
24
- /**
25
- * 折线顶点依次相连的总长度。
26
- *
27
- * @param points - 至少两个点;单点或空数组时循环不执行,返回 `0`。
28
- */
9
+ /** 折线总长(顺序累加段长度) */
29
10
  export declare function wholeDistance(points: LonLat[]): number;
30
- /**
31
- * 作为箭头宽度尺度的基准长度:总折线长的 `0.99` 次幂。
32
- *
33
- * 幂次小于 1 使较长箭头的宽度增长略慢于线性,避免过长箭头翼展过大。
34
- *
35
- * @param points - 定义箭杆路径的控制点
36
- */
11
+ /** 总长的 0.99 次幂(作为箭头宽度尺度) */
37
12
  export declare function getBaseLength(points: LonLat[]): number;
38
- /**
39
- * 两点的中点。
40
- */
13
+ /** 两点中点 */
41
14
  export declare function Mid(p1: LonLat, p2: LonLat): LonLat;
42
15
  /**
43
- * 从 `startPnt` 指向 `endPnt` 的方位角(类似地平经度),弧度,范围 **[0, 2π)**。
44
- *
45
- * @param startPnt - 起点
46
- * @param endPnt - 终点(与起点重合时除零由调用方避免)
16
+ * 求由 startPnt 指向 endPnt 的方位角(与 +x 轴夹角,逆时针为正,单位弧度,
17
+ * 范围 [0, 2π) )。
47
18
  */
48
19
  export declare function getAzimuth(startPnt: LonLat, endPnt: LonLat): number;
49
- /**
50
- * 在点 `b` 处,由 `b→a` 与 `b→c` 两方向方位角之差,归一化到 **[0, 2π)**。
51
- */
20
+ /** 三点夹角(pntB 为顶点),返回 [0, π] 内的弧度 */
52
21
  export declare function getAngleOfThreePoints(a: LonLat, b: LonLat, c: LonLat): number;
53
- /**
54
- * 判断折线段 `p1 → p2 → p3` 在 `p2` 处是否为顺时针转向(2D 叉积符号)。
55
- */
22
+ /** 判断 p1 → p2 → p3 是否顺时针 */
56
23
  export declare function isClockWise(p1: LonLat, p2: LonLat, p3: LonLat): boolean;
57
24
  /**
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` 两方向单位向量之和,用作角平分线法向(未单位化)。
25
+ * 以 endPnt 为基,根据相对 startPnt 的方位角 ± angle、距离 distance 求第三点。
26
+ * 箭翼 / 颈的构造核心。
65
27
  */
28
+ export declare function getThirdPoint(startPnt: LonLat, endPnt: LonLat, angle: number, distance: number, clockwise: boolean): LonLat;
29
+ /** 取 (p2 - p1) 与 (p3 - p2) 的角平分线方向向量(未归一化) */
66
30
  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
- */
31
+ /** 角平分线法向量对(曲线控制)。返回 [rightControl, leftControl] */
73
32
  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
- */
33
+ /** 用三次 Bézier 沿 controlPoints 拟合曲线并采样 FITTING_COUNT 段 */
84
34
  export declare function getCurvePoints(t: number, controlPoints: LonLat[]): LonLat[];
85
- /**
86
- * 均匀二次 B 样条对折线点列做平滑,步长 `0.05`。
87
- *
88
- * 用于攻击箭头左右侧边,使折线变为平滑曲线;适合「贴近控制点但不强制插值」的造型。
89
- *
90
- * @param points - 至少 2 个点;≤2 时原样返回
91
- */
35
+ /** 二次 B 样条平滑(attack 箭身侧边用) */
92
36
  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
- */
37
+ /** 细箭头:闭合多边形(CCW、去重、≤120 顶点) */
109
38
  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
- */
39
+ /** 突击方向箭头 */
40
+ export declare function createAssaultDirectionArrow(p1: LonLat, p2: LonLat): LonLat[];
41
+ /** 攻击箭头:首 2 点定义尾宽、其余点定义脊线(最后一个为 tip) */
129
42
  export declare function createAttackArrow(lnglatPoints: LonLat[]): LonLat[];
43
+ /** 燕尾攻击箭头:控制点约定与攻击箭头一致;尾部多一个燕尾凹口 */
44
+ export declare function createSwallowtailAttackArrow(lnglatPoints: LonLat[]): LonLat[];
45
+ /** 曲线箭头:2 点时退化为细箭头;≥3 点按曲线平滑构造 */
46
+ export declare function createCurvedArrow(lnglatPoints: LonLat[]): LonLat[];
@@ -1,18 +1,9 @@
1
- /**
2
- * @module colorUtils
3
- *
4
- * 颜色与不透明度工具函数。
5
- *
6
- * 为 {@link GroundDecalManager} 及标绘渲染管线提供颜色字符串解析与不透明度兼容层。
7
- * SDF shader 中颜色以归一化 RGBA `[0,1]` 传入,alpha 通道通常已合并 `fillOpacity` / `strokeOpacity`。
8
- */
9
- /** 归一化 RGBA 四元组,各分量 ∈ [0, 1]。 */
1
+ /** 归一化 RGBA:各分量 ∈ [0, 1] */
10
2
  export type NormalizedRGBA = readonly [number, number, number, number];
11
3
  /**
12
- * 可携带填充/描边不透明度或统一透明度的样式片段。
13
- *
14
- * - **store 格式(推荐)**:`fillOpacity` / `strokeOpacity` 为 **0–100** 的整数百分比。
15
- * - **旧版**:`opacity` 为 **0–1** 浮点数,同时作用于 fill 与 stroke。
4
+ * resolveOpacity 的输入对象。
5
+ * - fillOpacity / strokeOpacity:0..100 整数百分比(推荐)
6
+ * - opacity:0..1 浮点(旧版,同时作用于 fill 与 stroke)
16
7
  */
17
8
  export interface StyleOpacityInput {
18
9
  fillOpacity?: number;
@@ -20,32 +11,26 @@ export interface StyleOpacityInput {
20
11
  opacity?: number;
21
12
  }
22
13
  /**
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 数组(新数组,可安全修改副本若需)。
14
+ * 把 CSS 颜色字符串解析为归一化 RGBA `[r, g, b, a]`(各 ∈ [0, 1])。
15
+ *
16
+ * 支持格式:
17
+ * - `#hex`(3 / 6 / 8 位)
18
+ * - `rgb(r, g, b)`(分量 0–255)
19
+ * - `rgba(r, g, b, a)`(a ∈ [0, 1])
20
+ * - `'transparent'` / `null` / `undefined` / 空串 → `[0, 0, 0, 0]`
21
+ * - 无法识别 → 回退不透明白 `[1, 1, 1, 1]`
39
22
  */
40
23
  export declare function parseColorToRGBA(color: string | null | undefined): number[];
41
24
  /**
42
- * 解析不透明度参数,兼容两种样式约定,并写入长度为 2 的输出数组。
25
+ * 把不透明度写进长度为 2 的输出数组:
26
+ * - base[0] = 填充不透明度(0..1)
27
+ * - base[1] = 描边不透明度(0..1)
43
28
  *
44
- * 1. **store 格式**:`fillOpacity` / `strokeOpacity` 为 0–100 整数 → 除以 100 得到 0–1。
45
- * 2. **旧版**:仅提供 `opacity`(0–1)时,填充与描边共用该值。
46
- * 3. 若某通道未指定,默认 **1**(完全不透明)。
29
+ * 兼容规则(逐通道独立判定):
30
+ * 1. 有 fillOpacity(0..100) → base[0] = fillOpacity / 100
31
+ * 2. 否则有 opacity(0..1) → base[0] = opacity
32
+ * 3. 否则 → base[0] = 1
47
33
  *
48
- * @param style - 图形样式对象(仅需不透明度相关字段)。
49
- * @param base - 长度为 2 的数组;执行后 `base[0]` = 填充不透明度,`base[1]` = 描边不透明度,均为 0–1。
34
+ * strokeOpacity 同理写 base[1]。
50
35
  */
51
36
  export declare function resolveOpacity(style: StyleOpacityInput, base: [number, number]): void;
@@ -1,5 +1,5 @@
1
1
  import { Tile, TilesRenderer } from 'um-3d-tiles-renderer';
2
- import { TilesFadePlugin, UpdateOnChangePlugin, ImageOverlayPlugin, ReorientationPlugin, PlotSdfPlugin } from 'um-3d-tiles-renderer/plugins';
2
+ import { TilesFadePlugin, UpdateOnChangePlugin, ImageOverlayPlugin, ReorientationPlugin } from 'um-3d-tiles-renderer/plugins';
3
3
  import { default as SoonSpace } from 'soonspacejs';
4
4
  import { TileCustomMaterialPlugin } from './plugins';
5
5
  import { OverlayManager } from './OverlayManager';
@@ -23,8 +23,16 @@ export declare class TerrainTilesRenderer {
23
23
  customMaterialPlugin?: TileCustomMaterialPlugin;
24
24
  imageOverlayPlugin?: ImageOverlayPlugin;
25
25
  reorientationPlugin?: ReorientationPlugin;
26
- /** 标绘 SDF 插件(管理标绘实例) */
27
- plotSDFPlugin?: PlotSdfPlugin;
26
+ /** 标绘贴地深度通道(cesium-to-three classification 图元每帧所需的地形 packed depth) */
27
+ private _globeDepth?;
28
+ /**
29
+ * 虚拟 ECEF 相机:把真实相机(在 reorientation 原点系)经 R⁻¹ 变回绝对 WGS84 ECEF,
30
+ * 供 cesium-to-three 标绘图元的 RTE 着色器使用。标绘几何烘焙在绝对 ECEF,只有用
31
+ * ECEF 相机投影才能与「重定向后地形」对齐,同时保持 reorientation 开启(地形不抖)。
32
+ */
33
+ private readonly _plotVirtualCamera;
34
+ private readonly _reorientInverse;
35
+ private readonly _virtualScale;
28
36
  /** 资源管理器(存储配置) */
29
37
  resourceManager: ResourceManager;
30
38
  /** 地形管理器(记录地形列表) */
@@ -204,6 +212,26 @@ export declare class TerrainTilesRenderer {
204
212
  setOverlayOpacity(id: string, opacity: number): boolean;
205
213
  render: () => void;
206
214
  beforeRenderHandler: () => void;
215
+ /**
216
+ * 把真实相机变换回绝对 WGS84 ECEF,得到供标绘 RTE 着色器使用的虚拟相机。
217
+ *
218
+ * 原理:地形经 reorientation 用 R = tiles.group.matrixWorld(ECEF → 重定向世界)
219
+ * 渲染;标绘几何烘焙在绝对 ECEF。令 vCam.matrixWorld = R⁻¹ · realCamera.matrixWorld,
220
+ * 则 V_virtual = V_real · R,标绘 clip = P·V_virtual·p_ecef = P·V_real·(R·p_ecef)
221
+ * 与地形 clip 完全一致 → 对齐;且相机与几何都在 ECEF、局部差值小 → RTE 不抖。
222
+ * 当 R 为单位阵(reorientation 关闭)时,vCam 退化为真实相机,行为不变。
223
+ *
224
+ * 注意:cesium-to-three 只读 camera 的 position / quaternion / fov / aspect /
225
+ * near / far / projectionMatrixInverse,故只需保证这些字段正确。
226
+ *
227
+ * @param camera 真实透视相机(soonspacejs 视口相机)。
228
+ * @returns 复用的虚拟相机实例(每帧原地更新)。
229
+ */
230
+ private _buildPlotVirtualCamera;
231
+ /**
232
+ * 惰性创建(或复用)贴地深度通道,尺寸对齐当前渲染器绘制缓冲。
233
+ */
234
+ private _ensureGlobeDepth;
207
235
  enable(): void;
208
236
  disable(): void;
209
237
  invalidate(lon: number, lat: number, alt: number): () => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soonspacejs/plugin-tiles",
3
3
  "pluginName": "TilesPlugin",
4
- "version": "2.15.8",
4
+ "version": "2.15.10",
5
5
  "description": "3D Tiles plugin for SoonSpace.js",
6
6
  "main": "dist/index.esm.js",
7
7
  "module": "dist/index.esm.js",
@@ -21,6 +21,7 @@
21
21
  "um-3d-tiles-renderer": "^0.4.48",
22
22
  "three": "^0.183.0",
23
23
  "@mapbox/geojson-merge": "^1.1.1",
24
- "soonspacejs": "2.15.8"
24
+ "cesium-to-three": "^0.1.5",
25
+ "soonspacejs": "2.15.10"
25
26
  }
26
27
  }
@@ -1,48 +0,0 @@
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;