bruce-cesium 6.8.8 → 6.9.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.
Files changed (41) hide show
  1. package/dist/bruce-cesium.es5.js +2127 -1282
  2. package/dist/bruce-cesium.es5.js.map +1 -1
  3. package/dist/bruce-cesium.umd.js +2124 -1279
  4. package/dist/bruce-cesium.umd.js.map +1 -1
  5. package/dist/lib/bruce-cesium.js +1 -1
  6. package/dist/lib/rendering/cesium-animated-property.js +7 -3
  7. package/dist/lib/rendering/cesium-animated-property.js.map +1 -1
  8. package/dist/lib/rendering/render-managers/tilesets/tileset-cad-render-manager.js +12 -1
  9. package/dist/lib/rendering/render-managers/tilesets/tileset-cad-render-manager.js.map +1 -1
  10. package/dist/lib/rendering/visuals-register.js +75 -9
  11. package/dist/lib/rendering/visuals-register.js.map +1 -1
  12. package/dist/lib/widgets/common/cursorbar-mouse-event-throttle.js +173 -0
  13. package/dist/lib/widgets/common/cursorbar-mouse-event-throttle.js.map +1 -0
  14. package/dist/lib/widgets/common/walkthrough.js +8 -0
  15. package/dist/lib/widgets/common/walkthrough.js.map +1 -1
  16. package/dist/lib/widgets/controls-view-bar/widget-control-view-bar-search.js +10 -18
  17. package/dist/lib/widgets/controls-view-bar/widget-control-view-bar-search.js.map +1 -1
  18. package/dist/lib/widgets/widget-cursorbar.js +51 -713
  19. package/dist/lib/widgets/widget-cursorbar.js.map +1 -1
  20. package/dist/lib/widgets/widget-nav-compass-hold-loader.js +86 -0
  21. package/dist/lib/widgets/widget-nav-compass-hold-loader.js.map +1 -0
  22. package/dist/lib/widgets/widget-nav-compass-utils.js +470 -0
  23. package/dist/lib/widgets/widget-nav-compass-utils.js.map +1 -0
  24. package/dist/lib/widgets/widget-nav-compass-walkthrough-bar.js +419 -0
  25. package/dist/lib/widgets/widget-nav-compass-walkthrough-bar.js.map +1 -0
  26. package/dist/lib/widgets/widget-nav-compass.js +499 -229
  27. package/dist/lib/widgets/widget-nav-compass.js.map +1 -1
  28. package/dist/lib/widgets/widget-view-bar.js +36 -13
  29. package/dist/lib/widgets/widget-view-bar.js.map +1 -1
  30. package/dist/types/bruce-cesium.d.ts +1 -1
  31. package/dist/types/rendering/render-managers/tilesets/tileset-cad-render-manager.d.ts +1 -0
  32. package/dist/types/rendering/visuals-register.d.ts +8 -2
  33. package/dist/types/widgets/common/cursorbar-mouse-event-throttle.d.ts +47 -0
  34. package/dist/types/widgets/common/walkthrough.d.ts +9 -0
  35. package/dist/types/widgets/widget-cursorbar.d.ts +1 -14
  36. package/dist/types/widgets/widget-nav-compass-hold-loader.d.ts +16 -0
  37. package/dist/types/widgets/widget-nav-compass-utils.d.ts +80 -0
  38. package/dist/types/widgets/widget-nav-compass-walkthrough-bar.d.ts +31 -0
  39. package/dist/types/widgets/widget-nav-compass.d.ts +45 -10
  40. package/dist/types/widgets/widget-view-bar.d.ts +1 -0
  41. package/package.json +3 -1
@@ -1,6 +1,6 @@
1
1
  import * as Cesium from 'cesium';
2
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, HeightReference, HorizontalOrigin, VerticalOrigin, Cartesian3, ClassificationType, ConstantPositionProperty, ArcType, CornerType, ShadowMode, Math as Math$1, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, ColorBlendMode, Model, PolygonHierarchy, PolylineGraphics, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Ion, IonResource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Cesium3DTileset, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere, GeometryInstance, Intersect, CzmlDataSource, Fullscreen } from 'cesium';
3
- import { Cartes, Entity as Entity$1, ENVIRONMENT, Api, Calculator, ClientFile, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Carto, Geometry, EntityLod, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, Bounds, DataLab, DelayQueue, EntityHistoricData, BruceApi, AccountConcept, RecordChangeFeed, EntityRelation, ProgramKey, EntitySource, Camera, ProjectViewTile, ProjectViewLegacyTile, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session, EntityRelationType } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, HeightReference, HorizontalOrigin, VerticalOrigin, ClassificationType, ConstantPositionProperty, PolygonHierarchy, ShadowMode, PolylineGraphics, ArcType, CornerType, ColorBlendMode, Model, Cartesian2, SceneTransforms, Rectangle, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, IonResource, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Cesium3DTileset, OrthographicFrustum, EasingFunction, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, CesiumInspector, ClockRange, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, Intersect, CzmlDataSource } from 'cesium';
3
+ import { Cartes, Entity as Entity$1, ENVIRONMENT, Api, Calculator, ClientFile, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Bounds, Geometry, EntityLod, Carto, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, EntityHistoricData, AccountConcept, RecordChangeFeed, BruceApi, EntityRelation, ProgramKey, EntitySource, ProjectViewLegacyTile, ProjectViewTile, Camera, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session, EntityRelationType } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -495,8 +495,10 @@ var CesiumAnimatedProperty;
495
495
  this.startColor = this.startColor.clone();
496
496
  }
497
497
  if (!this.startColor) {
498
- this.startColor = Color.WHITE.clone();
499
- console.warn("No start color provided. Using WHITE as start color. Animation may not work as expected.");
498
+ // No prior colour to animate from (eg: a freshly-created graphic).
499
+ // Starting from WHITE would itself be a visible flash, so just skip the animation.
500
+ this.startColor = this.targetColor.clone();
501
+ this.durationMs = 0;
500
502
  }
501
503
  this.startTime = new Date();
502
504
  }
@@ -609,7 +611,9 @@ var CesiumAnimatedProperty;
609
611
  }
610
612
  }
611
613
  else {
612
- startColor = Color.WHITE.clone();
614
+ // No prior colour to animate from (eg: a freshly-loaded feature).
615
+ // Starting from WHITE would itself be a visible flash, so start from the target colour instead.
616
+ startColor = (color === null || color === void 0 ? void 0 : color.clone) ? color.clone() : color;
613
617
  }
614
618
  }
615
619
  // Don't animate if the colour is the same.
@@ -2721,6 +2725,9 @@ class WidgetControlViewBarSearch extends WidgetControlViewBar.AControl {
2721
2725
  if (this._element && this._element.parentElement) {
2722
2726
  this._element.parentElement.removeChild(this._element);
2723
2727
  }
2728
+ if (this._results && this._results.parentElement) {
2729
+ this._results.parentElement.removeChild(this._results);
2730
+ }
2724
2731
  }
2725
2732
  Toggle() {
2726
2733
  if (this.Disposed) {
@@ -2743,16 +2750,9 @@ class WidgetControlViewBarSearch extends WidgetControlViewBar.AControl {
2743
2750
  style.id = this.STYLESHEET_ID;
2744
2751
  style.innerHTML = `
2745
2752
  .NextspaceSearchBar {
2746
- top: 10px;
2747
- right: 10px;
2748
2753
  display: flex;
2749
2754
  box-sizing: border-box;
2750
- box-shadow: 0 0 1px rgba(18,22,25,.24),0 18px 36px -4px rgba(18,22,25,.6);
2751
- background: #21272a;
2752
- border-radius: 9px;
2753
- height: 48px;
2754
- padding-left: 2px;
2755
- padding-right: 2px;
2755
+ height: 100%;
2756
2756
  font-family: sans-serif;
2757
2757
  }
2758
2758
 
@@ -2785,17 +2785,13 @@ class WidgetControlViewBarSearch extends WidgetControlViewBar.AControl {
2785
2785
  }
2786
2786
 
2787
2787
  .NextspaceSearchBarResults {
2788
- background-color: #21272a;
2789
- border-radius: 0 0 6px 6px;
2790
- display: flex;
2788
+ /* No background of its own: it's a normal-flow section of the same
2789
+ translucent/blurred ViewBar panel, not a separate floating box. */
2790
+ border-top: 1px solid rgba(255, 255, 255, 0.12);
2791
+ display: none;
2791
2792
  flex-direction: column;
2792
- overflow: hidden;
2793
- padding: 12px 8px 8px;
2794
- position: absolute;
2795
- top: calc(100% - 6px);
2793
+ padding: 8px;
2796
2794
  width: 100%;
2797
- left: 0;
2798
- z-index: 1;
2799
2795
  }
2800
2796
 
2801
2797
  .NextspaceSearchBarResultsItem {
@@ -2882,9 +2878,9 @@ class WidgetControlViewBarSearch extends WidgetControlViewBar.AControl {
2882
2878
  };
2883
2879
  const results = document.createElement("div");
2884
2880
  results.className = "NextspaceSearchBarResults";
2885
- element.appendChild(results);
2886
2881
  results.style.display = "none";
2887
2882
  this._results = results;
2883
+ this.WidgetViewBar.Element.appendChild(results);
2888
2884
  this.Container.appendChild(element);
2889
2885
  this._element = element;
2890
2886
  }
@@ -3191,13 +3187,13 @@ class WidgetViewBar extends Widget.AWidget {
3191
3187
  style.id = this.STYLESHEET_ID;
3192
3188
  style.innerHTML = `
3193
3189
  .NextspaceViewBar {
3194
- align-items: center;
3195
- background-color: #21272a;
3190
+ background: rgba(33, 39, 42, 0.8);
3191
+ backdrop-filter: blur(20px);
3192
+ box-shadow: 0px 0px 1px rgba(18, 22, 25, 0.36), 0px 18px 36px -4px rgba(18, 22, 25, 0.36);
3196
3193
  border-radius: 9px;
3197
3194
  display: flex;
3195
+ flex-direction: column;
3198
3196
  flex-shrink: 1;
3199
- height: 48px;
3200
- justify-content: center;
3201
3197
  position: absolute;
3202
3198
  z-index: 1;
3203
3199
  top: 10px;
@@ -3209,6 +3205,14 @@ class WidgetViewBar extends Widget.AWidget {
3209
3205
  box-sizing: border-box;
3210
3206
  }
3211
3207
 
3208
+ .NextspaceViewBarRow {
3209
+ align-items: center;
3210
+ display: flex;
3211
+ flex-shrink: 0;
3212
+ height: 44px;
3213
+ justify-content: center;
3214
+ }
3215
+
3212
3216
  .NextspaceViewBarControl {
3213
3217
  align-items: center;
3214
3218
  border-radius: 0;
@@ -3224,9 +3228,19 @@ class WidgetViewBar extends Widget.AWidget {
3224
3228
  width: 46px;
3225
3229
  }
3226
3230
 
3231
+ .NextspaceViewBarControl:first-of-type {
3232
+ border-radius: 9px 0 0 9px;
3233
+ padding-left: 8px;
3234
+ }
3235
+
3236
+ .NextspaceViewBarControl:last-of-type {
3237
+ border-radius: 0 9px 9px 0;
3238
+ padding-right: 8px;
3239
+ }
3240
+
3227
3241
  .NextspaceViewBarControlIcon {
3228
- width: 32px;
3229
- height: 32px;
3242
+ width: 28px;
3243
+ height: 28px;
3230
3244
  display: flex;
3231
3245
  align-items: center;
3232
3246
  justify-content: center;
@@ -3242,6 +3256,7 @@ class WidgetViewBar extends Widget.AWidget {
3242
3256
 
3243
3257
  .NextspaceViewBarControl[is-enabled="true"] {
3244
3258
  background: #33b1ff;
3259
+ box-shadow: inset 0 2px 0 0 #64c4ff;
3245
3260
  }
3246
3261
 
3247
3262
  .NextspaceViewBarEndBreaker {
@@ -3259,6 +3274,10 @@ class WidgetViewBar extends Widget.AWidget {
3259
3274
  _generateElement() {
3260
3275
  const element = document.createElement("div");
3261
3276
  element.className = "NextspaceViewBar";
3277
+ const row = document.createElement("div");
3278
+ row.className = "NextspaceViewBarRow";
3279
+ element.appendChild(row);
3280
+ this._row = row;
3262
3281
  this.Container.appendChild(element);
3263
3282
  this._element = element;
3264
3283
  this._addBarControl({
@@ -3266,7 +3285,7 @@ class WidgetViewBar extends Widget.AWidget {
3266
3285
  title: "Search",
3267
3286
  iconDisabled: {
3268
3287
  icon: `
3269
- <svg class="" width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.3283 6C9.73857 6 6 9.73857 6 14.3283C6 18.918 9.73857 22.6566 14.3283 22.6566C16.3242 22.6566 18.1571 21.9479 19.5937 20.7714L24.5663 25.7439C24.643 25.8239 24.7349 25.8877 24.8366 25.9316C24.9383 25.9756 25.0478 25.9988 25.1586 26C25.2694 26.0011 25.3793 25.9801 25.4819 25.9382C25.5845 25.8963 25.6777 25.8344 25.756 25.756C25.8344 25.6777 25.8963 25.5845 25.9382 25.4819C25.9801 25.3793 26.0011 25.2694 26 25.1586C25.9988 25.0478 25.9756 24.9383 25.9316 24.8366C25.8877 24.7349 25.8239 24.643 25.7439 24.5663L20.7714 19.5937C21.9479 18.1571 22.6566 16.3242 22.6566 14.3283C22.6566 9.73857 18.918 6 14.3283 6ZM14.3283 7.66566C18.0178 7.66566 20.9909 10.6388 20.9909 14.3283C20.9909 18.0178 18.0178 20.9909 14.3283 20.9909C10.6388 20.9909 7.66566 18.0178 7.66566 14.3283C7.66566 10.6388 10.6388 7.66566 14.3283 7.66566Z" fill="white"></path></svg>
3288
+ <svg class="" width="28" height="28" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.3283 6C9.73857 6 6 9.73857 6 14.3283C6 18.918 9.73857 22.6566 14.3283 22.6566C16.3242 22.6566 18.1571 21.9479 19.5937 20.7714L24.5663 25.7439C24.643 25.8239 24.7349 25.8877 24.8366 25.9316C24.9383 25.9756 25.0478 25.9988 25.1586 26C25.2694 26.0011 25.3793 25.9801 25.4819 25.9382C25.5845 25.8963 25.6777 25.8344 25.756 25.756C25.8344 25.6777 25.8963 25.5845 25.9382 25.4819C25.9801 25.3793 26.0011 25.2694 26 25.1586C25.9988 25.0478 25.9756 24.9383 25.9316 24.8366C25.8877 24.7349 25.8239 24.643 25.7439 24.5663L20.7714 19.5937C21.9479 18.1571 22.6566 16.3242 22.6566 14.3283C22.6566 9.73857 18.918 6 14.3283 6ZM14.3283 7.66566C18.0178 7.66566 20.9909 10.6388 20.9909 14.3283C20.9909 18.0178 18.0178 20.9909 14.3283 20.9909C10.6388 20.9909 7.66566 18.0178 7.66566 14.3283C7.66566 10.6388 10.6388 7.66566 14.3283 7.66566Z" fill="white"></path></svg>
3270
3289
  `,
3271
3290
  iconSource: "svg"
3272
3291
  },
@@ -3274,7 +3293,7 @@ class WidgetViewBar extends Widget.AWidget {
3274
3293
  });
3275
3294
  const breaker = document.createElement("div");
3276
3295
  breaker.className = "NextspaceViewBarEndBreaker";
3277
- this._element.appendChild(breaker);
3296
+ this._row.appendChild(breaker);
3278
3297
  this._addBarControl({
3279
3298
  control: "fullscreen",
3280
3299
  title: "Fullscreen",
@@ -3300,7 +3319,7 @@ class WidgetViewBar extends Widget.AWidget {
3300
3319
  AddBarControl(params) {
3301
3320
  this.customControls.set(params.control, params.content);
3302
3321
  // We insert before the end breaker.
3303
- const endBreaker = this._element.querySelector(".NextspaceViewBarEndBreaker");
3322
+ const endBreaker = this._row.querySelector(".NextspaceViewBarEndBreaker");
3304
3323
  const afterElement = endBreaker ? endBreaker.previousElementSibling : null;
3305
3324
  let icon;
3306
3325
  let iconSource;
@@ -3371,21 +3390,21 @@ class WidgetViewBar extends Widget.AWidget {
3371
3390
  }
3372
3391
  }
3373
3392
  else {
3374
- this._element.appendChild(tabButton);
3393
+ this._row.appendChild(tabButton);
3375
3394
  }
3376
3395
  switch (control) {
3377
3396
  case "fullscreen":
3378
3397
  controller = new WidgetControlViewBarFullscreen({
3379
3398
  widget: this,
3380
3399
  element: tabButton,
3381
- container: this._element
3400
+ container: this._row
3382
3401
  });
3383
3402
  break;
3384
3403
  case "searchbar":
3385
3404
  controller = new WidgetControlViewBarSearch({
3386
3405
  widget: this,
3387
3406
  element: tabButton,
3388
- container: this._element
3407
+ container: this._row
3389
3408
  });
3390
3409
  break;
3391
3410
  default:
@@ -3396,7 +3415,7 @@ class WidgetViewBar extends Widget.AWidget {
3396
3415
  const clazz = this.customControls.get(control);
3397
3416
  controller = new clazz({
3398
3417
  widget: this,
3399
- container: this._element
3418
+ container: this._row
3400
3419
  });
3401
3420
  break;
3402
3421
  }
@@ -6340,7 +6359,12 @@ function updateEntity(viewer, entityId, register, refresh, cache = {}) {
6340
6359
  cache.isIsolatedAny = register.GetIsIsolatedAny();
6341
6360
  }
6342
6361
  if (cache.isIsolatedAny) {
6343
- return false;
6362
+ if (cache.isolationOpacity === undefined) {
6363
+ cache.isolationOpacity = register.GetIsolationOpacity();
6364
+ }
6365
+ if (cache.isolationOpacity == null) {
6366
+ return false;
6367
+ }
6344
6368
  }
6345
6369
  }
6346
6370
  // We show all regos in the same highest priority level.
@@ -6394,10 +6418,19 @@ function updateEntity(viewer, entityId, register, refresh, cache = {}) {
6394
6418
  }
6395
6419
  }
6396
6420
  if (refresh === true || (refresh !== false && (refresh === null || refresh === void 0 ? void 0 : refresh.opacity))) {
6397
- if (state.opacity != null && state.opacity != 1) {
6421
+ let effectiveOpacity = state.opacity;
6422
+ if ((effectiveOpacity == null || effectiveOpacity == 1) && !state.isolated && visible) {
6423
+ if (cache.isolationOpacity === undefined) {
6424
+ cache.isolationOpacity = register.GetIsolationOpacity();
6425
+ }
6426
+ if (cache.isolationOpacity != null) {
6427
+ effectiveOpacity = cache.isolationOpacity;
6428
+ }
6429
+ }
6430
+ if (effectiveOpacity != null && effectiveOpacity != 1) {
6398
6431
  EntityUtils.SetOpacity({
6399
6432
  entity: rego.visual,
6400
- opacity: state.opacity,
6433
+ opacity: effectiveOpacity,
6401
6434
  viewer: viewer,
6402
6435
  requestRender: false
6403
6436
  });
@@ -6541,6 +6574,10 @@ var VisualsRegister;
6541
6574
  // Caches GetIsIsolatedAny(). `null` means "unknown, recompute".
6542
6575
  // Invalidated on any write that could affect isolation.
6543
6576
  this.isolatedAnyCache = null;
6577
+ // Caches GetIsolationOpacity(). `undefined` means "unknown, recompute", `null` means
6578
+ // "isolation (if any) is the legacy boolean/full-hide kind, not a numeric dim".
6579
+ // Invalidated alongside isolatedAnyCache.
6580
+ this.isolationOpacityCache = undefined;
6544
6581
  // Lazy OverrideStates() bookkeeping. See cancelLazyOverride()/startLazyOverride().
6545
6582
  this.lazyOverrideToken = 0;
6546
6583
  this.lazyOverrideActive = false;
@@ -6722,12 +6759,12 @@ var VisualsRegister;
6722
6759
  if (!state || isBlankState(state)) {
6723
6760
  return;
6724
6761
  }
6762
+ const updateAll = state.hasOwnProperty("isolated");
6725
6763
  const refresh = {
6726
6764
  highlighted: state.hasOwnProperty("highlighted"),
6727
6765
  selected: state.hasOwnProperty("selected"),
6728
- opacity: state.hasOwnProperty("opacity")
6766
+ opacity: state.hasOwnProperty("opacity") || updateAll
6729
6767
  };
6730
- const updateAll = state.hasOwnProperty("isolated");
6731
6768
  let changed = this.setStateValues(state);
6732
6769
  // Update the related Entity.
6733
6770
  if (changed && update) {
@@ -6785,6 +6822,7 @@ var VisualsRegister;
6785
6822
  const updateRefreshMarkers = (state) => {
6786
6823
  if (state.hasOwnProperty("isolated")) {
6787
6824
  updateAll = true;
6825
+ refreshAccumulated.opacity = true;
6788
6826
  }
6789
6827
  let values = refresh[state.entityId];
6790
6828
  if (!values) {
@@ -6883,6 +6921,7 @@ var VisualsRegister;
6883
6921
  }
6884
6922
  if (keys.includes("isolated")) {
6885
6923
  this.isolatedAnyCache = null;
6924
+ this.isolationOpacityCache = undefined;
6886
6925
  }
6887
6926
  let changed = false;
6888
6927
  const eStates = this.states[entityId] || {};
@@ -7720,18 +7759,28 @@ var VisualsRegister;
7720
7759
  SetIsolated(params) {
7721
7760
  var _a;
7722
7761
  const { entityIds, isolated: isolate, requestRender, menuItemId, source, doUpdate } = params;
7762
+ let isolatedValue;
7763
+ if (isolate === true) {
7764
+ isolatedValue = true;
7765
+ }
7766
+ else if (typeof isolate === "number" && !isNaN(isolate)) {
7767
+ isolatedValue = Math.max(0, Math.min(1, isolate));
7768
+ }
7769
+ else {
7770
+ isolatedValue = null;
7771
+ }
7723
7772
  for (let i = 0; i < entityIds.length; i++) {
7724
7773
  const entityId = entityIds[i];
7725
7774
  this.setStateValues({
7726
7775
  entityId: entityId,
7727
7776
  menuItemId: menuItemId,
7728
7777
  // Null means it will be deleted from the object.
7729
- isolated: isolate ? true : null
7778
+ isolated: isolatedValue
7730
7779
  });
7731
7780
  const update = {
7732
7781
  entityId: entityId,
7733
7782
  type: EVisualUpdateType.Update,
7734
- isolated: isolate
7783
+ isolated: isolatedValue
7735
7784
  };
7736
7785
  if (source) {
7737
7786
  update.source = source;
@@ -7741,9 +7790,12 @@ var VisualsRegister;
7741
7790
  }
7742
7791
  }
7743
7792
  if (doUpdate !== false) {
7793
+ // Always a full refresh (not just when isolating): un-isolating these entities can
7794
+ // change opacity for every other entity too, eg: if this was the last isolated
7795
+ // entity, everyone else needs to revert from a numeric dim back to full opacity.
7744
7796
  this.updateAllEntities({
7745
7797
  requestRender: false,
7746
- refresh: isolate
7798
+ refresh: true
7747
7799
  });
7748
7800
  if (requestRender != false) {
7749
7801
  this.viewer.scene.requestRender();
@@ -7756,7 +7808,9 @@ var VisualsRegister;
7756
7808
  entityId: id,
7757
7809
  menuItemId: menuItemId
7758
7810
  });
7759
- return state.isolated === true;
7811
+ // Truthy check (not strict `=== true`) so a numeric isolate value (see
7812
+ // GetIsolationOpacity()) still counts as "this entity is isolated".
7813
+ return Boolean(state.isolated);
7760
7814
  }
7761
7815
  GetIsIsolatedAny() {
7762
7816
  if (this.isolatedAnyCache == null) {
@@ -7764,6 +7818,36 @@ var VisualsRegister;
7764
7818
  }
7765
7819
  return this.isolatedAnyCache;
7766
7820
  }
7821
+ /**
7822
+ * Returns the opacity that should be applied to non-isolated entities while isolation is
7823
+ * active, or null if isolation (if any) is the legacy boolean kind.
7824
+ */
7825
+ GetIsolationOpacity() {
7826
+ if (this.isolationOpacityCache !== undefined) {
7827
+ return this.isolationOpacityCache;
7828
+ }
7829
+ let sawBooleanIsolate = false;
7830
+ let minOpacity = null;
7831
+ for (const entityStates of Object.values(this.states)) {
7832
+ if (!entityStates) {
7833
+ continue;
7834
+ }
7835
+ for (const item of Object.values(entityStates)) {
7836
+ const isolated = item === null || item === void 0 ? void 0 : item.isolated;
7837
+ if (isolated === true) {
7838
+ sawBooleanIsolate = true;
7839
+ }
7840
+ else if (typeof isolated === "number" && !isNaN(isolated)) {
7841
+ const clamped = Math.max(0, Math.min(1, isolated));
7842
+ if (minOpacity == null || clamped < minOpacity) {
7843
+ minOpacity = clamped;
7844
+ }
7845
+ }
7846
+ }
7847
+ }
7848
+ this.isolationOpacityCache = sawBooleanIsolate ? null : minOpacity;
7849
+ return this.isolationOpacityCache;
7850
+ }
7767
7851
  /**
7768
7852
  * Returns all isolated entity ids, without regard to menu item id.
7769
7853
  * @returns
@@ -7790,6 +7874,7 @@ var VisualsRegister;
7790
7874
  if (changed) {
7791
7875
  // Mutated `isolated` directly rather than through setStateValues().
7792
7876
  this.isolatedAnyCache = false;
7877
+ this.isolationOpacityCache = null;
7793
7878
  }
7794
7879
  if (changed && (params === null || params === void 0 ? void 0 : params.doUpdate) !== false) {
7795
7880
  this.updateAllEntities({
@@ -14241,6 +14326,9 @@ var TilesetCadRenderManager;
14241
14326
  // Cache of 'something isolated' that we detect and use to calculate a default show state.
14242
14327
  // It's pretty expensive so we save it for a few seconds inbetween checks.
14243
14328
  this.somethingIsolated = null;
14329
+ // Dim opacity to apply to non-isolated features on load, when isolation is opacity-based rather than a full hide.
14330
+ // Null means isolation (if any) is the legacy full-hide kind.
14331
+ this.somethingIsolatedOpacity = null;
14244
14332
  this.somethingIsolatedDateTime = null;
14245
14333
  // Entity ID -> rego.
14246
14334
  // We retain this information as a quick look-up on what has been registered.
@@ -14891,9 +14979,12 @@ var TilesetCadRenderManager;
14891
14979
  // 5s cache.
14892
14980
  (this.somethingIsolatedDateTime && this.somethingIsolatedDateTime.getTime() + 5000 < new Date().getTime())) {
14893
14981
  this.somethingIsolated = this.visualsManager.GetIsIsolatedAny();
14982
+ this.somethingIsolatedOpacity = this.visualsManager.GetIsolationOpacity();
14894
14983
  this.somethingIsolatedDateTime = new Date();
14895
14984
  }
14896
14985
  // Override the default hide state set by the style.
14986
+ // Applying the isolation dim/hide here (rather than showing at full opacity and
14987
+ // letting the async styler queue correct it later) avoids a load-in flicker.
14897
14988
  let hide = false;
14898
14989
  if (state) {
14899
14990
  if (state.hidden) {
@@ -14903,7 +14994,12 @@ var TilesetCadRenderManager;
14903
14994
  hide = true;
14904
14995
  }
14905
14996
  else if (!state.isolated && this.somethingIsolated) {
14906
- hide = true;
14997
+ if (this.somethingIsolatedOpacity != null) {
14998
+ feature.color = Color.WHITE.clone().withAlpha(this.somethingIsolatedOpacity);
14999
+ }
15000
+ else {
15001
+ hide = true;
15002
+ }
14907
15003
  }
14908
15004
  }
14909
15005
  feature.show = !hide;
@@ -28441,343 +28537,179 @@ var MeasureCreator;
28441
28537
  MeasureCreator.Polygon = Polygon;
28442
28538
  })(MeasureCreator || (MeasureCreator = {}));
28443
28539
 
28444
- var EAction;
28445
- (function (EAction) {
28446
- EAction["Forward"] = "f";
28447
- EAction["Backward"] = "b";
28448
- EAction["Left"] = "l";
28449
- EAction["Right"] = "r";
28450
- EAction["Up"] = "u";
28451
- EAction["Down"] = "d";
28452
- EAction["LookUp"] = "lu";
28453
- EAction["LookDown"] = "ld";
28454
- EAction["LookLeft"] = "ll";
28455
- EAction["LookRight"] = "lr";
28456
- EAction["Looking"] = "looking";
28457
- })(EAction || (EAction = {}));
28458
- const DEFAULT_WALK_MOVE_RATE = 0.2;
28459
- const DEFAULT_FLY_MOVE_RATE = 0.2;
28460
- const DEFAULT_MOVE_TYPE = null;
28461
- const VIEWER_WALKTHROUGH_DATA_KEY = "_cesiumWalkthroughData";
28462
- /**
28463
- * Returns heading of camera towards where movement is happening.
28464
- * @returns
28465
- */
28466
- function getMovementHeading(viewer) {
28467
- var _a;
28468
- const actions = (_a = viewer[VIEWER_WALKTHROUGH_DATA_KEY]) === null || _a === void 0 ? void 0 : _a.actions;
28469
- if (!actions) {
28470
- return 0;
28471
- }
28472
- let heading = Math$1.toDegrees(viewer.camera.heading);
28473
- let count = 0;
28474
- let totalHeading = 0;
28475
- let left = actions.get(EAction.Left);
28476
- if (left) {
28477
- totalHeading += heading + 270;
28478
- count += 1;
28479
- }
28480
- if (actions.get(EAction.Right)) {
28481
- totalHeading += heading + 90;
28482
- count += 1;
28483
- }
28484
- let forward = actions.get(EAction.Forward);
28485
- if (forward) {
28486
- totalHeading += heading;
28487
- count += 1;
28488
- }
28489
- if (actions.get(EAction.Backward)) {
28490
- totalHeading += heading + 180;
28491
- count += 1;
28492
- }
28493
- if (left && forward) {
28494
- totalHeading = heading - 45;
28495
- }
28496
- else {
28497
- totalHeading /= count;
28498
- }
28499
- return totalHeading;
28500
- }
28540
+ // Adaptive hover-raycast delay brackets, keyed by smoothed scene FPS.
28541
+ // Mirrors cesium-navigator-ui's useMouseEvents: <20fps -> 350ms, <40fps -> 250ms, else 150ms.
28542
+ const HOVER_DELAY_FAST_MS = 150;
28543
+ const HOVER_DELAY_MID_MS = 250;
28544
+ const HOVER_DELAY_SLOW_MS = 350;
28545
+ const HOVER_DELAY_BRACKET_FPS_MID = 40;
28546
+ const HOVER_DELAY_BRACKET_FPS_SLOW = 20;
28547
+ // Minimum time between delay-bracket switches, so the delay itself doesn't flicker.
28548
+ const DELAY_SWITCH_MIN_INTERVAL_MS = 1000;
28549
+ // Scene is considered "slow" below ~60fps, with hysteresis to avoid flicker at the boundary.
28550
+ const SLOW_SCENE_ENTER_FPS = 55;
28551
+ const SLOW_SCENE_EXIT_FPS = 62;
28552
+ // While the scene is slow, hover raycasts are debounced until the cursor has been still this long.
28553
+ const CURSOR_SETTLE_MS = 150;
28554
+ // After camera movement ends, wait this long before forcing a fresh hover raycast.
28555
+ const POST_MOVE_RECHECK_DELAY_MS = 100;
28556
+ // Consecutive still frames (position/direction unchanged) before we consider the camera settled.
28557
+ // Cesium's own moveEnd event fires noticeably late, so this is checked independently per-frame.
28558
+ const STILL_FRAMES_TO_SETTLE = 2;
28559
+ // If the cursor hasn't moved more than this many pixels and the render frame hasn't advanced,
28560
+ // skip re-raycasting entirely (same scene, same cursor position -> same pick result).
28561
+ const STALE_RAYCAST_DISTANCE_PX = 2;
28501
28562
  /**
28502
- * Updates camera position and orientation based on current actions.
28563
+ * Tracks scene FPS and camera-movement state to drive an adaptive hover-raycast throttle,
28564
+ * following the design of cesium-navigator-ui's `useMouseEvents` hook as closely as possible
28565
+ * so the cursorbar widget avoids over-sampling hover picks on slow scenes/devices.
28503
28566
  */
28504
- function doMovementTick(viewer) {
28505
- const data = viewer[VIEWER_WALKTHROUGH_DATA_KEY];
28506
- if (!data) {
28507
- return;
28567
+ class CursorBarMouseEventThrottle {
28568
+ constructor(viewer) {
28569
+ this._renderFrameCount = 0;
28570
+ this._lastCameraPos = null;
28571
+ this._lastCameraDir = null;
28572
+ this._stillFrameCount = 0;
28573
+ this._isCameraMoving = false;
28574
+ this._lastFrameTime = null;
28575
+ this._avgFps = null;
28576
+ this._isSlowScene = false;
28577
+ this._hoverDelayMs = HOVER_DELAY_FAST_MS;
28578
+ this._lastDelaySwitchTime = 0;
28579
+ this._lastRaycast = null;
28580
+ this._onSettle = null;
28581
+ this._postMoveRecheckTimeout = null;
28582
+ this._viewer = viewer;
28583
+ const onPostRender = () => this._onPostRender();
28584
+ viewer.scene.postRender.addEventListener(onPostRender);
28585
+ this._postRenderRemoval = () => viewer.scene.postRender.removeEventListener(onPostRender);
28586
+ const onMoveStart = () => this._setCameraMoving(true);
28587
+ const onMoveEnd = () => this._settleCameraMovement();
28588
+ viewer.camera.moveStart.addEventListener(onMoveStart);
28589
+ viewer.camera.moveEnd.addEventListener(onMoveEnd);
28590
+ this._moveStartRemoval = () => viewer.camera.moveStart.removeEventListener(onMoveStart);
28591
+ this._moveEndRemoval = () => viewer.camera.moveEnd.removeEventListener(onMoveEnd);
28508
28592
  }
28509
- const canvas = viewer.canvas;
28510
- const camera = viewer.camera;
28511
- const moveRate = data.moveType == Walkthrough.EMoveType.Walk ? data.walkMoveRate : data.flyMoveRate;
28512
- if (data.actions.get(EAction.Looking)) {
28513
- let width = canvas.clientWidth;
28514
- let height = canvas.clientHeight;
28515
- // Coordinate (0.0, 0.0) will be where the mouse was clicked.
28516
- let x = (data.mousePosCurrent.x - data.mousePosStart.x) / width;
28517
- let y = -(data.mousePosCurrent.y - data.mousePosStart.y) / height;
28518
- let lookFactor = 0.1;
28519
- camera.lookRight(x * lookFactor);
28520
- camera.lookUp(y * lookFactor);
28521
- }
28522
- let lookStep = 0.03;
28523
- if (data.actions.get(EAction.LookLeft)) {
28524
- camera.lookLeft(lookStep);
28525
- }
28526
- if (data.actions.get(EAction.LookRight)) {
28527
- camera.lookRight(lookStep);
28593
+ Dispose() {
28594
+ var _a, _b, _c;
28595
+ (_a = this._postRenderRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
28596
+ (_b = this._moveStartRemoval) === null || _b === void 0 ? void 0 : _b.call(this);
28597
+ (_c = this._moveEndRemoval) === null || _c === void 0 ? void 0 : _c.call(this);
28598
+ if (this._postMoveRecheckTimeout) {
28599
+ clearTimeout(this._postMoveRecheckTimeout);
28600
+ this._postMoveRecheckTimeout = null;
28601
+ }
28602
+ this._onSettle = null;
28528
28603
  }
28529
- if (data.actions.get(EAction.LookUp)) {
28530
- camera.lookUp(lookStep);
28604
+ /**
28605
+ * Called after camera movement settles (or immediately once) to trigger a forced hover
28606
+ * recheck. Matches Navigator's `hoverRecheckRef`.
28607
+ */
28608
+ SetOnSettle(onSettle) {
28609
+ this._onSettle = onSettle;
28531
28610
  }
28532
- if (data.actions.get(EAction.LookDown)) {
28533
- camera.lookDown(lookStep);
28611
+ GetHoverDelayMs() {
28612
+ return this._hoverDelayMs;
28534
28613
  }
28535
- if (data.actions.get(EAction.Up)) {
28536
- camera.moveUp(moveRate / 2);
28614
+ IsSlowScene() {
28615
+ return this._isSlowScene;
28537
28616
  }
28538
- if (data.actions.get(EAction.Down)) {
28539
- camera.moveDown(moveRate / 2);
28617
+ IsCameraBusy() {
28618
+ return this._isCameraMoving;
28540
28619
  }
28541
- if (camera.roll > 0) {
28542
- camera.twistLeft(camera.roll);
28620
+ /**
28621
+ * True if the scene hasn't rendered a new frame and the cursor is within a couple pixels
28622
+ * of the last raycast, meaning a fresh raycast would return the same result.
28623
+ */
28624
+ ShouldSkipRaycast(x, y) {
28625
+ if (!this._lastRaycast) {
28626
+ return false;
28627
+ }
28628
+ const sceneUnchanged = this._lastRaycast.frame === this._renderFrameCount;
28629
+ const dx = x - this._lastRaycast.x;
28630
+ const dy = y - this._lastRaycast.y;
28631
+ const cursorSettled = (dx * dx + dy * dy) <= (STALE_RAYCAST_DISTANCE_PX * STALE_RAYCAST_DISTANCE_PX);
28632
+ return sceneUnchanged && cursorSettled;
28543
28633
  }
28544
- else if (camera.roll < 0) {
28545
- camera.twistRight(camera.roll * -1);
28634
+ RecordRaycast(x, y) {
28635
+ this._lastRaycast = { frame: this._renderFrameCount, x, y };
28546
28636
  }
28547
- // If movement type is fly use cesium movement methods
28548
- if (data.moveType == Walkthrough.EMoveType.Fly) {
28549
- if (data.actions.get(EAction.Forward)) {
28550
- camera.moveForward(moveRate);
28551
- }
28552
- if (data.actions.get(EAction.Backward)) {
28553
- camera.moveBackward(moveRate);
28554
- }
28555
- if (data.actions.get(EAction.Left)) {
28556
- camera.moveLeft(moveRate);
28557
- }
28558
- if (data.actions.get(EAction.Right)) {
28559
- camera.moveRight(moveRate);
28637
+ _setCameraMoving(moving) {
28638
+ this._isCameraMoving = moving;
28639
+ this._stillFrameCount = 0;
28640
+ if (this._postMoveRecheckTimeout) {
28641
+ clearTimeout(this._postMoveRecheckTimeout);
28642
+ this._postMoveRecheckTimeout = null;
28560
28643
  }
28561
28644
  }
28562
- // If movement type is walk, calculate new position without affecting altitude
28563
- else {
28564
- if (data.actions.get(EAction.Left) ||
28565
- data.actions.get(EAction.Right) ||
28566
- data.actions.get(EAction.Forward) ||
28567
- data.actions.get(EAction.Backward)) {
28568
- const heading = getMovementHeading(viewer);
28569
- const pos = viewer.camera.positionCartographic;
28570
- const newPos = _offsetPoint({
28571
- altitude: pos.height,
28572
- latitude: Math$1.toDegrees(pos.latitude),
28573
- longitude: Math$1.toDegrees(pos.longitude)
28574
- }, moveRate, heading);
28575
- camera.position = Cartesian3.fromDegrees(newPos.longitude, newPos.latitude, newPos.altitude);
28645
+ _settleCameraMovement() {
28646
+ this._isCameraMoving = false;
28647
+ if (this._postMoveRecheckTimeout) {
28648
+ clearTimeout(this._postMoveRecheckTimeout);
28576
28649
  }
28577
- }
28578
- viewer.scene.requestRender();
28579
- }
28580
- /**
28581
- * Moves a given point by a given distance towards a heading.
28582
- * @param point in degrees.
28583
- * @param distance in meters.
28584
- * @param heading in degrees.
28585
- * @returns
28586
- */
28587
- function _offsetPoint(point, distance, heading) {
28588
- // Radius of earth.
28589
- const radius = 6371e3;
28590
- const δ = distance / radius;
28591
- const θ = Math$1.toRadians(heading);
28592
- const φ1 = Math$1.toRadians(point.latitude);
28593
- const λ1 = Math$1.toRadians(point.longitude);
28594
- const sinφ2 = Math.sin(φ1) * Math.cos(δ) + Math.cos(φ1) * Math.sin(δ) * Math.cos(θ);
28595
- const φ2 = Math.asin(sinφ2);
28596
- const y = Math.sin(θ) * Math.sin(δ) * Math.cos(φ1);
28597
- const x = Math.cos(δ) - Math.sin(φ1) * sinφ2;
28598
- const λ2 = λ1 + Math.atan2(y, x);
28599
- return {
28600
- altitude: point.altitude,
28601
- latitude: Math$1.toDegrees(φ2),
28602
- longitude: Math$1.toDegrees(λ2)
28603
- };
28604
- }
28605
- /**
28606
- * Checks given keyboard key against keybinds and sets action accordingly.
28607
- * @param key
28608
- * @param keyDown
28609
- */
28610
- function checkKeybind(viewer, key, keyDown) {
28611
- const data = viewer[VIEWER_WALKTHROUGH_DATA_KEY];
28612
- if (!data) {
28613
- return;
28614
- }
28615
- key = key.toLowerCase();
28616
- if (key == "w") {
28617
- data.actions.set(EAction.Forward, keyDown);
28618
- }
28619
- else if (key == "s") {
28620
- data.actions.set(EAction.Backward, keyDown);
28621
- }
28622
- else if (key == "a") {
28623
- data.actions.set(EAction.Left, keyDown);
28624
- }
28625
- else if (key == "d") {
28626
- data.actions.set(EAction.Right, keyDown);
28627
- }
28628
- else if (key == "q") {
28629
- data.actions.set(EAction.Up, keyDown);
28630
- }
28631
- else if (key == "e") {
28632
- data.actions.set(EAction.Down, keyDown);
28633
- }
28634
- else if (key == "arrowup") {
28635
- data.actions.set(EAction.LookUp, keyDown);
28636
- }
28637
- else if (key == "arrowdown") {
28638
- data.actions.set(EAction.LookDown, keyDown);
28639
- }
28640
- else if (key == "arrowleft") {
28641
- data.actions.set(EAction.LookLeft, keyDown);
28642
- }
28643
- else if (key == "arrowright") {
28644
- data.actions.set(EAction.LookRight, keyDown);
28645
- }
28646
- }
28647
- var Walkthrough;
28648
- (function (Walkthrough) {
28649
- let EMoveType;
28650
- (function (EMoveType) {
28651
- EMoveType["Walk"] = "WALK";
28652
- EMoveType["Fly"] = "FLY";
28653
- })(EMoveType = Walkthrough.EMoveType || (Walkthrough.EMoveType = {}));
28654
- function Start(params) {
28655
- Stop(params);
28656
- const viewer = params.viewer;
28657
- const data = viewer[VIEWER_WALKTHROUGH_DATA_KEY] = {
28658
- walkMoveRate: DEFAULT_WALK_MOVE_RATE,
28659
- flyMoveRate: DEFAULT_FLY_MOVE_RATE,
28660
- moveType: DEFAULT_MOVE_TYPE,
28661
- actions: new Map(),
28662
- ...viewer[VIEWER_WALKTHROUGH_DATA_KEY]
28663
- };
28664
- data.handlerScreenSpace = new ScreenSpaceEventHandler(viewer.canvas);
28665
- ViewUtils.SetLockedCameraStatus({
28666
- viewer: viewer,
28667
- status: true
28668
- });
28669
- let lastCheck;
28670
- let currentTime = new Date();
28671
- const interval = setInterval(() => {
28672
- lastCheck = new Date();
28673
- if (lastCheck.getTime() - currentTime.getTime() >= (1000 / 60)) {
28674
- doMovementTick(viewer);
28675
- currentTime = new Date();
28676
- }
28677
- }, 1000 / 60);
28678
- data.tickRemoval = () => {
28679
- clearInterval(interval);
28680
- };
28681
- let keyDown = (e) => {
28682
- checkKeybind(viewer, e.key, true);
28683
- };
28684
- document.addEventListener("keydown", keyDown, false);
28685
- let keyUp = (e) => {
28686
- checkKeybind(viewer, e.key, false);
28687
- };
28688
- document.addEventListener("keyup", keyUp, false);
28689
- data.handlerKeysRemoval = () => {
28690
- document.removeEventListener("keydown", keyDown);
28691
- document.removeEventListener("keyup", keyUp);
28692
- };
28693
- data.handlerScreenSpace.setInputAction((e) => {
28694
- data.actions.set(EAction.Looking, true);
28695
- data.mousePosCurrent = data.mousePosStart = Cartesian2.clone(e.position);
28696
- }, ScreenSpaceEventType.LEFT_DOWN);
28697
- data.handlerScreenSpace.setInputAction(((e) => {
28698
- data.mousePosCurrent = e.endPosition;
28699
- }), ScreenSpaceEventType.MOUSE_MOVE);
28700
- data.handlerScreenSpace.setInputAction(() => {
28701
- data.actions.set(EAction.Looking, false);
28702
- }, ScreenSpaceEventType.LEFT_UP);
28703
- }
28704
- Walkthrough.Start = Start;
28705
- function Stop(params) {
28706
- var _a, _b;
28707
- const viewer = params.viewer;
28708
- const data = viewer[VIEWER_WALKTHROUGH_DATA_KEY];
28709
- ViewUtils.SetLockedCameraStatus({
28710
- viewer: viewer,
28711
- status: false
28712
- });
28713
- if (data) {
28714
- (_a = data.handlerScreenSpace) === null || _a === void 0 ? void 0 : _a.destroy();
28715
- data.handlerScreenSpace = null;
28716
- (_b = data.tickRemoval) === null || _b === void 0 ? void 0 : _b.call(data);
28717
- data.tickRemoval = null;
28718
- if (data.handlerKeysRemoval) {
28719
- data.handlerKeysRemoval();
28720
- data.handlerKeysRemoval = null;
28721
- }
28650
+ this._postMoveRecheckTimeout = setTimeout(() => {
28651
+ var _a;
28652
+ this._postMoveRecheckTimeout = null;
28653
+ (_a = this._onSettle) === null || _a === void 0 ? void 0 : _a.call(this);
28654
+ }, POST_MOVE_RECHECK_DELAY_MS);
28655
+ }
28656
+ _onPostRender() {
28657
+ this._renderFrameCount++;
28658
+ // Cesium's own moveStart/moveEnd fire noticeably late, so we also independently detect
28659
+ // camera movement by diffing position/direction between consecutive rendered frames.
28660
+ const camera = this._viewer.camera;
28661
+ if (this._lastCameraPos && this._lastCameraDir) {
28662
+ const unchanged = Cartesian3.equalsEpsilon(camera.positionWC, this._lastCameraPos, Math$1.EPSILON7) &&
28663
+ Cartesian3.equalsEpsilon(camera.directionWC, this._lastCameraDir, Math$1.EPSILON7);
28664
+ if (!unchanged) {
28665
+ this._setCameraMoving(true);
28666
+ }
28667
+ else if (this._isCameraMoving) {
28668
+ this._stillFrameCount++;
28669
+ if (this._stillFrameCount >= STILL_FRAMES_TO_SETTLE) {
28670
+ this._settleCameraMovement();
28671
+ }
28672
+ }
28673
+ }
28674
+ this._lastCameraPos = camera.positionWC.clone();
28675
+ this._lastCameraDir = camera.directionWC.clone();
28676
+ this._updateFps();
28677
+ }
28678
+ _updateFps() {
28679
+ const now = performance.now();
28680
+ if (this._lastFrameTime != null) {
28681
+ const dt = now - this._lastFrameTime;
28682
+ if (dt > 0) {
28683
+ const instantFps = 1000 / dt;
28684
+ this._avgFps = this._avgFps == null ? instantFps : (this._avgFps * 0.9 + instantFps * 0.1);
28685
+ }
28686
+ }
28687
+ this._lastFrameTime = now;
28688
+ if (this._avgFps == null) {
28689
+ return;
28722
28690
  }
28723
- }
28724
- Walkthrough.Stop = Stop;
28725
- function IsRunning(params) {
28726
- const viewer = params.viewer;
28727
- const data = viewer[VIEWER_WALKTHROUGH_DATA_KEY];
28728
- return (data === null || data === void 0 ? void 0 : data.handlerScreenSpace) != null;
28729
- }
28730
- Walkthrough.IsRunning = IsRunning;
28731
- function SetWalkMoveRate(params) {
28732
- var _a;
28733
- const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
28734
- if (data) {
28735
- data.walkMoveRate = params.rate;
28691
+ // Hysteresis around the slow-scene threshold to avoid flip-flopping at the boundary.
28692
+ if (!this._isSlowScene && this._avgFps < SLOW_SCENE_ENTER_FPS) {
28693
+ this._isSlowScene = true;
28736
28694
  }
28737
- }
28738
- Walkthrough.SetWalkMoveRate = SetWalkMoveRate;
28739
- function SetMoveType(params) {
28740
- var _a;
28741
- const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
28742
- if (data) {
28743
- data.moveType = params.type;
28695
+ else if (this._isSlowScene && this._avgFps > SLOW_SCENE_EXIT_FPS) {
28696
+ this._isSlowScene = false;
28744
28697
  }
28745
- }
28746
- Walkthrough.SetMoveType = SetMoveType;
28747
- function GetWalkMoveRate(params) {
28748
- var _a;
28749
- const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
28750
- return data === null || data === void 0 ? void 0 : data.walkMoveRate;
28751
- }
28752
- Walkthrough.GetWalkMoveRate = GetWalkMoveRate;
28753
- function GetFlyMoveRate(params) {
28754
- var _a;
28755
- const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
28756
- return data === null || data === void 0 ? void 0 : data.flyMoveRate;
28757
- }
28758
- Walkthrough.GetFlyMoveRate = GetFlyMoveRate;
28759
- function SetFlyMoveRate(params) {
28760
- var _a;
28761
- const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
28762
- if (data) {
28763
- data.flyMoveRate = params.rate;
28698
+ const targetDelay = this._avgFps < HOVER_DELAY_BRACKET_FPS_SLOW ? HOVER_DELAY_SLOW_MS :
28699
+ this._avgFps < HOVER_DELAY_BRACKET_FPS_MID ? HOVER_DELAY_MID_MS :
28700
+ HOVER_DELAY_FAST_MS;
28701
+ if (targetDelay !== this._hoverDelayMs && (now - this._lastDelaySwitchTime) > DELAY_SWITCH_MIN_INTERVAL_MS) {
28702
+ this._hoverDelayMs = targetDelay;
28703
+ this._lastDelaySwitchTime = now;
28764
28704
  }
28765
28705
  }
28766
- Walkthrough.SetFlyMoveRate = SetFlyMoveRate;
28767
- function GetMoveType(params) {
28768
- var _a;
28769
- const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
28770
- return data === null || data === void 0 ? void 0 : data.moveType;
28771
- }
28772
- Walkthrough.GetMoveType = GetMoveType;
28773
- })(Walkthrough || (Walkthrough = {}));
28706
+ }
28774
28707
 
28775
28708
  var ECursor;
28776
28709
  (function (ECursor) {
28777
28710
  ECursor["Select"] = "select";
28778
28711
  ECursor["Pan"] = "pan";
28779
28712
  ECursor["Measure"] = "measure";
28780
- ECursor["Walkthrough"] = "walkthrough";
28781
28713
  })(ECursor || (ECursor = {}));
28782
28714
  var ESecondaryCursor;
28783
28715
  (function (ESecondaryCursor) {
@@ -28787,13 +28719,7 @@ var ESecondaryCursor;
28787
28719
  ESecondaryCursor["MeasurePoint"] = "measure-point";
28788
28720
  ESecondaryCursor["MeasurePolyline"] = "measure-polyline";
28789
28721
  ESecondaryCursor["MeasurePolygon"] = "measure-polygon";
28790
- ESecondaryCursor["WalkthroughPin"] = "walkthrough-pin";
28791
28722
  })(ESecondaryCursor || (ESecondaryCursor = {}));
28792
- const KEY_WALKTHROUGH_MODE = "WidgetCursorBar.Walkthrough.Mode";
28793
- const KEY_WALKTHROUGH_SPEED_FLY = "WidgetCursorBar.Walkthrough.SpeedFly";
28794
- const KEY_WALKTHROUGH_SPEED_WALK = "WidgetCursorBar.Walkthrough.SpeedWalk";
28795
- const KEY_WALKTHROUGH_EXPANDED = "WidgetCursorBar.Walkthrough.Expanded";
28796
- const VIEWER_WALKTHROUGH_PANEL_CSS_VAR_BOTTOM = "--viewer-walkthrough-panel-bottom";
28797
28723
  class WidgetCursorBar extends Widget.AWidget {
28798
28724
  constructor(params) {
28799
28725
  super(params);
@@ -28806,22 +28732,15 @@ class WidgetCursorBar extends Widget.AWidget {
28806
28732
  if (this._selectedCursor == ECursor.Select || this._selectedSecondaryCursor == ESecondaryCursor.Select) {
28807
28733
  this._listenSelection();
28808
28734
  }
28809
- document.documentElement.style.setProperty(VIEWER_WALKTHROUGH_PANEL_CSS_VAR_BOTTOM, "0px");
28810
28735
  }
28811
28736
  Dispose() {
28812
- var _a, _b, _c;
28737
+ var _a, _b;
28813
28738
  super.Dispose();
28814
28739
  this._disposeMeasureTool();
28815
28740
  this._disposeCesiumEvent();
28816
- this._disposeWalkthroughBar();
28817
28741
  if ((_b = (_a = this._viewer) === null || _a === void 0 ? void 0 : _a.canvas) === null || _b === void 0 ? void 0 : _b.style.cursor) {
28818
28742
  this._viewer.canvas.style.removeProperty("cursor");
28819
28743
  }
28820
- if (((_c = this._viewer) === null || _c === void 0 ? void 0 : _c.scene) && !this._viewer.isDestroyed()) {
28821
- Walkthrough.Stop({
28822
- viewer: this._viewer
28823
- });
28824
- }
28825
28744
  }
28826
28745
  _generateStyles() {
28827
28746
  if (document.getElementById(this.STYLESHEET_ID)) {
@@ -28844,7 +28763,6 @@ class WidgetCursorBar extends Widget.AWidget {
28844
28763
  box-sizing: border-box;
28845
28764
  display: flex;
28846
28765
  flex-direction: column;
28847
- overflow: hidden;
28848
28766
  pointer-events: none;
28849
28767
  color: black;
28850
28768
  }
@@ -28862,9 +28780,13 @@ class WidgetCursorBar extends Widget.AWidget {
28862
28780
 
28863
28781
  .NextspaceCursorBarPrimContent {
28864
28782
  align-items: center;
28865
- background-color: #21272a;
28783
+ background: rgba(33, 39, 42, 0.8);
28784
+ -webkit-backdrop-filter: blur(20px);
28785
+ backdrop-filter: blur(20px);
28786
+ box-shadow: 0px 0px 1px rgba(18, 22, 25, 0.36), 0px 18px 36px -4px rgba(18, 22, 25, 0.36);
28866
28787
  border-radius: 9px;
28867
28788
  display: flex;
28789
+ height: 44px;
28868
28790
  pointer-events: auto;
28869
28791
  width: -webkit-max-content;
28870
28792
  width: max-content;
@@ -28880,21 +28802,18 @@ class WidgetCursorBar extends Widget.AWidget {
28880
28802
  border-radius: 0;
28881
28803
  display: flex;
28882
28804
  height: 100%;
28883
- height: -webkit-max-content;
28884
- height: max-content;
28885
28805
  justify-content: center;
28886
- padding: 8px;
28887
- padding-left: 8px;
28806
+ padding: 6px 4px;
28888
28807
  }
28889
28808
 
28890
28809
  .NextspaceCursorBarPrimControl:first-of-type .NextspaceCursorBarPrimControlInner {
28891
28810
  border-radius: 9px 0 0 9px;
28892
- padding-left: 8px;
28811
+ padding-left: 4px;
28893
28812
  }
28894
28813
 
28895
28814
  .NextspaceCursorBarPrimControl:last-of-type .NextspaceCursorBarPrimControlInner {
28896
28815
  border-radius: 0 9px 9px 0;
28897
- padding-right: 8px;
28816
+ padding-right: 4px;
28898
28817
  }
28899
28818
 
28900
28819
  .NextspaceCursorBarPrimControl:first-of-type:last-of-type .NextspaceCursorBarPrimControlInner {
@@ -28920,6 +28839,7 @@ class WidgetCursorBar extends Widget.AWidget {
28920
28839
 
28921
28840
  .NextspaceCursorBarPrimControlInner[is-selected="true"] {
28922
28841
  background: #33b1ff;
28842
+ box-shadow: inset 0 2px 0 0 #64c4ff;
28923
28843
  }
28924
28844
 
28925
28845
  .NextspaceCursorBarSec {
@@ -28950,8 +28870,7 @@ class WidgetCursorBar extends Widget.AWidget {
28950
28870
  height: -webkit-max-content;
28951
28871
  height: max-content;
28952
28872
  justify-content: center;
28953
- padding: 8px;
28954
- padding-left: 8px;
28873
+ padding: 6px;
28955
28874
  border: 2px solid transparent;
28956
28875
  flex-shrink: 0;
28957
28876
  margin: 6px 0 6px 6px;
@@ -28969,7 +28888,7 @@ class WidgetCursorBar extends Widget.AWidget {
28969
28888
  }
28970
28889
 
28971
28890
  .NextspaceCursorBarSecControl:first-of-type {
28972
- padding-left: 8px;
28891
+ padding-left: 6px;
28973
28892
  }
28974
28893
 
28975
28894
  .NextspaceCursorBarSecControlIcon {
@@ -28990,165 +28909,6 @@ class WidgetCursorBar extends Widget.AWidget {
28990
28909
  transform: scale(1.2);
28991
28910
  }
28992
28911
 
28993
- .NextspaceWalkthroughBar {
28994
- position: absolute;
28995
- z-index: 1;
28996
- bottom: 10px;
28997
- left: calc(45px + var(${VIEWER_LEFT_PANEL_CSS_VAR_LEFT}));
28998
- width: min(1100px, calc(100vw - 205px));
28999
- box-sizing: border-box;
29000
- display: flex;
29001
- flex-direction: column;
29002
- pointer-events: auto;
29003
- font-size: 12px;
29004
- font-family: Arial;
29005
- transition: 0.3s ease;
29006
- }
29007
-
29008
- .NextspaceWalkthroughBar * {
29009
- box-sizing: border-box;
29010
- }
29011
-
29012
- .NextspaceWalkthroughBar[expanded="false"] {
29013
- width: 395px;
29014
- }
29015
-
29016
- .NextspaceWalkthroughBar[expanded="false"] .NextspaceWalkthroughBarInputs {
29017
- flex-direction: row;
29018
- margin-right: 0;
29019
- }
29020
-
29021
- .NextspaceWalkthroughBar[expanded="false"] .NextspaceWalkthroughBarRow {
29022
- margin-right: 25px;
29023
- margin-bottom: 0;
29024
- }
29025
-
29026
- .NextspaceWalkthroughBar[expanded="false"] .NextspaceWalkthroughBarRowTip,
29027
- .NextspaceWalkthroughBar[expanded="false"] .NextspaceWalkthroughBarTips {
29028
- display: none;
29029
- }
29030
-
29031
- .NextspaceWalkthroughBarContent {
29032
- background-color: white;
29033
- border-radius: 8px;
29034
- display: flex;
29035
- flex-direction: row;
29036
- padding: 14px 18px;
29037
- box-shadow: 0px 0px 1px rgba(18, 22, 25, 0.36), 0px 18px 36px -4px rgba(18, 22, 25, 0.36);
29038
- }
29039
-
29040
- .NextspaceWalkthroughBarTitle {
29041
- opacity: 0.7;
29042
- color: white;
29043
- font-size: 12px;
29044
- font-family: Arial;
29045
- font-style: normal;
29046
- letter-spacing: 0.15em;
29047
- margin-bottom: 15px;
29048
- position: absolute;
29049
- top: -15px;
29050
- left: 5px;
29051
- }
29052
-
29053
- .NextspaceWalkthroughBarInputs {
29054
- display: flex;
29055
- flex-direction: column;
29056
- margin-right: 40px;
29057
- }
29058
-
29059
- .NextspaceWalkthroughBarRowTip {
29060
- color: #000;
29061
- font-family: Arial;
29062
- font-size: 12px;
29063
- font-style: normal;
29064
- font-weight: 300;
29065
- letter-spacing: .01em;
29066
- background: #efefefbf;
29067
- padding: 8px;
29068
- gap: 6px;
29069
- border-radius: 5px;
29070
- }
29071
-
29072
- .NextspaceWalkthroughBarRow {
29073
- align-items: center;
29074
- display: flex;
29075
- margin-bottom: 5px;
29076
- }
29077
-
29078
- .NextspaceWalkthroughBarInputs .NextspaceWalkthroughBarRow {
29079
- margin-right: 20px;
29080
- }
29081
-
29082
- .NextspaceWalkthroughBarRowLabel {
29083
- margin-right: 8px;
29084
- flex-shrink: 0;
29085
- }
29086
-
29087
- .NextspaceWalkthroughBarRowValue {
29088
- flex-grow: 1;
29089
- max-width: 120px;
29090
- }
29091
-
29092
- .NextspaceWalkthroughBarRowValue input {
29093
- width: 100%;
29094
- padding: 4px;
29095
- border: 1px solid #ccc;
29096
- border-radius: 4px;
29097
- }
29098
-
29099
- .NextspaceWalkthroughBarIcon {
29100
- margin-right: 20px;
29101
- flex-shrink: 0;
29102
- }
29103
-
29104
- .NextspaceWalkthroughButtonClose {
29105
- position: absolute;
29106
- top: 6px;
29107
- right: 8px;
29108
- z-index: 1;
29109
- font-size: 25px;
29110
- color: black;
29111
- cursor: pointer;
29112
- transition: 0.3s ease;
29113
- }
29114
-
29115
- .NextspaceWalkthroughButtonExpand {
29116
- position: absolute;
29117
- top: 6px;
29118
- right: 40px;
29119
- z-index: 1;
29120
- font-size: 25px;
29121
- color: black;
29122
- cursor: pointer;
29123
- transition: 0.3s ease;
29124
- display: flex;
29125
- align-items: center;
29126
- justify-content: center;
29127
- height: 24px;
29128
- width: 24px;
29129
- }
29130
-
29131
- .NextspaceWalkthroughButtonClose:hover,
29132
- .NextspaceWalkthroughButtonExpand:hover {
29133
- transform: scale(1.2);
29134
- }
29135
-
29136
- .NextspaceWalkthroughBarTips {
29137
- flex-grow: 1;
29138
- flex-shrink: 1;
29139
- display: flex;
29140
- color: black;
29141
- font-size: 12px;
29142
- font-family: Arial;
29143
- }
29144
-
29145
- .NextspaceWalkthroughBarTips >* {
29146
- margin-right: 24px;
29147
- }
29148
-
29149
- .NextspaceWalkthroughBarTips >*:last-child {
29150
- margin-right: 0;
29151
- }
29152
28912
  `;
29153
28913
  document.head.appendChild(style);
29154
28914
  }
@@ -29174,7 +28934,6 @@ class WidgetCursorBar extends Widget.AWidget {
29174
28934
  this._generateSelect();
29175
28935
  this._generatePan();
29176
28936
  this._generateMeasure();
29177
- this._generateWalkthrough();
29178
28937
  this._updateControls();
29179
28938
  this.Container.appendChild(element);
29180
28939
  this._element = element;
@@ -29193,16 +28952,8 @@ class WidgetCursorBar extends Widget.AWidget {
29193
28952
  `;
29194
28953
  div.appendChild(inner);
29195
28954
  inner.addEventListener("click", () => {
29196
- var _a;
29197
28955
  this._disposeMeasureTool();
29198
28956
  this._disposeCesiumEvent();
29199
- this._disposeWalkthroughBar();
29200
- if (((_a = this._viewer) === null || _a === void 0 ? void 0 : _a.scene) && !this._viewer.isDestroyed()) {
29201
- Walkthrough.Stop({
29202
- viewer: this._viewer
29203
- });
29204
- }
29205
- this._disposeWalkthroughBar();
29206
28957
  onClick();
29207
28958
  this._updateControls();
29208
28959
  });
@@ -29332,473 +29083,6 @@ class WidgetCursorBar extends Widget.AWidget {
29332
29083
  this._enabledMeasureTool.Start();
29333
29084
  }, polygonSvg);
29334
29085
  }
29335
- _generateWalkthrough() {
29336
- const svg = `
29337
- <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
29338
- <path d="M17.5033 4C16.8406 4 16.205 4.26339 15.7364 4.73223C15.2678 5.20107 15.0045 5.83696 15.0045 6.5C15.0045 7.16304 15.2678 7.79893 15.7364 8.26777C16.205 8.73661 16.8406 9 17.5033 9C18.166 9 18.8015 8.73661 19.2701 8.26777C19.7388 7.79893 20.002 7.16304 20.002 6.5C20.002 5.83696 19.7388 5.20107 19.2701 4.73223C18.8015 4.26339 18.166 4 17.5033 4ZM15.5023 10C15.1066 10 14.7378 10.1015 14.4052 10.2656C14.3549 10.2813 14.306 10.3009 14.2588 10.3242L10.3448 12.1992C10.1322 12.3003 9.96216 12.4733 9.86453 12.6875L8.09784 16.5859C8.0405 16.7059 8.00764 16.836 8.00118 16.9688C7.99472 17.1016 8.01479 17.2344 8.06021 17.3593C8.10563 17.4843 8.1755 17.5989 8.26572 17.6965C8.35594 17.7941 8.46471 17.8727 8.58567 17.9278C8.70662 17.9828 8.83733 18.0132 8.97016 18.0171C9.10299 18.0211 9.23526 17.9984 9.35924 17.9506C9.48323 17.9028 9.59644 17.8307 9.69225 17.7386C9.78806 17.6464 9.86454 17.5361 9.91724 17.4141L11.3638 14.2246L12.658 13.8359C12.3918 15.2411 12.0603 16.9816 12.0587 16.9902C12.0583 16.9923 12.0572 16.994 12.0568 16.9961C12.0568 16.9961 12.0568 17 12.0568 17C12.024 17.1615 12.006 17.3288 12.006 17.5C12.006 18.271 12.3631 18.9514 12.9118 19.4102L12.9196 19.4336L16.8103 22.5L17.923 26.6953L18.0225 27.1953C18.0677 27.4221 18.19 27.6263 18.3687 27.773C18.5474 27.9197 18.7714 27.9999 19.0025 28C19.2676 28 19.5218 27.8946 19.7093 27.7071C19.8967 27.5196 20.002 27.2652 20.002 27C20.0019 26.9344 19.9954 26.869 19.9825 26.8047V26.8008C19.9812 26.7969 19.9799 26.793 19.9786 26.7891L18.983 21.8047C18.9562 21.6693 18.9017 21.541 18.8229 21.4277L16.9528 18.0039C16.9546 17.9951 16.953 17.9854 16.9547 17.9766L17.9366 13.0625L17.9347 13.0605C17.9762 12.8798 18.003 12.6933 18.003 12.5C18.003 11.1207 16.8837 10.0011 15.5023 10ZM19.3871 13.7422L18.9186 16.0078L19.3344 16.3809C19.4093 16.4489 19.4962 16.5059 19.5882 16.5469L22.5866 17.9102V17.9082C22.7165 17.9681 22.8576 17.9994 23.0005 18C23.2656 18 23.5198 17.8946 23.7073 17.7071C23.8947 17.5196 24 17.2652 24 17C23.9996 16.8084 23.9442 16.6209 23.8404 16.4599C23.7366 16.2989 23.5887 16.1711 23.4144 16.0918V16.0898L20.5545 14.7891L19.3871 13.7422ZM11.9631 20.7246L11.4497 22.4219L9.22228 26.3613L9.1481 26.4863L9.15005 26.4883C9.13825 26.5087 9.12718 26.5296 9.11686 26.5508L9.10905 26.5625C9.0425 26.6987 9.00778 26.8484 9.00754 27C9.00754 27.2652 9.11285 27.5196 9.30029 27.7071C9.48773 27.8946 9.74195 28 10.007 28C10.1647 27.9999 10.3201 27.9626 10.4606 27.891C10.601 27.8193 10.7225 27.7155 10.8152 27.5879H10.8172L10.8328 27.5645C10.8334 27.5632 10.8341 27.5618 10.8347 27.5605L14.1592 22.5117L11.9631 20.7246Z" fill="white"/>
29339
- </svg>
29340
- `;
29341
- this._generateControl("Walkthrough", ECursor.Walkthrough, () => {
29342
- var _a;
29343
- this._selectedSecondaryCursor = ESecondaryCursor.Select;
29344
- this._selectedCursor = this._selectedCursor == ECursor.Walkthrough ? ECursor.Select : ECursor.Walkthrough;
29345
- if (this._selectedCursor == ECursor.Walkthrough) {
29346
- this._generateWalkthroughSecondary();
29347
- this._updateSecondary();
29348
- if (((_a = this._viewer) === null || _a === void 0 ? void 0 : _a.scene) && !this._viewer.isDestroyed()) {
29349
- Walkthrough.Start({
29350
- viewer: this._viewer
29351
- });
29352
- let moveType = localStorage.getItem(KEY_WALKTHROUGH_MODE);
29353
- if (!moveType) {
29354
- moveType = Walkthrough.EMoveType.Walk;
29355
- }
29356
- Walkthrough.SetMoveType({
29357
- type: moveType,
29358
- viewer: this._viewer
29359
- });
29360
- let speed = localStorage.getItem(KEY_WALKTHROUGH_SPEED_FLY);
29361
- if (speed != null && !isNaN(+speed)) {
29362
- Walkthrough.SetFlyMoveRate({
29363
- rate: +speed,
29364
- viewer: this._viewer
29365
- });
29366
- }
29367
- speed = localStorage.getItem(KEY_WALKTHROUGH_SPEED_WALK);
29368
- if (speed != null && !isNaN(+speed)) {
29369
- Walkthrough.SetWalkMoveRate({
29370
- rate: +speed,
29371
- viewer: this._viewer
29372
- });
29373
- }
29374
- }
29375
- this._generateWalkthroughBar();
29376
- }
29377
- else {
29378
- this._secondary.style.display = "none";
29379
- }
29380
- if (this._selectedCursor == ECursor.Select || this._selectedSecondaryCursor == ESecondaryCursor.Select) {
29381
- this._listenSelection();
29382
- }
29383
- this.OnCursorChange.Trigger(this._selectedCursor);
29384
- }, svg);
29385
- }
29386
- _generateWalkthroughSecondary() {
29387
- this._secondaryContent.innerHTML = "";
29388
- this._secondary.style.display = "flex";
29389
- const selectSvg = `
29390
- <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
29391
- <path d="M11.0706 25L9 7L23 17.8592L15.3135 18.3375L11.0706 25Z" fill="white" stroke="white" strokeLinejoin="round"/>
29392
- </svg>
29393
- `;
29394
- this._generateSecondaryControl("Select", ESecondaryCursor.Select, () => {
29395
- if (this._walkthroughPinEventRemoval) {
29396
- this._walkthroughPinEventRemoval();
29397
- this._walkthroughPinEventRemoval = null;
29398
- }
29399
- this._selectedSecondaryCursor = ESecondaryCursor.Select;
29400
- this._listenSelection();
29401
- }, selectSvg);
29402
- const panSvg = `
29403
- <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
29404
- <path d="M15.5652 6C14.9172 6 14.3913 6.51692 14.3913 7.15385V14.4615H13.6087V8.69231C13.6087 8.05538 13.0828 7.53846 12.4348 7.53846C11.7868 7.53846 11.2609 8.05538 11.2609 8.69231V14.4615V16.7692V19.6734C11.2609 19.6734 9.0069 18.2402 7.87211 17.7548C7.55594 17.6194 7.22575 17.5385 6.89079 17.5385C5.1401 17.5385 5 19.0769 5 19.0769L8.13043 21.3846L10.6357 24.3398C11.5279 25.3922 12.85 26 14.243 26H19.8696C21.5983 26 23 24.6223 23 22.9231V14.4615V11C23 10.3631 22.4741 9.84615 21.8261 9.84615C21.1781 9.84615 20.6522 10.3631 20.6522 11V14.4615H19.8696V8.69231C19.8696 8.05538 19.3437 7.53846 18.6957 7.53846C18.0477 7.53846 17.5217 8.05538 17.5217 8.69231V14.4615H16.7391V7.15385C16.7391 6.51692 16.2132 6 15.5652 6Z" fill="white"/>
29405
- </svg>
29406
- `;
29407
- this._generateSecondaryControl("Pan", ESecondaryCursor.Pan, () => {
29408
- if (this._walkthroughPinEventRemoval) {
29409
- this._walkthroughPinEventRemoval();
29410
- this._walkthroughPinEventRemoval = null;
29411
- }
29412
- if (this._selectedSecondaryCursor == ESecondaryCursor.Pan) {
29413
- this._selectedSecondaryCursor = ESecondaryCursor.Select;
29414
- this._listenSelection();
29415
- }
29416
- else {
29417
- this._selectedSecondaryCursor = ESecondaryCursor.Pan;
29418
- }
29419
- this._updateSecondary();
29420
- }, panSvg);
29421
- const pinSvg = `
29422
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
29423
- <path d="M6 20H18C18.55 20 19 20.45 19 21C19 21.55 18.55 22 18 22H6C5.45 22 5 21.55 5 21C5 20.45 5.45 20 6 20ZM12 7C10.9 7 10 7.9 10 9C10 10.1 10.9 11 12 11C13.1 11 14 10.1 14 9C14 7.9 13.1 7 12 7ZM12 2C15.27 2 19 4.46 19 9.15C19 12.13 16.87 15.27 12.61 18.54C12.25 18.82 11.75 18.82 11.39 18.54C7.13 15.26 5 12.13 5 9.15C5 4.46 8.73 2 12 2Z" fill="white"/>
29424
- </svg>
29425
- `;
29426
- this._generateSecondaryControl("Move to point", ESecondaryCursor.WalkthroughPin, () => {
29427
- if (this._selectedSecondaryCursor == ESecondaryCursor.WalkthroughPin) {
29428
- this._selectedSecondaryCursor = ESecondaryCursor.Select;
29429
- this._listenSelection();
29430
- }
29431
- else {
29432
- this._selectedSecondaryCursor = ESecondaryCursor.WalkthroughPin;
29433
- this._initWalkthroughPin();
29434
- }
29435
- this._updateSecondary();
29436
- }, pinSvg);
29437
- }
29438
- _initWalkthroughPin() {
29439
- if (this._walkthroughPinEventRemoval) {
29440
- this._walkthroughPinEventRemoval();
29441
- this._walkthroughPinEventRemoval = null;
29442
- }
29443
- let pointer;
29444
- let events = new ScreenSpaceEventHandler(this._viewer.scene.canvas);
29445
- this._walkthroughPinEventRemoval = () => {
29446
- var _a;
29447
- if (events && !events.isDestroyed()) {
29448
- events.destroy();
29449
- events = null;
29450
- }
29451
- if (((_a = this._viewer) === null || _a === void 0 ? void 0 : _a.scene) && !this._viewer.scene.isDestroyed()) {
29452
- if (pointer && this._viewer.entities.contains(pointer)) {
29453
- this._viewer.entities.remove(pointer);
29454
- }
29455
- pointer = null;
29456
- this._viewer.scene.requestRender();
29457
- }
29458
- };
29459
- let dropPosition3d;
29460
- let dropOnTerrain = false;
29461
- events.setInputAction((e) => {
29462
- const pos2d = e.endPosition;
29463
- // First try find a position on a 'thing'.
29464
- // This lets us put our pin underground if there is something there.
29465
- let pos3d = DrawingUtils.GetAccuratePosition(this._viewer, pos2d, true, pointer ? [pointer] : null);
29466
- dropOnTerrain = false;
29467
- // Fallback to position including terrain as an option.
29468
- if (!Cartes.ValidateCartes3(pos3d)) {
29469
- pos3d = DrawingUtils.GetAccuratePosition(this._viewer, pos2d, false, pointer ? [pointer] : null);
29470
- dropOnTerrain = true;
29471
- }
29472
- if (Cartes.ValidateCartes3(pos3d)) {
29473
- dropPosition3d = pos3d;
29474
- }
29475
- }, ScreenSpaceEventType.MOUSE_MOVE);
29476
- let processing = false;
29477
- events.setInputAction(async (e) => {
29478
- if (processing) {
29479
- return;
29480
- }
29481
- processing = true;
29482
- try {
29483
- if (!Cartes.ValidateCartes3(dropPosition3d) && e.position) {
29484
- // First try find a position on a 'thing'.
29485
- // This lets us put our pin underground if there is something there.
29486
- let pos3d = DrawingUtils.GetAccuratePosition(this._viewer, e.position, true);
29487
- dropOnTerrain = false;
29488
- // Fallback to position including terrain as an option.
29489
- if (!Cartes.ValidateCartes3(pos3d)) {
29490
- pos3d = DrawingUtils.GetAccuratePosition(this._viewer, e.position, false);
29491
- dropOnTerrain = true;
29492
- }
29493
- dropPosition3d = pos3d;
29494
- }
29495
- let pos3d = dropPosition3d === null || dropPosition3d === void 0 ? void 0 : dropPosition3d.clone();
29496
- if (Cartes.ValidateCartes3(pos3d)) {
29497
- const carto = Cartographic.fromCartesian(pos3d);
29498
- // If we can raycast to something then we won't adjust above terrain.
29499
- // Eg: we clicked on an Entity so if it's underground, that's likely intended.
29500
- if (dropOnTerrain) {
29501
- const terrainCarto = carto.clone();
29502
- terrainCarto.height = 0;
29503
- if (this._viewer.scene.terrainProvider instanceof EllipsoidTerrainProvider) ;
29504
- else {
29505
- const sample = await sampleTerrainMostDetailed(this._viewer.scene.terrainProvider, [terrainCarto]);
29506
- const terrainHeight = (sample === null || sample === void 0 ? void 0 : sample.length) ? sample[0].height : null;
29507
- if (terrainHeight != null) {
29508
- if (carto.height < terrainHeight) {
29509
- carto.height = terrainHeight;
29510
- }
29511
- }
29512
- }
29513
- }
29514
- // Add average human height.
29515
- carto.height += 1.7;
29516
- pos3d = Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height);
29517
- this._viewer.camera.flyTo({
29518
- destination: pos3d,
29519
- duration: 2,
29520
- orientation: {
29521
- heading: this._viewer.camera.heading,
29522
- pitch: Math$1.toRadians(0),
29523
- roll: Math$1.toRadians(0)
29524
- }
29525
- });
29526
- // Disable this picking cursor.
29527
- this._selectedSecondaryCursor = ESecondaryCursor.Select;
29528
- this._listenSelection();
29529
- this._updateSecondary();
29530
- if (this._walkthroughPinEventRemoval) {
29531
- this._walkthroughPinEventRemoval();
29532
- this._walkthroughPinEventRemoval = null;
29533
- }
29534
- }
29535
- }
29536
- catch (e) {
29537
- console.error(e);
29538
- }
29539
- processing = false;
29540
- }, ScreenSpaceEventType.LEFT_CLICK);
29541
- }
29542
- /**
29543
- * Generates the Walkthrough controls bar at the bottom of the screen.
29544
- * This bar will be collapsable to show minimal information.
29545
- * A TODO is to break this class into pieces similar the ViewBar.
29546
- */
29547
- _generateWalkthroughBar() {
29548
- this._disposeWalkthroughBar();
29549
- const element = document.createElement("div");
29550
- element.className = "NextspaceWalkthroughBar";
29551
- this.Container.appendChild(element);
29552
- const content = document.createElement("div");
29553
- content.className = "NextspaceWalkthroughBarContent";
29554
- element.appendChild(content);
29555
- const inputs = document.createElement("div");
29556
- inputs.className = "NextspaceWalkthroughBarInputs";
29557
- inputs.style.marginRight = "40px";
29558
- const title = document.createElement("div");
29559
- title.className = "NextspaceWalkthroughBarTitle";
29560
- title.innerText = "Walkthrough";
29561
- inputs.appendChild(title);
29562
- // Expanded by default to show how to use Walkthrough.
29563
- let expanded = localStorage.getItem(KEY_WALKTHROUGH_EXPANDED) != "false";
29564
- // Close button.
29565
- {
29566
- const svg = `
29567
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
29568
- <path d="M18.3002 5.70973C17.9102 5.31973 17.2802 5.31973 16.8902 5.70973L12.0002 10.5897L7.11022 5.69973C6.72022 5.30973 6.09021 5.30973 5.70021 5.69973C5.31021 6.08973 5.31021 6.71973 5.70021 7.10973L10.5902 11.9997L5.70021 16.8897C5.31021 17.2797 5.31021 17.9097 5.70021 18.2997C6.09021 18.6897 6.72022 18.6897 7.11022 18.2997L12.0002 13.4097L16.8902 18.2997C17.2802 18.6897 17.9102 18.6897 18.3002 18.2997C18.6902 17.9097 18.6902 17.2797 18.3002 16.8897L13.4102 11.9997L18.3002 7.10973C18.6802 6.72973 18.6802 6.08973 18.3002 5.70973Z" fill="black"/>
29569
- </svg>
29570
- `;
29571
- const close = document.createElement("div");
29572
- close.className = "NextspaceWalkthroughButtonClose";
29573
- close.innerHTML = svg;
29574
- close.onclick = () => {
29575
- var _a;
29576
- // Toggles off the Walkthrough mode (enables first primary cursor).
29577
- // TODO: We need a more elegant way to handle this.
29578
- this._secondary.style.display = "none";
29579
- this._selectedCursor = ECursor.Select;
29580
- this._selectedSecondaryCursor = ESecondaryCursor.None;
29581
- this._updateControls();
29582
- this._updateSecondary();
29583
- this._disposeWalkthroughBar();
29584
- this._listenSelection();
29585
- if (((_a = this._viewer) === null || _a === void 0 ? void 0 : _a.scene) && !this._viewer.isDestroyed()) {
29586
- Walkthrough.Stop({
29587
- viewer: this._viewer
29588
- });
29589
- }
29590
- this.OnCursorChange.Trigger(this._selectedCursor);
29591
- };
29592
- content.appendChild(close);
29593
- }
29594
- // Toggle expand button.
29595
- {
29596
- const svgExpand = `
29597
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
29598
- <path d="M6 14C5.45 14 5 14.45 5 15V18C5 18.55 5.45 19 6 19H9C9.55 19 10 18.55 10 18C10 17.45 9.55 17 9 17H7V15C7 14.45 6.55 14 6 14ZM6 10C6.55 10 7 9.55 7 9V7H9C9.55 7 10 6.55 10 6C10 5.45 9.55 5 9 5H6C5.45 5 5 5.45 5 6V9C5 9.55 5.45 10 6 10ZM17 17H15C14.45 17 14 17.45 14 18C14 18.55 14.45 19 15 19H18C18.55 19 19 18.55 19 18V15C19 14.45 18.55 14 18 14C17.45 14 17 14.45 17 15V17ZM14 6C14 6.55 14.45 7 15 7H17V9C17 9.55 17.45 10 18 10C18.55 10 19 9.55 19 9V6C19 5.45 18.55 5 18 5H15C14.45 5 14 5.45 14 6Z" fill="black"/>
29599
- </svg>
29600
- `;
29601
- const svgMinimize = `
29602
- <svg width="16" height="2" viewBox="0 0 16 2" fill="none" xmlns="http://www.w3.org/2000/svg">
29603
- <path d="M15 1L1 0.999999" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
29604
- </svg>
29605
- `;
29606
- const heightCollapsed = "70px";
29607
- const heightExpanded = "150px";
29608
- const expand = document.createElement("div");
29609
- expand.className = "NextspaceWalkthroughButtonExpand";
29610
- expand.innerHTML = expanded ? svgMinimize : svgExpand;
29611
- expand.onclick = () => {
29612
- expanded = !expanded;
29613
- expand.innerHTML = expanded ? svgMinimize : svgExpand;
29614
- element.setAttribute("expanded", expanded ? "true" : "false");
29615
- localStorage.setItem(KEY_WALKTHROUGH_EXPANDED, expanded ? "true" : "false");
29616
- document.documentElement.style.setProperty(VIEWER_WALKTHROUGH_PANEL_CSS_VAR_BOTTOM, expanded ? heightExpanded : heightCollapsed);
29617
- };
29618
- content.appendChild(expand);
29619
- element.setAttribute("expanded", expanded ? "true" : "false");
29620
- document.documentElement.style.setProperty(VIEWER_WALKTHROUGH_PANEL_CSS_VAR_BOTTOM, expanded ? heightExpanded : heightCollapsed);
29621
- }
29622
- content.appendChild(inputs);
29623
- const tips = document.createElement("div");
29624
- tips.className = "NextspaceWalkthroughBarTips";
29625
- {
29626
- const wasd = document.createElement("div");
29627
- wasd.setAttribute("style", `
29628
- display: flex;
29629
- flex-direction: column;
29630
- justify-content: flex-end;
29631
- `);
29632
- const wasdSvg = `
29633
- <svg width="132" height="87" viewBox="0 0 188 124" fill="none" xmlns="http://www.w3.org/2000/svg"><rect y="64" width="60" height="60" rx="6" fill="#ebebeb"></rect><rect x="128" y="64" width="60" height="60" rx="6" fill="#ebebeb"></rect><rect x="64" width="60" height="60" rx="6" fill="#ebebeb"></rect><rect x="64" y="64" width="60" height="60" rx="6" fill="#ebebeb"></rect><path d="M88.2841 39L83.5114 21.5455H85.6591L89.3068 35.7614H89.4773L93.1932 21.5455H95.5795L99.2955 35.7614H99.4659L103.114 21.5455H105.261L100.489 39H98.3068L94.4545 25.0909H94.3182L90.4659 39H88.2841Z" fill="#525252"></path><path d="M24.8295 103H22.6136L29.0227 85.5455H31.2045L37.6136 103H35.3977L30.1818 88.3068H30.0455L24.8295 103ZM25.6477 96.1818H34.5795V98.0568H25.6477V96.1818Z" fill="#525252"></path><path d="M97.6591 89.9091C97.5568 89.0455 97.142 88.375 96.4148 87.8977C95.6875 87.4205 94.7955 87.1818 93.7386 87.1818C92.9659 87.1818 92.2898 87.3068 91.7102 87.5568C91.1364 87.8068 90.6875 88.1506 90.3636 88.5881C90.0455 89.0256 89.8864 89.5227 89.8864 90.0795C89.8864 90.5455 89.9972 90.946 90.2188 91.2812C90.446 91.6108 90.7358 91.8864 91.0881 92.108C91.4403 92.3239 91.8097 92.5028 92.196 92.6449C92.5824 92.7812 92.9375 92.892 93.2614 92.9773L95.0341 93.4545C95.4886 93.5739 95.9943 93.7386 96.5511 93.9489C97.1136 94.1591 97.6506 94.446 98.1619 94.8097C98.679 95.1676 99.1051 95.6278 99.4403 96.1903C99.7756 96.7528 99.9432 97.4432 99.9432 98.2614C99.9432 99.2045 99.696 100.057 99.2017 100.818C98.7131 101.58 97.9972 102.185 97.054 102.634C96.1165 103.082 94.9773 103.307 93.6364 103.307C92.3864 103.307 91.304 103.105 90.3892 102.702C89.4801 102.298 88.7642 101.736 88.2415 101.014C87.7244 100.293 87.4318 99.4545 87.3636 98.5H89.5455C89.6023 99.1591 89.8239 99.7045 90.2102 100.136C90.6023 100.562 91.0966 100.881 91.6932 101.091C92.2955 101.295 92.9432 101.398 93.6364 101.398C94.4432 101.398 95.1676 101.267 95.8097 101.006C96.4517 100.739 96.9602 100.369 97.3352 99.8977C97.7102 99.4205 97.8977 98.8636 97.8977 98.2273C97.8977 97.6477 97.7358 97.1761 97.4119 96.8125C97.0881 96.4489 96.6619 96.1534 96.1335 95.9261C95.6051 95.6989 95.0341 95.5 94.4205 95.3295L92.2727 94.7159C90.9091 94.3239 89.8295 93.7642 89.0341 93.0369C88.2386 92.3097 87.8409 91.358 87.8409 90.1818C87.8409 89.2045 88.1051 88.3523 88.6335 87.625C89.1676 86.892 89.8835 86.3239 90.7812 85.9205C91.6847 85.5114 92.6932 85.3068 93.8068 85.3068C94.9318 85.3068 95.9318 85.5085 96.8068 85.9119C97.6818 86.3097 98.375 86.8551 98.8864 87.5483C99.4034 88.2415 99.6761 89.0284 99.7045 89.9091H97.6591Z" fill="#525252"></path><path d="M157.5 103H152.114V85.5455H157.739C159.432 85.5455 160.881 85.8949 162.085 86.5938C163.29 87.2869 164.213 88.2841 164.855 89.5852C165.497 90.8807 165.818 92.4318 165.818 94.2386C165.818 96.0568 165.494 97.6222 164.847 98.9347C164.199 100.241 163.256 101.247 162.017 101.952C160.778 102.651 159.273 103 157.5 103ZM154.227 101.125H157.364C158.807 101.125 160.003 100.847 160.952 100.29C161.901 99.733 162.608 98.9403 163.074 97.9119C163.54 96.8835 163.773 95.6591 163.773 94.2386C163.773 92.8295 163.543 91.6165 163.082 90.5994C162.622 89.5767 161.935 88.7926 161.02 88.2472C160.105 87.696 158.966 87.4205 157.602 87.4205H154.227V101.125Z" fill="#525252"></path></svg>
29634
- `;
29635
- wasd.innerHTML = wasdSvg;
29636
- wasd.innerHTML += `
29637
- <div style="margin-top: 5px;">
29638
- Click W,A,S,D on your keyboard to move your camera.
29639
- </div>
29640
- `;
29641
- tips.appendChild(wasd);
29642
- const arrows = document.createElement("div");
29643
- arrows.setAttribute("style", `
29644
- display: flex;
29645
- flex-direction: column;
29646
- justify-content: flex-end;
29647
- `);
29648
- const arrowsSvg = `
29649
- <svg width="132" height="87" viewBox="0 0 188 124" fill="none" xmlns="http://www.w3.org/2000/svg"><rect y="64" width="60" height="60" rx="6" fill="#ebebeb"></rect><rect x="128" y="64" width="60" height="60" rx="6" fill="#ebebeb"></rect><rect x="64" width="60" height="60" rx="6" fill="#ebebeb"></rect><rect x="64" y="64" width="60" height="60" rx="6" fill="#ebebeb"></rect><path d="M95.2503 38.75V24.7875L101.35 30.8875C101.838 31.375 102.638 31.375 103.125 30.8875C103.613 30.4 103.613 29.6125 103.125 29.125L94.8878 20.8875C94.4003 20.4 93.6128 20.4 93.1253 20.8875L84.8753 29.1125C84.3878 29.6 84.3878 30.3875 84.8753 30.875C85.3628 31.3625 86.1503 31.3625 86.6378 30.875L92.7503 24.7875V38.75C92.7503 39.4375 93.3128 40 94.0003 40C94.6878 40 95.2503 39.4375 95.2503 38.75Z" fill="#525252"></path><path d="M38.75 92.7497H24.7875L30.8875 86.6497C31.375 86.1622 31.375 85.3622 30.8875 84.8747C30.4 84.3872 29.6125 84.3872 29.125 84.8747L20.8875 93.1122C20.4 93.5997 20.4 94.3872 20.8875 94.8747L29.1125 103.125C29.6 103.612 30.3875 103.612 30.875 103.125C31.3625 102.637 31.3625 101.85 30.875 101.362L24.7875 95.2497H38.75C39.4375 95.2497 40 94.6872 40 93.9997C40 93.3122 39.4375 92.7497 38.75 92.7497Z" fill="#525252"></path><path d="M150.25 95.2503H164.213L158.113 101.35C157.625 101.838 157.625 102.638 158.113 103.125C158.6 103.613 159.388 103.613 159.875 103.125L168.113 94.8878C168.6 94.4003 168.6 93.6128 168.113 93.1253L159.888 84.8753C159.4 84.3878 158.613 84.3878 158.125 84.8753C157.638 85.3628 157.638 86.1503 158.125 86.6378L164.213 92.7503H150.25C149.563 92.7503 149 93.3128 149 94.0003C149 94.6878 149.563 95.2503 150.25 95.2503Z" fill="#525252"></path><path d="M92.7497 85.25V99.2125L86.6497 93.1125C86.1622 92.625 85.3622 92.625 84.8747 93.1125C84.3872 93.6 84.3872 94.3875 84.8747 94.875L93.1122 103.113C93.5997 103.6 94.3872 103.6 94.8747 103.113L103.125 94.8875C103.612 94.4 103.612 93.6125 103.125 93.125C102.637 92.6375 101.85 92.6375 101.362 93.125L95.2497 99.2125V85.25C95.2497 84.5625 94.6872 84 93.9997 84C93.3122 84 92.7497 84.5625 92.7497 85.25Z" fill="#525252"></path></svg>
29650
- `;
29651
- arrows.innerHTML = arrowsSvg;
29652
- arrows.innerHTML += `
29653
- <div style="margin-top: 5px;">
29654
- Click the arrow keys to pan.
29655
- </div>
29656
- `;
29657
- tips.appendChild(arrows);
29658
- const upDown = document.createElement("div");
29659
- upDown.setAttribute("style", `
29660
- display: flex;
29661
- flex-direction: column;
29662
- justify-content: flex-end;
29663
- `);
29664
- const upDownSvg = `
29665
- <svg width="87" height="42" viewBox="0 0 124 60" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="64" width="60" height="60" rx="6" fill="#ebebeb"></rect><rect width="60" height="60" rx="6" fill="#ebebeb"></rect><path d="M29.4545 33.5455H31.7727L33.7159 36.1023L34.2273 36.7841L37.125 40.6364H34.8068L32.8977 38.0795L32.4205 37.4318L29.4545 33.5455ZM37.8409 30.2727C37.8409 32.1136 37.5085 33.7045 36.8438 35.0455C36.179 36.3864 35.267 37.4205 34.108 38.1477C32.9489 38.875 31.625 39.2386 30.1364 39.2386C28.6477 39.2386 27.3239 38.875 26.1648 38.1477C25.0057 37.4205 24.0938 36.3864 23.429 35.0455C22.7642 33.7045 22.4318 32.1136 22.4318 30.2727C22.4318 28.4318 22.7642 26.8409 23.429 25.5C24.0938 24.1591 25.0057 23.125 26.1648 22.3977C27.3239 21.6705 28.6477 21.3068 30.1364 21.3068C31.625 21.3068 32.9489 21.6705 34.108 22.3977C35.267 23.125 36.179 24.1591 36.8438 25.5C37.5085 26.8409 37.8409 28.4318 37.8409 30.2727ZM35.7955 30.2727C35.7955 28.7614 35.5426 27.4858 35.0369 26.446C34.5369 25.4062 33.858 24.6193 33 24.0852C32.1477 23.5511 31.1932 23.2841 30.1364 23.2841C29.0795 23.2841 28.1222 23.5511 27.2642 24.0852C26.4119 24.6193 25.733 25.4062 25.2273 26.446C24.7273 27.4858 24.4773 28.7614 24.4773 30.2727C24.4773 31.7841 24.7273 33.0597 25.2273 34.0994C25.733 35.1392 26.4119 35.9261 27.2642 36.4602C28.1222 36.9943 29.0795 37.2614 30.1364 37.2614C31.1932 37.2614 32.1477 36.9943 33 36.4602C33.858 35.9261 34.5369 35.1392 35.0369 34.0994C35.5426 33.0597 35.7955 31.7841 35.7955 30.2727Z" fill="#525252"></path><path d="M88.1136 39V21.5455H98.6477V23.4205H90.2273V29.3182H98.1023V31.1932H90.2273V37.125H98.7841V39H88.1136Z" fill="#525252"></path></svg>
29666
- `;
29667
- upDown.innerHTML = upDownSvg;
29668
- upDown.innerHTML += `
29669
- <div style="margin-top: 5px;">
29670
- Click Q and E to move up and down.
29671
- </div>
29672
- `;
29673
- tips.appendChild(upDown);
29674
- }
29675
- content.appendChild(tips);
29676
- // Reference to our speed slider so we can adjust it when the move type changes.
29677
- let moveRateInput = null;
29678
- // Fly toggle row.
29679
- {
29680
- const row = document.createElement("div");
29681
- row.className = "NextspaceWalkthroughBarRow";
29682
- inputs.appendChild(row);
29683
- const label = document.createElement("div");
29684
- label.className = "NextspaceWalkthroughBarRowLabel";
29685
- label.innerText = "Fly";
29686
- row.appendChild(label);
29687
- const toggle = document.createElement("input");
29688
- toggle.className = "NextspaceWalkthroughBarRowToggle";
29689
- toggle.type = "checkbox";
29690
- row.appendChild(toggle);
29691
- toggle.checked = Walkthrough.GetMoveType({
29692
- viewer: this._viewer
29693
- }) == Walkthrough.EMoveType.Fly;
29694
- toggle.addEventListener("change", () => {
29695
- const newType = toggle.checked ? Walkthrough.EMoveType.Fly : Walkthrough.EMoveType.Walk;
29696
- Walkthrough.SetMoveType({
29697
- viewer: this._viewer,
29698
- type: newType
29699
- });
29700
- // Update the speed slider to match the new move type.
29701
- if (moveRateInput) {
29702
- if (newType == Walkthrough.EMoveType.Fly) {
29703
- const rate = Walkthrough.GetFlyMoveRate({
29704
- viewer: this._viewer
29705
- });
29706
- moveRateInput.value = (rate * 50).toFixed(2);
29707
- }
29708
- else {
29709
- const rate = Walkthrough.GetWalkMoveRate({
29710
- viewer: this._viewer
29711
- });
29712
- moveRateInput.value = (rate * 500).toFixed(2);
29713
- }
29714
- }
29715
- localStorage.setItem(KEY_WALKTHROUGH_MODE, newType);
29716
- });
29717
- // Tip for the row.
29718
- // Will be hidden while collapsed through css.
29719
- {
29720
- const tip = document.createElement("div");
29721
- tip.style.marginBottom = "10px";
29722
- tip.className = "NextspaceWalkthroughBarRowTip";
29723
- tip.innerText = "Flying means the camera will not maintain its height.";
29724
- inputs.appendChild(tip);
29725
- }
29726
- }
29727
- // Speed slider row.
29728
- {
29729
- const row = document.createElement("div");
29730
- row.className = "NextspaceWalkthroughBarRow";
29731
- inputs.appendChild(row);
29732
- const label = document.createElement("div");
29733
- label.className = "NextspaceWalkthroughBarRowLabel";
29734
- label.innerText = "Speed";
29735
- row.appendChild(label);
29736
- const slider = document.createElement("input");
29737
- moveRateInput = slider;
29738
- slider.className = "NextspaceWalkthroughBarRowSlider";
29739
- slider.type = "range";
29740
- slider.min = "0.01";
29741
- slider.max = "100";
29742
- slider.step = "0.01";
29743
- slider.value = "50";
29744
- slider.addEventListener("input", () => {
29745
- // Walk is between 0.01 and 0.5
29746
- // Fly is between 0.01 and 10
29747
- // We want to convert this slider's range into the respective values and apply based on active move type.
29748
- const type = Walkthrough.GetMoveType({
29749
- viewer: this._viewer
29750
- });
29751
- if (type == Walkthrough.EMoveType.Fly) {
29752
- const value = parseFloat(slider.value);
29753
- const speed = value / 50;
29754
- Walkthrough.SetFlyMoveRate({
29755
- viewer: this._viewer,
29756
- rate: speed
29757
- });
29758
- localStorage.setItem(KEY_WALKTHROUGH_SPEED_FLY, speed.toString());
29759
- }
29760
- else {
29761
- const value = parseFloat(slider.value);
29762
- const speed = value / 500;
29763
- Walkthrough.SetWalkMoveRate({
29764
- viewer: this._viewer,
29765
- rate: speed
29766
- });
29767
- localStorage.setItem(KEY_WALKTHROUGH_SPEED_WALK, speed.toString());
29768
- }
29769
- });
29770
- // Set the initial value based on the move type.
29771
- const type = Walkthrough.GetMoveType({
29772
- viewer: this._viewer
29773
- });
29774
- if (type == Walkthrough.EMoveType.Fly) {
29775
- const rate = Walkthrough.GetFlyMoveRate({
29776
- viewer: this._viewer
29777
- });
29778
- slider.value = (rate * 50).toFixed(2);
29779
- }
29780
- else {
29781
- const rate = Walkthrough.GetWalkMoveRate({
29782
- viewer: this._viewer
29783
- });
29784
- slider.value = (rate * 500).toFixed(2);
29785
- }
29786
- row.appendChild(slider);
29787
- }
29788
- this._walkthroughBar = element;
29789
- }
29790
- _disposeWalkthroughBar() {
29791
- var _a;
29792
- if (this._walkthroughPinEventRemoval) {
29793
- this._walkthroughPinEventRemoval();
29794
- this._walkthroughPinEventRemoval = null;
29795
- }
29796
- if ((_a = this._walkthroughBar) === null || _a === void 0 ? void 0 : _a.parentElement) {
29797
- this._walkthroughBar.parentElement.removeChild(this._walkthroughBar);
29798
- this._walkthroughBar = null;
29799
- }
29800
- document.documentElement.style.setProperty(VIEWER_WALKTHROUGH_PANEL_CSS_VAR_BOTTOM, "0px");
29801
- }
29802
29086
  _updateControls() {
29803
29087
  const controls = this._primaryContent.querySelectorAll(".NextspaceCursorBarPrimControlInner");
29804
29088
  controls.forEach((control) => {
@@ -29834,9 +29118,9 @@ class WidgetCursorBar extends Widget.AWidget {
29834
29118
  _listenSelection() {
29835
29119
  this._disposeCesiumEvent();
29836
29120
  const events = new ScreenSpaceEventHandler(this._viewer.scene.canvas);
29121
+ const throttle = new CursorBarMouseEventThrottle(this._viewer);
29837
29122
  let lastHoverPos = null;
29838
- //let lastHoveredEntityId: string = null;
29839
- //let unhighlightTimeout: any = null;
29123
+ let cursorSettleTimeout = null;
29840
29124
  const process2dCursor = (pos2d, isHover) => {
29841
29125
  try {
29842
29126
  const { regos } = this._manager.VisualsRegister.GetRegosFromCursor({
@@ -29851,34 +29135,6 @@ class WidgetCursorBar extends Widget.AWidget {
29851
29135
  else if (this._viewer.canvas.style.cursor) {
29852
29136
  this._viewer.canvas.style.removeProperty("cursor");
29853
29137
  }
29854
- /*
29855
- clearTimeout(unhighlightTimeout);
29856
- if (lastHoveredEntityId && lastHoveredEntityId != firstId) {
29857
- this._manager.VisualsRegister.SetHighlighted({
29858
- entityIds: [lastHoveredEntityId],
29859
- highlighted: false
29860
- });
29861
- }
29862
- if (firstId) {
29863
- unhighlightTimeout = setTimeout(() => {
29864
- if (lastHoveredEntityId == firstId) {
29865
- this._manager.VisualsRegister.SetHighlighted({
29866
- entityIds: [firstId],
29867
- highlighted: false
29868
- });
29869
- lastHoveredEntityId = null;
29870
- }
29871
- }, 5000);
29872
- if (lastHoveredEntityId != firstId) {
29873
- this._manager.VisualsRegister.SetHighlighted({
29874
- entityIds: [firstId],
29875
- highlighted: true
29876
- });
29877
- }
29878
- }
29879
-
29880
- lastHoveredEntityId = firstId;
29881
- */
29882
29138
  }
29883
29139
  else {
29884
29140
  this._manager.VisualsRegister.ClearSelected();
@@ -29895,8 +29151,27 @@ class WidgetCursorBar extends Widget.AWidget {
29895
29151
  }
29896
29152
  };
29897
29153
  const hoverDelayQueue = new DelayQueue(() => {
29154
+ // Skip raycasting entirely while the camera is moving, or if nothing has changed
29155
+ // (render frame + cursor position) since the last raycast.
29156
+ if (throttle.IsCameraBusy()) {
29157
+ return;
29158
+ }
29159
+ if (document.elementFromPoint(lastHoverPos.x, lastHoverPos.y) !== this._viewer.scene.canvas) {
29160
+ return;
29161
+ }
29162
+ if (throttle.ShouldSkipRaycast(lastHoverPos.x, lastHoverPos.y)) {
29163
+ return;
29164
+ }
29165
+ throttle.RecordRaycast(lastHoverPos.x, lastHoverPos.y);
29898
29166
  process2dCursor(lastHoverPos, true);
29899
- }, 80);
29167
+ }, throttle.GetHoverDelayMs());
29168
+ // Once camera movement settles, force a fresh hover check rather than waiting on the
29169
+ // regular throttle (matches Navigator's post-move recheck).
29170
+ throttle.SetOnSettle(() => {
29171
+ if (lastHoverPos) {
29172
+ hoverDelayQueue.Call(true);
29173
+ }
29174
+ });
29900
29175
  events.setInputAction((e) => {
29901
29176
  var _a;
29902
29177
  if (!((_a = e === null || e === void 0 ? void 0 : e.position) === null || _a === void 0 ? void 0 : _a.x)) {
@@ -29910,10 +29185,25 @@ class WidgetCursorBar extends Widget.AWidget {
29910
29185
  return;
29911
29186
  }
29912
29187
  lastHoverPos = e.endPosition;
29913
- hoverDelayQueue.Call();
29188
+ hoverDelayQueue.delay = throttle.GetHoverDelayMs();
29189
+ // On a slow scene, debounce until the cursor has been still for a bit rather than
29190
+ // raycasting on every throttled tick.
29191
+ if (throttle.IsSlowScene()) {
29192
+ clearTimeout(cursorSettleTimeout);
29193
+ cursorSettleTimeout = setTimeout(() => {
29194
+ hoverDelayQueue.Call(true);
29195
+ }, CURSOR_SETTLE_MS);
29196
+ }
29197
+ else {
29198
+ hoverDelayQueue.Call();
29199
+ }
29914
29200
  }, ScreenSpaceEventType.MOUSE_MOVE);
29915
29201
  this._cesiumEventRemoval = () => {
29202
+ if (cursorSettleTimeout) {
29203
+ clearTimeout(cursorSettleTimeout);
29204
+ }
29916
29205
  hoverDelayQueue.Dispose();
29206
+ throttle.Dispose();
29917
29207
  if (!events || events.isDestroyed()) {
29918
29208
  return;
29919
29209
  }
@@ -30842,20 +30132,1351 @@ class WidgetInfoView extends Widget.AWidget {
30842
30132
  }
30843
30133
  }
30844
30134
 
30135
+ var EAction;
30136
+ (function (EAction) {
30137
+ EAction["Forward"] = "f";
30138
+ EAction["Backward"] = "b";
30139
+ EAction["Left"] = "l";
30140
+ EAction["Right"] = "r";
30141
+ EAction["Up"] = "u";
30142
+ EAction["Down"] = "d";
30143
+ EAction["LookUp"] = "lu";
30144
+ EAction["LookDown"] = "ld";
30145
+ EAction["LookLeft"] = "ll";
30146
+ EAction["LookRight"] = "lr";
30147
+ EAction["Looking"] = "looking";
30148
+ })(EAction || (EAction = {}));
30149
+ const DEFAULT_WALK_MOVE_RATE = 0.2;
30150
+ const DEFAULT_FLY_MOVE_RATE = 0.2;
30151
+ const DEFAULT_MOVE_TYPE = null;
30152
+ const VIEWER_WALKTHROUGH_DATA_KEY = "_cesiumWalkthroughData";
30153
+ /**
30154
+ * Returns heading of camera towards where movement is happening.
30155
+ * @returns
30156
+ */
30157
+ function getMovementHeading(viewer) {
30158
+ var _a;
30159
+ const actions = (_a = viewer[VIEWER_WALKTHROUGH_DATA_KEY]) === null || _a === void 0 ? void 0 : _a.actions;
30160
+ if (!actions) {
30161
+ return 0;
30162
+ }
30163
+ let heading = Math$1.toDegrees(viewer.camera.heading);
30164
+ let count = 0;
30165
+ let totalHeading = 0;
30166
+ let left = actions.get(EAction.Left);
30167
+ if (left) {
30168
+ totalHeading += heading + 270;
30169
+ count += 1;
30170
+ }
30171
+ if (actions.get(EAction.Right)) {
30172
+ totalHeading += heading + 90;
30173
+ count += 1;
30174
+ }
30175
+ let forward = actions.get(EAction.Forward);
30176
+ if (forward) {
30177
+ totalHeading += heading;
30178
+ count += 1;
30179
+ }
30180
+ if (actions.get(EAction.Backward)) {
30181
+ totalHeading += heading + 180;
30182
+ count += 1;
30183
+ }
30184
+ if (left && forward) {
30185
+ totalHeading = heading - 45;
30186
+ }
30187
+ else {
30188
+ totalHeading /= count;
30189
+ }
30190
+ return totalHeading;
30191
+ }
30192
+ /**
30193
+ * Updates camera position and orientation based on current actions.
30194
+ */
30195
+ function doMovementTick(viewer) {
30196
+ const data = viewer[VIEWER_WALKTHROUGH_DATA_KEY];
30197
+ if (!data) {
30198
+ return;
30199
+ }
30200
+ const canvas = viewer.canvas;
30201
+ const camera = viewer.camera;
30202
+ const moveRate = data.moveType == Walkthrough.EMoveType.Walk ? data.walkMoveRate : data.flyMoveRate;
30203
+ if (data.actions.get(EAction.Looking)) {
30204
+ let width = canvas.clientWidth;
30205
+ let height = canvas.clientHeight;
30206
+ // Coordinate (0.0, 0.0) will be where the mouse was clicked.
30207
+ let x = (data.mousePosCurrent.x - data.mousePosStart.x) / width;
30208
+ let y = -(data.mousePosCurrent.y - data.mousePosStart.y) / height;
30209
+ let lookFactor = 0.1;
30210
+ camera.lookRight(x * lookFactor);
30211
+ camera.lookUp(y * lookFactor);
30212
+ }
30213
+ let lookStep = 0.03;
30214
+ if (data.actions.get(EAction.LookLeft)) {
30215
+ camera.lookLeft(lookStep);
30216
+ }
30217
+ if (data.actions.get(EAction.LookRight)) {
30218
+ camera.lookRight(lookStep);
30219
+ }
30220
+ if (data.actions.get(EAction.LookUp)) {
30221
+ camera.lookUp(lookStep);
30222
+ }
30223
+ if (data.actions.get(EAction.LookDown)) {
30224
+ camera.lookDown(lookStep);
30225
+ }
30226
+ if (data.actions.get(EAction.Up)) {
30227
+ camera.moveUp(moveRate / 2);
30228
+ }
30229
+ if (data.actions.get(EAction.Down)) {
30230
+ camera.moveDown(moveRate / 2);
30231
+ }
30232
+ if (camera.roll > 0) {
30233
+ camera.twistLeft(camera.roll);
30234
+ }
30235
+ else if (camera.roll < 0) {
30236
+ camera.twistRight(camera.roll * -1);
30237
+ }
30238
+ // If movement type is fly use cesium movement methods
30239
+ if (data.moveType == Walkthrough.EMoveType.Fly) {
30240
+ if (data.actions.get(EAction.Forward)) {
30241
+ camera.moveForward(moveRate);
30242
+ }
30243
+ if (data.actions.get(EAction.Backward)) {
30244
+ camera.moveBackward(moveRate);
30245
+ }
30246
+ if (data.actions.get(EAction.Left)) {
30247
+ camera.moveLeft(moveRate);
30248
+ }
30249
+ if (data.actions.get(EAction.Right)) {
30250
+ camera.moveRight(moveRate);
30251
+ }
30252
+ }
30253
+ // If movement type is walk, calculate new position without affecting altitude
30254
+ else {
30255
+ if (data.actions.get(EAction.Left) ||
30256
+ data.actions.get(EAction.Right) ||
30257
+ data.actions.get(EAction.Forward) ||
30258
+ data.actions.get(EAction.Backward)) {
30259
+ const heading = getMovementHeading(viewer);
30260
+ const pos = viewer.camera.positionCartographic;
30261
+ const newPos = _offsetPoint({
30262
+ altitude: pos.height,
30263
+ latitude: Math$1.toDegrees(pos.latitude),
30264
+ longitude: Math$1.toDegrees(pos.longitude)
30265
+ }, moveRate, heading);
30266
+ camera.position = Cartesian3.fromDegrees(newPos.longitude, newPos.latitude, newPos.altitude);
30267
+ }
30268
+ }
30269
+ viewer.scene.requestRender();
30270
+ }
30271
+ /**
30272
+ * Moves a given point by a given distance towards a heading.
30273
+ * @param point in degrees.
30274
+ * @param distance in meters.
30275
+ * @param heading in degrees.
30276
+ * @returns
30277
+ */
30278
+ function _offsetPoint(point, distance, heading) {
30279
+ // Radius of earth.
30280
+ const radius = 6371e3;
30281
+ const δ = distance / radius;
30282
+ const θ = Math$1.toRadians(heading);
30283
+ const φ1 = Math$1.toRadians(point.latitude);
30284
+ const λ1 = Math$1.toRadians(point.longitude);
30285
+ const sinφ2 = Math.sin(φ1) * Math.cos(δ) + Math.cos(φ1) * Math.sin(δ) * Math.cos(θ);
30286
+ const φ2 = Math.asin(sinφ2);
30287
+ const y = Math.sin(θ) * Math.sin(δ) * Math.cos(φ1);
30288
+ const x = Math.cos(δ) - Math.sin(φ1) * sinφ2;
30289
+ const λ2 = λ1 + Math.atan2(y, x);
30290
+ return {
30291
+ altitude: point.altitude,
30292
+ latitude: Math$1.toDegrees(φ2),
30293
+ longitude: Math$1.toDegrees(λ2)
30294
+ };
30295
+ }
30296
+ /**
30297
+ * Checks given keyboard key against keybinds and sets action accordingly.
30298
+ * @param key
30299
+ * @param keyDown
30300
+ */
30301
+ function checkKeybind(viewer, key, keyDown) {
30302
+ const data = viewer[VIEWER_WALKTHROUGH_DATA_KEY];
30303
+ if (!data) {
30304
+ return;
30305
+ }
30306
+ key = key.toLowerCase();
30307
+ if (key == "w") {
30308
+ data.actions.set(EAction.Forward, keyDown);
30309
+ }
30310
+ else if (key == "s") {
30311
+ data.actions.set(EAction.Backward, keyDown);
30312
+ }
30313
+ else if (key == "a") {
30314
+ data.actions.set(EAction.Left, keyDown);
30315
+ }
30316
+ else if (key == "d") {
30317
+ data.actions.set(EAction.Right, keyDown);
30318
+ }
30319
+ else if (key == "q") {
30320
+ data.actions.set(EAction.Up, keyDown);
30321
+ }
30322
+ else if (key == "e") {
30323
+ data.actions.set(EAction.Down, keyDown);
30324
+ }
30325
+ else if (key == "arrowup") {
30326
+ data.actions.set(EAction.LookUp, keyDown);
30327
+ }
30328
+ else if (key == "arrowdown") {
30329
+ data.actions.set(EAction.LookDown, keyDown);
30330
+ }
30331
+ else if (key == "arrowleft") {
30332
+ data.actions.set(EAction.LookLeft, keyDown);
30333
+ }
30334
+ else if (key == "arrowright") {
30335
+ data.actions.set(EAction.LookRight, keyDown);
30336
+ }
30337
+ }
30338
+ var Walkthrough;
30339
+ (function (Walkthrough) {
30340
+ let EMoveType;
30341
+ (function (EMoveType) {
30342
+ EMoveType["Walk"] = "WALK";
30343
+ EMoveType["Fly"] = "FLY";
30344
+ })(EMoveType = Walkthrough.EMoveType || (Walkthrough.EMoveType = {}));
30345
+ function Start(params) {
30346
+ Stop(params);
30347
+ const viewer = params.viewer;
30348
+ const data = viewer[VIEWER_WALKTHROUGH_DATA_KEY] = {
30349
+ walkMoveRate: DEFAULT_WALK_MOVE_RATE,
30350
+ flyMoveRate: DEFAULT_FLY_MOVE_RATE,
30351
+ moveType: DEFAULT_MOVE_TYPE,
30352
+ actions: new Map(),
30353
+ ...viewer[VIEWER_WALKTHROUGH_DATA_KEY]
30354
+ };
30355
+ data.handlerScreenSpace = new ScreenSpaceEventHandler(viewer.canvas);
30356
+ ViewUtils.SetLockedCameraStatus({
30357
+ viewer: viewer,
30358
+ status: true
30359
+ });
30360
+ let lastCheck;
30361
+ let currentTime = new Date();
30362
+ const interval = setInterval(() => {
30363
+ lastCheck = new Date();
30364
+ if (lastCheck.getTime() - currentTime.getTime() >= (1000 / 60)) {
30365
+ doMovementTick(viewer);
30366
+ currentTime = new Date();
30367
+ }
30368
+ }, 1000 / 60);
30369
+ data.tickRemoval = () => {
30370
+ clearInterval(interval);
30371
+ };
30372
+ let keyDown = (e) => {
30373
+ checkKeybind(viewer, e.key, true);
30374
+ };
30375
+ document.addEventListener("keydown", keyDown, false);
30376
+ let keyUp = (e) => {
30377
+ checkKeybind(viewer, e.key, false);
30378
+ };
30379
+ document.addEventListener("keyup", keyUp, false);
30380
+ data.handlerKeysRemoval = () => {
30381
+ document.removeEventListener("keydown", keyDown);
30382
+ document.removeEventListener("keyup", keyUp);
30383
+ };
30384
+ data.handlerScreenSpace.setInputAction((e) => {
30385
+ data.actions.set(EAction.Looking, true);
30386
+ data.mousePosCurrent = data.mousePosStart = Cartesian2.clone(e.position);
30387
+ }, ScreenSpaceEventType.LEFT_DOWN);
30388
+ data.handlerScreenSpace.setInputAction(((e) => {
30389
+ data.mousePosCurrent = e.endPosition;
30390
+ }), ScreenSpaceEventType.MOUSE_MOVE);
30391
+ data.handlerScreenSpace.setInputAction(() => {
30392
+ data.actions.set(EAction.Looking, false);
30393
+ }, ScreenSpaceEventType.LEFT_UP);
30394
+ }
30395
+ Walkthrough.Start = Start;
30396
+ function Stop(params) {
30397
+ var _a, _b;
30398
+ const viewer = params.viewer;
30399
+ const data = viewer[VIEWER_WALKTHROUGH_DATA_KEY];
30400
+ ViewUtils.SetLockedCameraStatus({
30401
+ viewer: viewer,
30402
+ status: false
30403
+ });
30404
+ if (data) {
30405
+ (_a = data.handlerScreenSpace) === null || _a === void 0 ? void 0 : _a.destroy();
30406
+ data.handlerScreenSpace = null;
30407
+ (_b = data.tickRemoval) === null || _b === void 0 ? void 0 : _b.call(data);
30408
+ data.tickRemoval = null;
30409
+ if (data.handlerKeysRemoval) {
30410
+ data.handlerKeysRemoval();
30411
+ data.handlerKeysRemoval = null;
30412
+ }
30413
+ }
30414
+ }
30415
+ Walkthrough.Stop = Stop;
30416
+ function IsRunning(params) {
30417
+ const viewer = params.viewer;
30418
+ const data = viewer[VIEWER_WALKTHROUGH_DATA_KEY];
30419
+ return (data === null || data === void 0 ? void 0 : data.handlerScreenSpace) != null;
30420
+ }
30421
+ Walkthrough.IsRunning = IsRunning;
30422
+ function SetWalkMoveRate(params) {
30423
+ var _a;
30424
+ const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
30425
+ if (data) {
30426
+ data.walkMoveRate = params.rate;
30427
+ }
30428
+ }
30429
+ Walkthrough.SetWalkMoveRate = SetWalkMoveRate;
30430
+ function SetMoveType(params) {
30431
+ var _a;
30432
+ const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
30433
+ if (data) {
30434
+ data.moveType = params.type;
30435
+ }
30436
+ }
30437
+ Walkthrough.SetMoveType = SetMoveType;
30438
+ function GetWalkMoveRate(params) {
30439
+ var _a;
30440
+ const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
30441
+ return data === null || data === void 0 ? void 0 : data.walkMoveRate;
30442
+ }
30443
+ Walkthrough.GetWalkMoveRate = GetWalkMoveRate;
30444
+ function GetFlyMoveRate(params) {
30445
+ var _a;
30446
+ const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
30447
+ return data === null || data === void 0 ? void 0 : data.flyMoveRate;
30448
+ }
30449
+ Walkthrough.GetFlyMoveRate = GetFlyMoveRate;
30450
+ function SetFlyMoveRate(params) {
30451
+ var _a;
30452
+ const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
30453
+ if (data) {
30454
+ data.flyMoveRate = params.rate;
30455
+ }
30456
+ }
30457
+ Walkthrough.SetFlyMoveRate = SetFlyMoveRate;
30458
+ function GetMoveType(params) {
30459
+ var _a;
30460
+ const data = (_a = params.viewer) === null || _a === void 0 ? void 0 : _a[VIEWER_WALKTHROUGH_DATA_KEY];
30461
+ return data === null || data === void 0 ? void 0 : data.moveType;
30462
+ }
30463
+ Walkthrough.GetMoveType = GetMoveType;
30464
+ /**
30465
+ * Simulates a keyboard key being pressed/released for movement purposes.
30466
+ * Lets UI (eg: an on-screen key diagram) drive movement the same way physical key presses do.
30467
+ */
30468
+ function CheckKeybind(params) {
30469
+ checkKeybind(params.viewer, params.key, params.keyDown);
30470
+ }
30471
+ Walkthrough.CheckKeybind = CheckKeybind;
30472
+ })(Walkthrough || (Walkthrough = {}));
30473
+
30474
+ const KEY_WALKTHROUGH_MODE = "WidgetNavCompass.Walkthrough.Mode";
30475
+ const KEY_WALKTHROUGH_SPEED_FLY = "WidgetNavCompass.Walkthrough.SpeedFly";
30476
+ const KEY_WALKTHROUGH_SPEED_WALK = "WidgetNavCompass.Walkthrough.SpeedWalk";
30477
+ const KEY_WALKTHROUGH_COLLAPSED = "WidgetNavCompass.Walkthrough.Collapsed";
30478
+ // CSS var other widgets (eg: the left panel) read to avoid overlapping this bar.
30479
+ const VIEWER_WALKTHROUGH_PANEL_CSS_VAR_BOTTOM = "--viewer-walkthrough-panel-bottom";
30480
+ const STYLESHEET_ID = "nextspace-nav-compass-walkthrough-bar-stylesheet";
30481
+ const HEIGHT_COLLAPSED = "58px";
30482
+ const HEIGHT_EXPANDED = "165px";
30483
+ /**
30484
+ * The Walkthrough controls bar shown at the bottom of the screen while in Walkthrough mode
30485
+ * (entered via the nav compass's Walkthrough toggle). Mirrors the design of cesium-navigator-ui's
30486
+ * "CollapsedWalkthrough" component (the current/latest design for this control), reimplemented
30487
+ * here as vanilla DOM since this widget has no React dependency.
30488
+ */
30489
+ class WidgetNavCompassWalkthroughBar {
30490
+ constructor(params) {
30491
+ this._keyRects = [];
30492
+ this._viewer = params.viewer;
30493
+ this._container = params.container;
30494
+ this._onClose = params.onClose;
30495
+ this._generateStyles();
30496
+ this._generateElement();
30497
+ this._listenPhysicalKeys();
30498
+ }
30499
+ Dispose() {
30500
+ var _a;
30501
+ if (this._keyDownHandler) {
30502
+ document.removeEventListener("keydown", this._keyDownHandler);
30503
+ document.removeEventListener("keyup", this._keyUpHandler);
30504
+ this._keyDownHandler = null;
30505
+ this._keyUpHandler = null;
30506
+ }
30507
+ if ((_a = this._element) === null || _a === void 0 ? void 0 : _a.parentElement) {
30508
+ this._element.parentElement.removeChild(this._element);
30509
+ }
30510
+ this._element = null;
30511
+ this._keyRects = [];
30512
+ document.documentElement.style.setProperty(VIEWER_WALKTHROUGH_PANEL_CSS_VAR_BOTTOM, "0px");
30513
+ }
30514
+ _generateStyles() {
30515
+ if (document.getElementById(STYLESHEET_ID)) {
30516
+ return;
30517
+ }
30518
+ const style = document.createElement("style");
30519
+ style.id = STYLESHEET_ID;
30520
+ style.innerHTML = `
30521
+ .NextspaceNavCompassWalkthroughBar {
30522
+ position: absolute;
30523
+ z-index: 1;
30524
+ bottom: 10px;
30525
+ left: calc(45px + var(${VIEWER_LEFT_PANEL_CSS_VAR_LEFT}));
30526
+ box-sizing: border-box;
30527
+ display: flex;
30528
+ flex-direction: column;
30529
+ background-color: #fafdff;
30530
+ color: #000;
30531
+ border-radius: 8px;
30532
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
30533
+ pointer-events: auto;
30534
+ box-shadow: 0px 0px 1px rgba(18, 22, 25, 0.36), 0px 18px 36px -4px rgba(18, 22, 25, 0.36);
30535
+ font-family: Arial;
30536
+ font-size: 12px;
30537
+ }
30538
+
30539
+ .NextspaceNavCompassWalkthroughBar * {
30540
+ box-sizing: border-box;
30541
+ }
30542
+
30543
+ .NextspaceNavCompassWalkthroughBar .row-primary {
30544
+ display: flex;
30545
+ flex-direction: row;
30546
+ align-items: center;
30547
+ height: 38px;
30548
+ padding: 0 10px;
30549
+ }
30550
+
30551
+ .NextspaceNavCompassWalkthroughBar .row-primary .icon-walkthrough {
30552
+ width: 24px;
30553
+ height: 24px;
30554
+ flex-shrink: 0;
30555
+ margin-right: 6px;
30556
+ display: flex;
30557
+ align-items: center;
30558
+ justify-content: center;
30559
+ }
30560
+
30561
+ .NextspaceNavCompassWalkthroughBar .row-primary select {
30562
+ height: 28px;
30563
+ padding: 0 8px;
30564
+ border-radius: 4px;
30565
+ border: 1px solid #ccc;
30566
+ background: #fff;
30567
+ color: #000;
30568
+ font-size: 12px;
30569
+ }
30570
+
30571
+ .NextspaceNavCompassWalkthroughBar .row-primary .mr-10 {
30572
+ width: 10px;
30573
+ flex-shrink: 0;
30574
+ }
30575
+
30576
+ .NextspaceNavCompassWalkthroughBar .row-primary .mr-auto {
30577
+ margin-left: auto;
30578
+ }
30579
+
30580
+ .NextspaceNavCompassWalkthroughBar .input-row {
30581
+ display: flex;
30582
+ flex-direction: row;
30583
+ align-items: center;
30584
+ }
30585
+
30586
+ .NextspaceNavCompassWalkthroughBar .input-row label {
30587
+ opacity: 0.7;
30588
+ margin-right: 12px;
30589
+ flex-shrink: 0;
30590
+ }
30591
+
30592
+ .NextspaceNavCompassWalkthroughBar .input-row input[type="range"] {
30593
+ flex-grow: 1;
30594
+ min-width: 60px;
30595
+ accent-color: #33b1ff;
30596
+ }
30597
+
30598
+ .NextspaceNavCompassWalkthroughBar .icon-btn {
30599
+ display: flex;
30600
+ align-items: center;
30601
+ justify-content: center;
30602
+ width: 28px;
30603
+ height: 28px;
30604
+ border-radius: 6px;
30605
+ cursor: pointer;
30606
+ transition: 0.3s ease;
30607
+ flex-shrink: 0;
30608
+ }
30609
+
30610
+ .NextspaceNavCompassWalkthroughBar .icon-btn:hover {
30611
+ background: rgba(0, 0, 0, 0.06);
30612
+ }
30613
+
30614
+ .NextspaceNavCompassWalkthroughBar .icon-btn.close-btn {
30615
+ margin-left: 4px;
30616
+ }
30617
+
30618
+ .NextspaceNavCompassWalkthroughBar .row-keys {
30619
+ display: flex;
30620
+ flex-direction: row;
30621
+ align-items: flex-start;
30622
+ justify-content: center;
30623
+ gap: 16px;
30624
+ padding: 10px 14px 12px;
30625
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
30626
+ }
30627
+
30628
+ .NextspaceNavCompassWalkthroughBar[collapsed="true"] .row-keys {
30629
+ display: none;
30630
+ }
30631
+
30632
+ .NextspaceNavCompassWalkthroughBar .key-group {
30633
+ display: flex;
30634
+ flex-direction: column;
30635
+ align-items: center;
30636
+ }
30637
+
30638
+ .NextspaceNavCompassWalkthroughBar .key-group svg {
30639
+ display: block;
30640
+ }
30641
+
30642
+ .NextspaceNavCompassWalkthroughBar .key-tip {
30643
+ opacity: 0.5;
30644
+ font-size: 11px;
30645
+ margin-top: 4px;
30646
+ text-align: center;
30647
+ }
30648
+
30649
+ .NextspaceNavCompassWalkthroughBar .key-rect {
30650
+ fill: #fff;
30651
+ transition: 0.3s ease;
30652
+ stroke: rgba(0, 0, 0, 0.2);
30653
+ stroke-width: 1.5;
30654
+ cursor: pointer;
30655
+ filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.12));
30656
+ }
30657
+
30658
+ .NextspaceNavCompassWalkthroughBar .key-rect-active {
30659
+ fill: #e8f4ff;
30660
+ stroke: #33b1ff;
30661
+ }
30662
+ `;
30663
+ document.head.appendChild(style);
30664
+ }
30665
+ _generateElement() {
30666
+ const collapsed = localStorage.getItem(KEY_WALKTHROUGH_COLLAPSED) == "true";
30667
+ const element = document.createElement("div");
30668
+ element.className = "NextspaceNavCompassWalkthroughBar";
30669
+ element.setAttribute("collapsed", collapsed ? "true" : "false");
30670
+ this._element = element;
30671
+ const rowPrimary = document.createElement("div");
30672
+ rowPrimary.className = "row-primary";
30673
+ element.appendChild(rowPrimary);
30674
+ const icon = document.createElement("div");
30675
+ icon.className = "icon-walkthrough";
30676
+ icon.innerHTML = `
30677
+ <svg width="20" height="20" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
30678
+ <path d="M17.5033 4C16.8406 4 16.205 4.26339 15.7364 4.73223C15.2678 5.20107 15.0045 5.83696 15.0045 6.5C15.0045 7.16304 15.2678 7.79893 15.7364 8.26777C16.205 8.73661 16.8406 9 17.5033 9C18.166 9 18.8015 8.73661 19.2701 8.26777C19.7388 7.79893 20.002 7.16304 20.002 6.5C20.002 5.83696 19.7388 5.20107 19.2701 4.73223C18.8015 4.26339 18.166 4 17.5033 4ZM15.5023 10C15.1066 10 14.7378 10.1015 14.4052 10.2656C14.3549 10.2813 14.306 10.3009 14.2588 10.3242L10.3448 12.1992C10.1322 12.3003 9.96216 12.4733 9.86453 12.6875L8.09784 16.5859C8.0405 16.7059 8.00764 16.836 8.00118 16.9688C7.99472 17.1016 8.01479 17.2344 8.06021 17.3593C8.10563 17.4843 8.1755 17.5989 8.26572 17.6965C8.35594 17.7941 8.46471 17.8727 8.58567 17.9278C8.70662 17.9828 8.83733 18.0132 8.97016 18.0171C9.10299 18.0211 9.23526 17.9984 9.35924 17.9506C9.48323 17.9028 9.59644 17.8307 9.69225 17.7386C9.78806 17.6464 9.86454 17.5361 9.91724 17.4141L11.3638 14.2246L12.658 13.8359C12.3918 15.2411 12.0603 16.9816 12.0587 16.9902C12.0583 16.9923 12.0572 16.994 12.0568 16.9961C12.0568 16.9961 12.0568 17 12.0568 17C12.024 17.1615 12.006 17.3288 12.006 17.5C12.006 18.271 12.3631 18.9514 12.9118 19.4102L12.9196 19.4336L16.8103 22.5L17.923 26.6953L18.0225 27.1953C18.0677 27.4221 18.19 27.6263 18.3687 27.773C18.5474 27.9197 18.7714 27.9999 19.0025 28C19.2676 28 19.5218 27.8946 19.7093 27.7071C19.8967 27.5196 20.002 27.2652 20.002 27C20.0019 26.9344 19.9954 26.869 19.9825 26.8047V26.8008C19.9812 26.7969 19.9799 26.793 19.9786 26.7891L18.983 21.8047C18.9562 21.6693 18.9017 21.541 18.8229 21.4277L16.9528 18.0039C16.9546 17.9951 16.953 17.9854 16.9547 17.9766L17.9366 13.0625L17.9347 13.0605C17.9762 12.8798 18.003 12.6933 18.003 12.5C18.003 11.1207 16.8837 10.0011 15.5023 10ZM19.3871 13.7422L18.9186 16.0078L19.3344 16.3809C19.4093 16.4489 19.4962 16.5059 19.5882 16.5469L22.5866 17.9102V17.9082C22.7165 17.9681 22.8576 17.9994 23.0005 18C23.2656 18 23.5198 17.8946 23.7073 17.7071C23.8947 17.5196 24 17.2652 24 17C23.9996 16.8084 23.9442 16.6209 23.8404 16.4599C23.7366 16.2989 23.5887 16.1711 23.4144 16.0918V16.0898L20.5545 14.7891L19.3871 13.7422ZM11.9631 20.7246L11.4497 22.4219L9.22228 26.3613L9.1481 26.4863L9.15005 26.4883C9.13825 26.5087 9.12718 26.5296 9.11686 26.5508L9.10905 26.5625C9.0425 26.6987 9.00778 26.8484 9.00754 27C9.00754 27.2652 9.11285 27.5196 9.30029 27.7071C9.48773 27.8946 9.74195 28 10.007 28C10.1647 27.9999 10.3201 27.9626 10.4606 27.891C10.601 27.8193 10.7225 27.7155 10.8152 27.5879H10.8172L10.8328 27.5645C10.8334 27.5632 10.8341 27.5618 10.8347 27.5605L14.1592 22.5117L11.9631 20.7246Z" fill="#000"/>
30679
+ </svg>
30680
+ `;
30681
+ rowPrimary.appendChild(icon);
30682
+ const select = document.createElement("select");
30683
+ const moveOptions = [
30684
+ { type: Walkthrough.EMoveType.Fly, label: "Free move" },
30685
+ { type: Walkthrough.EMoveType.Walk, label: "Maintain height" }
30686
+ ];
30687
+ moveOptions.forEach(o => {
30688
+ const option = document.createElement("option");
30689
+ option.value = o.type;
30690
+ option.innerText = o.label;
30691
+ select.appendChild(option);
30692
+ });
30693
+ select.value = Walkthrough.GetMoveType({ viewer: this._viewer }) || Walkthrough.EMoveType.Walk;
30694
+ rowPrimary.appendChild(select);
30695
+ const spacer1 = document.createElement("div");
30696
+ spacer1.className = "mr-10";
30697
+ rowPrimary.appendChild(spacer1);
30698
+ const inputRow = document.createElement("div");
30699
+ inputRow.className = "input-row";
30700
+ rowPrimary.appendChild(inputRow);
30701
+ const speedLabel = document.createElement("label");
30702
+ speedLabel.innerText = "Speed";
30703
+ inputRow.appendChild(speedLabel);
30704
+ const slider = document.createElement("input");
30705
+ slider.type = "range";
30706
+ slider.min = "0.01";
30707
+ slider.max = "100";
30708
+ slider.step = "0.01";
30709
+ inputRow.appendChild(slider);
30710
+ const syncSliderToMoveType = (type) => {
30711
+ if (type == Walkthrough.EMoveType.Fly) {
30712
+ const rate = Walkthrough.GetFlyMoveRate({ viewer: this._viewer });
30713
+ slider.value = ((rate !== null && rate !== void 0 ? rate : 0.2) * 50).toFixed(2);
30714
+ }
30715
+ else {
30716
+ const rate = Walkthrough.GetWalkMoveRate({ viewer: this._viewer });
30717
+ slider.value = ((rate !== null && rate !== void 0 ? rate : 0.2) * 500).toFixed(2);
30718
+ }
30719
+ };
30720
+ syncSliderToMoveType(select.value);
30721
+ select.addEventListener("change", () => {
30722
+ const newType = select.value;
30723
+ Walkthrough.SetMoveType({
30724
+ viewer: this._viewer,
30725
+ type: newType
30726
+ });
30727
+ syncSliderToMoveType(newType);
30728
+ localStorage.setItem(KEY_WALKTHROUGH_MODE, newType);
30729
+ });
30730
+ slider.addEventListener("input", () => {
30731
+ const type = Walkthrough.GetMoveType({ viewer: this._viewer });
30732
+ const value = parseFloat(slider.value);
30733
+ if (type == Walkthrough.EMoveType.Fly) {
30734
+ const speed = value / 50;
30735
+ Walkthrough.SetFlyMoveRate({ viewer: this._viewer, rate: speed });
30736
+ localStorage.setItem(KEY_WALKTHROUGH_SPEED_FLY, speed.toString());
30737
+ }
30738
+ else {
30739
+ const speed = value / 500;
30740
+ Walkthrough.SetWalkMoveRate({ viewer: this._viewer, rate: speed });
30741
+ localStorage.setItem(KEY_WALKTHROUGH_SPEED_WALK, speed.toString());
30742
+ }
30743
+ });
30744
+ const spacerAuto = document.createElement("div");
30745
+ spacerAuto.className = "mr-auto";
30746
+ rowPrimary.appendChild(spacerAuto);
30747
+ const svgExpand = `
30748
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
30749
+ <path d="M6 14C5.45 14 5 14.45 5 15V18C5 18.55 5.45 19 6 19H9C9.55 19 10 18.55 10 18C10 17.45 9.55 17 9 17H7V15C7 14.45 6.55 14 6 14ZM6 10C6.55 10 7 9.55 7 9V7H9C9.55 7 10 6.55 10 6C10 5.45 9.55 5 9 5H6C5.45 5 5 5.45 5 6V9C5 9.55 5.45 10 6 10ZM17 17H15C14.45 17 14 17.45 14 18C14 18.55 14.45 19 15 19H18C18.55 19 19 18.55 19 18V15C19 14.45 18.55 14 18 14C17.45 14 17 14.45 17 15V17ZM14 6C14 6.55 14.45 7 15 7H17V9C17 9.55 17.45 10 18 10C18.55 10 19 9.55 19 9V6C19 5.45 18.55 5 18 5H15C14.45 5 14 5.45 14 6Z" fill="#000"/>
30750
+ </svg>
30751
+ `;
30752
+ const svgMinimize = `
30753
+ <svg width="14" height="2" viewBox="0 0 16 2" fill="none" xmlns="http://www.w3.org/2000/svg">
30754
+ <path d="M15 1L1 0.999999" stroke="#000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
30755
+ </svg>
30756
+ `;
30757
+ const toggleBtn = document.createElement("div");
30758
+ toggleBtn.className = "icon-btn toggle-btn";
30759
+ toggleBtn.setAttribute("title", collapsed ? "Show controls" : "Hide controls");
30760
+ toggleBtn.innerHTML = collapsed ? svgExpand : svgMinimize;
30761
+ toggleBtn.onclick = () => {
30762
+ const nowCollapsed = element.getAttribute("collapsed") != "true";
30763
+ element.setAttribute("collapsed", nowCollapsed ? "true" : "false");
30764
+ toggleBtn.innerHTML = nowCollapsed ? svgExpand : svgMinimize;
30765
+ toggleBtn.setAttribute("title", nowCollapsed ? "Show controls" : "Hide controls");
30766
+ localStorage.setItem(KEY_WALKTHROUGH_COLLAPSED, nowCollapsed ? "true" : "false");
30767
+ document.documentElement.style.setProperty(VIEWER_WALKTHROUGH_PANEL_CSS_VAR_BOTTOM, nowCollapsed ? HEIGHT_COLLAPSED : HEIGHT_EXPANDED);
30768
+ };
30769
+ rowPrimary.appendChild(toggleBtn);
30770
+ const closeBtn = document.createElement("div");
30771
+ closeBtn.className = "icon-btn close-btn";
30772
+ closeBtn.setAttribute("title", "Close");
30773
+ closeBtn.innerHTML = `
30774
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
30775
+ <path d="M18.3002 5.70973C17.9102 5.31973 17.2802 5.31973 16.8902 5.70973L12.0002 10.5897L7.11022 5.69973C6.72022 5.30973 6.09021 5.30973 5.70021 5.69973C5.31021 6.08973 5.31021 6.71973 5.70021 7.10973L10.5902 11.9997L5.70021 16.8897C5.31021 17.2797 5.31021 17.9097 5.70021 18.2997C6.09021 18.6897 6.72022 18.6897 7.11022 18.2997L12.0002 13.4097L16.8902 18.2997C17.2802 18.6897 17.9102 18.6897 18.3002 18.2997C18.6902 17.9097 18.6902 17.2797 18.3002 16.8897L13.4102 11.9997L18.3002 7.10973C18.6802 6.72973 18.6802 6.08973 18.3002 5.70973Z" fill="#000"/>
30776
+ </svg>
30777
+ `;
30778
+ closeBtn.onclick = () => this._onClose();
30779
+ rowPrimary.appendChild(closeBtn);
30780
+ const rowKeys = document.createElement("div");
30781
+ rowKeys.className = "row-keys";
30782
+ element.appendChild(rowKeys);
30783
+ rowKeys.appendChild(this._buildKeyGroup({
30784
+ widthViewBox: 148,
30785
+ heightViewBox: 110,
30786
+ svgWidth: 111,
30787
+ svgHeight: 83,
30788
+ tip: "Move",
30789
+ keys: [
30790
+ { key: "W", x: 54, y: 10, label: "W" },
30791
+ { key: "A", x: 6, y: 58, label: "A" },
30792
+ { key: "S", x: 54, y: 58, label: "S" },
30793
+ { key: "D", x: 102, y: 58, label: "D" }
30794
+ ]
30795
+ }));
30796
+ rowKeys.appendChild(this._buildKeyGroup({
30797
+ widthViewBox: 148,
30798
+ heightViewBox: 110,
30799
+ svgWidth: 111,
30800
+ svgHeight: 83,
30801
+ tip: "Look",
30802
+ keys: [
30803
+ { key: "ARROWUP", x: 54, y: 10, label: "↑" },
30804
+ { key: "ARROWLEFT", x: 6, y: 58, label: "←" },
30805
+ { key: "ARROWDOWN", x: 54, y: 58, label: "↓" },
30806
+ { key: "ARROWRIGHT", x: 102, y: 58, label: "→" }
30807
+ ]
30808
+ }));
30809
+ rowKeys.appendChild(this._buildKeyGroup({
30810
+ widthViewBox: 98,
30811
+ heightViewBox: 60,
30812
+ svgWidth: 74,
30813
+ svgHeight: 45,
30814
+ tip: "Up / Down",
30815
+ keys: [
30816
+ { key: "Q", x: 6, y: 10, label: "Q" },
30817
+ { key: "E", x: 52, y: 10, label: "E" }
30818
+ ]
30819
+ }));
30820
+ this._container.appendChild(element);
30821
+ }
30822
+ _buildKeyGroup(params) {
30823
+ const NS = "http://www.w3.org/2000/svg";
30824
+ const group = document.createElement("div");
30825
+ group.className = "key-group";
30826
+ const svg = document.createElementNS(NS, "svg");
30827
+ svg.setAttribute("width", params.svgWidth.toString());
30828
+ svg.setAttribute("height", params.svgHeight.toString());
30829
+ svg.setAttribute("viewBox", `0 0 ${params.widthViewBox} ${params.heightViewBox}`);
30830
+ group.appendChild(svg);
30831
+ params.keys.forEach(k => {
30832
+ const rect = document.createElementNS(NS, "rect");
30833
+ rect.setAttribute("x", k.x.toString());
30834
+ rect.setAttribute("y", k.y.toString());
30835
+ rect.setAttribute("width", "40");
30836
+ rect.setAttribute("height", "40");
30837
+ rect.setAttribute("rx", "6");
30838
+ rect.setAttribute("class", "key-rect");
30839
+ svg.appendChild(rect);
30840
+ const text = document.createElementNS(NS, "text");
30841
+ text.setAttribute("x", (k.x + 20).toString());
30842
+ text.setAttribute("y", (k.y + 22).toString());
30843
+ text.setAttribute("text-anchor", "middle");
30844
+ text.setAttribute("dominant-baseline", "middle");
30845
+ text.setAttribute("pointer-events", "none");
30846
+ text.setAttribute("fill", "#000");
30847
+ text.setAttribute("font-size", "20");
30848
+ text.textContent = k.label;
30849
+ svg.appendChild(text);
30850
+ const setActive = (active) => {
30851
+ rect.setAttribute("class", active ? "key-rect key-rect-active" : "key-rect");
30852
+ };
30853
+ rect.addEventListener("mousedown", () => {
30854
+ setActive(true);
30855
+ Walkthrough.CheckKeybind({ viewer: this._viewer, key: k.key, keyDown: true });
30856
+ });
30857
+ const release = () => {
30858
+ setActive(false);
30859
+ Walkthrough.CheckKeybind({ viewer: this._viewer, key: k.key, keyDown: false });
30860
+ };
30861
+ rect.addEventListener("mouseup", release);
30862
+ rect.addEventListener("mouseleave", release);
30863
+ this._keyRects.push({ key: k.key, rect, text });
30864
+ });
30865
+ const tip = document.createElement("div");
30866
+ tip.className = "key-tip";
30867
+ tip.innerText = params.tip;
30868
+ group.appendChild(tip);
30869
+ return group;
30870
+ }
30871
+ _listenPhysicalKeys() {
30872
+ this._keyDownHandler = (e) => this._setKeyRectActive(e.key, true);
30873
+ this._keyUpHandler = (e) => this._setKeyRectActive(e.key, false);
30874
+ document.addEventListener("keydown", this._keyDownHandler);
30875
+ document.addEventListener("keyup", this._keyUpHandler);
30876
+ }
30877
+ _setKeyRectActive(key, active) {
30878
+ const upper = key.toUpperCase();
30879
+ this._keyRects.forEach(kr => {
30880
+ if (kr.key == upper) {
30881
+ kr.rect.setAttribute("class", active ? "key-rect key-rect-active" : "key-rect");
30882
+ }
30883
+ });
30884
+ }
30885
+ }
30886
+
30887
+ const STYLESHEET_ID$1 = "nextspace-nav-compass-hold-loader-stylesheet";
30888
+ function generateStyles() {
30889
+ if (document.getElementById(STYLESHEET_ID$1)) {
30890
+ return;
30891
+ }
30892
+ const style = document.createElement("style");
30893
+ style.id = STYLESHEET_ID$1;
30894
+ style.innerHTML = `
30895
+ .NextspaceHoldLoader {
30896
+ position: fixed;
30897
+ pointer-events: none;
30898
+ z-index: 10000;
30899
+ transform: translate(-50%, -50%);
30900
+ opacity: 0;
30901
+ animation: nextspaceHoldLoaderFadeIn 0.1s ease forwards;
30902
+ }
30903
+
30904
+ .NextspaceHoldLoader svg {
30905
+ filter: drop-shadow(0px 2px 8px rgba(0, 0, 0, 0.4));
30906
+ }
30907
+
30908
+ .NextspaceHoldLoader .progress {
30909
+ transition: stroke-dashoffset 0.05s linear;
30910
+ }
30911
+
30912
+ @keyframes nextspaceHoldLoaderFadeIn {
30913
+ to {
30914
+ opacity: 1;
30915
+ }
30916
+ }
30917
+ `;
30918
+ document.head.appendChild(style);
30919
+ }
30920
+ /**
30921
+ * A press-and-hold radial progress indicator, shown near the cursor while a compass button's interaction is held.
30922
+ */
30923
+ class WidgetNavCompassHoldLoader {
30924
+ constructor(params) {
30925
+ generateStyles();
30926
+ const size = params.isTouch ? 40 : 30;
30927
+ this._radius = (size / 2) - 3;
30928
+ const element = document.createElement("div");
30929
+ element.className = "NextspaceHoldLoader";
30930
+ element.style.left = `${params.x}px`;
30931
+ element.style.top = `${params.y}px`;
30932
+ const circumference = 2 * Math.PI * this._radius;
30933
+ element.innerHTML = `
30934
+ <svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">
30935
+ <circle class="background" cx="${size / 2}" cy="${size / 2}" r="${this._radius}" fill="none" stroke="rgba(255, 255, 255, 0.2)" stroke-width="3"/>
30936
+ <circle class="progress" cx="${size / 2}" cy="${size / 2}" r="${this._radius}" fill="none" stroke="white" stroke-width="3" stroke-linecap="round"
30937
+ stroke-dasharray="${circumference}" stroke-dashoffset="${circumference}"
30938
+ transform="rotate(-90 ${size / 2} ${size / 2})"/>
30939
+ </svg>
30940
+ `;
30941
+ this._progressCircle = element.querySelector(".progress");
30942
+ document.body.appendChild(element);
30943
+ this._element = element;
30944
+ const circ = circumference;
30945
+ const startTime = performance.now();
30946
+ const animate = () => {
30947
+ const elapsed = performance.now() - startTime;
30948
+ const progress = Math.min(elapsed / params.durationMs, 1);
30949
+ this._progressCircle.setAttribute("stroke-dashoffset", (circ * (1 - progress)).toString());
30950
+ if (progress < 1) {
30951
+ this._animationFrame = requestAnimationFrame(animate);
30952
+ }
30953
+ };
30954
+ this._animationFrame = requestAnimationFrame(animate);
30955
+ }
30956
+ Dispose() {
30957
+ var _a;
30958
+ if (this._animationFrame) {
30959
+ cancelAnimationFrame(this._animationFrame);
30960
+ this._animationFrame = null;
30961
+ }
30962
+ if ((_a = this._element) === null || _a === void 0 ? void 0 : _a.parentElement) {
30963
+ this._element.parentElement.removeChild(this._element);
30964
+ }
30965
+ this._element = null;
30966
+ }
30967
+ }
30968
+
30969
+ // Animation constants. All compass animations use 150ms at 60fps for consistency.
30970
+ const ANIMATION_DURATION_MS = 150;
30971
+ // Hold-to-activate constants.
30972
+ const HOLD_ACTIVATION_TIME_MS = 350;
30973
+ const HOLD_LOADER_DELAY_MS = 150;
30974
+ const CONTINUOUS_ANIMATION_SPEED = 0.02 / 3;
30975
+ const ZOOM_DISTANCE = 0.85;
30976
+ const MIN_ZOOM_DISTANCE = 0.3;
30977
+ const NEAR_NADIR_PITCH = -Math.PI / 2 + 0.05;
30978
+ const MIN_ORBIT_OFFSET_METERS = 5;
30979
+ // Caps how far a pivot may be from the camera relative to the camera's own altitude.
30980
+ const MAX_PIVOT_DISTANCE_TO_HEIGHT_RATIO = 200;
30981
+ // Caps how much a single rotate step may change the camera's altitude before we treat it as a
30982
+ // runaway and skip it instead of applying it.
30983
+ const MAX_SINGLE_STEP_HEIGHT_CHANGE_RATIO = 1.15;
30984
+ function GetIs2d(viewer) {
30985
+ var _a;
30986
+ return ((_a = viewer === null || viewer === void 0 ? void 0 : viewer.camera) === null || _a === void 0 ? void 0 : _a.frustum) instanceof OrthographicFrustum;
30987
+ }
30988
+ /**
30989
+ * Validates a candidate rotate/look/zoom pivot against the camera's own altitude.
30990
+ */
30991
+ function IsPivotPlausible(viewer, pivot) {
30992
+ if (!pivot || !isFinite(pivot.x) || !isFinite(pivot.y) || !isFinite(pivot.z)) {
30993
+ return false;
30994
+ }
30995
+ const cameraPos = viewer.camera.positionWC;
30996
+ const distance = Cartesian3.distance(cameraPos, pivot);
30997
+ if (!isFinite(distance)) {
30998
+ return false;
30999
+ }
31000
+ const cameraCarto = Cartographic.fromCartesian(cameraPos);
31001
+ if (!cameraCarto || !isFinite(cameraCarto.height)) {
31002
+ return true;
31003
+ }
31004
+ const cameraHeight = Math.max(cameraCarto.height, 1);
31005
+ return distance <= cameraHeight * MAX_PIVOT_DISTANCE_TO_HEIGHT_RATIO;
31006
+ }
31007
+ function snapshotCamera(camera) {
31008
+ return {
31009
+ position: camera.position.clone(),
31010
+ direction: camera.direction.clone(),
31011
+ up: camera.up.clone()
31012
+ };
31013
+ }
31014
+ function restoreCamera(camera, snapshot) {
31015
+ camera.position = snapshot.position;
31016
+ camera.direction = snapshot.direction;
31017
+ camera.up = snapshot.up;
31018
+ }
31019
+ function getHeightAboveEllipsoid(position) {
31020
+ const carto = Cartographic.fromCartesian(position);
31021
+ return carto && isFinite(carto.height) ? carto.height : null;
31022
+ }
31023
+ /**
31024
+ * Probes the final camera pose an orbit step would produce, and rejects it if the camera's
31025
+ * altitude would change implausibly for what should be a fixed-range orbit.
31026
+ */
31027
+ function isOrbitStepSafe(viewer, target, heading, pitch, range) {
31028
+ const camera = viewer.camera;
31029
+ const before = snapshotCamera(camera);
31030
+ const preHeight = getHeightAboveEllipsoid(before.position);
31031
+ camera.lookAt(target, new HeadingPitchRange(heading, pitch, range));
31032
+ const postHeight = getHeightAboveEllipsoid(camera.positionWC);
31033
+ camera.lookAtTransform(Matrix4.IDENTITY);
31034
+ restoreCamera(camera, before);
31035
+ if (preHeight == null || postHeight == null || preHeight <= 0) {
31036
+ return true;
31037
+ }
31038
+ const ratio = postHeight / preHeight;
31039
+ return ratio <= MAX_SINGLE_STEP_HEIGHT_CHANGE_RATIO && ratio >= 1 / MAX_SINGLE_STEP_HEIGHT_CHANGE_RATIO;
31040
+ }
31041
+ /**
31042
+ * Resolves the center point compass rotate/zoom/look operations should orbit around,
31043
+ * preferring the currently-selected entities' location over a raw screen-center raycast.
31044
+ */
31045
+ async function CalculateEntityCenter(viewer, manager, selectedIds) {
31046
+ var _a, _b;
31047
+ if (!selectedIds || selectedIds.length === 0) {
31048
+ return undefined;
31049
+ }
31050
+ const is2d = GetIs2d(viewer);
31051
+ const location = await EntityUtils.GetLocation({
31052
+ samples: selectedIds.map((id) => ({
31053
+ entityId: id,
31054
+ returnHeightRef: HeightReference.NONE,
31055
+ heightRef: HeightReference.RELATIVE_TO_GROUND
31056
+ })),
31057
+ viewer: viewer,
31058
+ visualRegister: manager.VisualsRegister,
31059
+ api: manager.Getters.GetBruceApi(),
31060
+ minimumAlt: is2d ? 5 : null,
31061
+ paddingAlt: is2d ? 5 : null
31062
+ });
31063
+ if ((_a = location === null || location === void 0 ? void 0 : location.sphere) === null || _a === void 0 ? void 0 : _a.radius) {
31064
+ if (location.sphere.radius < 1) {
31065
+ location.sphere.radius = 1;
31066
+ }
31067
+ return location.sphere.center;
31068
+ }
31069
+ else if (location === null || location === void 0 ? void 0 : location.rectangle) {
31070
+ if (is2d) {
31071
+ return undefined;
31072
+ }
31073
+ const destinationCarto = Rectangle.center(location.rectangle);
31074
+ return Cartesian3.fromRadians(destinationCarto.longitude, destinationCarto.latitude, 0);
31075
+ }
31076
+ else if ((_b = location === null || location === void 0 ? void 0 : location.pos3d) === null || _b === void 0 ? void 0 : _b.x) {
31077
+ return location.pos3d;
31078
+ }
31079
+ return undefined;
31080
+ }
31081
+ function easeInOutQuad(progress) {
31082
+ return progress < 0.5
31083
+ ? 2 * progress * progress
31084
+ : 1 - Math.pow(-2 * progress + 2, 2) / 2;
31085
+ }
31086
+ async function resolvePivot(viewer, manager, selectedIds, stablePivot) {
31087
+ if (stablePivot && IsPivotPlausible(viewer, stablePivot)) {
31088
+ return stablePivot;
31089
+ }
31090
+ if (selectedIds === null || selectedIds === void 0 ? void 0 : selectedIds.length) {
31091
+ const entityCenter = await CalculateEntityCenter(viewer, manager, selectedIds);
31092
+ if (entityCenter && IsPivotPlausible(viewer, entityCenter)) {
31093
+ return entityCenter;
31094
+ }
31095
+ }
31096
+ const c = viewer.canvas;
31097
+ const center = new Cartesian2(c.width / 2, c.height / 2);
31098
+ const ground = DrawingUtils.GetAccuratePosition(viewer, center);
31099
+ if (ground && IsPivotPlausible(viewer, ground)) {
31100
+ return ground;
31101
+ }
31102
+ return undefined;
31103
+ }
31104
+ /**
31105
+ * Rotates the camera around a pivot point by the given radians (single tap action).
31106
+ */
31107
+ async function DoRotate(params) {
31108
+ const { viewer, manager, selectedIds, stablePivot, onPivotUpdate } = params;
31109
+ const left = params.radians < 0;
31110
+ const radians = Math.abs(params.radians);
31111
+ const camera = viewer.camera;
31112
+ const is2d = GetIs2d(viewer);
31113
+ const isLookingStraightDown = camera.pitch <= NEAR_NADIR_PITCH;
31114
+ if (is2d || isLookingStraightDown) {
31115
+ camera.flyTo({
31116
+ destination: camera.position,
31117
+ orientation: {
31118
+ heading: camera.heading + (left ? radians : -radians),
31119
+ pitch: camera.pitch,
31120
+ roll: camera.roll
31121
+ },
31122
+ duration: ANIMATION_DURATION_MS / 1000
31123
+ });
31124
+ return null;
31125
+ }
31126
+ const ground = await resolvePivot(viewer, manager, selectedIds, stablePivot);
31127
+ if (!(ground === null || ground === void 0 ? void 0 : ground.x)) {
31128
+ return null;
31129
+ }
31130
+ const offset = Math.max(Cartesian3.distance(camera.position, ground), MIN_ORBIT_OFFSET_METERS);
31131
+ const startHeading = camera.heading;
31132
+ const fixedPitch = camera.pitch;
31133
+ const totalRotation = left ? radians : -radians;
31134
+ // Distance-to-target stays fixed by construction, but altitude can still drift if `ground`
31135
+ // isn't exactly at the camera's sub-nadir point. Skip the action rather than apply it.
31136
+ if (!isOrbitStepSafe(viewer, ground, startHeading + totalRotation, fixedPitch, offset)) {
31137
+ return null;
31138
+ }
31139
+ const startTime = performance.now();
31140
+ return new Promise((resolve) => {
31141
+ const animate = () => {
31142
+ const elapsed = performance.now() - startTime;
31143
+ const progress = Math.min(elapsed / ANIMATION_DURATION_MS, 1);
31144
+ const eased = easeInOutQuad(progress);
31145
+ const newHeading = startHeading + totalRotation * eased;
31146
+ camera.lookAt(ground, new HeadingPitchRange(newHeading, fixedPitch, offset));
31147
+ if (progress < 1) {
31148
+ requestAnimationFrame(animate);
31149
+ }
31150
+ else {
31151
+ camera.lookAtTransform(Matrix4.IDENTITY);
31152
+ onPivotUpdate === null || onPivotUpdate === void 0 ? void 0 : onPivotUpdate(ground);
31153
+ resolve(ground);
31154
+ }
31155
+ };
31156
+ requestAnimationFrame(animate);
31157
+ });
31158
+ }
31159
+ /**
31160
+ * Zooms the camera in or out by a fixed amount (single tap action).
31161
+ */
31162
+ function DoZoom(params) {
31163
+ const { viewer, zoomIn, stablePivot, onPivotUpdate } = params;
31164
+ const camera = viewer.camera;
31165
+ const p = camera.position;
31166
+ let ground;
31167
+ if (stablePivot && IsPivotPlausible(viewer, stablePivot)) {
31168
+ ground = stablePivot;
31169
+ }
31170
+ else {
31171
+ const c = viewer.canvas;
31172
+ const center = new Cartesian2(c.width / 2, c.height / 2);
31173
+ ground = DrawingUtils.GetAccuratePosition(viewer, center);
31174
+ }
31175
+ if (!(ground === null || ground === void 0 ? void 0 : ground.x) || !IsPivotPlausible(viewer, ground)) {
31176
+ return Promise.resolve(null);
31177
+ }
31178
+ const height = Cartesian3.distance(p, ground);
31179
+ const mag = (ZOOM_DISTANCE * 0.5) / Math.max(1, 4 - Math.log10(height));
31180
+ const zoom = zoomIn ? 1 - mag : 1 + mag;
31181
+ const offset = Cartesian3.multiplyByScalar(Cartesian3.subtract(p, ground, new Cartesian3()), zoom, new Cartesian3());
31182
+ if (zoomIn && Cartesian3.magnitude(offset) <= MIN_ZOOM_DISTANCE) {
31183
+ return Promise.resolve(null);
31184
+ }
31185
+ const to = Cartesian3.add(ground, offset, new Cartesian3());
31186
+ return new Promise((resolve) => {
31187
+ camera.flyTo({
31188
+ destination: to,
31189
+ orientation: { heading: camera.heading, pitch: camera.pitch, roll: camera.roll },
31190
+ duration: ANIMATION_DURATION_MS / 1000,
31191
+ easingFunction: EasingFunction.QUADRATIC_IN_OUT,
31192
+ complete: () => {
31193
+ onPivotUpdate === null || onPivotUpdate === void 0 ? void 0 : onPivotUpdate(ground);
31194
+ resolve(ground);
31195
+ }
31196
+ });
31197
+ });
31198
+ }
31199
+ /**
31200
+ * Tilts the camera up or down by arcing around a pivot point (single tap action).
31201
+ */
31202
+ async function DoLook(params) {
31203
+ const { viewer, manager, tiltUp, selectedIds, stablePivot, onPivotUpdate } = params;
31204
+ // ~11.25 degrees per click.
31205
+ const pitchIncrement = (Math.PI / 32) * 2;
31206
+ const camera = viewer.camera;
31207
+ const MIN_PITCH = -Math.PI / 2 + 0.1;
31208
+ const MAX_PITCH = Math.PI / 8;
31209
+ const currentPitch = camera.pitch;
31210
+ const targetPitch = currentPitch + (tiltUp ? -pitchIncrement : pitchIncrement);
31211
+ const clampedPitch = Math.max(MIN_PITCH, Math.min(MAX_PITCH, targetPitch));
31212
+ if (Math.abs(clampedPitch - currentPitch) < 0.001) {
31213
+ return null;
31214
+ }
31215
+ const center = await resolvePivot(viewer, manager, selectedIds, stablePivot);
31216
+ if (!(center === null || center === void 0 ? void 0 : center.x)) {
31217
+ camera.flyTo({
31218
+ destination: camera.position,
31219
+ orientation: {
31220
+ heading: camera.heading,
31221
+ pitch: clampedPitch,
31222
+ roll: camera.roll
31223
+ },
31224
+ duration: ANIMATION_DURATION_MS / 1000
31225
+ });
31226
+ return null;
31227
+ }
31228
+ const offset = Math.max(Cartesian3.distance(camera.position, center), MIN_ORBIT_OFFSET_METERS);
31229
+ const startPitch = currentPitch;
31230
+ const fixedHeading = camera.heading;
31231
+ const totalPitchChange = clampedPitch - currentPitch;
31232
+ const startTime = performance.now();
31233
+ return new Promise((resolve) => {
31234
+ const animate = () => {
31235
+ const elapsed = performance.now() - startTime;
31236
+ const progress = Math.min(elapsed / ANIMATION_DURATION_MS, 1);
31237
+ const eased = easeInOutQuad(progress);
31238
+ const newPitch = startPitch + totalPitchChange * eased;
31239
+ camera.lookAt(center, new HeadingPitchRange(fixedHeading, newPitch, offset));
31240
+ if (progress < 1) {
31241
+ requestAnimationFrame(animate);
31242
+ }
31243
+ else {
31244
+ camera.lookAtTransform(Matrix4.IDENTITY);
31245
+ onPivotUpdate === null || onPivotUpdate === void 0 ? void 0 : onPivotUpdate(center);
31246
+ resolve(center);
31247
+ }
31248
+ };
31249
+ requestAnimationFrame(animate);
31250
+ });
31251
+ }
31252
+ /**
31253
+ * Continuously rotates the camera while active (press-and-hold). Returns a stop function.
31254
+ */
31255
+ function StartContinuousRotate(params) {
31256
+ const { viewer, manager, rotateLeft, selectedIds, stablePivot, onPivotUpdate } = params;
31257
+ let active = true;
31258
+ let center;
31259
+ const camera = viewer.camera;
31260
+ const is2d = GetIs2d(viewer);
31261
+ const isLookingStraightDown = camera.pitch <= NEAR_NADIR_PITCH;
31262
+ if (is2d || isLookingStraightDown) {
31263
+ const animate = () => {
31264
+ if (!active) {
31265
+ return;
31266
+ }
31267
+ const inc = Math.PI * CONTINUOUS_ANIMATION_SPEED;
31268
+ const newHeading = camera.heading + (rotateLeft ? inc : -inc);
31269
+ camera.setView({
31270
+ destination: camera.position,
31271
+ orientation: { heading: newHeading, pitch: camera.pitch, roll: camera.roll }
31272
+ });
31273
+ if (active) {
31274
+ requestAnimationFrame(animate);
31275
+ }
31276
+ };
31277
+ requestAnimationFrame(animate);
31278
+ return () => { active = false; };
31279
+ }
31280
+ const fixedPitch = camera.pitch;
31281
+ // Fixed for the whole hold, not recomputed every frame. Recomputing it from the camera's
31282
+ // current position each frame cements any per-frame drift as the new normal distance, then
31283
+ // rotates further from there, compounding into a runaway over many frames.
31284
+ let fixedOffset = null;
31285
+ let holdStartHeight = null;
31286
+ let holdStartSnapshot = null;
31287
+ resolvePivot(viewer, manager, selectedIds, stablePivot).then(p => {
31288
+ center = p;
31289
+ if (center) {
31290
+ fixedOffset = Math.max(Cartesian3.distance(camera.position, center), MIN_ORBIT_OFFSET_METERS);
31291
+ holdStartHeight = getHeightAboveEllipsoid(camera.positionWC);
31292
+ holdStartSnapshot = snapshotCamera(camera);
31293
+ }
31294
+ });
31295
+ const animate = () => {
31296
+ if (!active || !center || fixedOffset == null) {
31297
+ if (active) {
31298
+ requestAnimationFrame(animate);
31299
+ }
31300
+ return;
31301
+ }
31302
+ const inc = Math.PI * CONTINUOUS_ANIMATION_SPEED;
31303
+ camera.lookAt(center, new HeadingPitchRange(camera.heading, fixedPitch, fixedOffset));
31304
+ rotateLeft ? camera.rotateLeft(inc) : camera.rotateRight(inc);
31305
+ // Backstop against the hold's starting altitude, so slow compounding across many frames
31306
+ // still gets caught, not just a single big jump.
31307
+ const postHeight = getHeightAboveEllipsoid(camera.positionWC);
31308
+ if (holdStartHeight != null && postHeight != null && holdStartHeight > 0) {
31309
+ const ratio = postHeight / holdStartHeight;
31310
+ if (ratio > MAX_SINGLE_STEP_HEIGHT_CHANGE_RATIO || ratio < 1 / MAX_SINGLE_STEP_HEIGHT_CHANGE_RATIO) {
31311
+ camera.lookAtTransform(Matrix4.IDENTITY);
31312
+ if (holdStartSnapshot) {
31313
+ restoreCamera(camera, holdStartSnapshot);
31314
+ }
31315
+ active = false;
31316
+ return;
31317
+ }
31318
+ }
31319
+ onPivotUpdate === null || onPivotUpdate === void 0 ? void 0 : onPivotUpdate(center);
31320
+ if (active) {
31321
+ requestAnimationFrame(animate);
31322
+ }
31323
+ };
31324
+ requestAnimationFrame(animate);
31325
+ return () => {
31326
+ active = false;
31327
+ camera.lookAtTransform(Matrix4.IDENTITY);
31328
+ };
31329
+ }
31330
+ /**
31331
+ * Continuously tilts the camera up or down while active (press-and-hold). Returns a stop function.
31332
+ */
31333
+ function StartContinuousLook(params) {
31334
+ const { viewer, manager, lookUp, selectedIds, stablePivot, onPivotUpdate } = params;
31335
+ let active = true;
31336
+ let center;
31337
+ const fixedHeading = viewer.camera.heading;
31338
+ const MIN_PITCH = -Math.PI / 2 + 0.1;
31339
+ const MAX_PITCH = Math.PI / 8;
31340
+ // Fixed for the whole hold, not recomputed every frame. See StartContinuousRotate.
31341
+ let fixedOffset = null;
31342
+ resolvePivot(viewer, manager, selectedIds, stablePivot).then(p => {
31343
+ center = p;
31344
+ if (center) {
31345
+ fixedOffset = Math.max(Cartesian3.distance(viewer.camera.position, center), MIN_ORBIT_OFFSET_METERS);
31346
+ }
31347
+ });
31348
+ const animate = () => {
31349
+ if (!active) {
31350
+ return;
31351
+ }
31352
+ if (!center || fixedOffset == null) {
31353
+ requestAnimationFrame(animate);
31354
+ return;
31355
+ }
31356
+ const camera = viewer.camera;
31357
+ const currentPitch = camera.pitch;
31358
+ const inc = Math.PI * CONTINUOUS_ANIMATION_SPEED * (lookUp ? -1 : 1);
31359
+ const newPitch = Math.max(MIN_PITCH, Math.min(MAX_PITCH, currentPitch + inc));
31360
+ if (Math.abs(newPitch - currentPitch) < 0.001) {
31361
+ active = false;
31362
+ return;
31363
+ }
31364
+ camera.lookAt(center, new HeadingPitchRange(fixedHeading, newPitch, fixedOffset));
31365
+ onPivotUpdate === null || onPivotUpdate === void 0 ? void 0 : onPivotUpdate(center);
31366
+ if (active) {
31367
+ requestAnimationFrame(animate);
31368
+ }
31369
+ };
31370
+ requestAnimationFrame(animate);
31371
+ return () => {
31372
+ active = false;
31373
+ viewer.camera.lookAtTransform(Matrix4.IDENTITY);
31374
+ };
31375
+ }
31376
+ /**
31377
+ * Continuously zooms the camera while active (press-and-hold). Returns a stop function.
31378
+ */
31379
+ function StartContinuousZoom(params) {
31380
+ const { viewer, zoomIn, stablePivot, onPivotUpdate } = params;
31381
+ let active = true;
31382
+ let center = (stablePivot && IsPivotPlausible(viewer, stablePivot)) ? stablePivot : undefined;
31383
+ const animate = () => {
31384
+ if (!active) {
31385
+ return;
31386
+ }
31387
+ const camera = viewer.camera;
31388
+ let ground;
31389
+ if (center) {
31390
+ ground = center;
31391
+ }
31392
+ else {
31393
+ const c = viewer.canvas;
31394
+ const screenCenter = new Cartesian2(c.width / 2, c.height / 2);
31395
+ ground = DrawingUtils.GetAccuratePosition(viewer, screenCenter);
31396
+ if (!ground || !IsPivotPlausible(viewer, ground)) {
31397
+ active = false;
31398
+ return;
31399
+ }
31400
+ }
31401
+ const p = camera.position;
31402
+ const height = Cartesian3.distance(p, ground);
31403
+ const mag = (ZOOM_DISTANCE * 0.5) / Math.max(1, 4 - Math.log10(height));
31404
+ const zoom = zoomIn ? 1 - mag * 0.03 : 1 + mag * 0.03;
31405
+ const offset = Cartesian3.multiplyByScalar(Cartesian3.subtract(p, ground, new Cartesian3()), zoom, new Cartesian3());
31406
+ if (zoomIn && Cartesian3.magnitude(offset) <= MIN_ZOOM_DISTANCE) {
31407
+ active = false;
31408
+ return;
31409
+ }
31410
+ const to = Cartesian3.add(ground, offset, new Cartesian3());
31411
+ camera.setView({
31412
+ destination: to,
31413
+ orientation: { heading: camera.heading, pitch: camera.pitch, roll: camera.roll }
31414
+ });
31415
+ onPivotUpdate === null || onPivotUpdate === void 0 ? void 0 : onPivotUpdate(ground);
31416
+ if (active) {
31417
+ requestAnimationFrame(animate);
31418
+ }
31419
+ };
31420
+ requestAnimationFrame(animate);
31421
+ return () => { active = false; };
31422
+ }
31423
+
30845
31424
  class WidgetNavCompass$$1 extends Widget.AWidget {
30846
31425
  constructor(params) {
30847
31426
  super(params);
30848
- this.ZOOM_DISTANCE = 0.85;
30849
- this.ZOOM_TIME = 0.2;
30850
- this.TURN_SPEED = 0.04;
30851
- this.MIN_ZOOM_DISTANCE = 0.3;
30852
31427
  this.STYLESHEET_ID = "nextspace-nav-compass-stylesheet";
31428
+ this._stablePivot = null;
31429
+ this.PIVOT_DISTANCE_TOLERANCE_METERS = 50;
31430
+ // Press-and-hold state.
31431
+ this._holdTimer = null;
31432
+ this._loaderTimer = null;
31433
+ this._stopContinuous = null;
31434
+ this._didActivateContinuous = false;
31435
+ this._pendingSingleAction = null;
31436
+ this._holdLoader = null;
31437
+ // Serializes single-tap rotate/look/zoom actions so a rapid click can't overlap an in-flight animation.
31438
+ this._orbitActionChain = Promise.resolve();
31439
+ this._isWalkthroughActive = false;
31440
+ this._walkthroughBar = null;
31441
+ this._isVR = false;
30853
31442
  this._generateStyles();
30854
31443
  this._generateElement();
30855
31444
  this._listenToRenders();
31445
+ this._listenGlobalRelease();
30856
31446
  }
30857
- _getIs2d() {
30858
- return this._viewer.camera.frustum instanceof OrthographicFrustum;
31447
+ _getSelectedIds() {
31448
+ var _a, _b;
31449
+ return ((_b = (_a = this._manager) === null || _a === void 0 ? void 0 : _a.VisualsRegister) === null || _b === void 0 ? void 0 : _b.GetSelected()) || [];
31450
+ }
31451
+ _getStablePivot() {
31452
+ const camera = this._viewer.camera;
31453
+ // Re-validate a cached pivot too, since it may have been established from a bad raycast.
31454
+ if (this._stablePivot && IsPivotPlausible(this._viewer, this._stablePivot)) {
31455
+ const distance = Cartesian3.distance(camera.position, this._stablePivot);
31456
+ if (distance <= this.PIVOT_DISTANCE_TOLERANCE_METERS) {
31457
+ return this._stablePivot;
31458
+ }
31459
+ }
31460
+ const c = this._viewer.canvas;
31461
+ const center = new Cartesian2(c.width / 2, c.height / 2);
31462
+ const ground = DrawingUtils.GetAccuratePosition(this._viewer, center);
31463
+ if ((ground === null || ground === void 0 ? void 0 : ground.x) && IsPivotPlausible(this._viewer, ground)) {
31464
+ this._stablePivot = ground.clone();
31465
+ return this._stablePivot;
31466
+ }
31467
+ this._stablePivot = null;
31468
+ return null;
31469
+ }
31470
+ _updateStablePivot(pivot) {
31471
+ if (pivot && IsPivotPlausible(this._viewer, pivot)) {
31472
+ this._stablePivot = pivot.clone ? pivot.clone() : pivot;
31473
+ }
31474
+ }
31475
+ _listenGlobalRelease() {
31476
+ this._globalMouseUp = () => this._handlePointerUp();
31477
+ this._globalTouchEnd = () => this._handlePointerUp();
31478
+ window.addEventListener("mouseup", this._globalMouseUp);
31479
+ window.addEventListener("touchend", this._globalTouchEnd);
30859
31480
  }
30860
31481
  _listenToRenders() {
30861
31482
  if (this._renderRemoval) {
@@ -30867,10 +31488,30 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
30867
31488
  });
30868
31489
  }
30869
31490
  Dispose() {
31491
+ var _a, _b, _c;
30870
31492
  if (this._renderRemoval) {
30871
31493
  this._renderRemoval();
30872
31494
  this._renderRemoval = null;
30873
31495
  }
31496
+ if (this._globalMouseUp) {
31497
+ window.removeEventListener("mouseup", this._globalMouseUp);
31498
+ }
31499
+ if (this._globalTouchEnd) {
31500
+ window.removeEventListener("touchend", this._globalTouchEnd);
31501
+ }
31502
+ if (this._fullscreenChange) {
31503
+ document.removeEventListener("fullscreenchange", this._fullscreenChange);
31504
+ document.removeEventListener("webkitfullscreenchange", this._fullscreenChange);
31505
+ }
31506
+ if (this._loaderTimer) {
31507
+ window.clearTimeout(this._loaderTimer);
31508
+ }
31509
+ if (this._holdTimer) {
31510
+ window.clearTimeout(this._holdTimer);
31511
+ }
31512
+ (_a = this._stopContinuous) === null || _a === void 0 ? void 0 : _a.call(this);
31513
+ (_b = this._holdLoader) === null || _b === void 0 ? void 0 : _b.Dispose();
31514
+ (_c = this._walkthroughBar) === null || _c === void 0 ? void 0 : _c.Dispose();
30874
31515
  super.Dispose();
30875
31516
  }
30876
31517
  _generateStyles() {
@@ -30884,15 +31525,14 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
30884
31525
  display: flex;
30885
31526
  flex-direction: column;
30886
31527
  align-items: center;
30887
- width: 85px;
30888
- min-height: 150px;
31528
+ width: 65px;
31529
+ min-height: 100px;
30889
31530
  background: rgba(33, 39, 42, 0.75);
30890
- box-shadow: 0px 0px 1px rgba(18, 22, 25, 0.18), 0px 18px 36px -4px rgba(18, 22, 25, 0.36);
31531
+ box-shadow: 0px 0px 1px rgba(18, 22, 25, 0.18), 0px 12px 22px -2px rgba(18, 22, 25, 0.26);
30891
31532
  backdrop-filter: blur(20px);
30892
- border-radius: 102px 102px 9px 9px;
31533
+ border-radius: 102px 102px 30px 30px;
30893
31534
  overflow: hidden;
30894
- padding-top: 85px;
30895
- padding-bottom: 5px;
31535
+ padding-top: 60px;
30896
31536
  position: absolute;
30897
31537
  bottom: 10px;
30898
31538
  right: 10px;
@@ -30905,27 +31545,27 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
30905
31545
 
30906
31546
  .NextspaceNavCompassTop {
30907
31547
  position: absolute;
30908
- height: 85px;
30909
- width: 85px;
30910
- top: -2px;
31548
+ height: 65px;
31549
+ width: 100%;
31550
+ top: 0;
30911
31551
  border-radius: 50%;
30912
- border: 1px solid #4D5358;
30913
31552
  display: flex;
30914
31553
  justify-content: center;
30915
31554
  align-items: center;
30916
31555
  }
30917
31556
 
30918
31557
  .NextspaceNavCompassAxis {
30919
- background: #181d20;
30920
- border: 1px solid rgba(255, 255, 255, 0.15);
30921
- width: 60px;
30922
- height: 60px;
31558
+ background: #121619;
31559
+ border: 1px solid #ffffff1f;
31560
+ width: 50px;
31561
+ height: 50px;
30923
31562
  border-radius: 50%;
30924
31563
  position: relative;
30925
31564
  display: flex;
30926
31565
  align-items: center;
30927
31566
  justify-content: center;
30928
31567
  cursor: pointer;
31568
+ z-index: 2;
30929
31569
  }
30930
31570
 
30931
31571
  .NextspaceNavCompassAxis >svg {
@@ -30936,6 +31576,7 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
30936
31576
 
30937
31577
  .NextspaceNavCompassArrow {
30938
31578
  margin-bottom: 6px;
31579
+ z-index: 1;
30939
31580
  }
30940
31581
 
30941
31582
  .NextspaceNavCompassAxis:hover .NextspaceNavCompassArrow {
@@ -30946,6 +31587,8 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
30946
31587
  .NextspaceNavCompassRow {
30947
31588
  display: flex;
30948
31589
  align-items: center;
31590
+ padding-top: 4px;
31591
+ padding-bottom: 4px;
30949
31592
  }
30950
31593
 
30951
31594
  .NextspaceNavCompassCol {
@@ -30954,8 +31597,8 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
30954
31597
  }
30955
31598
 
30956
31599
  .NextspaceNavCompassButt {
30957
- width: 40px;
30958
- height: 35px;
31600
+ width: 28px;
31601
+ height: 28px;
30959
31602
  flex-shrink: 1;
30960
31603
  flex-grow: 0;
30961
31604
  display: flex;
@@ -30965,24 +31608,56 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
30965
31608
  transition: 0.3s ease;
30966
31609
  }
30967
31610
 
31611
+ .NextspaceNavCompassButt:hover {
31612
+ transform: translateY(-2px);
31613
+ }
31614
+
30968
31615
  .NextspaceNavCompassButt[is-disabled="true"] {
30969
31616
  opacity: 0.4;
30970
31617
  cursor: default;
30971
31618
  pointer-events: none;
30972
31619
  }
30973
31620
 
30974
- .NextspaceNavCompassButt:hover {
30975
- transform: scale(1.2);
31621
+ .NextspaceNavCompassLookButt {
31622
+ position: absolute;
31623
+ z-index: 3;
31624
+ margin-top: -6px;
31625
+ opacity: 0.7;
30976
31626
  }
30977
31627
 
30978
- .NextspaceNavCompassHorDash {
30979
- background-color: rgba(255, 255, 255, 0.12);
30980
- width: calc(100% - 10px);
30981
- height: 1px;
30982
- flex-shrink: 0;
30983
- flex-grow: 0;
30984
- margin-top: 5px;
30985
- margin-bottom: 5px;
31628
+ .NextspaceNavCompassLookButt:hover {
31629
+ opacity: 1;
31630
+ }
31631
+
31632
+ .NextspaceNavCompassLookButt.look-up {
31633
+ top: 0;
31634
+ }
31635
+
31636
+ .NextspaceNavCompassLookButt.look-down {
31637
+ bottom: -6px;
31638
+ }
31639
+
31640
+ .NextspaceNavCompassRotateButt {
31641
+ position: absolute;
31642
+ z-index: 3;
31643
+ margin-top: 14px;
31644
+ width: 32px;
31645
+ height: 28px;
31646
+ transform: scale(0.8);
31647
+ opacity: 0.7;
31648
+ }
31649
+
31650
+ .NextspaceNavCompassRotateButt:hover {
31651
+ transform: scale(0.85) translateY(-2px);
31652
+ opacity: 1;
31653
+ }
31654
+
31655
+ .NextspaceNavCompassRotateButt.rotate-left {
31656
+ left: -6px;
31657
+ }
31658
+
31659
+ .NextspaceNavCompassRotateButt.rotate-right {
31660
+ right: -6px;
30986
31661
  }
30987
31662
 
30988
31663
  .NextspaceNavCompassVerDash {
@@ -30999,13 +31674,22 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
30999
31674
 
31000
31675
  .NextspaceNavCompassDimToggle {
31001
31676
  background: #121619;
31002
- border-radius: 6px;
31003
- width: calc(100% - 10px);
31677
+ width: 100%;
31678
+ margin-left: auto;
31679
+ margin-right: auto;
31004
31680
  height: 24px;
31005
31681
  flex-grow: 0;
31006
31682
  flex-shrink: 1;
31007
- padding: 2px;
31683
+ padding: 2px 0;
31008
31684
  display: flex;
31685
+ align-items: center;
31686
+ justify-content: center;
31687
+ color: white;
31688
+ transition: 0.3s ease;
31689
+ font-size: 12px;
31690
+ font-family: Arial, Helvetica, sans-serif;
31691
+ border: 1px solid #ffffff1f;
31692
+ border-radius: 0 0 9px 9px;
31009
31693
  }
31010
31694
 
31011
31695
  .NextspaceNavCompassDimToggleButt {
@@ -31016,12 +31700,21 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
31016
31700
  flex-grow: 1;
31017
31701
  flex-shrink: 1;
31018
31702
  width: 100%;
31703
+ height: 100%;
31019
31704
  transition: 0.3s ease;
31020
31705
  cursor: pointer;
31021
31706
  opacity: 0.4;
31022
31707
  color: white;
31023
- font-size: 12px;
31024
- font-family: Arial, Helvetica, sans-serif;
31708
+ }
31709
+
31710
+ .NextspaceNavCompassDimToggleButt:first-child {
31711
+ margin-left: 2px;
31712
+ border-radius: 2px 2px 1px 6px;
31713
+ }
31714
+
31715
+ .NextspaceNavCompassDimToggleButt:last-child {
31716
+ margin-right: 2px;
31717
+ border-radius: 2px 2px 6px 1px;
31025
31718
  }
31026
31719
 
31027
31720
  .NextspaceNavCompassDimToggleButt[is-selected="true"] {
@@ -31029,6 +31722,12 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
31029
31722
  background-color: #4D5358;
31030
31723
  box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.12);
31031
31724
  }
31725
+
31726
+ .NextspaceNavCompassDimToggle[is-disabled="true"] {
31727
+ opacity: 0.7;
31728
+ cursor: default;
31729
+ pointer-events: none;
31730
+ }
31032
31731
  `;
31033
31732
  document.head.appendChild(style);
31034
31733
  }
@@ -31038,34 +31737,24 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
31038
31737
  const top = document.createElement("div");
31039
31738
  top.className = "NextspaceNavCompassTop";
31040
31739
  element.appendChild(top);
31740
+ this._generateLookButtons(top);
31741
+ this._generateRotateButtons(top);
31742
+ this._generateAxis(top);
31743
+ this._generateZoomRow(element);
31744
+ this._generateExtraTools(element);
31745
+ this._generateDimensionToggle(element);
31746
+ this.Container.appendChild(element);
31747
+ this._element = element;
31748
+ this._update2d3d();
31749
+ }
31750
+ _generateAxis(top) {
31041
31751
  const axis = document.createElement("div");
31042
31752
  axis.className = "NextspaceNavCompassAxis";
31043
31753
  axis.setAttribute("title", "Click to reset north");
31044
31754
  top.appendChild(axis);
31045
- axis.addEventListener("click", () => {
31046
- this._clickResetNorth();
31047
- });
31755
+ axis.addEventListener("click", () => this._clickResetNorth());
31048
31756
  axis.innerHTML = `
31049
- <svg width="72" height="72" viewBox="0 0 94 94" fill="none" xmlns="http://www.w3.org/2000/svg">
31050
- <rect x="46" width="2" height="8" rx="1" fill="#FF3D00"/>
31051
- <rect x="46" y="86" width="2" height="8" rx="1" fill="#4D5254"/>
31052
- <rect x="94" y="46" width="2" height="8" rx="1" transform="rotate(90 94 46)" fill="#4D5254"/>
31053
- <rect x="8" y="46" width="2" height="8" rx="1" transform="rotate(90 8 46)" fill="#4D5254"/>
31054
- <rect x="79.5269" y="13.0589" width="2" height="8" rx="1" transform="rotate(45 79.5269 13.0589)" fill="#4D5254"/>
31055
- <rect x="18.7157" y="73.8701" width="2" height="8" rx="1" transform="rotate(45 18.7157 73.8701)" fill="#4D5254"/>
31056
- <rect x="80.9412" y="79.5269" width="2" height="8" rx="1" transform="rotate(135 80.9412 79.5269)" fill="#4D5254"/>
31057
- <rect x="20.1299" y="18.7157" width="2" height="8" rx="1" transform="rotate(135 20.1299 18.7157)" fill="#4D5254"/>
31058
- <rect x="28.8555" y="5.80811" width="2" height="4" rx="1" transform="rotate(-22.5 28.8555 5.80811)" fill="#505456"/>
31059
- <rect x="61.7662" y="85.2617" width="2" height="4" rx="1" transform="rotate(-22.5 61.7662 85.2617)" fill="#505456"/>
31060
- <rect x="88.1919" y="28.8553" width="2" height="4" rx="1" transform="rotate(67.5 88.1919 28.8553)" fill="#505456"/>
31061
- <rect x="8.73828" y="61.7661" width="2" height="4" rx="1" transform="rotate(67.5 8.73828 61.7661)" fill="#505456"/>
31062
- <rect x="63.2969" y="5.04272" width="2" height="4" rx="1" transform="rotate(22.5 63.2969 5.04272)" fill="#505456"/>
31063
- <rect x="30.386" y="84.4963" width="2" height="4" rx="1" transform="rotate(22.5 30.386 84.4963)" fill="#505456"/>
31064
- <rect x="88.9572" y="63.2969" width="2" height="4" rx="1" transform="rotate(112.5 88.9572 63.2969)" fill="#505456"/>
31065
- <rect x="9.50354" y="30.3861" width="2" height="4" rx="1" transform="rotate(112.5 9.50354 30.3861)" fill="#505456"/>
31066
- </svg>
31067
-
31068
- <svg class="NextspaceNavCompassArrow" width="28" height="35" viewBox="0 0 32 40" fill="none" xmlns="http://www.w3.org/2000/svg">
31757
+ <svg class="NextspaceNavCompassArrow" width="21" height="26.25" viewBox="0 0 32 40" fill="none" xmlns="http://www.w3.org/2000/svg">
31069
31758
  <path d="M31.544 39.666C31.969 39.29 32.114 38.682 31.905 38.15L17.229 0.845C17.028 0.334 16.542 0 16.001 0C15.46 0 14.974 0.335 14.773 0.846L0.0950303 38.155C-0.11397 38.687 0.0310303 39.295 0.45603 39.67C0.88103 40.046 1.49303 40.106 1.98203 39.821L14.699 32.401C15.515 31.925 16.518 31.925 17.333 32.401L30.019 39.816C30.507 40.101 31.12 40.041 31.545 39.665L31.544 39.666Z" fill="url(#paint0_linear_363_9865)"/>
31070
31759
  <path d="M16.001 0C15.46 0 14.974 0.335 14.773 0.846L0.0950303 38.155C-0.11397 38.687 0.0310303 39.295 0.45603 39.67C0.88103 40.046 1.49303 40.106 1.98203 39.821L14.699 32.401C15.103 32.165 15.552 32.047 16.002 32.045V0H16.001Z" fill="#1192E8"/>
31071
31760
  <path d="M0.454956 39.67C0.879956 40.046 1.49196 40.106 1.98096 39.821L14.698 32.401C15.102 32.165 15.551 32.047 16.001 32.045V24.844L0.454956 39.67Z" fill="url(#paint1_linear_363_9865)"/>
@@ -31087,214 +31776,370 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
31087
31776
  </svg>
31088
31777
  `;
31089
31778
  this._axis = axis;
31090
- const rotateRow = document.createElement("div");
31091
- rotateRow.className = "NextspaceNavCompassRow";
31092
- rotateRow.innerHTML = `
31093
- <div class="NextspaceNavCompassButt">
31094
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
31095
- <path d="M8 12.5C8 16.743 10.5205 20.389 14.1445 22.043C14.6875 22.291 15.3286 22.0152 15.5176 21.4492C15.6776 20.9702 15.4522 20.4473 14.9922 20.2383C12.0482 18.9023 10 15.943 10 12.5C10 10.3219 10.8297 8.34307 12.1777 6.83983L15.1465 9.80858C15.3415 10.0036 15.6585 10.0036 15.8535 9.80858C15.9505 9.71058 16 9.58306 16 9.45506L16 2.95506C16 2.68985 15.8946 2.43549 15.7071 2.24795C15.5196 2.06042 15.2652 1.95506 15 1.95506L8.5 1.95506C8.372 1.95506 8.24348 2.00355 8.14648 2.10155C7.95148 2.29655 7.95148 2.61358 8.14648 2.80858L10.7695 5.43163C9.05703 7.29483 8 9.76796 8 12.5Z" fill="#A2A9B0"/>
31096
- </svg>
31097
- </div>
31098
-
31099
- <div class="NextspaceNavCompassButt">
31100
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
31101
- <path d="M16 12.5C16 16.743 13.4795 20.389 9.85547 22.043C9.31247 22.291 8.67142 22.0152 8.48242 21.4492C8.32242 20.9702 8.54781 20.4473 9.00781 20.2383C11.9518 18.9023 14 15.943 14 12.5C14 10.3219 13.1703 8.34307 11.8223 6.83983L8.85352 9.80858C8.65852 10.0036 8.34149 10.0036 8.14648 9.80858C8.04948 9.71058 8 9.58306 8 9.45506L8 2.95506C8 2.68985 8.10536 2.43549 8.29289 2.24795C8.48043 2.06042 8.73478 1.95506 9 1.95506L15.5 1.95506C15.628 1.95506 15.7565 2.00355 15.8535 2.10155C16.0485 2.29655 16.0485 2.61358 15.8535 2.80858L13.2305 5.43163C14.943 7.29483 16 9.76796 16 12.5Z" fill="#A2A9B0"/>
31102
- </svg>
31103
- </div>
31779
+ }
31780
+ _generateLookButtons(top) {
31781
+ const lookUp = document.createElement("div");
31782
+ lookUp.className = "NextspaceNavCompassButt NextspaceNavCompassLookButt look-up";
31783
+ lookUp.innerHTML = `
31784
+ <svg width="16" height="9" viewBox="0 0 16 9" fill="none" xmlns="http://www.w3.org/2000/svg">
31785
+ <path d="M1 8L8 1L15 8" stroke="#A2A9B0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
31786
+ </svg>
31104
31787
  `;
31105
- element.appendChild(rotateRow);
31106
- const rotateLeft = rotateRow.children[0];
31107
- const rotateRight = rotateRow.children[1];
31108
- rotateLeft.addEventListener("click", () => {
31109
- this._doRotate(-Math.PI * 0.25);
31788
+ top.appendChild(lookUp);
31789
+ this._attachHold(lookUp, {
31790
+ action: () => this._clickLookUp(),
31791
+ continuousAction: () => StartContinuousLook({
31792
+ viewer: this._viewer,
31793
+ manager: this._manager,
31794
+ lookUp: true,
31795
+ selectedIds: this._getSelectedIds(),
31796
+ stablePivot: this._getStablePivot(),
31797
+ onPivotUpdate: (p) => this._updateStablePivot(p)
31798
+ })
31110
31799
  });
31111
- rotateRight.addEventListener("click", () => {
31112
- this._doRotate(Math.PI * 0.25);
31800
+ this._lookUp = lookUp;
31801
+ const lookDown = document.createElement("div");
31802
+ lookDown.className = "NextspaceNavCompassButt NextspaceNavCompassLookButt look-down";
31803
+ lookDown.innerHTML = `
31804
+ <svg width="16" height="9" viewBox="0 0 16 9" fill="none" xmlns="http://www.w3.org/2000/svg">
31805
+ <path d="M15 1L8 8L1 1" stroke="#A2A9B0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
31806
+ </svg>
31807
+ `;
31808
+ top.appendChild(lookDown);
31809
+ this._attachHold(lookDown, {
31810
+ action: () => this._clickLookDown(),
31811
+ continuousAction: () => StartContinuousLook({
31812
+ viewer: this._viewer,
31813
+ manager: this._manager,
31814
+ lookUp: false,
31815
+ selectedIds: this._getSelectedIds(),
31816
+ stablePivot: this._getStablePivot(),
31817
+ onPivotUpdate: (p) => this._updateStablePivot(p)
31818
+ })
31113
31819
  });
31114
- const horDash = document.createElement("div");
31115
- horDash.className = "NextspaceNavCompassHorDash";
31116
- element.appendChild(horDash);
31117
- const etcRow = document.createElement("div");
31118
- etcRow.className = "NextspaceNavCompassRow";
31119
- etcRow.innerHTML = `
31120
- <div class="NextspaceNavCompassCol">
31121
- <div class="NextspaceNavCompassButt">
31122
- <svg width="16" height="9" viewBox="0 0 16 9" fill="none" xmlns="http://www.w3.org/2000/svg">
31123
- <path d="M1 8L8 1L15 8" stroke="#A2A9B0" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
31124
- </svg>
31125
- </div>
31126
-
31127
- <div class="NextspaceNavCompassButt">
31128
- <svg width="16" height="9" viewBox="0 0 16 9" fill="none" xmlns="http://www.w3.org/2000/svg">
31129
- <path d="M15 1L8 8L1 1" stroke="#A2A9B0" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
31130
- </svg>
31131
- </div>
31132
- </div>
31133
- <div class="NextspaceNavCompassVerDash"></div>
31134
- <div class="NextspaceNavCompassCol">
31135
- <div class="NextspaceNavCompassButt">
31136
- <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
31137
- <path d="M8 1V15" stroke="#A2A9B0" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
31138
- <path d="M15 8L1 8" stroke="#A2A9B0" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
31139
- </svg>
31140
- </div>
31141
-
31142
- <div class="NextspaceNavCompassButt">
31143
- <svg width="16" height="2" viewBox="0 0 16 2" fill="none" xmlns="http://www.w3.org/2000/svg">
31144
- <path d="M15 1L1 0.999999" stroke="#A2A9B0" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
31145
- </svg>
31146
- </div>
31147
- </div>
31820
+ this._lookDown = lookDown;
31821
+ }
31822
+ _rotateIconSvg(flip) {
31823
+ const transform = flip ? "scaleX(-1) rotate(145deg)" : "rotate(145deg)";
31824
+ return `
31825
+ <svg style="transform: ${transform}" width="22" height="22" viewBox="0 0 565.3 533.667" fill="none" xmlns="http://www.w3.org/2000/svg">
31826
+ <g transform="translate(33.5 33.5)">
31827
+ <path d="M0 0L97.1 97.0987C97.1 97.0987 97.1 97.0987 97.1 97.0987C98.7 98.701 98.7 101.3 97.1 102.9C97.1 102.9 97.1 102.9 97.1 102.9L0 200" fill="none" stroke-width="67" stroke="#A2A9B0" stroke-linecap="round" stroke-linejoin="round" transform="translate(400 0)"/>
31828
+ <path d="M466.667 0C466.667 0 350 0 350 0C156.7 0 0 156.7 0 350C0 350 0 366.667 0 366.667" fill="none" stroke-width="67" stroke="#A2A9B0" stroke-linecap="round" stroke-linejoin="round" transform="translate(0 100)"/>
31829
+ </g>
31830
+ </svg>
31148
31831
  `;
31149
- element.appendChild(etcRow);
31150
- const lookUp = etcRow.children[0].children[0];
31151
- this._up = lookUp;
31152
- const lookDown = etcRow.children[0].children[1];
31153
- lookUp.addEventListener("click", () => {
31154
- this._doLook(true);
31832
+ }
31833
+ _generateRotateButtons(top) {
31834
+ const rotateLeft = document.createElement("div");
31835
+ rotateLeft.className = "NextspaceNavCompassButt NextspaceNavCompassRotateButt rotate-left";
31836
+ rotateLeft.innerHTML = this._rotateIconSvg(true);
31837
+ top.appendChild(rotateLeft);
31838
+ this._attachHold(rotateLeft, {
31839
+ action: () => this._clickRotate(-Math.PI * 0.25),
31840
+ continuousAction: () => StartContinuousRotate({
31841
+ viewer: this._viewer,
31842
+ manager: this._manager,
31843
+ rotateLeft: true,
31844
+ selectedIds: this._getSelectedIds(),
31845
+ stablePivot: this._getStablePivot(),
31846
+ onPivotUpdate: (p) => this._updateStablePivot(p)
31847
+ })
31155
31848
  });
31156
- this._down = lookDown;
31157
- lookDown.addEventListener("click", () => {
31158
- this._doLook(false);
31849
+ const rotateRight = document.createElement("div");
31850
+ rotateRight.className = "NextspaceNavCompassButt NextspaceNavCompassRotateButt rotate-right";
31851
+ rotateRight.innerHTML = this._rotateIconSvg(false);
31852
+ top.appendChild(rotateRight);
31853
+ this._attachHold(rotateRight, {
31854
+ action: () => this._clickRotate(Math.PI * 0.25),
31855
+ continuousAction: () => StartContinuousRotate({
31856
+ viewer: this._viewer,
31857
+ manager: this._manager,
31858
+ rotateLeft: false,
31859
+ selectedIds: this._getSelectedIds(),
31860
+ stablePivot: this._getStablePivot(),
31861
+ onPivotUpdate: (p) => this._updateStablePivot(p)
31862
+ })
31159
31863
  });
31160
- const zoomIn = etcRow.children[2].children[0];
31161
- const zoomOut = etcRow.children[2].children[1];
31162
- zoomIn.addEventListener("click", () => {
31163
- this._doZoom(true);
31864
+ }
31865
+ _generateZoomRow(element) {
31866
+ const row = document.createElement("div");
31867
+ row.className = "NextspaceNavCompassRow";
31868
+ element.appendChild(row);
31869
+ const zoomIn = document.createElement("div");
31870
+ zoomIn.className = "NextspaceNavCompassButt";
31871
+ zoomIn.innerHTML = `
31872
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
31873
+ <path d="M8 1V15" stroke="#A2A9B0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
31874
+ <path d="M15 8L1 8" stroke="#A2A9B0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
31875
+ </svg>
31876
+ `;
31877
+ row.appendChild(zoomIn);
31878
+ this._attachHold(zoomIn, {
31879
+ action: () => this._clickZoom(true),
31880
+ continuousAction: () => StartContinuousZoom({
31881
+ viewer: this._viewer,
31882
+ zoomIn: true,
31883
+ stablePivot: this._getStablePivot(),
31884
+ onPivotUpdate: (p) => this._updateStablePivot(p)
31885
+ })
31164
31886
  });
31165
- zoomOut.addEventListener("click", () => {
31166
- this._doZoom(false);
31887
+ const zoomOut = document.createElement("div");
31888
+ zoomOut.className = "NextspaceNavCompassButt";
31889
+ zoomOut.innerHTML = `
31890
+ <svg width="16" height="2" viewBox="0 0 16 2" fill="none" xmlns="http://www.w3.org/2000/svg">
31891
+ <path d="M15 1L1 0.999999" stroke="#A2A9B0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
31892
+ </svg>
31893
+ `;
31894
+ row.appendChild(zoomOut);
31895
+ this._attachHold(zoomOut, {
31896
+ action: () => this._clickZoom(false),
31897
+ continuousAction: () => StartContinuousZoom({
31898
+ viewer: this._viewer,
31899
+ zoomIn: false,
31900
+ stablePivot: this._getStablePivot(),
31901
+ onPivotUpdate: (p) => this._updateStablePivot(p)
31902
+ })
31167
31903
  });
31904
+ }
31905
+ _generateExtraTools(element) {
31906
+ const row = document.createElement("div");
31907
+ row.className = "NextspaceNavCompassRow";
31908
+ row.style.paddingTop = "0";
31909
+ row.style.paddingBottom = "8px";
31910
+ element.appendChild(row);
31911
+ const walkthroughButt = document.createElement("div");
31912
+ walkthroughButt.className = "NextspaceNavCompassButt";
31913
+ walkthroughButt.setAttribute("title", "Toggle Walkthrough mode");
31914
+ walkthroughButt.innerHTML = this._walkthroughIconSvg(false);
31915
+ walkthroughButt.addEventListener("click", () => this._toggleWalkthrough());
31916
+ row.appendChild(walkthroughButt);
31917
+ this._walkthroughButt = walkthroughButt;
31918
+ const vrButt = document.createElement("div");
31919
+ vrButt.className = "NextspaceNavCompassButt";
31920
+ vrButt.setAttribute("title", "Toggle VR mode");
31921
+ vrButt.innerHTML = this._vrIconSvg(false);
31922
+ vrButt.addEventListener("click", () => this._toggleVR());
31923
+ row.appendChild(vrButt);
31924
+ this._vrButt = vrButt;
31925
+ this._fullscreenChange = () => {
31926
+ if (Fullscreen.fullscreen || !this._isVR) {
31927
+ return;
31928
+ }
31929
+ this._setVR(false);
31930
+ };
31931
+ document.addEventListener("fullscreenchange", this._fullscreenChange);
31932
+ document.addEventListener("webkitfullscreenchange", this._fullscreenChange);
31933
+ }
31934
+ _walkthroughIconSvg(active) {
31935
+ const color = active ? "#4D9CF8" : "#A2A9B0";
31936
+ return `
31937
+ <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
31938
+ <path d="M17.5033 4C16.8406 4 16.205 4.26339 15.7364 4.73223C15.2678 5.20107 15.0045 5.83696 15.0045 6.5C15.0045 7.16304 15.2678 7.79893 15.7364 8.26777C16.205 8.73661 16.8406 9 17.5033 9C18.166 9 18.8015 8.73661 19.2701 8.26777C19.7388 7.79893 20.002 7.16304 20.002 6.5C20.002 5.83696 19.7388 5.20107 19.2701 4.73223C18.8015 4.26339 18.166 4 17.5033 4ZM15.5023 10C15.1066 10 14.7378 10.1015 14.4052 10.2656C14.3549 10.2813 14.306 10.3009 14.2588 10.3242L10.3448 12.1992C10.1322 12.3003 9.96216 12.4733 9.86453 12.6875L8.09784 16.5859C8.0405 16.7059 8.00764 16.836 8.00118 16.9688C7.99472 17.1016 8.01479 17.2344 8.06021 17.3593C8.10563 17.4843 8.1755 17.5989 8.26572 17.6965C8.35594 17.7941 8.46471 17.8727 8.58567 17.9278C8.70662 17.9828 8.83733 18.0132 8.97016 18.0171C9.10299 18.0211 9.23526 17.9984 9.35924 17.9506C9.48323 17.9028 9.59644 17.8307 9.69225 17.7386C9.78806 17.6464 9.86454 17.5361 9.91724 17.4141L11.3638 14.2246L12.658 13.8359C12.3918 15.2411 12.0603 16.9816 12.0587 16.9902C12.0583 16.9923 12.0572 16.994 12.0568 16.9961C12.0568 16.9961 12.0568 17 12.0568 17C12.024 17.1615 12.006 17.3288 12.006 17.5C12.006 18.271 12.3631 18.9514 12.9118 19.4102L12.9196 19.4336L16.8103 22.5L17.923 26.6953L18.0225 27.1953C18.0677 27.4221 18.19 27.6263 18.3687 27.773C18.5474 27.9197 18.7714 27.9999 19.0025 28C19.2676 28 19.5218 27.8946 19.7093 27.7071C19.8967 27.5196 20.002 27.2652 20.002 27C20.0019 26.9344 19.9954 26.869 19.9825 26.8047V26.8008C19.9812 26.7969 19.9799 26.793 19.9786 26.7891L18.983 21.8047C18.9562 21.6693 18.9017 21.541 18.8229 21.4277L16.9528 18.0039C16.9546 17.9951 16.953 17.9854 16.9547 17.9766L17.9366 13.0625L17.9347 13.0605C17.9762 12.8798 18.003 12.6933 18.003 12.5C18.003 11.1207 16.8837 10.0011 15.5023 10ZM19.3871 13.7422L18.9186 16.0078L19.3344 16.3809C19.4093 16.4489 19.4962 16.5059 19.5882 16.5469L22.5866 17.9102V17.9082C22.7165 17.9681 22.8576 17.9994 23.0005 18C23.2656 18 23.5198 17.8946 23.7073 17.7071C23.8947 17.5196 24 17.2652 24 17C23.9996 16.8084 23.9442 16.6209 23.8404 16.4599C23.7366 16.2989 23.5887 16.1711 23.4144 16.0918V16.0898L20.5545 14.7891L19.3871 13.7422ZM11.9631 20.7246L11.4497 22.4219L9.22228 26.3613L9.1481 26.4863L9.15005 26.4883C9.13825 26.5087 9.12718 26.5296 9.11686 26.5508L9.10905 26.5625C9.0425 26.6987 9.00778 26.8484 9.00754 27C9.00754 27.2652 9.11285 27.5196 9.30029 27.7071C9.48773 27.8946 9.74195 28 10.007 28C10.1647 27.9999 10.3201 27.9626 10.4606 27.891C10.601 27.8193 10.7225 27.7155 10.8152 27.5879H10.8172L10.8328 27.5645C10.8334 27.5632 10.8341 27.5618 10.8347 27.5605L14.1592 22.5117L11.9631 20.7246Z" fill="${color}"/>
31939
+ </svg>
31940
+ `;
31941
+ }
31942
+ _vrIconSvg(active) {
31943
+ const color = active ? "#4D9CF8" : "#A2A9B0";
31944
+ return `
31945
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="${color}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
31946
+ <path d="M20 6a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-4a2 2 0 0 1-1.6-.8l-1.6-2.13a1 1 0 0 0-1.6 0L9.6 17.2A2 2 0 0 1 8 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z"/>
31947
+ </svg>
31948
+ `;
31949
+ }
31950
+ _generateDimensionToggle(element) {
31168
31951
  const dimToggle = document.createElement("div");
31169
31952
  dimToggle.className = "NextspaceNavCompassDimToggle";
31170
31953
  dimToggle.innerHTML = `
31171
- <div class="NextspaceNavCompassDimToggleButt" is-selected="false">
31172
- 3D
31173
- </div>
31174
-
31175
- <div class="NextspaceNavCompassDimToggleButt" is-selected="false">
31176
- 2D
31177
- </div>
31954
+ <div class="NextspaceNavCompassDimToggleButt" is-selected="false">3D</div>
31955
+ <div class="NextspaceNavCompassDimToggleButt" is-selected="false">2D</div>
31178
31956
  `;
31179
31957
  element.appendChild(dimToggle);
31180
- const butt2d = dimToggle.children[1];
31181
- this._2d = butt2d;
31182
- butt2d.addEventListener("click", () => {
31183
- this._toggle2d3d();
31184
- });
31958
+ this._dimensionToggle = dimToggle;
31185
31959
  const butt3d = dimToggle.children[0];
31960
+ const butt2d = dimToggle.children[1];
31186
31961
  this._3d = butt3d;
31187
- butt3d.addEventListener("click", () => {
31188
- this._toggle2d3d();
31189
- });
31190
- this.Container.appendChild(element);
31191
- this._element = element;
31192
- this._update2d3d();
31962
+ this._2d = butt2d;
31963
+ butt3d.addEventListener("click", () => this._toggle2d3d());
31964
+ butt2d.addEventListener("click", () => this._toggle2d3d());
31965
+ }
31966
+ _attachHold(el, params) {
31967
+ const start = (e) => {
31968
+ e.stopPropagation();
31969
+ this._handlePointerDown(params.action, params.continuousAction, e);
31970
+ };
31971
+ el.addEventListener("mousedown", start);
31972
+ el.addEventListener("touchstart", start, { passive: true });
31973
+ }
31974
+ _handlePointerDown(action, continuousAction, e) {
31975
+ const x = "clientX" in e ? e.clientX : e.touches[0].clientX;
31976
+ const y = "clientY" in e ? e.clientY : e.touches[0].clientY;
31977
+ const isTouch = "touches" in e;
31978
+ this._didActivateContinuous = false;
31979
+ this._pendingSingleAction = action;
31980
+ this._loaderTimer = window.setTimeout(() => {
31981
+ this._holdLoader = new WidgetNavCompassHoldLoader({ x, y, durationMs: 200, isTouch });
31982
+ this._loaderTimer = null;
31983
+ }, HOLD_LOADER_DELAY_MS);
31984
+ this._holdTimer = window.setTimeout(() => {
31985
+ this._didActivateContinuous = true;
31986
+ this._pendingSingleAction = null;
31987
+ this._stopContinuous = continuousAction();
31988
+ this._holdTimer = null;
31989
+ }, HOLD_ACTIVATION_TIME_MS);
31990
+ }
31991
+ _handlePointerUp() {
31992
+ var _a;
31993
+ if (!this._holdLoader && !this._holdTimer && !this._stopContinuous && !this._loaderTimer) {
31994
+ return;
31995
+ }
31996
+ if (this._loaderTimer) {
31997
+ window.clearTimeout(this._loaderTimer);
31998
+ this._loaderTimer = null;
31999
+ }
32000
+ if (this._holdTimer) {
32001
+ window.clearTimeout(this._holdTimer);
32002
+ this._holdTimer = null;
32003
+ }
32004
+ if (this._stopContinuous) {
32005
+ this._stopContinuous();
32006
+ this._stopContinuous = null;
32007
+ }
32008
+ if (this._pendingSingleAction && !this._didActivateContinuous) {
32009
+ const action = this._pendingSingleAction;
32010
+ this._pendingSingleAction = null;
32011
+ setTimeout(() => action(), 0);
32012
+ }
32013
+ (_a = this._holdLoader) === null || _a === void 0 ? void 0 : _a.Dispose();
32014
+ this._holdLoader = null;
32015
+ this._didActivateContinuous = false;
31193
32016
  }
31194
32017
  _updateAxis() {
31195
- const heading = this._viewer.camera.heading;
31196
- const axis = this._axis;
31197
- axis.style.transform = `rotate(${heading}rad)`;
32018
+ const heading = Number(this._viewer.camera.heading);
32019
+ const headingDegrees = 360 - Math$1.toDegrees(heading);
32020
+ this._axis.style.transform = `rotate(${headingDegrees}deg)`;
31198
32021
  }
31199
32022
  _clickResetNorth() {
31200
32023
  const viewer = this._viewer;
31201
32024
  const h = viewer.camera.heading;
31202
32025
  const north = h < Math.PI ? h : h - Math.PI * 2;
31203
- this._doRotate(north);
32026
+ this._clickRotate(north);
32027
+ }
32028
+ // Chains a single-tap action onto any in-flight one so animations never overlap.
32029
+ _runOrbitAction(fn) {
32030
+ const run = this._orbitActionChain.then(fn, fn);
32031
+ this._orbitActionChain = run.catch(() => { });
32032
+ return run;
32033
+ }
32034
+ _clickRotate(radians) {
32035
+ this._runOrbitAction(async () => {
32036
+ const pivot = await DoRotate({
32037
+ viewer: this._viewer,
32038
+ manager: this._manager,
32039
+ radians,
32040
+ selectedIds: this._getSelectedIds(),
32041
+ stablePivot: this._getStablePivot(),
32042
+ onPivotUpdate: (p) => this._updateStablePivot(p)
32043
+ });
32044
+ this._updateStablePivot(pivot);
32045
+ });
31204
32046
  }
31205
- _doRotate(radians) {
31206
- const viewer = this._viewer;
31207
- const TURN_SPEED = this.TURN_SPEED;
31208
- const left = radians < 0;
31209
- radians = Math.abs(radians);
31210
- const camera = viewer.camera;
31211
- const is2d = this._getIs2d();
31212
- const isLookingStraightDown = camera.pitch === -Math.PI / 2;
31213
- if (is2d || isLookingStraightDown) {
31214
- camera.flyTo({
31215
- destination: camera.position,
31216
- orientation: {
31217
- heading: camera.heading + (left ? radians : -radians),
31218
- pitch: camera.pitch,
31219
- roll: camera.roll
31220
- },
31221
- duration: 0.2
32047
+ _clickZoom(zoomIn) {
32048
+ this._runOrbitAction(async () => {
32049
+ const pivot = await DoZoom({
32050
+ viewer: this._viewer,
32051
+ zoomIn,
32052
+ stablePivot: this._getStablePivot(),
32053
+ onPivotUpdate: (p) => this._updateStablePivot(p)
32054
+ });
32055
+ this._updateStablePivot(pivot);
32056
+ });
32057
+ }
32058
+ _clickLookUp() {
32059
+ if (GetIs2d(this._viewer)) {
32060
+ return;
32061
+ }
32062
+ this._runOrbitAction(async () => {
32063
+ const pivot = await DoLook({
32064
+ viewer: this._viewer,
32065
+ manager: this._manager,
32066
+ tiltUp: true,
32067
+ selectedIds: this._getSelectedIds(),
32068
+ stablePivot: this._getStablePivot(),
32069
+ onPivotUpdate: (p) => this._updateStablePivot(p)
32070
+ });
32071
+ this._updateStablePivot(pivot);
32072
+ });
32073
+ }
32074
+ _clickLookDown() {
32075
+ if (GetIs2d(this._viewer)) {
32076
+ return;
32077
+ }
32078
+ this._runOrbitAction(async () => {
32079
+ const pivot = await DoLook({
32080
+ viewer: this._viewer,
32081
+ manager: this._manager,
32082
+ tiltUp: false,
32083
+ selectedIds: this._getSelectedIds(),
32084
+ stablePivot: this._getStablePivot(),
32085
+ onPivotUpdate: (p) => this._updateStablePivot(p)
32086
+ });
32087
+ this._updateStablePivot(pivot);
32088
+ });
32089
+ }
32090
+ _toggleWalkthrough() {
32091
+ this._setWalkthrough(!this._isWalkthroughActive);
32092
+ }
32093
+ _setWalkthrough(active) {
32094
+ var _a, _b, _c;
32095
+ this._isWalkthroughActive = active;
32096
+ this._walkthroughButt.innerHTML = this._walkthroughIconSvg(active);
32097
+ this._dimensionToggle.setAttribute("is-disabled", active ? "true" : "false");
32098
+ if (active) {
32099
+ Walkthrough.Start({ viewer: this._viewer });
32100
+ (_a = this._walkthroughBar) === null || _a === void 0 ? void 0 : _a.Dispose();
32101
+ this._walkthroughBar = new WidgetNavCompassWalkthroughBar({
32102
+ viewer: this._viewer,
32103
+ container: this.Container,
32104
+ onClose: () => this._setWalkthrough(false)
31222
32105
  });
31223
32106
  }
31224
32107
  else {
31225
- const c = viewer.canvas;
31226
- const center = new Cartesian2(c.width / 2, c.height / 2);
31227
- const ground = DrawingUtils.GetAccuratePosition(viewer, center);
31228
- if (!(ground === null || ground === void 0 ? void 0 : ground.x)) {
31229
- return;
32108
+ if (((_b = this._viewer) === null || _b === void 0 ? void 0 : _b.scene) && !this._viewer.isDestroyed()) {
32109
+ Walkthrough.Stop({ viewer: this._viewer });
31230
32110
  }
31231
- const offset = Cartesian3.distance(camera.position, ground);
31232
- let r = 0;
31233
- const unsub = viewer.clock.onTick.addEventListener(function () {
31234
- let inc = Math.PI * TURN_SPEED;
31235
- if (r + inc >= radians) {
31236
- unsub();
31237
- inc = radians - r;
31238
- }
31239
- camera.lookAt(ground, new HeadingPitchRange(camera.heading, camera.pitch, offset));
31240
- left ? camera.rotateLeft(inc) : camera.rotateRight(inc);
31241
- camera.lookAtTransform(Matrix4.IDENTITY);
31242
- r += inc;
31243
- });
32111
+ (_c = this._walkthroughBar) === null || _c === void 0 ? void 0 : _c.Dispose();
32112
+ this._walkthroughBar = null;
31244
32113
  }
31245
32114
  }
31246
- _doZoom(zoomIn) {
31247
- const viewer = this._viewer;
31248
- const c = viewer.canvas;
31249
- const center = new Cartesian2(c.width / 2, c.height / 2);
31250
- const camera = viewer.camera;
31251
- const ground = DrawingUtils.GetAccuratePosition(viewer, center);
31252
- if (!(ground === null || ground === void 0 ? void 0 : ground.x)) {
32115
+ _toggleVR() {
32116
+ this._setVR(!this._isVR);
32117
+ }
32118
+ _setVR(active) {
32119
+ var _a, _b;
32120
+ const scene = (_a = this._viewer) === null || _a === void 0 ? void 0 : _a.scene;
32121
+ if (!scene) {
31253
32122
  return;
31254
32123
  }
31255
- const p = camera.position;
31256
- const height = Cartesian3.distance(p, ground);
31257
- const mag = this.ZOOM_DISTANCE / Math.max(1, 4 - Math.log10(height));
31258
- const zoom = zoomIn ? 1 - mag : 1 + mag;
31259
- const offset = Cartesian3.multiplyByScalar(Cartesian3.subtract(p, ground, new Cartesian3), zoom, new Cartesian3);
31260
- if (zoomIn && Cartesian3.magnitude(offset) <= this.MIN_ZOOM_DISTANCE) {
31261
- return;
32124
+ try {
32125
+ scene.useWebVR = active;
32126
+ (_b = scene.requestRender) === null || _b === void 0 ? void 0 : _b.call(scene);
32127
+ this._isVR = active;
32128
+ this._vrButt.innerHTML = this._vrIconSvg(active);
32129
+ }
32130
+ catch (e) {
32131
+ console.warn("[VR] Failed to toggle VR mode.", e);
31262
32132
  }
31263
- const to = Cartesian3.add(ground, offset, new Cartesian3);
31264
- camera.flyTo({
31265
- destination: to,
31266
- orientation: { heading: camera.heading, pitch: camera.pitch, roll: camera.roll },
31267
- duration: this.ZOOM_TIME,
31268
- easingFunction: EasingFunction.QUADRATIC_IN_OUT
31269
- });
31270
- }
31271
- _doLook(tiltUp) {
31272
- const viewer = this._viewer;
31273
- let diff = 6.26 / 32;
31274
- if (!tiltUp) {
31275
- diff *= -1;
31276
- }
31277
- let current = viewer.camera.pitch;
31278
- current += diff;
31279
- viewer.camera.flyTo({
31280
- destination: viewer.camera.position,
31281
- orientation: {
31282
- heading: viewer.camera.heading,
31283
- pitch: current,
31284
- roll: viewer.camera.roll
31285
- },
31286
- duration: 0.2
31287
- });
31288
32133
  }
31289
32134
  _update2d3d() {
31290
- const is2d = this._getIs2d();
32135
+ const is2d = GetIs2d(this._viewer);
31291
32136
  this._2d.setAttribute("is-selected", is2d ? "true" : "false");
31292
32137
  this._3d.setAttribute("is-selected", is2d ? "false" : "true");
31293
- this._up.setAttribute("is-disabled", is2d ? "true" : "false");
31294
- this._down.setAttribute("is-disabled", is2d ? "true" : "false");
32138
+ this._lookUp.style.display = is2d ? "none" : "flex";
32139
+ this._lookDown.style.display = is2d ? "none" : "flex";
31295
32140
  }
31296
32141
  _toggle2d3d() {
31297
- const shouldBe2d = !this._getIs2d();
32142
+ const shouldBe2d = !GetIs2d(this._viewer);
31298
32143
  ViewUtils.Set2dStatus({
31299
32144
  status: shouldBe2d,
31300
32145
  viewer: this._viewer,
@@ -37568,7 +38413,7 @@ var StyleUtils;
37568
38413
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
37569
38414
  })(StyleUtils || (StyleUtils = {}));
37570
38415
 
37571
- const VERSION = "6.8.8";
38416
+ const VERSION = "6.9.0";
37572
38417
  /**
37573
38418
  * Updates the environment instance used by bruce-cesium to one specified.
37574
38419
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.