bruce-cesium 4.2.9 → 4.3.1

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
- import { BruceEvent, Cartes, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ProjectViewTile, DelayQueue, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, Api, EntityRelationType, ENVIRONMENT, EntityHistoricData, EntityCoords, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, EntityAttribute, EntityAttachment, EntityAttachmentType, AbstractApi } from 'bruce-models';
1
+ import { BruceEvent, Cartes, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ProjectViewTile, DelayQueue, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, Api, EntityRelationType, ENVIRONMENT, EntityHistoricData, EntityCoords, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, EntityAttribute, EntityAttachment, EntityAttachmentType, 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, SceneMode, DistanceDisplayCondition, NearFarScalar, Model, ColorMaterialProperty, Entity, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorBlendMode, HeadingPitchRoll, Transforms, GeoJsonDataSource, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, Cesium3DTileset, PolygonPipeline, BoundingSphere, Matrix3, Matrix4, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ScreenSpaceEventHandler, ScreenSpaceEventType, IonResource, CzmlDataSource, Quaternion, Intersect } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, DistanceDisplayCondition, NearFarScalar, Model, ColorMaterialProperty, Entity, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorBlendMode, HeadingPitchRoll, Transforms, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Quaternion, Intersect } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -23238,6 +23238,10 @@ var WidgetLeftPanel = /** @class */ (function (_super) {
23238
23238
  };
23239
23239
  WidgetLeftPanel.prototype.Dispose = function () {
23240
23240
  _super.prototype.Dispose.call(this);
23241
+ if (this.envSubRemoval) {
23242
+ this.envSubRemoval();
23243
+ this.envSubRemoval = null;
23244
+ }
23241
23245
  if (this._enabledTabContent) {
23242
23246
  this._enabledTabContent.Dispose();
23243
23247
  this._enabledTabContent = null;
@@ -23250,7 +23254,7 @@ var WidgetLeftPanel = /** @class */ (function (_super) {
23250
23254
  }
23251
23255
  var style = document.createElement("style");
23252
23256
  style.id = this.STYLESHEET_ID;
23253
- style.innerHTML = "\n .NextspaceLeftPanel {\n align-items: center;\n background-color: #21272a;\n cursor: default;\n display: flex;\n flex-direction: column;\n flex-shrink: 0;\n height: 100%;\n padding-top: 15px;\n position: absolute;\n width: 50px;\n z-index: 1;\n top: 0;\n left: 0;\n box-sizing: border-box;\n }\n\n .NextspaceLeftPanel * {\n box-sizing: border-box;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelBreaker {\n background-color: hsla(0,0%,50%,.231);\n flex-shrink: 0;\n height: 2px;\n margin-bottom: 15px;\n width: calc(100% - 8px);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelBottomBreaker {\n margin-top: auto;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton {\n border-radius: 3px;\n color: #fff;\n cursor: pointer;\n font-size: 18px;\n height: 32px;\n overflow: hidden;\n width: 32px;\n margin-bottom: 15px;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton:first-of-type {\n margin-bottom: 8px;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon {\n align-items: center;\n display: flex;\n justify-content: center;\n position: relative;\n transition: .3s ease;\n height: 100%;\n width: 100%;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon:hover {\n transform: scale(1.2);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon >svg {\n cursor: pointer;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled=\"true\"] >.NextspaceLeftPanelButtonIcon {\n background-color: #fff;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled=\"true\"] >.NextspaceLeftPanelButtonIcon >svg {\n filter: invert(1);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelTabContent {\n display: none;\n width: 300px;\n height: 100%;\n position: absolute;\n top: 0;\n left: 50px;\n background-color: #21272a;\n padding: 40px 30px 30px;\n flex-direction: column;\n flex-grow: 1;\n flex-shrink: 1;\n overflow: hidden;\n }\n\n .NextspaceLeftPanel .NextspaceLeftPanelTabContentCloseButton {\n color: #fff;\n cursor: pointer;\n opacity: .7;\n position: absolute;\n right: 22px;\n top: 14px;\n transition: transform .3s ease;\n z-index: 1;\n }\n\n .NextspaceLeftPanel .NextspaceLeftPanelTabContentCloseButton:hover {\n transform: scale(1.2);\n }\n ";
23257
+ style.innerHTML = "\n .NextspaceLeftPanel {\n align-items: center;\n background-color: #21272a;\n cursor: default;\n display: flex;\n flex-direction: column;\n flex-shrink: 0;\n height: 100%;\n padding-top: 15px;\n position: absolute;\n width: 50px;\n z-index: 1;\n top: 0;\n left: 0;\n box-sizing: border-box;\n }\n\n .NextspaceLeftPanel * {\n box-sizing: border-box;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelBreaker {\n background-color: hsla(0,0%,50%,.231);\n flex-shrink: 0;\n height: 2px;\n margin-bottom: 15px;\n width: calc(100% - 8px);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelBottomBreaker {\n margin-top: auto;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton {\n border-radius: 3px;\n color: #fff;\n cursor: pointer;\n font-size: 18px;\n height: 32px;\n overflow: hidden;\n width: 32px;\n margin-bottom: 15px;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton:first-of-type {\n margin-bottom: 8px;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon {\n align-items: center;\n display: flex;\n justify-content: center;\n position: relative;\n transition: .3s ease;\n height: 100%;\n width: 100%;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon:hover {\n transform: scale(1.2);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[no-content=\"true\"] {\n cursor: default;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[no-content=\"true\"] >.NextspaceLeftPanelButtonIcon:hover {\n transform: none;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon >svg {\n cursor: pointer;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled=\"true\"] >.NextspaceLeftPanelButtonIcon {\n background-color: #fff;\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled=\"true\"] >.NextspaceLeftPanelButtonIcon >svg {\n filter: invert(1);\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-disabled=\"true\"] {\n opacity: .5;\n pointer-events: none\n }\n\n .NextspaceLeftPanel >.NextspaceLeftPanelTabContent {\n display: none;\n width: 300px;\n height: 100%;\n position: absolute;\n top: 0;\n left: 50px;\n background-color: #21272a;\n padding: 40px 30px 30px;\n flex-direction: column;\n flex-grow: 1;\n flex-shrink: 1;\n overflow: hidden;\n }\n\n .NextspaceLeftPanel .NextspaceLeftPanelTabContentCloseButton {\n color: #fff;\n cursor: pointer;\n opacity: .7;\n position: absolute;\n right: 22px;\n top: 14px;\n transition: transform .3s ease;\n z-index: 1;\n }\n\n .NextspaceLeftPanel .NextspaceLeftPanelTabContentCloseButton:hover {\n transform: scale(1.2);\n }\n ";
23254
23258
  document.head.appendChild(style);
23255
23259
  };
23256
23260
  WidgetLeftPanel.prototype._generateElement = function () {
@@ -23267,7 +23271,7 @@ var WidgetLeftPanel = /** @class */ (function (_super) {
23267
23271
  var bottomBreaker = document.createElement("div");
23268
23272
  bottomBreaker.className = "NextspaceLeftPanelBottomBreaker";
23269
23273
  this._element.appendChild(bottomBreaker);
23270
- this._addPlaceholderTab("Profile", "\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 12C14.21 12 16 10.21 16 8C16 5.79 14.21 4 12 4C9.79 4 8 5.79 8 8C8 10.21 9.79 12 12 12ZM12 14C9.33 14 4 15.34 4 18V19C4 19.55 4.45 20 5 20H19C19.55 20 20 19.55 20 19V18C20 15.34 14.67 14 12 14Z\" fill=\"white\"/>\n </svg>\n ");
23274
+ this._addUserProfileTab();
23271
23275
  var panelContent = document.createElement("div");
23272
23276
  panelContent.className = "NextspaceLeftPanelTabContent";
23273
23277
  var panelContentCloseButton = document.createElement("div");
@@ -23289,9 +23293,12 @@ var WidgetLeftPanel = /** @class */ (function (_super) {
23289
23293
  */
23290
23294
  WidgetLeftPanel.prototype.AddPanelTab = function (params) {
23291
23295
  this.customTabs.set(params.tab, params.content);
23292
- this._addPanelTab(params.tab, params.title, params.svgStr);
23296
+ // We insert before the bottom breaker.
23297
+ var bottomBreaker = this._element.querySelector(".NextspaceLeftPanelBottomBreaker");
23298
+ var afterElement = bottomBreaker ? bottomBreaker.previousElementSibling : null;
23299
+ this._addPanelTab(params.tab, params.title, params.svgStr, afterElement);
23293
23300
  };
23294
- WidgetLeftPanel.prototype._addPanelTab = function (tab, title, svgStr) {
23301
+ WidgetLeftPanel.prototype._addPanelTab = function (tab, title, svgStr, afterElement) {
23295
23302
  var _this = this;
23296
23303
  var tabButton = document.createElement("div");
23297
23304
  tabButton.setAttribute("widget-left-panel-tab", tab);
@@ -23316,7 +23323,17 @@ var WidgetLeftPanel = /** @class */ (function (_super) {
23316
23323
  _this._updatePanelContent();
23317
23324
  _this._updatePanelStyles();
23318
23325
  };
23319
- this._element.appendChild(tabButton);
23326
+ if (afterElement && afterElement.parentElement) {
23327
+ if (afterElement.nextSibling) {
23328
+ afterElement.parentElement.insertBefore(tabButton, afterElement.nextSibling);
23329
+ }
23330
+ else {
23331
+ afterElement.parentElement.appendChild(tabButton);
23332
+ }
23333
+ }
23334
+ else {
23335
+ this._element.appendChild(tabButton);
23336
+ }
23320
23337
  };
23321
23338
  WidgetLeftPanel.prototype._addPlaceholderTab = function (title, svgStr) {
23322
23339
  var tabButton = document.createElement("div");
@@ -23330,6 +23347,83 @@ var WidgetLeftPanel = /** @class */ (function (_super) {
23330
23347
  tabButton.appendChild(buttonBookmarksIcon);
23331
23348
  this._element.appendChild(tabButton);
23332
23349
  };
23350
+ /**
23351
+ * User profile handled separately.
23352
+ * This is because for a while it will be just an indicator of logged in user session.
23353
+ * It won't have a tab content.
23354
+ */
23355
+ WidgetLeftPanel.prototype._addUserProfileTab = function () {
23356
+ var tabButton = document.createElement("div");
23357
+ tabButton.className = "NextspaceLeftPanelButton";
23358
+ tabButton.setAttribute("title", "Not logged in");
23359
+ tabButton.setAttribute("no-content", "true");
23360
+ var buttonBookmarksIcon = document.createElement("div");
23361
+ buttonBookmarksIcon.className = "NextspaceLeftPanelButtonIcon";
23362
+ var LOGGED_OUT_ICON = "\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 12C14.21 12 16 10.21 16 8C16 5.79 14.21 4 12 4C9.79 4 8 5.79 8 8C8 10.21 9.79 12 12 12ZM12 14C9.33 14 4 15.34 4 18V19C4 19.55 4.45 20 5 20H19C19.55 20 20 19.55 20 19V18C20 15.34 14.67 14 12 14Z\" fill=\"white\"/>\n </svg>\n ";
23363
+ buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
23364
+ tabButton.appendChild(buttonBookmarksIcon);
23365
+ this._element.appendChild(tabButton);
23366
+ function getInitials(name) {
23367
+ var nameSplit = name.split(" ");
23368
+ if (nameSplit.length > 1) {
23369
+ return nameSplit[0][0] + nameSplit[1][0];
23370
+ }
23371
+ else {
23372
+ return nameSplit[0][0];
23373
+ }
23374
+ }
23375
+ function GetColorForString(str) {
23376
+ var stringUniqueHash = [].concat(str).reduce(function (acc, char) { return char.charCodeAt(0) + ((acc << 5) - acc); }, 0);
23377
+ return "hsl(".concat(stringUniqueHash % 360, ", 95%, 35%)");
23378
+ }
23379
+ /**
23380
+ * Updates the tab button based on the current user session.
23381
+ */
23382
+ function updateProfile() {
23383
+ var _a;
23384
+ return __awaiter(this, void 0, void 0, function () {
23385
+ var session, isLoggedIn, userName, initials, e_2;
23386
+ return __generator(this, function (_b) {
23387
+ switch (_b.label) {
23388
+ case 0:
23389
+ _b.trys.push([0, 2, , 3]);
23390
+ return [4 /*yield*/, Session.Get({
23391
+ sessionId: ENVIRONMENT.PARAMS.sessionId ? ENVIRONMENT.PARAMS.sessionId : "anonymous",
23392
+ })];
23393
+ case 1:
23394
+ session = (_b.sent()).session;
23395
+ isLoggedIn = session.ID != "anonymous" && ((_a = session.User) === null || _a === void 0 ? void 0 : _a.ID) != "anonymous";
23396
+ userName = session.User.FullName ? session.User.FullName : session.User.ID;
23397
+ tabButton.setAttribute("title", isLoggedIn ? userName : "Not logged in");
23398
+ // Draw a circle with the user's initials.
23399
+ if (isLoggedIn) {
23400
+ initials = getInitials(userName);
23401
+ buttonBookmarksIcon.innerHTML = "\n <div \n style=\"\n background-color: ".concat(GetColorForString(userName), "; \n color: white;\n border-radius: 50%;\n display: flex; \n align-items: center; \n justify-content: center; \n font-size: 12px;\n font-family: Arial;\n height: 100%; \n width: 100%;\">\n ").concat(initials, "\n </div>\n ");
23402
+ }
23403
+ else {
23404
+ buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
23405
+ }
23406
+ return [3 /*break*/, 3];
23407
+ case 2:
23408
+ e_2 = _b.sent();
23409
+ console.error(e_2);
23410
+ tabButton.setAttribute("title", "Not logged in");
23411
+ buttonBookmarksIcon.innerHTML = LOGGED_OUT_ICON;
23412
+ return [3 /*break*/, 3];
23413
+ case 3: return [2 /*return*/];
23414
+ }
23415
+ });
23416
+ });
23417
+ }
23418
+ if (this.envSubRemoval) {
23419
+ this.envSubRemoval();
23420
+ this.envSubRemoval = null;
23421
+ }
23422
+ this.envSubRemoval = ENVIRONMENT.OnParamsChange.Subscribe(function () {
23423
+ updateProfile();
23424
+ });
23425
+ updateProfile();
23426
+ };
23333
23427
  /**
23334
23428
  * Updates the panel styles based on the current state.
23335
23429
  * Eg: if a tab is enabled, the button should be highlighted.
@@ -23338,8 +23432,14 @@ var WidgetLeftPanel = /** @class */ (function (_super) {
23338
23432
  var _this = this;
23339
23433
  var buttons = this._element.querySelectorAll(".NextspaceLeftPanelButton");
23340
23434
  buttons.forEach(function (button) {
23341
- var isEnabled = button.getAttribute("widget-left-panel-tab") === _this._enabledPanelTab;
23435
+ var buttonTab = button.getAttribute("widget-left-panel-tab");
23436
+ var isEnabled = buttonTab === _this._enabledPanelTab;
23342
23437
  button.setAttribute("is-enabled", isEnabled ? "true" : "false");
23438
+ // Disable for specific tabs.
23439
+ // Eg: bookmarks require a viewId.
23440
+ if (buttonTab === "bookmarks") {
23441
+ button.setAttribute("is-disabled", !_this._viewId ? "true" : "false");
23442
+ }
23343
23443
  });
23344
23444
  // Make the tab content visible/invisible based on the current state.
23345
23445
  var contentDisplayState = this._enabledPanelTab ? "flex" : "none";
@@ -23366,10 +23466,15 @@ var WidgetLeftPanel = /** @class */ (function (_super) {
23366
23466
  });
23367
23467
  break;
23368
23468
  default:
23369
- tabContent = new (this.customTabs.get(this._enabledPanelTab)({
23469
+ if (this.customTabs.has(this._enabledPanelTab) === false) {
23470
+ console.error("Tab ".concat(this._enabledPanelTab, " not found."));
23471
+ return;
23472
+ }
23473
+ var clazz = this.customTabs.get(this._enabledPanelTab);
23474
+ tabContent = new clazz({
23370
23475
  widget: this,
23371
23476
  container: container
23372
- }));
23477
+ });
23373
23478
  break;
23374
23479
  }
23375
23480
  this._enabledTabContent = tabContent;
@@ -26336,7 +26441,7 @@ var ViewerUtils;
26336
26441
  ViewerUtils.AssertIonToken = AssertIonToken;
26337
26442
  })(ViewerUtils || (ViewerUtils = {}));
26338
26443
 
26339
- var VERSION = "4.2.9";
26444
+ var VERSION = "4.3.1";
26340
26445
 
26341
26446
  export { VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, WidgetNavCompass$$1 as WidgetNavCompass, WidgetSearchBar, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks };
26342
26447
  //# sourceMappingURL=bruce-cesium.es5.js.map