bruce-cesium 5.5.3 → 5.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { BruceEvent, Cartes, Entity as Entity$1, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, ProjectViewTile, DelayQueue, EntityLod, Bounds, ZoomControl, EntityRelationType, ENVIRONMENT, EntityHistoricData, Tileset, EntityCoords, DataLab, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, EntityAttachment, EntityAttachmentType, EntityAttribute, AbstractApi, Session } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, ConstantProperty, ClassificationType, ConstantPositionProperty, ArcType, CornerType, ShadowMode, ColorBlendMode, HeadingPitchRoll, Transforms, Model, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileStyle, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, KmlDataSource, OrthographicFrustum, EasingFunction, NearFarScalar, SceneTransforms, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, IonResource, Cesium3DTileset, Matrix4, Matrix3, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, DistanceDisplayCondition, ClassificationType, ArcType, CornerType, ShadowMode, ConstantProperty, ConstantPositionProperty, HorizontalOrigin, VerticalOrigin, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, SceneMode, Primitive, Cesium3DTileFeature, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidTerrainProvider, CesiumInspector, defined, ClockRange, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
4
4
 
5
5
  const TIME_LAG = 300;
6
6
  const POSITION_CHECK_TIMER = 950;
@@ -9741,7 +9741,9 @@ var EntityLabel;
9741
9741
  lineEle.style.display = "none";
9742
9742
  return;
9743
9743
  }
9744
- const lineStartPos2d = SceneTransforms.wgs84ToWindowCoordinates(this.viewer.scene, this._pos3d);
9744
+ const CESIUM = Cesium;
9745
+ const _3dTo2D = SceneTransforms.hasOwnProperty("wgs84ToWindowCoordinates") ? CESIUM.SceneTransforms.wgs84ToWindowCoordinates : CESIUM.SceneTransforms.worldToWindowCoordinates;
9746
+ const lineStartPos2d = _3dTo2D(this.viewer.scene, this._pos3d);
9745
9747
  // Invalid point.
9746
9748
  if (isNaN(lineStartPos2d === null || lineStartPos2d === void 0 ? void 0 : lineStartPos2d.x)) {
9747
9749
  ele.style.transform = "";
@@ -9795,7 +9797,9 @@ var EntityLabel;
9795
9797
  }
9796
9798
  lineEndPoint.height += addHeight;
9797
9799
  lineEndPos3d = Cartographic.toCartesian(lineEndPoint);
9798
- let lineEndPos2d = SceneTransforms.wgs84ToWindowCoordinates(this.viewer.scene, lineEndPos3d);
9800
+ const CESIUM = Cesium;
9801
+ const _3dTo2D = SceneTransforms.hasOwnProperty("wgs84ToWindowCoordinates") ? CESIUM.SceneTransforms.wgs84ToWindowCoordinates : CESIUM.SceneTransforms.worldToWindowCoordinates;
9802
+ let lineEndPos2d = _3dTo2D(this.viewer.scene, lineEndPos3d);
9799
9803
  // Invalid point.
9800
9804
  if (isNaN(lineEndPos2d === null || lineEndPos2d === void 0 ? void 0 : lineEndPos2d.x)) {
9801
9805
  ele.style.transform = "";
@@ -24116,9 +24120,12 @@ var TileRenderEngine;
24116
24120
  else if (settings.terrainType == "CesiumIon") {
24117
24121
  const ionId = settings.externalId;
24118
24122
  const key = settings.key ? settings.key : await findKey(params.apiGetter, params.apiGetter.accountId, ProgramKey.EProgramId.CesiumIon);
24119
- const resource = IonResource.fromAssetId(Number(ionId), {
24123
+ const resource = await IonResource.fromAssetId(Number(ionId), {
24120
24124
  accessToken: key
24121
24125
  });
24126
+ if (!assertIteration(params.viewer, iteration)) {
24127
+ return;
24128
+ }
24122
24129
  if (CesiumTerrainProvider.hasOwnProperty("fromUrl")) {
24123
24130
  provider = await CESIUM.CesiumTerrainProvider.fromUrl(resource, {
24124
24131
  requestVertexNormals: vertexes
@@ -25478,6 +25485,304 @@ var ViewRenderEngine;
25478
25485
  ViewRenderEngine.FlyTo = FlyTo;
25479
25486
  })(ViewRenderEngine || (ViewRenderEngine = {}));
25480
25487
 
25488
+ class WidgetLeftPanelTabUser extends WidgetLeftPanelTab.ATab {
25489
+ constructor(params) {
25490
+ super(params);
25491
+ this.STYLESHEET_ID = "nextspace-left-panel-tab-user-stylesheet";
25492
+ this.loadedSessionId = null;
25493
+ this.user = null;
25494
+ this.loaded = false;
25495
+ this.loggingOut = false;
25496
+ this.loggingIn = false;
25497
+ this.inputUsername = null;
25498
+ this.inputPassword = null;
25499
+ this._generateStyles();
25500
+ this._generateElement();
25501
+ // In case another widget messed with the panel width.
25502
+ // Probably should just add a SetWidth method to avoid having plugins mess with the container CSS.
25503
+ if (this.Container) {
25504
+ this.Container.style.width = "300px";
25505
+ }
25506
+ this.loadUser();
25507
+ this.paramsChangeRemoval = ENVIRONMENT.OnParamsChange.Subscribe(() => {
25508
+ this.loadUser();
25509
+ });
25510
+ }
25511
+ async loadUser() {
25512
+ if (this.loadedSessionId === ENVIRONMENT.PARAMS.sessionId) {
25513
+ return;
25514
+ }
25515
+ let loadingSessionId = ENVIRONMENT.PARAMS.sessionId;
25516
+ try {
25517
+ this.user = null;
25518
+ if (ENVIRONMENT.PARAMS.sessionId && ENVIRONMENT.PARAMS.sessionId !== "anonymous") {
25519
+ const { session } = await Session.Get({
25520
+ accountId: ENVIRONMENT.PARAMS.accountId,
25521
+ sessionId: loadingSessionId
25522
+ });
25523
+ if (loadingSessionId !== ENVIRONMENT.PARAMS.sessionId) {
25524
+ return;
25525
+ }
25526
+ this.user = session === null || session === void 0 ? void 0 : session.User;
25527
+ }
25528
+ }
25529
+ catch (e) {
25530
+ console.error(e);
25531
+ }
25532
+ finally {
25533
+ if (loadingSessionId === ENVIRONMENT.PARAMS.sessionId) {
25534
+ this.loaded = true;
25535
+ this._generateElement();
25536
+ }
25537
+ }
25538
+ }
25539
+ /**
25540
+ * Returns if the user can logout.
25541
+ * If the session is part of URL, we don't want to show the logout button.
25542
+ * @returns {boolean}
25543
+ */
25544
+ canLogout() {
25545
+ if (!this.user || this.user.ID === "anonymous") {
25546
+ return false;
25547
+ }
25548
+ const url = new URL(window.location.href);
25549
+ let sessionId = url.searchParams.get("sessionId");
25550
+ if (!sessionId) {
25551
+ sessionId = url.searchParams.get("ssid");
25552
+ }
25553
+ if (sessionId) {
25554
+ return false;
25555
+ }
25556
+ return true;
25557
+ }
25558
+ async logout() {
25559
+ if (this.loggingOut) {
25560
+ return;
25561
+ }
25562
+ else if (!this.canLogout()) {
25563
+ return;
25564
+ }
25565
+ try {
25566
+ await Session.Logout({});
25567
+ ENVIRONMENT.SetPageLoadSessionId(null);
25568
+ }
25569
+ catch (e) {
25570
+ console.error(e);
25571
+ }
25572
+ window.location.reload();
25573
+ }
25574
+ Dispose() {
25575
+ super.Dispose();
25576
+ if (this.paramsChangeRemoval) {
25577
+ this.paramsChangeRemoval();
25578
+ this.paramsChangeRemoval = null;
25579
+ }
25580
+ }
25581
+ _generateStyles() {
25582
+ if (document.getElementById(this.STYLESHEET_ID)) {
25583
+ return;
25584
+ }
25585
+ const style = document.createElement("style");
25586
+ style.id = this.STYLESHEET_ID;
25587
+ style.innerHTML = `
25588
+ .NextspaceLeftPanelTabUser * {
25589
+ box-sizing: border-box;
25590
+ font-family: Arial;
25591
+ font-size: 13px;
25592
+ }
25593
+
25594
+ .NextspaceLeftPanelTabUser {
25595
+ display: flex;
25596
+ flex-direction: column;
25597
+ flex-grow: 1;
25598
+ flex-shrink: 1;
25599
+ overflow: hidden;
25600
+ width: 100%;
25601
+ box-sizing: border-box;
25602
+ }
25603
+
25604
+ .NextspaceLeftPanelTabUser >.NextspaceLeftPanelTabUserTitleBar {
25605
+ align-items: center;
25606
+ color: #fff;
25607
+ display: flex;
25608
+ font-size: 17px;
25609
+ font-style: normal;
25610
+ font-weight: 500;
25611
+ justify-content: center;
25612
+ letter-spacing: -.005em;
25613
+ line-height: 20px;
25614
+ margin-bottom: 15px;
25615
+ font-family: Arial;
25616
+ }
25617
+
25618
+ .NextspaceLeftPanelTabUser >.NextspaceLeftPanelTabUserTitleBreaker {
25619
+ background-color: #000;
25620
+ flex-shrink: 0;
25621
+ height: 2px;
25622
+ margin-bottom: 15px;
25623
+ }
25624
+
25625
+ .NextspaceLeftPanelTabUser >.NextspaceLeftPanelTabUserInputRow {
25626
+ display: flex;
25627
+ flex-direction: row;
25628
+ align-items: center;
25629
+ margin-bottom: 8px;
25630
+ width: 100%;
25631
+ }
25632
+
25633
+ .NextspaceLeftPanelTabUser >.NextspaceLeftPanelTabUserInputRow >label {
25634
+ width: 90px;
25635
+ flex-shrink: 0;
25636
+ margin-right: 8px;
25637
+ color: white;
25638
+ }
25639
+
25640
+ .NextspaceLeftPanelTabUser >.NextspaceLeftPanelTabUserInputRow >input {
25641
+ flex-grow: 1;
25642
+ max-width: 220px;
25643
+
25644
+ background-color: #121619;
25645
+ border: 1px solid #ffffff36;
25646
+ color: #fff;
25647
+ flex-grow: 1;
25648
+ flex-shrink: 1;
25649
+ height: 30px;
25650
+ text-align: left;
25651
+ border-radius: .375rem;
25652
+ outline: none;
25653
+ padding: .5rem .75rem;
25654
+ box-sizing: border-box;
25655
+ width: 10px;
25656
+ }
25657
+
25658
+ .NextspaceLeftPanelTabUser button {
25659
+ cursor: pointer;
25660
+ border-radius: .375rem;
25661
+ padding: 4px 9px;
25662
+ transition: opacity 0.3s ease;
25663
+ width: 100px;
25664
+ width: min-content;
25665
+ height: min-content;
25666
+ white-space: nowrap;
25667
+ border: 1px solid grey;
25668
+ color: black;
25669
+ background-color: white;
25670
+ display: flex;
25671
+ align-items: center;
25672
+ justify-content: center;
25673
+ position: relative;
25674
+ background-color: #0072c3;
25675
+ border: 1px solid #0072c3;
25676
+ color: white;
25677
+
25678
+ margin-left: auto;
25679
+ }
25680
+ `;
25681
+ document.head.appendChild(style);
25682
+ }
25683
+ _generateElement() {
25684
+ var _a, _b;
25685
+ if ((_a = this._element) === null || _a === void 0 ? void 0 : _a.parentElement) {
25686
+ this._element.parentElement.removeChild(this._element);
25687
+ }
25688
+ this._element = null;
25689
+ const element = document.createElement("div");
25690
+ element.className = "NextspaceLeftPanelTabUser";
25691
+ const title = document.createElement("div");
25692
+ title.className = "NextspaceLeftPanelTabUserTitleBar";
25693
+ title.textContent = this.loaded ? (this.user ? ((_b = this.user.FullName) !== null && _b !== void 0 ? _b : "#" + this.user.ID) : "Guest") : "Loading..";
25694
+ element.appendChild(title);
25695
+ const breaker = document.createElement("div");
25696
+ breaker.className = "NextspaceLeftPanelTabUserTitleBreaker";
25697
+ element.appendChild(breaker);
25698
+ if (!this.user || this.user.ID === "anonymous") {
25699
+ {
25700
+ const inputRow = document.createElement("div");
25701
+ inputRow.className = "NextspaceLeftPanelTabUserInputRow";
25702
+ const label = document.createElement("label");
25703
+ label.textContent = "Username";
25704
+ inputRow.appendChild(label);
25705
+ const input = document.createElement("input");
25706
+ input.type = "text";
25707
+ input.placeholder = "...";
25708
+ this.inputUsername = input;
25709
+ inputRow.appendChild(this.inputUsername);
25710
+ element.appendChild(inputRow);
25711
+ }
25712
+ {
25713
+ const inputRow = document.createElement("div");
25714
+ inputRow.className = "NextspaceLeftPanelTabUserInputRow";
25715
+ const label = document.createElement("label");
25716
+ label.textContent = "Password";
25717
+ inputRow.appendChild(label);
25718
+ const input = document.createElement("input");
25719
+ input.type = "password";
25720
+ input.placeholder = "...";
25721
+ this.inputPassword = input;
25722
+ inputRow.appendChild(this.inputPassword);
25723
+ element.appendChild(inputRow);
25724
+ }
25725
+ {
25726
+ const button = document.createElement("button");
25727
+ button.textContent = "Login";
25728
+ button.onclick = async () => {
25729
+ var _a, _b, _c, _d, _e, _f;
25730
+ if (this.loggingIn) {
25731
+ return;
25732
+ }
25733
+ button.style.opacity = "0.7";
25734
+ this.loggingIn = true;
25735
+ try {
25736
+ const { session } = await Session.Login({
25737
+ accountId: ENVIRONMENT.PARAMS.accountId,
25738
+ username: (_b = (_a = this.inputUsername) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "",
25739
+ password: (_d = (_c = this.inputPassword) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : ""
25740
+ });
25741
+ ENVIRONMENT.SetPageLoadSessionId((_e = session === null || session === void 0 ? void 0 : session.ID) !== null && _e !== void 0 ? _e : null);
25742
+ ENVIRONMENT.Reset({
25743
+ accountId: ENVIRONMENT.PARAMS.accountId,
25744
+ sessionId: (_f = (session === null || session === void 0 ? void 0 : session.ID)) !== null && _f !== void 0 ? _f : null,
25745
+ });
25746
+ window.location.reload();
25747
+ }
25748
+ catch (e) {
25749
+ console.error(e);
25750
+ }
25751
+ finally {
25752
+ this.loggingIn = false;
25753
+ button.style.opacity = "1";
25754
+ }
25755
+ };
25756
+ element.appendChild(button);
25757
+ }
25758
+ }
25759
+ else {
25760
+ if (this.canLogout()) {
25761
+ const button = document.createElement("button");
25762
+ button.textContent = "Logout";
25763
+ button.onclick = async () => {
25764
+ if (this.loggingOut) {
25765
+ return;
25766
+ }
25767
+ button.style.opacity = "0.7";
25768
+ try {
25769
+ this.logout();
25770
+ }
25771
+ catch (e) {
25772
+ console.error(e);
25773
+ }
25774
+ finally {
25775
+ button.style.opacity = "1";
25776
+ }
25777
+ };
25778
+ element.appendChild(button);
25779
+ }
25780
+ }
25781
+ this.Container.appendChild(element);
25782
+ this._element = element;
25783
+ }
25784
+ }
25785
+
25481
25786
  const VIEWER_LEFT_PANEL_WIDGET_KEY = "_viewerLeftPanelWidget";
25482
25787
  const VIEWER_LEFT_PANEL_CSS_VAR_LEFT = "--nextspace-left-panel-width";
25483
25788
  class WidgetLeftPanel extends Widget.AWidget {
@@ -25846,6 +26151,7 @@ class WidgetLeftPanel extends Widget.AWidget {
25846
26151
  </svg>
25847
26152
  `;
25848
26153
  buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
26154
+ buttonBookmarksIcon.style.cursor = "pointer";
25849
26155
  tabButton.appendChild(buttonBookmarksIcon);
25850
26156
  this._element.appendChild(tabButton);
25851
26157
  function getInitials(name) {
@@ -25903,6 +26209,16 @@ class WidgetLeftPanel extends Widget.AWidget {
25903
26209
  buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
25904
26210
  }
25905
26211
  }
26212
+ buttonBookmarksIcon.onclick = () => {
26213
+ if (this._enabledPanelTab === "user") {
26214
+ this._enabledPanelTab = "";
26215
+ }
26216
+ else {
26217
+ this._enabledPanelTab = "user";
26218
+ }
26219
+ this._updatePanelContent();
26220
+ this._updatePanelStyles();
26221
+ };
25906
26222
  if (this.envSubRemoval) {
25907
26223
  this.envSubRemoval();
25908
26224
  this.envSubRemoval = null;
@@ -25952,6 +26268,12 @@ class WidgetLeftPanel extends Widget.AWidget {
25952
26268
  container: container
25953
26269
  });
25954
26270
  break;
26271
+ case "user":
26272
+ tabContent = new WidgetLeftPanelTabUser({
26273
+ widget: this,
26274
+ container: container
26275
+ });
26276
+ break;
25955
26277
  default:
25956
26278
  if (this.customTabs.has(this._enabledPanelTab) === false) {
25957
26279
  console.error(`Tab ${this._enabledPanelTab} not found.`);
@@ -30899,7 +31221,7 @@ class WidgetViewBar extends Widget.AWidget {
30899
31221
  }
30900
31222
  }
30901
31223
 
30902
- const VERSION = "5.5.3";
31224
+ const VERSION = "5.5.5";
30903
31225
 
30904
31226
  export { VERSION, CesiumViewMonitor, ViewerUtils, ViewerEventTracker, MenuItemManager, isHistoricMetadataChanged, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, DataLabRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, DEFAULT_LIVE_PADDING_SECONDS, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar, WidgetControlViewBar, WidgetControlViewBarSearch, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks };
30905
31227
  //# sourceMappingURL=bruce-cesium.es5.js.map