@jorgmoritz/gis-manager 0.1.27 → 0.1.29
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.cjs +445 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +139 -1
- package/dist/index.d.ts +139 -1
- package/dist/index.js +444 -29
- package/dist/index.js.map +1 -1
- package/dist/vue/index.cjs +442 -27
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +442 -27
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13,7 +13,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "@jorgmoritz/gis-manager",
|
|
16
|
-
version: "0.1.
|
|
16
|
+
version: "0.1.28"};
|
|
17
17
|
|
|
18
18
|
// src/utils/version.ts
|
|
19
19
|
var version = package_default.version;
|
|
@@ -1229,6 +1229,7 @@ var SceneManager = class {
|
|
|
1229
1229
|
const tileset = await this.apply3Dtiles(url);
|
|
1230
1230
|
if (tileset) {
|
|
1231
1231
|
tileset._customId = layer_id;
|
|
1232
|
+
tileset._url = url;
|
|
1232
1233
|
this.viewer.scene.primitives.add(tileset);
|
|
1233
1234
|
console.log(`[SceneManager] \u65B0\u5EFA 3DTiles_id`, tileset._customId);
|
|
1234
1235
|
}
|
|
@@ -1960,6 +1961,8 @@ var PathPreview = class {
|
|
|
1960
1961
|
__publicField(this, "fovController");
|
|
1961
1962
|
// FOV 控制器
|
|
1962
1963
|
__publicField(this, "currentFOV");
|
|
1964
|
+
/** 已加载的 3D Tiles 实例(预览窗口独立的) */
|
|
1965
|
+
__publicField(this, "tilesets", /* @__PURE__ */ new Map());
|
|
1963
1966
|
this.currentFOV = opts.fov ?? 50;
|
|
1964
1967
|
this.ensureViewer();
|
|
1965
1968
|
this.ensureFOVController();
|
|
@@ -2014,8 +2017,201 @@ var PathPreview = class {
|
|
|
2014
2017
|
}
|
|
2015
2018
|
} catch {
|
|
2016
2019
|
}
|
|
2017
|
-
v.scene;
|
|
2018
2020
|
this.overlayViewer = v;
|
|
2021
|
+
this.syncFromMainViewer();
|
|
2022
|
+
this.disableUserInteraction();
|
|
2023
|
+
}
|
|
2024
|
+
/**
|
|
2025
|
+
* 从主 viewer 同步配置
|
|
2026
|
+
* 共享 Provider(安全)而非 DataSource
|
|
2027
|
+
*/
|
|
2028
|
+
syncFromMainViewer() {
|
|
2029
|
+
if (!this.overlayViewer) return;
|
|
2030
|
+
this.syncImageryLayers();
|
|
2031
|
+
this.syncTerrainProvider();
|
|
2032
|
+
this.syncSceneSettings();
|
|
2033
|
+
this.sync3DTiles();
|
|
2034
|
+
}
|
|
2035
|
+
/**
|
|
2036
|
+
* 同步影像图层(共享 ImageryProvider)
|
|
2037
|
+
*/
|
|
2038
|
+
syncImageryLayers() {
|
|
2039
|
+
const v = this.overlayViewer;
|
|
2040
|
+
if (!v) return;
|
|
2041
|
+
try {
|
|
2042
|
+
v.imageryLayers?.removeAll?.();
|
|
2043
|
+
const mainImageryLayers = this.mainViewer.imageryLayers;
|
|
2044
|
+
for (let i = 0; i < mainImageryLayers.length; i++) {
|
|
2045
|
+
const layer = mainImageryLayers.get(i);
|
|
2046
|
+
try {
|
|
2047
|
+
v.imageryLayers?.addImageryProvider?.(layer.imageryProvider);
|
|
2048
|
+
} catch {
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
} catch (e) {
|
|
2052
|
+
console.warn("[PathPreview] Failed to sync imagery layers:", e);
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
/**
|
|
2056
|
+
* 同步地形提供者(共享 TerrainProvider)
|
|
2057
|
+
*/
|
|
2058
|
+
syncTerrainProvider() {
|
|
2059
|
+
const v = this.overlayViewer;
|
|
2060
|
+
if (!v) return;
|
|
2061
|
+
try {
|
|
2062
|
+
if (this.mainViewer.terrainProvider) {
|
|
2063
|
+
v.terrainProvider = this.mainViewer.terrainProvider;
|
|
2064
|
+
}
|
|
2065
|
+
} catch (e) {
|
|
2066
|
+
console.warn("[PathPreview] Failed to sync terrain provider:", e);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* 同步 3D Tiles(点云、倾斜摄影等)
|
|
2071
|
+
* 注意:Primitive 不能直接共享,需要创建独立实例
|
|
2072
|
+
* 此方法查找主 viewer 中的 tileset 并尝试使用相同 URL 创建新实例
|
|
2073
|
+
*/
|
|
2074
|
+
sync3DTiles() {
|
|
2075
|
+
const v = this.overlayViewer;
|
|
2076
|
+
if (!v) return;
|
|
2077
|
+
const C = this.CesiumNS;
|
|
2078
|
+
const mainPrimitives = this.mainViewer.scene.primitives;
|
|
2079
|
+
try {
|
|
2080
|
+
for (let i = 0; i < mainPrimitives.length; i++) {
|
|
2081
|
+
const primitive = mainPrimitives.get(i);
|
|
2082
|
+
if (primitive && primitive instanceof C.Cesium3DTileset) {
|
|
2083
|
+
const customId = primitive._customId;
|
|
2084
|
+
const url = primitive._url || primitive.resource?.url;
|
|
2085
|
+
if (url && customId && !this.tilesets.has(customId)) {
|
|
2086
|
+
this.add3DTiles(url, customId);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
} catch (e) {
|
|
2091
|
+
console.warn("[PathPreview] Failed to sync 3DTiles:", e);
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
/**
|
|
2095
|
+
* 手动添加 3D Tiles 到预览窗口
|
|
2096
|
+
* @param url 3D Tiles URL
|
|
2097
|
+
* @param id 唯一标识符
|
|
2098
|
+
*/
|
|
2099
|
+
async add3DTiles(url, id) {
|
|
2100
|
+
const v = this.overlayViewer;
|
|
2101
|
+
if (!v) return void 0;
|
|
2102
|
+
if (this.tilesets.has(id)) {
|
|
2103
|
+
return this.tilesets.get(id);
|
|
2104
|
+
}
|
|
2105
|
+
const C = this.CesiumNS;
|
|
2106
|
+
try {
|
|
2107
|
+
const tileset = await C.Cesium3DTileset.fromUrl(url, {
|
|
2108
|
+
maximumScreenSpaceError: 16
|
|
2109
|
+
});
|
|
2110
|
+
if (tileset) {
|
|
2111
|
+
tileset._customId = id;
|
|
2112
|
+
tileset._url = url;
|
|
2113
|
+
v.scene.primitives.add(tileset);
|
|
2114
|
+
this.tilesets.set(id, tileset);
|
|
2115
|
+
console.log("[PathPreview] Added 3DTiles:", id);
|
|
2116
|
+
}
|
|
2117
|
+
return tileset;
|
|
2118
|
+
} catch (e) {
|
|
2119
|
+
console.warn("[PathPreview] Failed to add 3DTiles:", url, e);
|
|
2120
|
+
return void 0;
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
/**
|
|
2124
|
+
* 移除 3D Tiles
|
|
2125
|
+
*/
|
|
2126
|
+
remove3DTiles(id) {
|
|
2127
|
+
const v = this.overlayViewer;
|
|
2128
|
+
if (!v) return;
|
|
2129
|
+
const tileset = this.tilesets.get(id);
|
|
2130
|
+
if (tileset) {
|
|
2131
|
+
try {
|
|
2132
|
+
v.scene.primitives.remove(tileset);
|
|
2133
|
+
} catch {
|
|
2134
|
+
}
|
|
2135
|
+
this.tilesets.delete(id);
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
/**
|
|
2139
|
+
* 同步场景设置(Globe、天空、雾效等)
|
|
2140
|
+
*/
|
|
2141
|
+
syncSceneSettings() {
|
|
2142
|
+
const v = this.overlayViewer;
|
|
2143
|
+
if (!v) return;
|
|
2144
|
+
const s = v.scene;
|
|
2145
|
+
const mainScene = this.mainViewer.scene;
|
|
2146
|
+
try {
|
|
2147
|
+
if (s.globe && mainScene.globe) {
|
|
2148
|
+
s.globe.show = mainScene.globe.show;
|
|
2149
|
+
s.globe.enableLighting = mainScene.globe.enableLighting;
|
|
2150
|
+
s.globe.baseColor = mainScene.globe.baseColor;
|
|
2151
|
+
s.globe.showGroundAtmosphere = mainScene.globe.showGroundAtmosphere;
|
|
2152
|
+
s.globe.depthTestAgainstTerrain = mainScene.globe.depthTestAgainstTerrain;
|
|
2153
|
+
}
|
|
2154
|
+
if (mainScene.skyBox) {
|
|
2155
|
+
s.skyBox = mainScene.skyBox;
|
|
2156
|
+
} else {
|
|
2157
|
+
s.skyBox = void 0;
|
|
2158
|
+
}
|
|
2159
|
+
if (mainScene.skyAtmosphere) {
|
|
2160
|
+
s.skyAtmosphere.show = mainScene.skyAtmosphere.show;
|
|
2161
|
+
}
|
|
2162
|
+
if (s.fog && mainScene.fog) {
|
|
2163
|
+
s.fog.enabled = mainScene.fog.enabled;
|
|
2164
|
+
s.fog.density = mainScene.fog.density;
|
|
2165
|
+
}
|
|
2166
|
+
v.shadows = this.mainViewer.shadows;
|
|
2167
|
+
if (s.postProcessStages?.fxaa && mainScene.postProcessStages?.fxaa) {
|
|
2168
|
+
s.postProcessStages.fxaa.enabled = mainScene.postProcessStages.fxaa.enabled;
|
|
2169
|
+
}
|
|
2170
|
+
} catch (e) {
|
|
2171
|
+
console.warn("[PathPreview] Failed to sync scene settings:", e);
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
/**
|
|
2175
|
+
* 禁用用户交互,相机仅通过 setPose() 控制
|
|
2176
|
+
*/
|
|
2177
|
+
disableUserInteraction() {
|
|
2178
|
+
const v = this.overlayViewer;
|
|
2179
|
+
if (!v) return;
|
|
2180
|
+
const s = v.scene;
|
|
2181
|
+
try {
|
|
2182
|
+
const scc = s.screenSpaceCameraController;
|
|
2183
|
+
if (scc) {
|
|
2184
|
+
scc.enableInputs = false;
|
|
2185
|
+
scc.enableRotate = false;
|
|
2186
|
+
scc.enableTranslate = false;
|
|
2187
|
+
scc.enableZoom = false;
|
|
2188
|
+
scc.enableTilt = false;
|
|
2189
|
+
scc.enableLook = false;
|
|
2190
|
+
scc.inertiaSpin = 0;
|
|
2191
|
+
scc.inertiaZoom = 0;
|
|
2192
|
+
scc.inertiaTranslate = 0;
|
|
2193
|
+
}
|
|
2194
|
+
const canvas = s?.canvas ?? v.scene?.canvas;
|
|
2195
|
+
if (canvas && canvas.style) {
|
|
2196
|
+
canvas.style.pointerEvents = "none";
|
|
2197
|
+
try {
|
|
2198
|
+
canvas.setAttribute("tabindex", "-1");
|
|
2199
|
+
} catch {
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
v.trackedEntity = void 0;
|
|
2203
|
+
if (v.clock) {
|
|
2204
|
+
v.clock.shouldAnimate = false;
|
|
2205
|
+
}
|
|
2206
|
+
} catch (e) {
|
|
2207
|
+
console.warn("[PathPreview] Failed to disable user interaction:", e);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
/**
|
|
2211
|
+
* 刷新同步(运行时更新)
|
|
2212
|
+
*/
|
|
2213
|
+
refresh() {
|
|
2214
|
+
this.syncFromMainViewer();
|
|
2019
2215
|
}
|
|
2020
2216
|
/**
|
|
2021
2217
|
* 创建 FOV 控制器
|
|
@@ -2177,30 +2373,63 @@ var PathPreview = class {
|
|
|
2177
2373
|
this.fovController.hide();
|
|
2178
2374
|
}
|
|
2179
2375
|
}
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2376
|
+
/**
|
|
2377
|
+
* 显示预览窗口
|
|
2378
|
+
*/
|
|
2379
|
+
show() {
|
|
2380
|
+
if (this.containerEl) {
|
|
2381
|
+
this.containerEl.style.display = "block";
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
/**
|
|
2385
|
+
* 隐藏预览窗口
|
|
2386
|
+
*/
|
|
2387
|
+
hide() {
|
|
2388
|
+
if (this.containerEl) {
|
|
2389
|
+
this.containerEl.style.display = "none";
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
/**
|
|
2393
|
+
* 获取预览 viewer 实例
|
|
2394
|
+
*/
|
|
2395
|
+
getOverlayViewer() {
|
|
2396
|
+
return this.overlayViewer;
|
|
2397
|
+
}
|
|
2398
|
+
/**
|
|
2399
|
+
* 销毁预览窗口,释放所有资源
|
|
2400
|
+
*/
|
|
2401
|
+
destroy() {
|
|
2402
|
+
if (this.destroyed) return;
|
|
2403
|
+
this.destroyed = true;
|
|
2404
|
+
try {
|
|
2405
|
+
this.fovController?.destroy();
|
|
2406
|
+
} catch {
|
|
2407
|
+
}
|
|
2408
|
+
this.fovController = void 0;
|
|
2409
|
+
this.footprintEntity = void 0;
|
|
2410
|
+
try {
|
|
2411
|
+
this.tilesets.forEach((tileset) => {
|
|
2412
|
+
try {
|
|
2413
|
+
this.overlayViewer?.scene?.primitives?.remove?.(tileset);
|
|
2414
|
+
} catch {
|
|
2415
|
+
}
|
|
2416
|
+
});
|
|
2417
|
+
this.tilesets.clear();
|
|
2418
|
+
} catch {
|
|
2419
|
+
}
|
|
2420
|
+
try {
|
|
2421
|
+
this.overlayViewer?.destroy?.();
|
|
2422
|
+
} catch {
|
|
2423
|
+
}
|
|
2424
|
+
this.overlayViewer = void 0;
|
|
2425
|
+
try {
|
|
2426
|
+
if (this.containerEl && this.containerEl.parentElement) {
|
|
2427
|
+
this.containerEl.parentElement.removeChild(this.containerEl);
|
|
2428
|
+
}
|
|
2429
|
+
} catch {
|
|
2430
|
+
}
|
|
2431
|
+
this.containerEl = void 0;
|
|
2432
|
+
}
|
|
2204
2433
|
};
|
|
2205
2434
|
|
|
2206
2435
|
// src/core/path-manager/FrustumPyramid.ts
|
|
@@ -4088,6 +4317,7 @@ var PathEditingEventHandler = class {
|
|
|
4088
4317
|
__publicField(this, "contextMenuManager");
|
|
4089
4318
|
__publicField(this, "vertexDragHandler");
|
|
4090
4319
|
__publicField(this, "callbacks");
|
|
4320
|
+
__publicField(this, "keydownListener");
|
|
4091
4321
|
this.CesiumNS = options.CesiumNS;
|
|
4092
4322
|
this.viewer = options.viewer;
|
|
4093
4323
|
this.hiddenClimbIndex = options.hiddenClimbIndex;
|
|
@@ -4212,6 +4442,37 @@ var PathEditingEventHandler = class {
|
|
|
4212
4442
|
}
|
|
4213
4443
|
this.handleRightClick(movement);
|
|
4214
4444
|
}, C.ScreenSpaceEventType.RIGHT_CLICK);
|
|
4445
|
+
this.keydownListener = (e) => {
|
|
4446
|
+
if (e.code !== "Space") return;
|
|
4447
|
+
const target = e.target;
|
|
4448
|
+
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) {
|
|
4449
|
+
return;
|
|
4450
|
+
}
|
|
4451
|
+
if (this.vertexDragHandler.isDragging()) return;
|
|
4452
|
+
e.preventDefault();
|
|
4453
|
+
this.handleSpaceKeyInsert();
|
|
4454
|
+
};
|
|
4455
|
+
document.addEventListener("keydown", this.keydownListener);
|
|
4456
|
+
}
|
|
4457
|
+
/**
|
|
4458
|
+
* 处理空格键快捷插入航点
|
|
4459
|
+
* 在飞机游标当前位置,将航点添加到所有航点末尾
|
|
4460
|
+
*/
|
|
4461
|
+
handleSpaceKeyInsert() {
|
|
4462
|
+
const airplaneCursor = this.callbacks.getAirplaneCursor?.();
|
|
4463
|
+
if (!airplaneCursor) {
|
|
4464
|
+
console.warn("[PathEditingEventHandler] \u7A7A\u683C\u952E\u63D2\u5165\uFF1A\u98DE\u673A\u6E38\u6807\u4E0D\u5B58\u5728");
|
|
4465
|
+
return;
|
|
4466
|
+
}
|
|
4467
|
+
const pose = airplaneCursor.getPose();
|
|
4468
|
+
if (!pose || !pose.position) {
|
|
4469
|
+
console.warn("[PathEditingEventHandler] \u7A7A\u683C\u952E\u63D2\u5165\uFF1A\u65E0\u6CD5\u83B7\u53D6\u6E38\u6807\u59FF\u6001");
|
|
4470
|
+
return;
|
|
4471
|
+
}
|
|
4472
|
+
const positions = this.callbacks.getPositions?.() || [];
|
|
4473
|
+
const insertAt = positions.length;
|
|
4474
|
+
console.log("[PathEditingEventHandler] \u7A7A\u683C\u952E\u5FEB\u6377\u63D2\u5165\u822A\u70B9\uFF0C\u4F4D\u7F6E\u7D22\u5F15:", insertAt);
|
|
4475
|
+
this.handleInsertVertex(insertAt, pose, "after");
|
|
4215
4476
|
}
|
|
4216
4477
|
/**
|
|
4217
4478
|
* 处理右键点击事件
|
|
@@ -4226,12 +4487,13 @@ var PathEditingEventHandler = class {
|
|
|
4226
4487
|
const entity = picked?.id;
|
|
4227
4488
|
const airplaneCursor = this.callbacks.getAirplaneCursor?.();
|
|
4228
4489
|
const vertexIndex = pickVertexIndex(this.viewer, movement.position, this.hiddenClimbIndex);
|
|
4490
|
+
const viewportPosition = this.canvasToViewportPosition(movement.position);
|
|
4229
4491
|
if (typeof vertexIndex === "number") {
|
|
4230
4492
|
const menuItems = this.buildVertexContextMenuItems(vertexIndex);
|
|
4231
|
-
this.contextMenuManager.show(
|
|
4493
|
+
this.contextMenuManager.show(viewportPosition, menuItems);
|
|
4232
4494
|
} else if (airplaneCursor && airplaneCursor.containsEntity(entity)) {
|
|
4233
4495
|
const menuItems = this.buildAirplaneCursorContextMenuItems();
|
|
4234
|
-
this.contextMenuManager.show(
|
|
4496
|
+
this.contextMenuManager.show(viewportPosition, menuItems);
|
|
4235
4497
|
}
|
|
4236
4498
|
} catch (error) {
|
|
4237
4499
|
console.error("Error handling right click:", error);
|
|
@@ -4535,6 +4797,18 @@ var PathEditingEventHandler = class {
|
|
|
4535
4797
|
return 0;
|
|
4536
4798
|
}
|
|
4537
4799
|
}
|
|
4800
|
+
/**
|
|
4801
|
+
* 将 canvas 坐标转换为视口坐标
|
|
4802
|
+
* Cesium 事件返回的坐标是相对于 canvas 的,而菜单需要相对于视口的坐标
|
|
4803
|
+
*/
|
|
4804
|
+
canvasToViewportPosition(canvasPosition) {
|
|
4805
|
+
const canvas = this.viewer.scene.canvas;
|
|
4806
|
+
const rect = canvas.getBoundingClientRect();
|
|
4807
|
+
return {
|
|
4808
|
+
x: canvasPosition.x + rect.left,
|
|
4809
|
+
y: canvasPosition.y + rect.top
|
|
4810
|
+
};
|
|
4811
|
+
}
|
|
4538
4812
|
/**
|
|
4539
4813
|
* 🆕 从鼠标事件获取位置
|
|
4540
4814
|
*/
|
|
@@ -4560,6 +4834,10 @@ var PathEditingEventHandler = class {
|
|
|
4560
4834
|
* 销毁事件处理器
|
|
4561
4835
|
*/
|
|
4562
4836
|
destroy() {
|
|
4837
|
+
if (this.keydownListener) {
|
|
4838
|
+
document.removeEventListener("keydown", this.keydownListener);
|
|
4839
|
+
this.keydownListener = void 0;
|
|
4840
|
+
}
|
|
4563
4841
|
try {
|
|
4564
4842
|
this.vertexDragHandler.destroy();
|
|
4565
4843
|
} catch {
|
|
@@ -6460,6 +6738,98 @@ function renderFlightPath(CesiumNS, viewer, options) {
|
|
|
6460
6738
|
}
|
|
6461
6739
|
return entity;
|
|
6462
6740
|
}
|
|
6741
|
+
function renderFlightPathPreview(CesiumNS, viewer, options) {
|
|
6742
|
+
const C = CesiumNS;
|
|
6743
|
+
const entity = renderFlightPath(CesiumNS, viewer, options);
|
|
6744
|
+
const vertexLabelManager = entity._vertexLabelManager;
|
|
6745
|
+
let selectedWaypointIndex = options.initialSelectedIndex ?? null;
|
|
6746
|
+
const polyline = entity.polyline;
|
|
6747
|
+
let positions = [];
|
|
6748
|
+
if (polyline && polyline.positions) {
|
|
6749
|
+
const posValue = polyline.positions.getValue?.(C.JulianDate.now());
|
|
6750
|
+
if (Array.isArray(posValue)) {
|
|
6751
|
+
positions = posValue;
|
|
6752
|
+
}
|
|
6753
|
+
}
|
|
6754
|
+
let waypointDataArray = [];
|
|
6755
|
+
try {
|
|
6756
|
+
const adapterOptions = {
|
|
6757
|
+
CesiumNS,
|
|
6758
|
+
...options.adapterOptions
|
|
6759
|
+
};
|
|
6760
|
+
const converted = convertSinoflyWayline(options.data, adapterOptions);
|
|
6761
|
+
if (converted && converted.waypointData) {
|
|
6762
|
+
waypointDataArray = [...converted.waypointData].sort((a, b) => a.index - b.index);
|
|
6763
|
+
}
|
|
6764
|
+
} catch (e) {
|
|
6765
|
+
console.warn("[renderFlightPathPreview] \u65E0\u6CD5\u83B7\u53D6\u822A\u70B9\u6570\u636E:", e);
|
|
6766
|
+
}
|
|
6767
|
+
const hasHiddenClimb = entity.properties?._hasHiddenClimb?.getValue?.() ?? false;
|
|
6768
|
+
const hiddenClimbIndex = hasHiddenClimb ? 1 : void 0;
|
|
6769
|
+
const updateWaypointHighlight = (newIndex) => {
|
|
6770
|
+
if (!vertexLabelManager || positions.length === 0) return;
|
|
6771
|
+
const editedIndices = /* @__PURE__ */ new Set();
|
|
6772
|
+
vertexLabelManager.recreateAllLabels(positions, editedIndices, newIndex ?? void 0);
|
|
6773
|
+
};
|
|
6774
|
+
if (selectedWaypointIndex !== null) {
|
|
6775
|
+
updateWaypointHighlight(selectedWaypointIndex);
|
|
6776
|
+
}
|
|
6777
|
+
const handler = new C.ScreenSpaceEventHandler(viewer.scene.canvas);
|
|
6778
|
+
handler.setInputAction((movement) => {
|
|
6779
|
+
const pickedObject = viewer.scene.pick(movement.position);
|
|
6780
|
+
if (C.defined(pickedObject) && pickedObject.id) {
|
|
6781
|
+
const pickedEntity = pickedObject.id;
|
|
6782
|
+
const properties = pickedEntity.properties;
|
|
6783
|
+
if (properties) {
|
|
6784
|
+
const type = properties._type?.getValue?.(C.JulianDate.now());
|
|
6785
|
+
const ownerId = properties._ownerId?.getValue?.(C.JulianDate.now());
|
|
6786
|
+
const vertexIndex = properties._vertexIndex?.getValue?.(C.JulianDate.now());
|
|
6787
|
+
if (type === "vertex-label" && ownerId === entity.id && vertexIndex !== void 0) {
|
|
6788
|
+
let displayIndex = vertexIndex;
|
|
6789
|
+
if (hiddenClimbIndex === 1) {
|
|
6790
|
+
if (vertexIndex >= 2) {
|
|
6791
|
+
displayIndex = vertexIndex - 2;
|
|
6792
|
+
}
|
|
6793
|
+
} else {
|
|
6794
|
+
displayIndex = vertexIndex;
|
|
6795
|
+
}
|
|
6796
|
+
selectedWaypointIndex = vertexIndex;
|
|
6797
|
+
updateWaypointHighlight(selectedWaypointIndex);
|
|
6798
|
+
if (options.onWaypointClick) {
|
|
6799
|
+
const waypointData = waypointDataArray.find((wp) => wp.index === vertexIndex);
|
|
6800
|
+
options.onWaypointClick(displayIndex, waypointData);
|
|
6801
|
+
}
|
|
6802
|
+
}
|
|
6803
|
+
}
|
|
6804
|
+
}
|
|
6805
|
+
}, C.ScreenSpaceEventType.LEFT_CLICK);
|
|
6806
|
+
const controller = {
|
|
6807
|
+
setSelectedWaypoint: (index) => {
|
|
6808
|
+
if (index === null) {
|
|
6809
|
+
selectedWaypointIndex = null;
|
|
6810
|
+
updateWaypointHighlight(null);
|
|
6811
|
+
return;
|
|
6812
|
+
}
|
|
6813
|
+
let actualIndex = index;
|
|
6814
|
+
if (hiddenClimbIndex === 1) {
|
|
6815
|
+
actualIndex = index + 2;
|
|
6816
|
+
}
|
|
6817
|
+
selectedWaypointIndex = actualIndex;
|
|
6818
|
+
updateWaypointHighlight(selectedWaypointIndex);
|
|
6819
|
+
},
|
|
6820
|
+
getSelectedWaypoint: () => {
|
|
6821
|
+
if (selectedWaypointIndex === null) return null;
|
|
6822
|
+
if (hiddenClimbIndex === 1) {
|
|
6823
|
+
return selectedWaypointIndex >= 2 ? selectedWaypointIndex - 2 : null;
|
|
6824
|
+
}
|
|
6825
|
+
return selectedWaypointIndex;
|
|
6826
|
+
},
|
|
6827
|
+
destroy: () => {
|
|
6828
|
+
handler.destroy();
|
|
6829
|
+
}
|
|
6830
|
+
};
|
|
6831
|
+
return { entity, controller };
|
|
6832
|
+
}
|
|
6463
6833
|
|
|
6464
6834
|
// src/core/CZMLPathManager.ts
|
|
6465
6835
|
var _CZMLPathManager = class _CZMLPathManager {
|
|
@@ -6543,6 +6913,37 @@ var _CZMLPathManager = class _CZMLPathManager {
|
|
|
6543
6913
|
renderFlightPath(options) {
|
|
6544
6914
|
return renderFlightPath(this.CesiumNS, this.viewer, options);
|
|
6545
6915
|
}
|
|
6916
|
+
/**
|
|
6917
|
+
* 预览模式渲染飞航路线:支持航点点击高亮
|
|
6918
|
+
*
|
|
6919
|
+
* 与 renderFlightPath 不同,此方法返回一个控制器对象,支持:
|
|
6920
|
+
* - 航点点击事件回调
|
|
6921
|
+
* - 程序化设置选中航点(高亮显示)
|
|
6922
|
+
* - 列表与地图双向联动
|
|
6923
|
+
*
|
|
6924
|
+
* @param options 预览选项
|
|
6925
|
+
* @returns 包含实体和控制器的对象
|
|
6926
|
+
*
|
|
6927
|
+
* @example
|
|
6928
|
+
* ```typescript
|
|
6929
|
+
* const { entity, controller } = pathManager.renderFlightPathPreview({
|
|
6930
|
+
* data: sinoflyData,
|
|
6931
|
+
* onWaypointClick: (index, waypoint) => {
|
|
6932
|
+
* console.log('点击了航点', index, waypoint);
|
|
6933
|
+
* },
|
|
6934
|
+
* initialSelectedIndex: 0
|
|
6935
|
+
* });
|
|
6936
|
+
*
|
|
6937
|
+
* // 程序化设置选中航点
|
|
6938
|
+
* controller.setSelectedWaypoint(2);
|
|
6939
|
+
*
|
|
6940
|
+
* // 销毁
|
|
6941
|
+
* controller.destroy();
|
|
6942
|
+
* ```
|
|
6943
|
+
*/
|
|
6944
|
+
renderFlightPathPreview(options) {
|
|
6945
|
+
return renderFlightPathPreview(this.CesiumNS, this.viewer, options);
|
|
6946
|
+
}
|
|
6546
6947
|
resolveEntity(entityOrId) {
|
|
6547
6948
|
return typeof entityOrId === "string" ? this.viewer.entities.getById(entityOrId) : entityOrId;
|
|
6548
6949
|
}
|
|
@@ -9432,6 +9833,20 @@ var CZMLManager = class {
|
|
|
9432
9833
|
renderFlightPath(options) {
|
|
9433
9834
|
return this.pathMgr.renderFlightPath(options);
|
|
9434
9835
|
}
|
|
9836
|
+
/**
|
|
9837
|
+
* 预览模式渲染飞航路线:支持航点点击高亮
|
|
9838
|
+
*
|
|
9839
|
+
* 与 renderFlightPath 不同,此方法返回一个控制器对象,支持:
|
|
9840
|
+
* - 航点点击事件回调
|
|
9841
|
+
* - 程序化设置选中航点(高亮显示)
|
|
9842
|
+
* - 列表与地图双向联动
|
|
9843
|
+
*
|
|
9844
|
+
* @param options 预览选项
|
|
9845
|
+
* @returns 包含实体和控制器的对象
|
|
9846
|
+
*/
|
|
9847
|
+
renderFlightPathPreview(options) {
|
|
9848
|
+
return this.pathMgr.renderFlightPathPreview(options);
|
|
9849
|
+
}
|
|
9435
9850
|
addPathSample(entityOrId, sample) {
|
|
9436
9851
|
return this.pathMgr.addPathSample(entityOrId, sample);
|
|
9437
9852
|
}
|
|
@@ -10496,6 +10911,8 @@ exports.getCesiumIonToken = getCesiumIonToken;
|
|
|
10496
10911
|
exports.globalCameraEventBus = globalCameraEventBus;
|
|
10497
10912
|
exports.globalState = globalState;
|
|
10498
10913
|
exports.placeholder = placeholder;
|
|
10914
|
+
exports.renderFlightPath = renderFlightPath;
|
|
10915
|
+
exports.renderFlightPathPreview = renderFlightPathPreview;
|
|
10499
10916
|
exports.toggle2D3D = toggle2D3D;
|
|
10500
10917
|
exports.version = version;
|
|
10501
10918
|
exports.versionInfo = versionInfo;
|