@metagl/smartearth-base 0.0.0-stage → 0.3.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/CHANGELOG.md +78 -0
- package/README.md +320 -3
- package/dist/chunk-24R3PPPA.js +2116 -0
- package/dist/chunk-POH7K3F4.js +705 -0
- package/dist/chunk-UENQT22J.js +885 -0
- package/dist/createEarth-BY0dtgQQ.d.ts +647 -0
- package/dist/errors-cB7IQlHy.d.ts +15 -0
- package/dist/index.d.ts +345 -0
- package/dist/index.js +2 -0
- package/dist/presets.d.ts +312 -0
- package/dist/presets.js +2 -0
- package/dist/vite.d.ts +20 -0
- package/dist/vite.js +89 -0
- package/dist/vue.d.ts +108 -0
- package/dist/vue.js +291 -0
- package/package.json +75 -6
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { L as LayerSpec, P as PbrMaterialParams, G as GeoPosition, a as PickedFeature } from './createEarth-BY0dtgQQ.js';
|
|
2
|
+
export { C as CESIUM_MAX_VERSION_EXCLUSIVE, b as CESIUM_MIN_VERSION, c as COLOR_FILTERS, d as CameraPose, e as CaptureOptions, f as ClickEvent, g as ClockOfDay, h as ClockState, i as ColorFilter, j as CreateEarthOptions, k as CustomBasemap, E as ENVIRONMENT_PRESETS, l as Earth, m as EarthEnvironment, n as EarthEvents, o as EarthLayers, p as EarthPbr, q as EffectOptions, r as EffectOptionsTarget, s as EnvironmentBaseline, t as EnvironmentChange, u as EnvironmentChangeSource, v as EnvironmentConfig, w as EnvironmentEffect, x as EnvironmentPreset, y as EnvironmentSnapshot, z as EnvironmentTime, F as FlyToTarget, I as InitialView, A as LayerContext, B as LayerFactory, D as LayerHandle, H as LayerInfo, J as LightDirection, K as LightingMode, M as PRESET_DOCUMENT_SCHEMA, N as PbrConfig, O as PbrGlobalParams, Q as PbrTarget, R as PickEvent, S as PickResolver, T as PresetDocumentCore, U as Quality, V as RestoreOptions, W as SceneFogOptions, X as SdkAuth, Y as TerrainAdjustOptions, Z as WindOptions, _ as createEarth, $ as createEarthPbr, a0 as getSupportedQualities, a1 as makeExtensible, a2 as requirePresetDocument, a3 as requireSnapshot, a4 as supportsPbr } from './createEarth-BY0dtgQQ.js';
|
|
3
|
+
export { M as MAP_TOKEN_APPLY_URL, S as SmartEarthError, a as SmartEarthErrorCode, i as isSmartEarthError } from './errors-cB7IQlHy.js';
|
|
4
|
+
import { Cesium3DTileset } from 'cesium';
|
|
5
|
+
import { RiverWaterConfig } from '@metagl/sdk-render';
|
|
6
|
+
|
|
7
|
+
/** 本包用到的 4.x Render 环境能力子集。 */
|
|
8
|
+
interface EnvironmentCapableRender {
|
|
9
|
+
applyPreset(presetId: string): void;
|
|
10
|
+
transitionToPreset(presetId: string, durationSec?: number): void;
|
|
11
|
+
clearPreset(): void;
|
|
12
|
+
getActivePreset(): string | null;
|
|
13
|
+
toggleSystem(systemName: string, enabled?: boolean): void;
|
|
14
|
+
getSystemStatus(systemName: string): boolean | undefined;
|
|
15
|
+
getSystemConfig(systemName: string): unknown;
|
|
16
|
+
updateSystemConfig(systemName: string, config: unknown): void;
|
|
17
|
+
}
|
|
18
|
+
declare function supportsEnvironment(render: unknown): render is EnvironmentCapableRender;
|
|
19
|
+
|
|
20
|
+
/** 底座版本(预设文档的 producedBy.base 用)。发版时与 package.json 的 version 一起改,有测试核对。 */
|
|
21
|
+
declare const BASE_VERSION = "0.3.0";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* sdk-render 3.0 没有画质档位接口时,本包按 geovisearthsdk_web《渲染性能优化方案》(2026-08-18)
|
|
25
|
+
* 的 T0「low 档」在出厂 baseline 上叠一层配置。high 即 baseline 原样。
|
|
26
|
+
*
|
|
27
|
+
* | 项 | baseline | low |
|
|
28
|
+
* |---|---|---|
|
|
29
|
+
* | ssgi / ssrt / ssr | 开 | 关(保留 gBuffer + hbao) |
|
|
30
|
+
* | 云 nubis.maxSteps / noiseEnabled | 256 / true | 56 / false |
|
|
31
|
+
* | 高度雾 quality | cinematic | low |
|
|
32
|
+
* | msaaEnabled / hdrEnabled | true(8) / true | false / false(只留 fxaa) |
|
|
33
|
+
* | 阴影 size / numBlurSamples / softShadows | 4864 / 24 / true | 2048 / 8 / false |
|
|
34
|
+
*/
|
|
35
|
+
declare const LOW_QUALITY_OVERRIDES: {
|
|
36
|
+
readonly ssgi: {
|
|
37
|
+
readonly enabled: false;
|
|
38
|
+
};
|
|
39
|
+
readonly ssrt: {
|
|
40
|
+
readonly enabled: false;
|
|
41
|
+
};
|
|
42
|
+
readonly ssr: {
|
|
43
|
+
readonly enabled: false;
|
|
44
|
+
};
|
|
45
|
+
readonly volumetricClouds: {
|
|
46
|
+
readonly nubis: {
|
|
47
|
+
readonly maxSteps: 56;
|
|
48
|
+
readonly noiseEnabled: false;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
readonly heightFog: {
|
|
52
|
+
readonly quality: "low";
|
|
53
|
+
};
|
|
54
|
+
readonly postProcessing: {
|
|
55
|
+
readonly msaaEnabled: false;
|
|
56
|
+
readonly hdrEnabled: false;
|
|
57
|
+
readonly fxaaEnabled: true;
|
|
58
|
+
};
|
|
59
|
+
readonly shadow: {
|
|
60
|
+
readonly size: 2048;
|
|
61
|
+
readonly numBlurSamples: 8;
|
|
62
|
+
readonly softShadows: false;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** 按字段取色:`field` 的值查 `colors`,查不到用 `fallback`。 */
|
|
67
|
+
interface FieldColors {
|
|
68
|
+
readonly field: string;
|
|
69
|
+
/** 字段值 → CSS 颜色。 */
|
|
70
|
+
readonly colors: Readonly<Record<string, string>>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface PointDatum {
|
|
74
|
+
/** 要素 id,缺省用序号。 */
|
|
75
|
+
readonly id?: string | number;
|
|
76
|
+
readonly lon: number;
|
|
77
|
+
readonly lat: number;
|
|
78
|
+
/** 米;缺省贴地。 */
|
|
79
|
+
readonly height?: number;
|
|
80
|
+
readonly [field: string]: unknown;
|
|
81
|
+
}
|
|
82
|
+
interface PointsLayerSpec extends LayerSpec {
|
|
83
|
+
readonly kind: 'points';
|
|
84
|
+
readonly data: readonly PointDatum[];
|
|
85
|
+
/** 按这个字段的值分色。 */
|
|
86
|
+
readonly colorBy?: string;
|
|
87
|
+
/** 字段值 → CSS 颜色。 */
|
|
88
|
+
readonly colors?: Readonly<Record<string, string>>;
|
|
89
|
+
/** 没匹配上时的颜色,默认白色。 */
|
|
90
|
+
readonly defaultColor?: string;
|
|
91
|
+
readonly pixelSize?: number;
|
|
92
|
+
/** 用作文字标注的字段;不传不显示标注。 */
|
|
93
|
+
readonly labelField?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface GeojsonStyle {
|
|
97
|
+
/** 面填充色,默认 #3b82f6。 */
|
|
98
|
+
readonly fill?: string;
|
|
99
|
+
/** 面填充不透明度 0~1,默认 0.35。 */
|
|
100
|
+
readonly fillOpacity?: number;
|
|
101
|
+
/** 线与面边框颜色,默认 #1d4ed8。 */
|
|
102
|
+
readonly stroke?: string;
|
|
103
|
+
/** 线宽(像素),默认 2。 */
|
|
104
|
+
readonly strokeWidth?: number;
|
|
105
|
+
/** 点颜色,默认 #ffffff。 */
|
|
106
|
+
readonly pointColor?: string;
|
|
107
|
+
/** 点大小(像素),默认 10。 */
|
|
108
|
+
readonly pointSize?: number;
|
|
109
|
+
}
|
|
110
|
+
interface GeojsonLayerSpec extends LayerSpec {
|
|
111
|
+
readonly kind: 'geojson';
|
|
112
|
+
/** GeoJSON 对象(FeatureCollection / Feature / Geometry)或其 URL。 */
|
|
113
|
+
readonly data: unknown;
|
|
114
|
+
readonly style?: GeojsonStyle;
|
|
115
|
+
/** 按字段着色:面填充、线、点都按这个字段取色。 */
|
|
116
|
+
readonly colorBy?: FieldColors;
|
|
117
|
+
/** 贴地,默认 true。 */
|
|
118
|
+
readonly clampToGround?: boolean;
|
|
119
|
+
/** 用作文字标注的字段。 */
|
|
120
|
+
readonly labelField?: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
interface Tileset3dLayerSpec extends LayerSpec {
|
|
124
|
+
readonly kind: 'tileset3d';
|
|
125
|
+
/** tileset.json 地址。 */
|
|
126
|
+
readonly url: string;
|
|
127
|
+
/**
|
|
128
|
+
* 该 tileset 的单独 PBR 材质(亮度、金属/镜面、粗糙度、自发光、IBL 等),经 earth.pbr.setTilesetMaterial 设置。
|
|
129
|
+
* 不传就不动:sdk-render 4.x 默认会给 3D Tiles 挂共享 PBR。需要 sdk-render 4.x,3.0 下传了抛 PBR_UNSUPPORTED。
|
|
130
|
+
*/
|
|
131
|
+
readonly pbr?: PbrMaterialParams;
|
|
132
|
+
/** 屏幕空间误差阈值,越大越省,默认沿用 Cesium(16)。 */
|
|
133
|
+
readonly maximumScreenSpaceError?: number;
|
|
134
|
+
}
|
|
135
|
+
interface Tileset3dApi {
|
|
136
|
+
readonly tileset: Cesium3DTileset;
|
|
137
|
+
/** 改这个 tileset 的单独材质(需要 sdk-render 4.x)。 */
|
|
138
|
+
setMaterial(params: PbrMaterialParams): void;
|
|
139
|
+
/** 清除单独材质,回到共享 PBR。 */
|
|
140
|
+
clearMaterial(): void;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** 航线顶点:经度、纬度(度),高度(米,可省略=贴地)。 */
|
|
144
|
+
interface RoutePoint {
|
|
145
|
+
readonly lon: number;
|
|
146
|
+
readonly lat: number;
|
|
147
|
+
readonly height?: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* 航线来源:
|
|
151
|
+
* - 坐标数组:`[[lon, lat, height?], ...]` 或 `[{ lon, lat, height? }, ...]`
|
|
152
|
+
* - GeoJSON:LineString,或含 LineString 的 Feature / FeatureCollection(取第一条)
|
|
153
|
+
* - KML 文本:取第一个 `<LineString><coordinates>`
|
|
154
|
+
*/
|
|
155
|
+
type RouteSource = readonly (readonly number[])[] | readonly RoutePoint[] | Readonly<Record<string, unknown>> | string;
|
|
156
|
+
|
|
157
|
+
interface RouteLayerSpec extends LayerSpec {
|
|
158
|
+
readonly kind: 'route';
|
|
159
|
+
/**
|
|
160
|
+
* 坐标数组、GeoJSON LineString(或含它的 Feature/FeatureCollection)、KML 文本;
|
|
161
|
+
* 字符串以 http(s):// 或 / 开头且不含 `<` 时当作地址去取(内容可以是 KML 或 GeoJSON)。
|
|
162
|
+
*/
|
|
163
|
+
readonly path: RouteSource;
|
|
164
|
+
/** 1 倍速下走完全程的秒数,默认 60。 */
|
|
165
|
+
readonly durationSeconds?: number;
|
|
166
|
+
/** 循环播放,默认 false。 */
|
|
167
|
+
readonly loop?: boolean;
|
|
168
|
+
/** 加载后立即播放,默认 false。 */
|
|
169
|
+
readonly autoplay?: boolean;
|
|
170
|
+
/** 相机跟随,默认 false。 */
|
|
171
|
+
readonly follow?: boolean;
|
|
172
|
+
/** 跟随时相机在标记点后方的距离(米),默认 2000;高度取其 0.6 倍。 */
|
|
173
|
+
readonly followRange?: number;
|
|
174
|
+
/** 显示整条航线,默认 true。 */
|
|
175
|
+
readonly showPath?: boolean;
|
|
176
|
+
readonly pathColor?: string;
|
|
177
|
+
readonly pathWidth?: number;
|
|
178
|
+
readonly markerColor?: string;
|
|
179
|
+
readonly markerSize?: number;
|
|
180
|
+
}
|
|
181
|
+
interface RouteProgressEvent {
|
|
182
|
+
/** 0~1。 */
|
|
183
|
+
readonly progress: number;
|
|
184
|
+
readonly lon: number;
|
|
185
|
+
readonly lat: number;
|
|
186
|
+
readonly height: number;
|
|
187
|
+
}
|
|
188
|
+
interface RouteEvents extends Record<string, unknown> {
|
|
189
|
+
progress: RouteProgressEvent;
|
|
190
|
+
end: undefined;
|
|
191
|
+
}
|
|
192
|
+
interface RouteApi {
|
|
193
|
+
readonly progress: number;
|
|
194
|
+
readonly playing: boolean;
|
|
195
|
+
readonly speed: number;
|
|
196
|
+
play(): void;
|
|
197
|
+
pause(): void;
|
|
198
|
+
/** 跳到进度 0~1。 */
|
|
199
|
+
seek(progress: number): void;
|
|
200
|
+
/** 倍速,> 0。 */
|
|
201
|
+
setSpeed(multiplier: number): void;
|
|
202
|
+
setFollow(follow: boolean): void;
|
|
203
|
+
on<K extends keyof RouteEvents>(event: K, listener: (payload: RouteEvents[K]) => void): () => void;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** 弹窗内容:HTMLElement,或 HTML 字符串(由调用方保证可信;拼用户数据时先 escapeHtml)。返回 null 表示这次不弹。 */
|
|
207
|
+
type PopupContent = HTMLElement | string | null;
|
|
208
|
+
interface PopupLayerSpec extends LayerSpec {
|
|
209
|
+
readonly kind: 'popup';
|
|
210
|
+
/** 只对这些图层的要素弹出;不传 = 所有图层。 */
|
|
211
|
+
readonly layers?: readonly string[];
|
|
212
|
+
/** 点到要素时生成弹窗内容。 */
|
|
213
|
+
readonly render: (feature: PickedFeature, position: GeoPosition | undefined) => PopupContent;
|
|
214
|
+
/** 附加到弹窗根元素的 class,便于改样式。 */
|
|
215
|
+
readonly className?: string;
|
|
216
|
+
/** 相对锚点的像素偏移,默认 { x: 0, y: -14 }(显示在点上方)。 */
|
|
217
|
+
readonly offset?: {
|
|
218
|
+
readonly x: number;
|
|
219
|
+
readonly y: number;
|
|
220
|
+
};
|
|
221
|
+
/** 点击没有打开本弹窗时(空白处、别的图层、render 返回 null)关闭旧弹窗,默认 true。 */
|
|
222
|
+
readonly closeOnEmptyClick?: boolean;
|
|
223
|
+
}
|
|
224
|
+
interface PopupApi {
|
|
225
|
+
readonly isOpen: boolean;
|
|
226
|
+
/** 手动在某个位置打开弹窗。 */
|
|
227
|
+
open(position: GeoPosition, content: Exclude<PopupContent, null>): void;
|
|
228
|
+
close(): void;
|
|
229
|
+
}
|
|
230
|
+
/** 转义 HTML 特殊字符;把字段值拼进弹窗 HTML 前用它。 */
|
|
231
|
+
declare function escapeHtml(value: unknown): string;
|
|
232
|
+
|
|
233
|
+
interface AnnotationDraft {
|
|
234
|
+
readonly name: string;
|
|
235
|
+
/** 等级,按 levels 着色;默认「中」。 */
|
|
236
|
+
readonly level?: string;
|
|
237
|
+
readonly description?: string;
|
|
238
|
+
}
|
|
239
|
+
interface AnnotationItem extends AnnotationDraft {
|
|
240
|
+
readonly id: string;
|
|
241
|
+
readonly level: string;
|
|
242
|
+
readonly lon: number;
|
|
243
|
+
readonly lat: number;
|
|
244
|
+
readonly height?: number;
|
|
245
|
+
/** ISO 时间。 */
|
|
246
|
+
readonly createdAt: string;
|
|
247
|
+
}
|
|
248
|
+
interface AnnotationLayerSpec extends LayerSpec {
|
|
249
|
+
readonly kind: 'annotation';
|
|
250
|
+
/** 等级 → CSS 颜色,默认 高 红 / 中 橙 / 低 黄。 */
|
|
251
|
+
readonly levels?: Readonly<Record<string, string>>;
|
|
252
|
+
/** 初始标注(比如上层从后端读回的)。 */
|
|
253
|
+
readonly items?: readonly AnnotationItem[];
|
|
254
|
+
}
|
|
255
|
+
interface AnnotationEvents extends Record<string, unknown> {
|
|
256
|
+
change: readonly AnnotationItem[];
|
|
257
|
+
}
|
|
258
|
+
interface AnnotationApi {
|
|
259
|
+
/** 进入放置状态:下一次点到地表就按 draft 加一条标注。再次调用会替换待放置的 draft。 */
|
|
260
|
+
startPlacing(draft: AnnotationDraft): Promise<AnnotationItem | undefined>;
|
|
261
|
+
/** 退出放置状态;等待中的 startPlacing 以 undefined 结束。 */
|
|
262
|
+
cancelPlacing(): void;
|
|
263
|
+
readonly placing: boolean;
|
|
264
|
+
add(item: AnnotationDraft & {
|
|
265
|
+
readonly lon: number;
|
|
266
|
+
readonly lat: number;
|
|
267
|
+
readonly height?: number;
|
|
268
|
+
readonly id?: string;
|
|
269
|
+
}): AnnotationItem;
|
|
270
|
+
remove(id: string): boolean;
|
|
271
|
+
list(): AnnotationItem[];
|
|
272
|
+
clear(): void;
|
|
273
|
+
/** 导出 { version: 1, items };不做持久化,存哪里由上层决定。 */
|
|
274
|
+
exportJSON(): string;
|
|
275
|
+
/** 导入 exportJSON 的结果(字符串或对象);默认替换现有标注,返回导入条数。 */
|
|
276
|
+
importJSON(json: string | object, options?: {
|
|
277
|
+
readonly append?: boolean;
|
|
278
|
+
}): number;
|
|
279
|
+
on<K extends keyof AnnotationEvents>(event: K, listener: (payload: AnnotationEvents[K]) => void): () => void;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** 按坑加水:在挖好的坑里生成顺着坑走的水面(sdk-render ≥ 4.0.3)。 */
|
|
283
|
+
interface PitWaterOptions {
|
|
284
|
+
/** 水面比坑沿低多少米,默认 5。 */
|
|
285
|
+
readonly freeboard?: number;
|
|
286
|
+
/** 水面至少比坑底高多少米,默认 0.5。 */
|
|
287
|
+
readonly minDepth?: number;
|
|
288
|
+
/** 网格间距(米),默认按坑面积自适应。 */
|
|
289
|
+
readonly spacingMeters?: number;
|
|
290
|
+
}
|
|
291
|
+
interface RiverWaterLayerSpec extends LayerSpec {
|
|
292
|
+
readonly kind: 'riverWater';
|
|
293
|
+
/**
|
|
294
|
+
* 水系 GeoJSON(LineString = 河道,Polygon = 湖面)或其 URL。水面高度只取坐标的 Z(米):
|
|
295
|
+
* 坐标没有 Z 时必须给 `height`,否则报 INVALID_OPTIONS(不让水面悄悄落在 0 米)。
|
|
296
|
+
*/
|
|
297
|
+
readonly data: unknown;
|
|
298
|
+
/** 给缺 Z 的坐标补的水面高程(米,绝对高程)。 */
|
|
299
|
+
readonly height?: number;
|
|
300
|
+
/** 河道宽度(米),线要素用,默认 60。 */
|
|
301
|
+
readonly width?: number;
|
|
302
|
+
/**
|
|
303
|
+
* 线要素怎么交给 sdk-render:
|
|
304
|
+
* - 'auto'(默认):sdk-render ≥ 4.0.2 原样传线;更早的版本按 width 先转成飘带面(4.0.1 及以前传线会停止整个场景渲染)。
|
|
305
|
+
* - 'ribbon' / 'native':强制转面 / 强制传线。
|
|
306
|
+
*/
|
|
307
|
+
readonly lineMode?: 'auto' | 'ribbon' | 'native';
|
|
308
|
+
/** 水面相对高程偏移(米)。 */
|
|
309
|
+
readonly offsetHeight?: number;
|
|
310
|
+
/** 厚水体下沉米数,0 = 平面水面。 */
|
|
311
|
+
readonly thickness?: number;
|
|
312
|
+
/**
|
|
313
|
+
* 地形挖坑,把地形压低 depth 米(正数)。
|
|
314
|
+
* `fillWater`(sdk-render ≥ 4.0.3):按坑加水,水面顺着坑走、比坑沿低 freeboard 米,
|
|
315
|
+
* 这时不再按数据另铺平水面,坐标也不需要 Z。
|
|
316
|
+
* - sdk-render ≥ 4.0.2:湖、库与河道线都挖(河道线按 width 转成面交给挖坑,逐点顺坡下挖)。
|
|
317
|
+
* - 更早的版本:只挖 Polygon(旧版把区域压平到「平均高程 + 偏移」,沿坡的河道会被压成平台)。
|
|
318
|
+
* 地形调整在 sdk-render 里是全局的,一个地球同时只能有一个带 dig 的 riverWater 图层。
|
|
319
|
+
*/
|
|
320
|
+
readonly dig?: {
|
|
321
|
+
readonly depth: number;
|
|
322
|
+
readonly fillWater?: boolean | PitWaterOptions;
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* 坐标没有 Z、也没给 height 时,sdk-render ≥ 4.0.3 会把水面贴着地形放,lift 是比地形高的米数(默认 0.5)。
|
|
326
|
+
* 更早的版本没有这个能力,仍要求坐标带 Z 或给 height。
|
|
327
|
+
*/
|
|
328
|
+
readonly lift?: number;
|
|
329
|
+
/** 显示 sdk-render 挖坑的青色示意面和「区域 N」标签,默认 false。 */
|
|
330
|
+
readonly showDigViz?: boolean;
|
|
331
|
+
/** 河道水面外观参数,原样交给 sdk-render 的 RiverWaterSystem.update(颜色、波浪、反射、浪花、焦散等)。 */
|
|
332
|
+
readonly config?: Readonly<Partial<RiverWaterConfig>>;
|
|
333
|
+
}
|
|
334
|
+
interface RiverWaterApi {
|
|
335
|
+
/** 本图层创建的水面图层 id。 */
|
|
336
|
+
readonly layerIds: readonly string[];
|
|
337
|
+
/** 实际用的线模式。 */
|
|
338
|
+
readonly lineMode: 'ribbon' | 'native';
|
|
339
|
+
/** 水面是怎么放的:'data' = 按数据里的高度,'terrain' = 贴地形(4.0.3),'pit' = 按坑加水(4.0.3)。 */
|
|
340
|
+
readonly placement: 'data' | 'terrain' | 'pit';
|
|
341
|
+
/** 改水面外观参数(作用于整个河道水面系统;也可用 earth.environment.setEffectOptions('riverWater', …))。 */
|
|
342
|
+
update(config: Readonly<Partial<RiverWaterConfig>>): void;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export { type AnnotationApi, type AnnotationDraft, type AnnotationEvents, type AnnotationItem, type AnnotationLayerSpec, BASE_VERSION, type FieldColors, GeoPosition, type GeojsonLayerSpec, type GeojsonStyle, LOW_QUALITY_OVERRIDES, LayerSpec, PbrMaterialParams, PickedFeature, type PointDatum, type PointsLayerSpec, type PopupApi, type PopupContent, type PopupLayerSpec, type RiverWaterApi, type RiverWaterLayerSpec, type RouteApi, type RouteEvents, type RouteLayerSpec, type RoutePoint, type RouteProgressEvent, type RouteSource, type Tileset3dApi, type Tileset3dLayerSpec, escapeHtml, supportsEnvironment };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { CESIUM_MAX_VERSION_EXCLUSIVE, CESIUM_MIN_VERSION, LOW_QUALITY_OVERRIDES, createEarth, createEarthPbr, escapeHtml, getSupportedQualities, makeExtensible, supportsPbr } from './chunk-24R3PPPA.js';
|
|
2
|
+
export { BASE_VERSION, COLOR_FILTERS, ENVIRONMENT_PRESETS, MAP_TOKEN_APPLY_URL, PRESET_DOCUMENT_SCHEMA, SmartEarthError, isSmartEarthError, requirePresetDocument, requireSnapshot, supportsEnvironment } from './chunk-UENQT22J.js';
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { T as PresetDocumentCore, l as Earth } from './createEarth-BY0dtgQQ.js';
|
|
2
|
+
import 'cesium';
|
|
3
|
+
import '@metagl/sdk-render';
|
|
4
|
+
|
|
5
|
+
/** 预设文档:底座认的部分(schema + snapshot)加上预设层的元数据。智作冻结进工程的文件就是它。 */
|
|
6
|
+
interface PresetDocument extends PresetDocumentCore {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly desc?: string;
|
|
10
|
+
/** 归属城市(6 位 adcode);SDK 内置预设没有。 */
|
|
11
|
+
readonly adcode?: string;
|
|
12
|
+
readonly tags?: readonly string[];
|
|
13
|
+
/** 由服务端从令牌里填,前端写了也会被覆盖。 */
|
|
14
|
+
readonly author?: string;
|
|
15
|
+
readonly createdAt: number;
|
|
16
|
+
/** 生成时的版本:判断兼容用。legacy 表示样板间桶里的老格式(裸 sdk-render 配置)。 */
|
|
17
|
+
readonly producedBy: {
|
|
18
|
+
readonly base: string;
|
|
19
|
+
readonly sdkRender: string;
|
|
20
|
+
} | 'legacy';
|
|
21
|
+
/** 冻结进工程时记下来源,便于提示「业务集群上有新版本」。 */
|
|
22
|
+
readonly source?: {
|
|
23
|
+
readonly kind: string;
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly frozenAt?: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** 卡片列表用的摘要(不含快照)。 */
|
|
29
|
+
interface PresetSummary {
|
|
30
|
+
/** 全局唯一:`{来源}:{来源内 id}`。 */
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly source: string;
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly desc?: string;
|
|
35
|
+
readonly adcode?: string;
|
|
36
|
+
readonly thumb?: string;
|
|
37
|
+
readonly createdAt?: number;
|
|
38
|
+
readonly producedBy?: PresetDocument['producedBy'];
|
|
39
|
+
readonly writable: boolean;
|
|
40
|
+
}
|
|
41
|
+
declare function requireDocument(value: unknown, what?: string): PresetDocument;
|
|
42
|
+
/** 样板间桶里的老格式(裸 sdk-render 配置,时间在 settings.clockIsoTime)包成预设文档。 */
|
|
43
|
+
declare function wrapLegacyConfig(config: Record<string, unknown>, meta: {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly desc?: string;
|
|
47
|
+
readonly adcode?: string;
|
|
48
|
+
}): PresetDocument;
|
|
49
|
+
/** 主版本不同算「可能不兼容」:套用前提醒,不阻止。 */
|
|
50
|
+
declare function compatibilityNote(producedBy: PresetDocument['producedBy'] | undefined, sdkRenderVersion: string | undefined): string | null;
|
|
51
|
+
|
|
52
|
+
/** 保存时由预设库填好的草稿:快照、版本、截图都已就绪,数据源只管存。 */
|
|
53
|
+
interface PresetDraft {
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly desc?: string;
|
|
56
|
+
readonly adcode?: string;
|
|
57
|
+
readonly tags?: readonly string[];
|
|
58
|
+
readonly document: PresetDocument;
|
|
59
|
+
/** 缩略图(JPEG dataURL)。 */
|
|
60
|
+
readonly thumb?: string;
|
|
61
|
+
/** 地区:名称取城市名,范围取保存时的可视范围(业务集群预设必填)。 */
|
|
62
|
+
readonly region?: {
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly bbox: readonly [number, number, number, number];
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** 列卡片的条件:adcode 与(预设库知道时)对应的城市名、省份。 */
|
|
68
|
+
interface PresetListQuery {
|
|
69
|
+
readonly adcode?: string;
|
|
70
|
+
readonly city?: {
|
|
71
|
+
readonly name: string;
|
|
72
|
+
readonly province?: string;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 预设数据源(可插拔)。内置:builtin(SDK 场景预设)、cluster(`httpPresetStore`,业务集群预设服务)、
|
|
77
|
+
* bucket(样板间储存桶,只读)、local(离线演示用,显式开启)。业务可以自己实现。
|
|
78
|
+
*/
|
|
79
|
+
interface PresetSource {
|
|
80
|
+
/** 来源 id,也是卡片 id 的前缀。 */
|
|
81
|
+
readonly id: string;
|
|
82
|
+
/** 卡片上显示的来源名,如「业务集群」「样板间」。 */
|
|
83
|
+
readonly label: string;
|
|
84
|
+
readonly writable: boolean;
|
|
85
|
+
/** 列某城市的预设;adcode 为空时列不分城市的(如 SDK 内置)。 */
|
|
86
|
+
list(query: PresetListQuery): Promise<PresetSummary[]>;
|
|
87
|
+
/** 取完整预设(id 是来源内的 id,不带前缀)。 */
|
|
88
|
+
get(id: string): Promise<PresetDocument>;
|
|
89
|
+
save?(draft: PresetDraft): Promise<PresetSummary>;
|
|
90
|
+
remove?(id: string): Promise<void>;
|
|
91
|
+
/** 自定义套用方式(SDK 内置预设走 setPreset 的渐变与防护,不走整份导入)。 */
|
|
92
|
+
apply?(earth: Earth, id: string): Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 样板间储存桶(与 sdk-render 样板间同一套 CDN 目录,只读):
|
|
97
|
+
* {base}/{adcode}/index.json 清单 { configs: [{ file, name, desc, thumb? }] }
|
|
98
|
+
* {base}/{adcode}/render-config-时间戳.json 整份环境配置(含 settings.clockIsoTime)
|
|
99
|
+
*/
|
|
100
|
+
declare const DEFAULT_CITY_CONFIG_BASE_URL = "https://io-qos.geovisearth.com/getfile/46/brainsim-cdn/CityConfig";
|
|
101
|
+
interface CityConfigEntry {
|
|
102
|
+
/** 配置文件名,如 render-config-2026-04-29-04-15-19.json。 */
|
|
103
|
+
readonly file: string;
|
|
104
|
+
/** 名称,如「晨曦北京」。 */
|
|
105
|
+
readonly name: string;
|
|
106
|
+
readonly desc?: string;
|
|
107
|
+
/** 缩略图完整地址(清单里有 thumb 时)。 */
|
|
108
|
+
readonly thumbUrl?: string;
|
|
109
|
+
}
|
|
110
|
+
interface CityConfigIndex {
|
|
111
|
+
readonly configs: readonly {
|
|
112
|
+
readonly file: string;
|
|
113
|
+
readonly name: string;
|
|
114
|
+
readonly desc?: string;
|
|
115
|
+
readonly thumb?: string;
|
|
116
|
+
}[];
|
|
117
|
+
}
|
|
118
|
+
/** createCityConfig 的结果:两个文件交给有 CDN 写权限的人上传到 {base}/{adcode}/。 */
|
|
119
|
+
interface CityConfigDraft {
|
|
120
|
+
readonly adcode: string;
|
|
121
|
+
/** 配置文件名与内容。 */
|
|
122
|
+
readonly filename: string;
|
|
123
|
+
readonly config: Record<string, unknown>;
|
|
124
|
+
/** 合并好新条目的 index.json 内容(同名覆盖,否则追加)。 */
|
|
125
|
+
readonly index: CityConfigIndex;
|
|
126
|
+
/** 上传目录。 */
|
|
127
|
+
readonly uploadDir: string;
|
|
128
|
+
}
|
|
129
|
+
declare function createCityConfigLibrary(baseUrl: string): {
|
|
130
|
+
listCityConfigs(adcode: string | number): Promise<CityConfigEntry[]>;
|
|
131
|
+
fetchCityConfig(adcode: string | number, file: string): Promise<Record<string, unknown>>;
|
|
132
|
+
draftCityConfig(adcode: string | number, entry: {
|
|
133
|
+
readonly name: string;
|
|
134
|
+
readonly desc?: string;
|
|
135
|
+
}, config: Record<string, unknown>, now: Date): Promise<CityConfigDraft>;
|
|
136
|
+
};
|
|
137
|
+
interface BucketSourceOptions {
|
|
138
|
+
/** 储存桶根地址,默认样板间的 CityConfig 目录。 */
|
|
139
|
+
readonly baseUrl?: string;
|
|
140
|
+
readonly label?: string;
|
|
141
|
+
}
|
|
142
|
+
/** 样板间储存桶数据源:只读,老格式(裸 SDK 配置)自动包成预设文档。 */
|
|
143
|
+
declare function bucketSource(options?: BucketSourceOptions): PresetSource & {
|
|
144
|
+
/** 生成样板间桶的上传包(配置 + 合并好的 index.json),给有 CDN 写权限的人手动上传。 */
|
|
145
|
+
draftUpload: ReturnType<typeof createCityConfigLibrary>['draftCityConfig'];
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/** 样板间同款城市列表接口(公开、允许跨域)。 */
|
|
149
|
+
declare const DEFAULT_CITY_LIST_URL = "https://metaverseds.geovisearth.com/api/v1/city/list";
|
|
150
|
+
/** 按行政区划代码前两位分的 7 个大区(同样板间)。 */
|
|
151
|
+
declare const REGION_RULES: readonly [{
|
|
152
|
+
readonly id: "north";
|
|
153
|
+
readonly name: "华北";
|
|
154
|
+
readonly prefixes: readonly [11, 12, 13, 14, 15];
|
|
155
|
+
}, {
|
|
156
|
+
readonly id: "northeast";
|
|
157
|
+
readonly name: "东北";
|
|
158
|
+
readonly prefixes: readonly [21, 22, 23];
|
|
159
|
+
}, {
|
|
160
|
+
readonly id: "east";
|
|
161
|
+
readonly name: "华东";
|
|
162
|
+
readonly prefixes: readonly [31, 32, 33, 34, 35, 36, 37];
|
|
163
|
+
}, {
|
|
164
|
+
readonly id: "central";
|
|
165
|
+
readonly name: "华中";
|
|
166
|
+
readonly prefixes: readonly [41, 42, 43];
|
|
167
|
+
}, {
|
|
168
|
+
readonly id: "south";
|
|
169
|
+
readonly name: "华南";
|
|
170
|
+
readonly prefixes: readonly [44, 45, 46];
|
|
171
|
+
}, {
|
|
172
|
+
readonly id: "southwest";
|
|
173
|
+
readonly name: "西南";
|
|
174
|
+
readonly prefixes: readonly [50, 51, 52, 53, 54];
|
|
175
|
+
}, {
|
|
176
|
+
readonly id: "northwest";
|
|
177
|
+
readonly name: "西北";
|
|
178
|
+
readonly prefixes: readonly [61, 62, 63, 64, 65];
|
|
179
|
+
}];
|
|
180
|
+
type RegionId = (typeof REGION_RULES)[number]['id'] | 'other';
|
|
181
|
+
declare const REGIONS: readonly {
|
|
182
|
+
readonly id: RegionId;
|
|
183
|
+
readonly name: string;
|
|
184
|
+
}[];
|
|
185
|
+
interface LibraryCity {
|
|
186
|
+
/** 6 位行政区划代码。 */
|
|
187
|
+
readonly adcode: string;
|
|
188
|
+
readonly name: string;
|
|
189
|
+
/** 所属省份(如「河北省」);直辖市为自身。 */
|
|
190
|
+
readonly province?: string;
|
|
191
|
+
readonly regionId: RegionId;
|
|
192
|
+
}
|
|
193
|
+
declare function regionOf(adcode: string): RegionId;
|
|
194
|
+
|
|
195
|
+
/** 本地存的一条:完整预设文档 + 缩略图。 */
|
|
196
|
+
interface LocalPresetRecord {
|
|
197
|
+
readonly document: PresetDocument;
|
|
198
|
+
readonly thumb?: string;
|
|
199
|
+
}
|
|
200
|
+
/** 本地存储接口。预设默认存上层传的 store;这个只给离线演示等场景显式开启。 */
|
|
201
|
+
interface PresetLibraryStorage {
|
|
202
|
+
load(): LocalPresetRecord[] | Promise<LocalPresetRecord[]>;
|
|
203
|
+
save(records: readonly LocalPresetRecord[]): void | Promise<void>;
|
|
204
|
+
}
|
|
205
|
+
declare const LOCAL_STORAGE_KEY = "smartearth-base.presets";
|
|
206
|
+
/** 用 localStorage 实现的本地存储(离线演示用;读失败当作空,写失败报错)。 */
|
|
207
|
+
declare function createLocalStorageStorage(key?: string): PresetLibraryStorage;
|
|
208
|
+
/** 本地数据源(显式开启)。 */
|
|
209
|
+
declare function localSource(storage: PresetLibraryStorage, label?: string): PresetSource;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* SDK 内置场景预设(sdk-render 4.x 的 7 个)。不分城市,套用走 environment.setPreset
|
|
213
|
+
* (渐变、高空延后、关镜面这些防护都在那里),不走整份导入。
|
|
214
|
+
*/
|
|
215
|
+
declare function builtinSource(options?: {
|
|
216
|
+
readonly transition?: number;
|
|
217
|
+
readonly label?: string;
|
|
218
|
+
}): PresetSource;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 业务集群预设服务(stratex-cluster `docs/api-v1.md`「地区预设 render-preset/1」)。
|
|
222
|
+
* 地址和令牌都由上层给:智作里是主进程的本机代理地址,转发到已部署的服务,如
|
|
223
|
+
* `https://sites.geovisearth.com/stratex-cluster/api/v1/presets`,令牌是 AEP 访问令牌。底座不存令牌。
|
|
224
|
+
*/
|
|
225
|
+
interface HttpPresetStoreOptions {
|
|
226
|
+
/** 预设接口根地址,到 `/presets` 为止,如 `https://sites.geovisearth.com/stratex-cluster/api/v1/presets`。 */
|
|
227
|
+
readonly baseUrl: string;
|
|
228
|
+
/** 每次请求现取的 Bearer 令牌;返回空或不给就不带(经上层代理附令牌时)。 */
|
|
229
|
+
readonly getToken?: () => string | null | undefined | Promise<string | null | undefined>;
|
|
230
|
+
/** 本集群编号:非管理员写入必填,读取时用来带出自己写的本集群版本。 */
|
|
231
|
+
readonly clusterId?: string;
|
|
232
|
+
/** 换请求方式(如 Electron 里走 IPC);默认全局 fetch。 */
|
|
233
|
+
readonly fetch?: typeof fetch;
|
|
234
|
+
/** 卡片上的来源名,默认「业务集群」。 */
|
|
235
|
+
readonly label?: string;
|
|
236
|
+
/** 预设里 time 字段(日期 + 时分)按哪个时区理解,默认 8(北京时间)。 */
|
|
237
|
+
readonly utcOffset?: number;
|
|
238
|
+
}
|
|
239
|
+
/** 去掉省 / 市等后缀,比较地区名。 */
|
|
240
|
+
declare function normalizeRegionName(name: string): string;
|
|
241
|
+
declare function httpPresetStore(options: HttpPresetStoreOptions): PresetSource;
|
|
242
|
+
|
|
243
|
+
interface PresetLibraryOptions {
|
|
244
|
+
/**
|
|
245
|
+
* 存预设的地方(可写数据源),由上层建好传进来,底座不认识地址和令牌。
|
|
246
|
+
* 智作里是 `httpPresetStore({ baseUrl, getToken, clusterId })`(业务集群预设服务)。没给就只能浏览、不能存。
|
|
247
|
+
*/
|
|
248
|
+
readonly store?: PresetSource;
|
|
249
|
+
/** 样板间储存桶(只读),默认开;false 关掉。 */
|
|
250
|
+
readonly bucket?: BucketSourceOptions | false;
|
|
251
|
+
/** SDK 内置场景预设,默认开。 */
|
|
252
|
+
readonly builtin?: boolean;
|
|
253
|
+
/** 浏览器本地存储,默认关;只给离线演示显式开启。 */
|
|
254
|
+
readonly storage?: PresetLibraryStorage;
|
|
255
|
+
/** 业务自己的数据源,排在内置的后面。 */
|
|
256
|
+
readonly sources?: readonly PresetSource[];
|
|
257
|
+
/** 城市列表接口,默认样板间同一个。 */
|
|
258
|
+
readonly cityListUrl?: string;
|
|
259
|
+
}
|
|
260
|
+
interface SavePresetOptions {
|
|
261
|
+
readonly name: string;
|
|
262
|
+
readonly desc?: string;
|
|
263
|
+
/** 归属城市(6 位 adcode);存业务集群时必填。 */
|
|
264
|
+
readonly adcode?: string;
|
|
265
|
+
readonly tags?: readonly string[];
|
|
266
|
+
/** 存下当前视角,默认 true;套用时默认不飞过去。 */
|
|
267
|
+
readonly camera?: boolean;
|
|
268
|
+
/** 截缩略图,默认 true。 */
|
|
269
|
+
readonly thumbnail?: boolean;
|
|
270
|
+
/** 存到哪个数据源(id),默认第一个可写的。 */
|
|
271
|
+
readonly target?: string;
|
|
272
|
+
}
|
|
273
|
+
interface PresetLibrary {
|
|
274
|
+
readonly sources: readonly PresetSource[];
|
|
275
|
+
readonly regions: typeof REGIONS;
|
|
276
|
+
/** 有没有可写的数据源。 */
|
|
277
|
+
readonly canSave: boolean;
|
|
278
|
+
listCities(): Promise<LibraryCity[]>;
|
|
279
|
+
/** 搜城市:城市名、省份、大区名,或看过的卡片名称 / 描述。 */
|
|
280
|
+
searchCities(query: string): Promise<LibraryCity[]>;
|
|
281
|
+
/** 卡片:各数据源合并(SDK 内置不分城市,总在最前)。 */
|
|
282
|
+
list(adcode?: string | number): Promise<PresetSummary[]>;
|
|
283
|
+
/** 取完整预设文档(SDK 内置没有,会报错)。 */
|
|
284
|
+
getDocument(card: PresetSummary): Promise<PresetDocument>;
|
|
285
|
+
/** 套用前的兼容提醒(版本不一致时有)。 */
|
|
286
|
+
compatibility(card: PresetSummary): string | null;
|
|
287
|
+
/** 预览:第一次预览前拍快照,之后套用这张卡。 */
|
|
288
|
+
preview(card: PresetSummary): Promise<void>;
|
|
289
|
+
confirmPreview(): void;
|
|
290
|
+
/** 取消预览:恢复到第一次预览前(含时间)。 */
|
|
291
|
+
cancelPreview(): Promise<void>;
|
|
292
|
+
readonly isPreviewing: boolean;
|
|
293
|
+
/** 套用;`camera: true` 时顺便飞到预设里存的视角(默认不飞)。 */
|
|
294
|
+
apply(card: PresetSummary, options?: {
|
|
295
|
+
readonly camera?: boolean;
|
|
296
|
+
}): Promise<void>;
|
|
297
|
+
/** 把当前环境存成预设(默认存第一个可写数据源,通常是业务集群)。 */
|
|
298
|
+
save(options: SavePresetOptions): Promise<PresetSummary>;
|
|
299
|
+
remove(card: PresetSummary): Promise<void>;
|
|
300
|
+
/** 把当前环境做成预设文档(不存):智作「冻结进工程」用。 */
|
|
301
|
+
documentFromCurrent(options: Omit<SavePresetOptions, 'thumbnail' | 'target'>): Promise<PresetDocument>;
|
|
302
|
+
/** 生成样板间储存桶的上传包(手动上传)。 */
|
|
303
|
+
bucketUploadPackage(adcode: string | number, options: SavePresetOptions): Promise<CityConfigDraft & {
|
|
304
|
+
thumb?: {
|
|
305
|
+
filename: string;
|
|
306
|
+
dataUrl: string;
|
|
307
|
+
};
|
|
308
|
+
}>;
|
|
309
|
+
}
|
|
310
|
+
declare function createPresetLibrary(earth: Earth, options?: PresetLibraryOptions): PresetLibrary;
|
|
311
|
+
|
|
312
|
+
export { type BucketSourceOptions, type CityConfigDraft, DEFAULT_CITY_CONFIG_BASE_URL, DEFAULT_CITY_LIST_URL, type HttpPresetStoreOptions, LOCAL_STORAGE_KEY, type LibraryCity, type LocalPresetRecord, type PresetDocument, type PresetDraft, type PresetLibrary, type PresetLibraryOptions, type PresetLibraryStorage, type PresetListQuery, type PresetSource, type PresetSummary, REGIONS, type RegionId, type SavePresetOptions, bucketSource, builtinSource, compatibilityNote, createLocalStorageStorage, createPresetLibrary, httpPresetStore, localSource, normalizeRegionName, regionOf, requireDocument, wrapLegacyConfig };
|
package/dist/presets.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { DEFAULT_CITY_CONFIG_BASE_URL, DEFAULT_CITY_LIST_URL, LOCAL_STORAGE_KEY, REGIONS, bucketSource, builtinSource, compatibilityNote, createLocalStorageStorage, createPresetLibrary, httpPresetStore, localSource, normalizeRegionName, regionOf, requireDocument, wrapLegacyConfig } from './chunk-POH7K3F4.js';
|
|
2
|
+
import './chunk-UENQT22J.js';
|