bruce-cesium 5.5.2 → 5.5.4

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, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, BoundingSphere, GeometryInstance, Quaternion, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } 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, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileStyle, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, 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, 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 = "";
@@ -24109,8 +24113,28 @@ var TileRenderEngine;
24109
24113
  }
24110
24114
  else if (tileset.type === Tileset.EType.ExternalTerrain) {
24111
24115
  const settings = tileset.settings;
24112
- url = settings.url;
24113
24116
  vertexes = settings.requestVertexNormals == null ? true : settings.requestVertexNormals;
24117
+ if (!settings.terrainType || settings.terrainType === "Default") {
24118
+ url = settings.url;
24119
+ }
24120
+ else if (settings.terrainType == "CesiumIon") {
24121
+ const ionId = settings.externalId;
24122
+ const key = settings.key ? settings.key : await findKey(params.apiGetter, params.apiGetter.accountId, ProgramKey.EProgramId.CesiumIon);
24123
+ const resource = IonResource.fromAssetId(Number(ionId), {
24124
+ accessToken: key
24125
+ });
24126
+ if (CesiumTerrainProvider.hasOwnProperty("fromUrl")) {
24127
+ provider = await CESIUM.CesiumTerrainProvider.fromUrl(resource, {
24128
+ requestVertexNormals: vertexes
24129
+ });
24130
+ }
24131
+ else {
24132
+ provider = new CESIUM.CesiumTerrainProvider({
24133
+ url: resource,
24134
+ requestVertexNormals: vertexes
24135
+ });
24136
+ }
24137
+ }
24114
24138
  }
24115
24139
  else {
24116
24140
  console.error("Invalid tileset type.", tileset);
@@ -25458,6 +25482,304 @@ var ViewRenderEngine;
25458
25482
  ViewRenderEngine.FlyTo = FlyTo;
25459
25483
  })(ViewRenderEngine || (ViewRenderEngine = {}));
25460
25484
 
25485
+ class WidgetLeftPanelTabUser extends WidgetLeftPanelTab.ATab {
25486
+ constructor(params) {
25487
+ super(params);
25488
+ this.STYLESHEET_ID = "nextspace-left-panel-tab-user-stylesheet";
25489
+ this.loadedSessionId = null;
25490
+ this.user = null;
25491
+ this.loaded = false;
25492
+ this.loggingOut = false;
25493
+ this.loggingIn = false;
25494
+ this.inputUsername = null;
25495
+ this.inputPassword = null;
25496
+ this._generateStyles();
25497
+ this._generateElement();
25498
+ // In case another widget messed with the panel width.
25499
+ // Probably should just add a SetWidth method to avoid having plugins mess with the container CSS.
25500
+ if (this.Container) {
25501
+ this.Container.style.width = "300px";
25502
+ }
25503
+ this.loadUser();
25504
+ this.paramsChangeRemoval = ENVIRONMENT.OnParamsChange.Subscribe(() => {
25505
+ this.loadUser();
25506
+ });
25507
+ }
25508
+ async loadUser() {
25509
+ if (this.loadedSessionId === ENVIRONMENT.PARAMS.sessionId) {
25510
+ return;
25511
+ }
25512
+ let loadingSessionId = ENVIRONMENT.PARAMS.sessionId;
25513
+ try {
25514
+ this.user = null;
25515
+ if (ENVIRONMENT.PARAMS.sessionId && ENVIRONMENT.PARAMS.sessionId !== "anonymous") {
25516
+ const { session } = await Session.Get({
25517
+ accountId: ENVIRONMENT.PARAMS.accountId,
25518
+ sessionId: loadingSessionId
25519
+ });
25520
+ if (loadingSessionId !== ENVIRONMENT.PARAMS.sessionId) {
25521
+ return;
25522
+ }
25523
+ this.user = session === null || session === void 0 ? void 0 : session.User;
25524
+ }
25525
+ }
25526
+ catch (e) {
25527
+ console.error(e);
25528
+ }
25529
+ finally {
25530
+ if (loadingSessionId === ENVIRONMENT.PARAMS.sessionId) {
25531
+ this.loaded = true;
25532
+ this._generateElement();
25533
+ }
25534
+ }
25535
+ }
25536
+ /**
25537
+ * Returns if the user can logout.
25538
+ * If the session is part of URL, we don't want to show the logout button.
25539
+ * @returns {boolean}
25540
+ */
25541
+ canLogout() {
25542
+ if (!this.user || this.user.ID === "anonymous") {
25543
+ return false;
25544
+ }
25545
+ const url = new URL(window.location.href);
25546
+ let sessionId = url.searchParams.get("sessionId");
25547
+ if (!sessionId) {
25548
+ sessionId = url.searchParams.get("ssid");
25549
+ }
25550
+ if (sessionId) {
25551
+ return false;
25552
+ }
25553
+ return true;
25554
+ }
25555
+ async logout() {
25556
+ if (this.loggingOut) {
25557
+ return;
25558
+ }
25559
+ else if (!this.canLogout()) {
25560
+ return;
25561
+ }
25562
+ try {
25563
+ await Session.Logout({});
25564
+ ENVIRONMENT.SetPageLoadSessionId(null);
25565
+ }
25566
+ catch (e) {
25567
+ console.error(e);
25568
+ }
25569
+ window.location.reload();
25570
+ }
25571
+ Dispose() {
25572
+ super.Dispose();
25573
+ if (this.paramsChangeRemoval) {
25574
+ this.paramsChangeRemoval();
25575
+ this.paramsChangeRemoval = null;
25576
+ }
25577
+ }
25578
+ _generateStyles() {
25579
+ if (document.getElementById(this.STYLESHEET_ID)) {
25580
+ return;
25581
+ }
25582
+ const style = document.createElement("style");
25583
+ style.id = this.STYLESHEET_ID;
25584
+ style.innerHTML = `
25585
+ .NextspaceLeftPanelTabUser * {
25586
+ box-sizing: border-box;
25587
+ font-family: Arial;
25588
+ font-size: 13px;
25589
+ }
25590
+
25591
+ .NextspaceLeftPanelTabUser {
25592
+ display: flex;
25593
+ flex-direction: column;
25594
+ flex-grow: 1;
25595
+ flex-shrink: 1;
25596
+ overflow: hidden;
25597
+ width: 100%;
25598
+ box-sizing: border-box;
25599
+ }
25600
+
25601
+ .NextspaceLeftPanelTabUser >.NextspaceLeftPanelTabUserTitleBar {
25602
+ align-items: center;
25603
+ color: #fff;
25604
+ display: flex;
25605
+ font-size: 17px;
25606
+ font-style: normal;
25607
+ font-weight: 500;
25608
+ justify-content: center;
25609
+ letter-spacing: -.005em;
25610
+ line-height: 20px;
25611
+ margin-bottom: 15px;
25612
+ font-family: Arial;
25613
+ }
25614
+
25615
+ .NextspaceLeftPanelTabUser >.NextspaceLeftPanelTabUserTitleBreaker {
25616
+ background-color: #000;
25617
+ flex-shrink: 0;
25618
+ height: 2px;
25619
+ margin-bottom: 15px;
25620
+ }
25621
+
25622
+ .NextspaceLeftPanelTabUser >.NextspaceLeftPanelTabUserInputRow {
25623
+ display: flex;
25624
+ flex-direction: row;
25625
+ align-items: center;
25626
+ margin-bottom: 8px;
25627
+ width: 100%;
25628
+ }
25629
+
25630
+ .NextspaceLeftPanelTabUser >.NextspaceLeftPanelTabUserInputRow >label {
25631
+ width: 90px;
25632
+ flex-shrink: 0;
25633
+ margin-right: 8px;
25634
+ color: white;
25635
+ }
25636
+
25637
+ .NextspaceLeftPanelTabUser >.NextspaceLeftPanelTabUserInputRow >input {
25638
+ flex-grow: 1;
25639
+ max-width: 220px;
25640
+
25641
+ background-color: #121619;
25642
+ border: 1px solid #ffffff36;
25643
+ color: #fff;
25644
+ flex-grow: 1;
25645
+ flex-shrink: 1;
25646
+ height: 30px;
25647
+ text-align: left;
25648
+ border-radius: .375rem;
25649
+ outline: none;
25650
+ padding: .5rem .75rem;
25651
+ box-sizing: border-box;
25652
+ width: 10px;
25653
+ }
25654
+
25655
+ .NextspaceLeftPanelTabUser button {
25656
+ cursor: pointer;
25657
+ border-radius: .375rem;
25658
+ padding: 4px 9px;
25659
+ transition: opacity 0.3s ease;
25660
+ width: 100px;
25661
+ width: min-content;
25662
+ height: min-content;
25663
+ white-space: nowrap;
25664
+ border: 1px solid grey;
25665
+ color: black;
25666
+ background-color: white;
25667
+ display: flex;
25668
+ align-items: center;
25669
+ justify-content: center;
25670
+ position: relative;
25671
+ background-color: #0072c3;
25672
+ border: 1px solid #0072c3;
25673
+ color: white;
25674
+
25675
+ margin-left: auto;
25676
+ }
25677
+ `;
25678
+ document.head.appendChild(style);
25679
+ }
25680
+ _generateElement() {
25681
+ var _a, _b;
25682
+ if ((_a = this._element) === null || _a === void 0 ? void 0 : _a.parentElement) {
25683
+ this._element.parentElement.removeChild(this._element);
25684
+ }
25685
+ this._element = null;
25686
+ const element = document.createElement("div");
25687
+ element.className = "NextspaceLeftPanelTabUser";
25688
+ const title = document.createElement("div");
25689
+ title.className = "NextspaceLeftPanelTabUserTitleBar";
25690
+ title.textContent = this.loaded ? (this.user ? ((_b = this.user.FullName) !== null && _b !== void 0 ? _b : "#" + this.user.ID) : "Guest") : "Loading..";
25691
+ element.appendChild(title);
25692
+ const breaker = document.createElement("div");
25693
+ breaker.className = "NextspaceLeftPanelTabUserTitleBreaker";
25694
+ element.appendChild(breaker);
25695
+ if (!this.user || this.user.ID === "anonymous") {
25696
+ {
25697
+ const inputRow = document.createElement("div");
25698
+ inputRow.className = "NextspaceLeftPanelTabUserInputRow";
25699
+ const label = document.createElement("label");
25700
+ label.textContent = "Username";
25701
+ inputRow.appendChild(label);
25702
+ const input = document.createElement("input");
25703
+ input.type = "text";
25704
+ input.placeholder = "...";
25705
+ this.inputUsername = input;
25706
+ inputRow.appendChild(this.inputUsername);
25707
+ element.appendChild(inputRow);
25708
+ }
25709
+ {
25710
+ const inputRow = document.createElement("div");
25711
+ inputRow.className = "NextspaceLeftPanelTabUserInputRow";
25712
+ const label = document.createElement("label");
25713
+ label.textContent = "Password";
25714
+ inputRow.appendChild(label);
25715
+ const input = document.createElement("input");
25716
+ input.type = "password";
25717
+ input.placeholder = "...";
25718
+ this.inputPassword = input;
25719
+ inputRow.appendChild(this.inputPassword);
25720
+ element.appendChild(inputRow);
25721
+ }
25722
+ {
25723
+ const button = document.createElement("button");
25724
+ button.textContent = "Login";
25725
+ button.onclick = async () => {
25726
+ var _a, _b, _c, _d, _e, _f;
25727
+ if (this.loggingIn) {
25728
+ return;
25729
+ }
25730
+ button.style.opacity = "0.7";
25731
+ this.loggingIn = true;
25732
+ try {
25733
+ const { session } = await Session.Login({
25734
+ accountId: ENVIRONMENT.PARAMS.accountId,
25735
+ username: (_b = (_a = this.inputUsername) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "",
25736
+ password: (_d = (_c = this.inputPassword) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : ""
25737
+ });
25738
+ ENVIRONMENT.SetPageLoadSessionId((_e = session === null || session === void 0 ? void 0 : session.ID) !== null && _e !== void 0 ? _e : null);
25739
+ ENVIRONMENT.Reset({
25740
+ accountId: ENVIRONMENT.PARAMS.accountId,
25741
+ sessionId: (_f = (session === null || session === void 0 ? void 0 : session.ID)) !== null && _f !== void 0 ? _f : null,
25742
+ });
25743
+ window.location.reload();
25744
+ }
25745
+ catch (e) {
25746
+ console.error(e);
25747
+ }
25748
+ finally {
25749
+ this.loggingIn = false;
25750
+ button.style.opacity = "1";
25751
+ }
25752
+ };
25753
+ element.appendChild(button);
25754
+ }
25755
+ }
25756
+ else {
25757
+ if (this.canLogout()) {
25758
+ const button = document.createElement("button");
25759
+ button.textContent = "Logout";
25760
+ button.onclick = async () => {
25761
+ if (this.loggingOut) {
25762
+ return;
25763
+ }
25764
+ button.style.opacity = "0.7";
25765
+ try {
25766
+ this.logout();
25767
+ }
25768
+ catch (e) {
25769
+ console.error(e);
25770
+ }
25771
+ finally {
25772
+ button.style.opacity = "1";
25773
+ }
25774
+ };
25775
+ element.appendChild(button);
25776
+ }
25777
+ }
25778
+ this.Container.appendChild(element);
25779
+ this._element = element;
25780
+ }
25781
+ }
25782
+
25461
25783
  const VIEWER_LEFT_PANEL_WIDGET_KEY = "_viewerLeftPanelWidget";
25462
25784
  const VIEWER_LEFT_PANEL_CSS_VAR_LEFT = "--nextspace-left-panel-width";
25463
25785
  class WidgetLeftPanel extends Widget.AWidget {
@@ -25826,6 +26148,7 @@ class WidgetLeftPanel extends Widget.AWidget {
25826
26148
  </svg>
25827
26149
  `;
25828
26150
  buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
26151
+ buttonBookmarksIcon.style.cursor = "pointer";
25829
26152
  tabButton.appendChild(buttonBookmarksIcon);
25830
26153
  this._element.appendChild(tabButton);
25831
26154
  function getInitials(name) {
@@ -25883,6 +26206,16 @@ class WidgetLeftPanel extends Widget.AWidget {
25883
26206
  buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
25884
26207
  }
25885
26208
  }
26209
+ buttonBookmarksIcon.onclick = () => {
26210
+ if (this._enabledPanelTab === "user") {
26211
+ this._enabledPanelTab = "";
26212
+ }
26213
+ else {
26214
+ this._enabledPanelTab = "user";
26215
+ }
26216
+ this._updatePanelContent();
26217
+ this._updatePanelStyles();
26218
+ };
25886
26219
  if (this.envSubRemoval) {
25887
26220
  this.envSubRemoval();
25888
26221
  this.envSubRemoval = null;
@@ -25932,6 +26265,12 @@ class WidgetLeftPanel extends Widget.AWidget {
25932
26265
  container: container
25933
26266
  });
25934
26267
  break;
26268
+ case "user":
26269
+ tabContent = new WidgetLeftPanelTabUser({
26270
+ widget: this,
26271
+ container: container
26272
+ });
26273
+ break;
25935
26274
  default:
25936
26275
  if (this.customTabs.has(this._enabledPanelTab) === false) {
25937
26276
  console.error(`Tab ${this._enabledPanelTab} not found.`);
@@ -30879,7 +31218,7 @@ class WidgetViewBar extends Widget.AWidget {
30879
31218
  }
30880
31219
  }
30881
31220
 
30882
- const VERSION = "5.5.2";
31221
+ const VERSION = "5.5.4";
30883
31222
 
30884
31223
  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 };
30885
31224
  //# sourceMappingURL=bruce-cesium.es5.js.map