@jorgmoritz/gis-manager 0.1.38 → 0.1.40

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 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.37"};
16
+ version: "0.1.40"};
17
17
 
18
18
  // src/utils/version.ts
19
19
  var version = package_default.version;
@@ -1553,6 +1553,11 @@ var HeightMarker = class {
1553
1553
  }
1554
1554
  };
1555
1555
 
1556
+ // src/core/path-manager/constants.ts
1557
+ var DEFAULT_FOV = 172;
1558
+ var SENSOR_WIDTH = 36;
1559
+ var FOCAL_LENGTH_PRESETS = [112, 56, 14, 7, 3, 1];
1560
+
1556
1561
  // src/core/path-manager/CameraFOVController.ts
1557
1562
  var CameraFOVController = class {
1558
1563
  constructor(opts = {}) {
@@ -1584,8 +1589,8 @@ var CameraFOVController = class {
1584
1589
  this.updateDisplay();
1585
1590
  this.emitChange();
1586
1591
  });
1587
- this.sensorWidth = opts.sensorWidth ?? 36;
1588
- this.focalLengthPresets = opts.focalLengthPresets ?? [112, 56, 14, 7, 3, 1];
1592
+ this.sensorWidth = opts.sensorWidth ?? SENSOR_WIDTH;
1593
+ this.focalLengthPresets = opts.focalLengthPresets ?? FOCAL_LENGTH_PRESETS;
1589
1594
  if (opts.minFOV === void 0 || opts.maxFOV === void 0) {
1590
1595
  const minFocalLength = Math.min(...this.focalLengthPresets);
1591
1596
  const maxFocalLength = Math.max(...this.focalLengthPresets);
@@ -1595,7 +1600,7 @@ var CameraFOVController = class {
1595
1600
  this.minFOV = opts.minFOV;
1596
1601
  this.maxFOV = opts.maxFOV;
1597
1602
  }
1598
- this.currentFOV = opts.initialFOV ?? this.focalLengthToFOVDirect(56);
1603
+ this.currentFOV = opts.initialFOV ?? DEFAULT_FOV;
1599
1604
  this.useGlobalEventBus = opts.useGlobalEventBus ?? true;
1600
1605
  this.createUI();
1601
1606
  this.setupExternalFOVListener();
@@ -1945,7 +1950,7 @@ var CameraFOVController = class {
1945
1950
 
1946
1951
  // src/core/path-manager/PathPreview.ts
1947
1952
  var PathPreview = class {
1948
- // 当前 FOV 值
1953
+ // 折叠按钮
1949
1954
  constructor(CesiumNS, mainViewer, opts = {}) {
1950
1955
  this.CesiumNS = CesiumNS;
1951
1956
  this.mainViewer = mainViewer;
@@ -1954,16 +1959,18 @@ var PathPreview = class {
1954
1959
  // Lightweight overlay viewer
1955
1960
  __publicField(this, "containerEl");
1956
1961
  // Container for the overlay viewer
1957
- __publicField(this, "footprintEntity");
1958
- // Entity for ground footprint polygon
1959
1962
  __publicField(this, "destroyed", false);
1960
1963
  // Track if the instance has been destroyed
1961
1964
  __publicField(this, "fovController");
1962
1965
  // FOV 控制器
1963
1966
  __publicField(this, "currentFOV");
1967
+ // 当前 FOV 值
1968
+ __publicField(this, "collapsed", false);
1969
+ // 折叠状态
1970
+ __publicField(this, "toggleBtn");
1964
1971
  /** 已加载的 3D Tiles 实例(预览窗口独立的) */
1965
1972
  __publicField(this, "tilesets", /* @__PURE__ */ new Map());
1966
- this.currentFOV = opts.fov ?? 50;
1973
+ this.currentFOV = opts.fov ?? DEFAULT_FOV;
1967
1974
  this.ensureViewer();
1968
1975
  this.ensureFOVController();
1969
1976
  }
@@ -1975,9 +1982,9 @@ var PathPreview = class {
1975
1982
  host = document.createElement("div");
1976
1983
  host.style.position = "absolute";
1977
1984
  host.style.right = "10px";
1978
- host.style.bottom = "10px";
1979
- host.style.width = "480px";
1980
- host.style.height = "320px";
1985
+ host.style.bottom = "80px";
1986
+ host.style.width = "320px";
1987
+ host.style.height = "200px";
1981
1988
  host.style.border = "1px solid rgba(255, 255, 255, 1)";
1982
1989
  host.style.borderRadius = "6px";
1983
1990
  host.style.overflow = "hidden";
@@ -1987,6 +1994,7 @@ var PathPreview = class {
1987
1994
  parent?.appendChild(host);
1988
1995
  } catch {
1989
1996
  }
1997
+ this.createToggleButton(host);
1990
1998
  }
1991
1999
  this.containerEl = host;
1992
2000
  const v = new C.Viewer(host, {
@@ -2021,6 +2029,157 @@ var PathPreview = class {
2021
2029
  this.syncFromMainViewer();
2022
2030
  this.disableUserInteraction();
2023
2031
  }
2032
+ /**
2033
+ * 创建折叠按钮
2034
+ */
2035
+ createToggleButton(container) {
2036
+ if (typeof document === "undefined") return;
2037
+ this.toggleBtn = document.createElement("div");
2038
+ this.toggleBtn.style.cssText = `
2039
+ position: absolute;
2040
+ top: 6px;
2041
+ left: 6px;
2042
+ width: 24px;
2043
+ height: 24px;
2044
+ background: rgba(0, 0, 0, 0.6);
2045
+ border: 1px solid rgba(255, 255, 255, 0.5);
2046
+ border-radius: 4px;
2047
+ cursor: pointer;
2048
+ z-index: 20;
2049
+ display: flex;
2050
+ align-items: center;
2051
+ justify-content: center;
2052
+ transition: all 0.2s;
2053
+ pointer-events: auto;
2054
+ `;
2055
+ this.toggleBtn.innerHTML = `
2056
+ <svg width="12" height="12" viewBox="0 0 12 12" fill="white" style="transition: transform 0.2s;">
2057
+ <path d="M4 2 L8 6 L4 10" stroke="white" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
2058
+ </svg>
2059
+ `;
2060
+ this.toggleBtn.addEventListener("mouseenter", () => {
2061
+ if (this.toggleBtn) {
2062
+ this.toggleBtn.style.background = "rgba(47, 119, 251, 0.8)";
2063
+ }
2064
+ });
2065
+ this.toggleBtn.addEventListener("mouseleave", () => {
2066
+ if (this.toggleBtn) {
2067
+ this.toggleBtn.style.background = "rgba(0, 0, 0, 0.6)";
2068
+ }
2069
+ });
2070
+ this.toggleBtn.addEventListener("click", (e) => {
2071
+ e.stopPropagation();
2072
+ this.toggle();
2073
+ });
2074
+ container.appendChild(this.toggleBtn);
2075
+ }
2076
+ /**
2077
+ * 切换折叠状态
2078
+ */
2079
+ toggle() {
2080
+ if (this.collapsed) {
2081
+ this.expand();
2082
+ } else {
2083
+ this.collapse();
2084
+ }
2085
+ }
2086
+ /**
2087
+ * 折叠预览窗口
2088
+ */
2089
+ collapse() {
2090
+ if (this.collapsed || !this.containerEl) return;
2091
+ this.collapsed = true;
2092
+ this.containerEl.dataset.originalWidth = this.containerEl.style.width;
2093
+ this.containerEl.dataset.originalHeight = this.containerEl.style.height;
2094
+ this.containerEl.style.width = "36px";
2095
+ this.containerEl.style.height = "36px";
2096
+ this.containerEl.style.overflow = "hidden";
2097
+ if (this.overlayViewer) {
2098
+ const viewerContainer = this.overlayViewer.container;
2099
+ if (viewerContainer) {
2100
+ viewerContainer.style.display = "none";
2101
+ }
2102
+ }
2103
+ this.hideFOVController();
2104
+ if (this.toggleBtn) {
2105
+ this.toggleBtn.style.cssText = `
2106
+ position: absolute;
2107
+ top: 2px;
2108
+ left: 2px;
2109
+ right: 2px;
2110
+ bottom: 2px;
2111
+ width: auto;
2112
+ height: auto;
2113
+ background: rgba(47, 119, 251, 0.9);
2114
+ border: 1px solid rgba(255, 255, 255, 0.8);
2115
+ border-radius: 4px;
2116
+ cursor: pointer;
2117
+ z-index: 20;
2118
+ display: flex;
2119
+ align-items: center;
2120
+ justify-content: center;
2121
+ transition: all 0.2s;
2122
+ pointer-events: auto;
2123
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
2124
+ `;
2125
+ this.toggleBtn.innerHTML = `
2126
+ <svg width="16" height="16" viewBox="0 0 12 12" fill="white">
2127
+ <path d="M8 2 L4 6 L8 10" stroke="white" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
2128
+ </svg>
2129
+ `;
2130
+ }
2131
+ this.containerEl.style.display = "block";
2132
+ }
2133
+ /**
2134
+ * 展开预览窗口
2135
+ */
2136
+ expand() {
2137
+ if (!this.collapsed || !this.containerEl) return;
2138
+ this.collapsed = false;
2139
+ this.containerEl.style.width = this.containerEl.dataset.originalWidth || "320px";
2140
+ this.containerEl.style.height = this.containerEl.dataset.originalHeight || "200px";
2141
+ if (this.overlayViewer) {
2142
+ const viewerContainer = this.overlayViewer.container;
2143
+ if (viewerContainer) {
2144
+ viewerContainer.style.display = "block";
2145
+ }
2146
+ }
2147
+ this.showFOVController();
2148
+ if (this.toggleBtn) {
2149
+ this.toggleBtn.style.cssText = `
2150
+ position: absolute;
2151
+ top: 6px;
2152
+ left: 6px;
2153
+ width: 24px;
2154
+ height: 24px;
2155
+ background: rgba(0, 0, 0, 0.6);
2156
+ border: 1px solid rgba(255, 255, 255, 0.5);
2157
+ border-radius: 4px;
2158
+ cursor: pointer;
2159
+ z-index: 20;
2160
+ display: flex;
2161
+ align-items: center;
2162
+ justify-content: center;
2163
+ transition: all 0.2s;
2164
+ pointer-events: auto;
2165
+ `;
2166
+ this.toggleBtn.innerHTML = `
2167
+ <svg width="12" height="12" viewBox="0 0 12 12" fill="white">
2168
+ <path d="M4 2 L8 6 L4 10" stroke="white" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
2169
+ </svg>
2170
+ `;
2171
+ }
2172
+ try {
2173
+ this.overlayViewer?.scene?.requestRender?.();
2174
+ } catch {
2175
+ }
2176
+ }
2177
+ /**
2178
+ * 获取折叠状态
2179
+ */
2180
+ isCollapsed() {
2181
+ return this.collapsed;
2182
+ }
2024
2183
  /**
2025
2184
  * 从主 viewer 同步配置
2026
2185
  * 共享 Provider(安全)而非 DataSource
@@ -2276,28 +2435,6 @@ var PathPreview = class {
2276
2435
  console.warn("[PathPreview] Failed to update FOV:", e);
2277
2436
  }
2278
2437
  }
2279
- // private ensureFootprint(): void {
2280
- // const C: any = this.CesiumNS as any;
2281
- // if (this.footprintEntity) return;
2282
- // this.footprintEntity = (this.layer.entities as any).add({
2283
- // polygon: {
2284
- // // Only show when we have at least 3 ground hit points
2285
- // show: new C.CallbackProperty(() => (this._footprintPositions?.length ?? 0) >= 3, false),
2286
- // hierarchy: new C.CallbackProperty(() => {
2287
- // const arr = this._footprintPositions;
2288
- // return arr && arr.length >= 3 ? arr.slice() : undefined;
2289
- // }, false),
2290
- // material: C.Color.CYAN.withAlpha(0.18),
2291
- // outline: true,
2292
- // outlineColor: C.Color.CYAN.withAlpha(0.7),
2293
- // outlineWidth: 1,
2294
- // // Use per-position heights from globe intersections to avoid terrain-ground primitive path
2295
- // perPositionHeight: true,
2296
- // },
2297
- // properties: { _type: 'preview-footprint' },
2298
- // });
2299
- // }
2300
- // private _footprintPositions: any[] | undefined;
2301
2438
  /**
2302
2439
  * Set the camera pose and field of view for the overlay viewer.
2303
2440
  * @param cartesian cartesian position
@@ -2317,29 +2454,6 @@ var PathPreview = class {
2317
2454
  orientation: { heading: h, pitch: p, roll: r }
2318
2455
  });
2319
2456
  }
2320
- // // Recompute footprint using overlay scene
2321
- // try {
2322
- // const scene: any = v.scene;
2323
- // const w = scene?.canvas?.width ?? 256;
2324
- // const hgt = scene?.canvas?.height ?? 144;
2325
- // const corners = [
2326
- // new C.Cartesian2(2, 2),
2327
- // new C.Cartesian2(w - 2, 2),
2328
- // new C.Cartesian2(w - 2, hgt - 2),
2329
- // new C.Cartesian2(2, hgt - 2),
2330
- // ];
2331
- // const pts: any[] = [];
2332
- // for (const c of corners) {
2333
- // const ray = v.camera.getPickRay(c);
2334
- // if (!ray) continue;
2335
- // const hit = scene.globe?.pick?.(ray, scene);
2336
- // if (hit) pts.push(hit);
2337
- // }
2338
- // // this._footprintPositions = pts.length >= 3 ? pts : undefined;
2339
- // v.scene?.requestRender?.();
2340
- // (this.mainViewer.scene as any)?.requestRender?.();
2341
- // } catch {}
2342
- // }
2343
2457
  /**
2344
2458
  * 设置 FOV(如果启用了 FOV 控制器)
2345
2459
  */
@@ -2406,7 +2520,11 @@ var PathPreview = class {
2406
2520
  } catch {
2407
2521
  }
2408
2522
  this.fovController = void 0;
2409
- this.footprintEntity = void 0;
2523
+ try {
2524
+ this.toggleBtn?.remove();
2525
+ } catch {
2526
+ }
2527
+ this.toggleBtn = void 0;
2410
2528
  try {
2411
2529
  this.tilesets.forEach((tileset) => {
2412
2530
  try {
@@ -2460,7 +2578,7 @@ var FrustumPyramid = class {
2460
2578
  */
2461
2579
  computeFrustumGeometry(apex, headingDeg, pitchDeg, rollDeg, fovDeg, length) {
2462
2580
  const C = this.CesiumNS;
2463
- const fov = Math.max(1, Math.min(120, fovDeg ?? this.opts.fov ?? 50));
2581
+ const fov = Math.max(1, Math.min(120, fovDeg ?? this.opts.fov ?? DEFAULT_FOV));
2464
2582
  const aspectRatio = this.opts.aspectRatio ?? 4 / 3;
2465
2583
  const halfFovH = C.Math.toRadians(fov / 2);
2466
2584
  const halfWidth = Math.tan(halfFovH) * length;
@@ -2639,7 +2757,7 @@ var FrustumPyramid = class {
2639
2757
  const lakeFill = (this.opts.fillColor ?? C.Color.fromCssColorString("#1e90ff")).withAlpha(alpha);
2640
2758
  const width = this.opts.width ?? 3;
2641
2759
  this.ensureEntities(lakeEdge, width, lakeFill);
2642
- const effectiveFov = Math.max(1, Math.min(120, fovDeg ?? this.opts.fov ?? 50));
2760
+ const effectiveFov = Math.max(1, Math.min(120, fovDeg ?? this.opts.fov ?? DEFAULT_FOV));
2643
2761
  const aspectRatio = this.opts.aspectRatio ?? 4 / 3;
2644
2762
  this.logAnglesIfChanged(effectiveFov, aspectRatio, headingDeg, pitchDeg);
2645
2763
  const { apex: apexPos, corners, baseCenter } = this.computeFrustumGeometry(
@@ -2843,7 +2961,7 @@ var AirplaneCursor = class {
2843
2961
  this.step = opts.stepMeters ?? 2;
2844
2962
  this.angleStep = opts.angleStepDeg ?? 1;
2845
2963
  this.fastFactor = opts.fastFactor ?? 5;
2846
- this.currentFOV = opts.fovDeg ?? 50;
2964
+ this.currentFOV = opts.fovDeg ?? DEFAULT_FOV;
2847
2965
  this.ensureEntity(opts.color ?? C.Color.CYAN.withAlpha(0.9));
2848
2966
  this.attachKeyboard(opts);
2849
2967
  this.setupFOVListener();
@@ -3121,7 +3239,8 @@ var AirplaneCursor = class {
3121
3239
  this.viewer.dataSources.add(layer);
3122
3240
  }
3123
3241
  this.frustum = new FrustumPyramid(this.CesiumNS, layer, {
3124
- fov: this.opts.fovDeg ?? 40,
3242
+ fov: this.opts.fovDeg ?? DEFAULT_FOV,
3243
+ // 使用统一的默认 FOV
3125
3244
  length: 80,
3126
3245
  color: this.opts.color,
3127
3246
  fillAlpha: 0.25,
@@ -3130,8 +3249,8 @@ var AirplaneCursor = class {
3130
3249
  logAngles: false,
3131
3250
  logThrottleMs: 300
3132
3251
  });
3133
- const frustumFovScale = 0.6;
3134
- const frustumLengthScale = 0.1;
3252
+ const frustumFovScale = 0.5;
3253
+ const frustumLengthScale = 0.2;
3135
3254
  this.frustum.showAtDynamic(
3136
3255
  () => this.pose.position,
3137
3256
  () => this.pose.heading,
@@ -5216,11 +5335,11 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5216
5335
  const fArr = getArr("_vertexFov");
5217
5336
  pitches[i] = typeof pArr?.[i] === "number" ? pArr[i] : -10;
5218
5337
  rolls[i] = typeof rArr?.[i] === "number" ? rArr[i] : 0;
5219
- fovs[i] = typeof fArr?.[i] === "number" ? fArr[i] : 50;
5338
+ fovs[i] = typeof fArr?.[i] === "number" ? fArr[i] : DEFAULT_FOV;
5220
5339
  } catch {
5221
5340
  pitches[i] = -10;
5222
5341
  rolls[i] = 0;
5223
- fovs[i] = 50;
5342
+ fovs[i] = DEFAULT_FOV;
5224
5343
  }
5225
5344
  }
5226
5345
  entity.polyline.positions = new C.CallbackProperty(() => positions.slice(), false);
@@ -5249,7 +5368,7 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5249
5368
  headings[activeIndex] ?? 0,
5250
5369
  pitches[activeIndex] ?? -10,
5251
5370
  0,
5252
- fovs[activeIndex] ?? 50
5371
+ fovs[activeIndex] ?? DEFAULT_FOV
5253
5372
  );
5254
5373
  }
5255
5374
  } catch {
@@ -5425,13 +5544,13 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5425
5544
  }
5426
5545
  },
5427
5546
  // frustumLengthFactor: options?.preview?.lengthFactor ?? 0.3,
5428
- fovDeg: options?.preview?.fov ?? 50
5547
+ fovDeg: options?.preview?.fov ?? DEFAULT_FOV
5429
5548
  });
5430
5549
  if (options?.preview?.enabled !== false && airplaneCursor) {
5431
5550
  preview = new PathPreview(CesiumNS, viewer, {
5432
5551
  container: options?.preview?.container,
5433
5552
  showFootprint: options?.preview?.showFootprint ?? false,
5434
- fov: options?.preview?.fov ?? 50,
5553
+ fov: options?.preview?.fov ?? DEFAULT_FOV,
5435
5554
  pitch: options?.preview?.pitch ?? -10,
5436
5555
  roll: options?.preview?.roll ?? 0
5437
5556
  });
@@ -5443,7 +5562,7 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5443
5562
  initialPose.heading,
5444
5563
  initialPose.pitch,
5445
5564
  initialPose.roll,
5446
- options?.preview?.fov ?? 50
5565
+ options?.preview?.fov ?? DEFAULT_FOV
5447
5566
  );
5448
5567
  } catch {
5449
5568
  console.warn("PathEditing: failed to set initial preview pose");
@@ -5701,7 +5820,7 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5701
5820
  heading: headings[index] ?? 0,
5702
5821
  pitch: pitches[index] ?? 0,
5703
5822
  roll: rolls[index] ?? 0,
5704
- fov: fovs[index] ?? 50
5823
+ fov: fovs[index] ?? DEFAULT_FOV
5705
5824
  };
5706
5825
  const totalVertices = positions.length;
5707
5826
  const totalVisibleVertices = totalVertices;
@@ -5775,7 +5894,7 @@ function startPathEditing(CesiumNS, viewer, entityOrId, options) {
5775
5894
  heading: headings[index] ?? 0,
5776
5895
  pitch: pitches[index] ?? -10,
5777
5896
  roll: rolls[index] ?? 0,
5778
- fov: fovs[index] ?? 50,
5897
+ fov: fovs[index] ?? DEFAULT_FOV,
5779
5898
  index,
5780
5899
  distance: calculatePathDistance(CesiumNS, positions, index),
5781
5900
  ellipsoidHeight,
@@ -6245,7 +6364,7 @@ function startPathDrawing(CesiumNS, viewer, options, onComplete) {
6245
6364
  try {
6246
6365
  const auto = options?.autoStartEditing;
6247
6366
  const editOptions = {
6248
- // 🔧 默认使用自由编辑模式(快速编辑和自由编辑互斥)
6367
+ // 默认使用自由编辑模式(快速编辑和自由编辑互斥)
6249
6368
  quickEdit: false
6250
6369
  };
6251
6370
  if (typeof auto === "object" && auto.preview) {
@@ -11713,6 +11832,7 @@ var PathSafetyChecker = class {
11713
11832
 
11714
11833
  // src/index.ts
11715
11834
  var placeholder = { ready: true };
11835
+ var droneModelUrl = wurenji_default;
11716
11836
 
11717
11837
  exports.CZMLManager = CZMLManager;
11718
11838
  exports.CameraEventBus = CameraEventBus;
@@ -11736,6 +11856,7 @@ exports.configureCesiumIonToken = configureCesiumIonToken;
11736
11856
  exports.convertPathToSinofly = convertPathToSinofly;
11737
11857
  exports.convertSinoflyWayline = convertSinoflyWayline;
11738
11858
  exports.convertSinoflyWaylines = convertSinoflyWaylines;
11859
+ exports.droneModelUrl = droneModelUrl;
11739
11860
  exports.ensureCesiumIonToken = ensureCesiumIonToken;
11740
11861
  exports.getCesiumBaseUrl = getCesiumBaseUrl;
11741
11862
  exports.getCesiumIonToken = getCesiumIonToken;