bruce-cesium 3.1.7 → 3.1.9

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 { Cartes, ProjectViewTile, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, DelayQueue, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, EntityRelationType, BruceEvent, EntityCoords, Api, EntitySource, MenuItem, EntityRelation, ENVIRONMENT, AbstractApi, ProjectViewBookmark, EntityAttachment, EntityAttachmentType, EntityAttribute, ProjectView, ProjectViewLegacyTile, ProgramKey, Camera } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, DistanceDisplayCondition, NearFarScalar, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Model, JulianDate, Primitive, Cesium3DTileFeature, SceneMode, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, Cesium3DTileset, Matrix4, Matrix3, IonResource, Ion, PolygonPipeline, CesiumInspector, ColorMaterialProperty, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect } from 'cesium';
3
+ import { Cartographic, Color, HeightReference, Cartesian3, DistanceDisplayCondition, NearFarScalar, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Math as Math$1, Transforms, ColorBlendMode, Model, Cartesian2, CallbackProperty, Rectangle, JulianDate, SceneMode, Primitive, Cesium3DTileFeature, HeadingPitchRange, Cesium3DTileColorBlendMode, Cesium3DTileStyle, createOsmBuildings, KmlDataSource, OrthographicFrustum, EasingFunction, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, SceneTransforms, Cesium3DTileset, Matrix4, Matrix3, IonResource, Ion, CesiumInspector, defined, PolygonPipeline, ScreenSpaceEventHandler, ScreenSpaceEventType, ColorMaterialProperty, BoundingSphere, GeometryInstance, EllipsoidGeodesic, sampleTerrainMostDetailed, Intersect } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5603,13 +5603,13 @@ function unmarkEntity(visual, ignoreParent) {
5603
5603
  var ORG_COLOR_KEY = "_org_color_";
5604
5604
  function select(viewer, visual, color, reqRender) {
5605
5605
  var _a;
5606
- if (!isAlive$1(viewer, visual)) {
5607
- return;
5608
- }
5609
5606
  if (!color) {
5610
5607
  color = Color.fromAlpha(Color.YELLOW, 0.5);
5611
5608
  }
5612
5609
  if (visual instanceof Entity) {
5610
+ if (!(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
5611
+ return;
5612
+ }
5613
5613
  var entities = EntityUtils.GatherEntity({
5614
5614
  entity: visual
5615
5615
  });
@@ -5644,8 +5644,12 @@ function select(viewer, visual, color, reqRender) {
5644
5644
  for (var i = 0; i < entities.length; i++) {
5645
5645
  _loop_1(i);
5646
5646
  }
5647
+ return;
5647
5648
  }
5648
- else if (visual instanceof Primitive) ;
5649
+ if (!isAlive$1(viewer, visual)) {
5650
+ return;
5651
+ }
5652
+ if (visual instanceof Primitive) ;
5649
5653
  else if (visual instanceof Cesium3DTileFeature) {
5650
5654
  var orgColor = visual[ORG_COLOR_KEY];
5651
5655
  if (orgColor == null) {
@@ -5670,10 +5674,10 @@ function select(viewer, visual, color, reqRender) {
5670
5674
  }
5671
5675
  }
5672
5676
  function deselect(viewer, visual, reqRender) {
5673
- if (!isAlive$1(viewer, visual)) {
5674
- return;
5675
- }
5676
5677
  if (visual instanceof Entity) {
5678
+ if (!(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
5679
+ return;
5680
+ }
5677
5681
  var entities = EntityUtils.GatherEntity({
5678
5682
  entity: visual
5679
5683
  });
@@ -5702,8 +5706,12 @@ function deselect(viewer, visual, reqRender) {
5702
5706
  for (var i = 0; i < entities.length; i++) {
5703
5707
  _loop_2(i);
5704
5708
  }
5709
+ return;
5705
5710
  }
5706
- else if (visual instanceof Primitive) ;
5711
+ if (!isAlive$1(viewer, visual)) {
5712
+ return;
5713
+ }
5714
+ if (visual instanceof Primitive) ;
5707
5715
  else if (visual instanceof Cesium3DTileFeature) {
5708
5716
  var orgColor = visual[ORG_COLOR_KEY];
5709
5717
  if (orgColor != null) {
@@ -15813,6 +15821,192 @@ var WidgetInfoView = /** @class */ (function (_super) {
15813
15821
  return WidgetInfoView;
15814
15822
  }(Widget.AWidget));
15815
15823
 
15824
+ var WidgetEmbeddedInfoView = /** @class */ (function (_super) {
15825
+ __extends(WidgetEmbeddedInfoView, _super);
15826
+ function WidgetEmbeddedInfoView(params) {
15827
+ var _this = _super.call(this, params) || this;
15828
+ _this.STYLESHEET_ID = "nextspace-info-view-stylesheet";
15829
+ _this._generateStyles();
15830
+ _this._generateElement();
15831
+ _this._updateRemoval = _this._manager.VisualsRegister.OnUpdate.Subscribe(function (data) {
15832
+ if (data.type == "UPDATE" || data.type == "DESELECT_ALL") {
15833
+ _this._updateInfoView();
15834
+ }
15835
+ });
15836
+ if (window) {
15837
+ var winEvent_1 = null;
15838
+ window.addEventListener("message", winEvent_1 = function (event) {
15839
+ try {
15840
+ var data = (event.data && typeof event.data == "string" && String(event.data).startsWith("{")) ? JSON.parse(event.data) : event.data;
15841
+ if (!data) {
15842
+ return;
15843
+ }
15844
+ var embedId = data.embedId;
15845
+ // Detecting when selection changes within iframe.
15846
+ if (embedId == "info-view") {
15847
+ if (data.action == "select") {
15848
+ _this._manager.VisualsRegister.ClearSelected();
15849
+ _this._manager.VisualsRegister.SetSelected({
15850
+ entityIds: data.selectedIds ? data.selectedIds : [],
15851
+ selected: true
15852
+ });
15853
+ }
15854
+ else if (data.action == "fly-to") {
15855
+ _this._flyTo();
15856
+ }
15857
+ }
15858
+ }
15859
+ catch (e) {
15860
+ console.error(e);
15861
+ }
15862
+ });
15863
+ _this._windowTopRemoval = function () {
15864
+ window.removeEventListener("message", winEvent_1);
15865
+ };
15866
+ }
15867
+ return _this;
15868
+ }
15869
+ WidgetEmbeddedInfoView.prototype.Dispose = function () {
15870
+ var _a;
15871
+ _super.prototype.Dispose.call(this);
15872
+ this._updateRemoval();
15873
+ (_a = this._windowTopRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
15874
+ this._windowTopRemoval = null;
15875
+ };
15876
+ WidgetEmbeddedInfoView.prototype._generateStyles = function () {
15877
+ if (document.getElementById(this.STYLESHEET_ID)) {
15878
+ return;
15879
+ }
15880
+ var style = document.createElement("style");
15881
+ style.id = this.STYLESHEET_ID;
15882
+ style.innerHTML = "\n .NextspaceInfoView {\n width: 500px;\n border-radius: 8px;\n right: 10px;\n top: 66px;\n height: 600px;\n max-height: calc(100% - 320px);\n min-height: 50px;\n align-items: center;\n background: rgba(33,39,42,0.8);\n border-radius: 9px;\n box-shadow: 0 0 1px rgba(18,22,25,.36),0 18px 36px -4px rgba(18,22,25,.36);\n backdrop-filter: blur(20px);\n display: flex;\n flex-direction: column;\n flex-shrink: 1;\n opacity: 0;\n position: absolute;\n z-index: 1;\n transition: opacity .3s ease,-webkit-transform .1s;\n transition: opacity .3s ease,transform .1s;\n transition: opacity .3s ease,transform .1s,-webkit-transform .1s;\n font-family: Arial;\n overflow: hidden;\n }\n\n .NextspaceInfoView * {\n box-sizing: border-box;\n }\n ";
15883
+ document.head.appendChild(style);
15884
+ };
15885
+ WidgetEmbeddedInfoView.prototype._generateElement = function () {
15886
+ var element = document.createElement("div");
15887
+ element.className = "NextspaceInfoView";
15888
+ element.style.display = "none";
15889
+ this.Container.appendChild(element);
15890
+ this._element = element;
15891
+ this._updateInfoView();
15892
+ };
15893
+ WidgetEmbeddedInfoView.prototype._updateInfoView = function () {
15894
+ return __awaiter(this, void 0, void 0, function () {
15895
+ var selectedIds, firstId, url, urlParams, iframe;
15896
+ return __generator(this, function (_a) {
15897
+ selectedIds = this._manager.VisualsRegister.GetSelected();
15898
+ if (selectedIds.length <= 0) {
15899
+ this._element.style.display = "none";
15900
+ this._element.style.opacity = "0";
15901
+ return [2 /*return*/];
15902
+ }
15903
+ this._element.style.display = "flex";
15904
+ this._element.style.opacity = "1";
15905
+ firstId = selectedIds[0];
15906
+ if (this._lastSelectedId == firstId) {
15907
+ return [2 /*return*/];
15908
+ }
15909
+ this._lastSelectedId = firstId;
15910
+ try {
15911
+ url = "https://embed.nextspace-dev.net/embed";
15912
+ urlParams = new URLSearchParams();
15913
+ urlParams.append("id", "info-view");
15914
+ urlParams.append("entityId", firstId);
15915
+ urlParams.append("sessionId", this._manager.Getters.GetSessionId());
15916
+ urlParams.append("accountId", this._manager.Getters.GetAccountId());
15917
+ urlParams.append("env", this._manager.Getters.GetEnv());
15918
+ urlParams.append("bgStyle", "transparent");
15919
+ urlParams.append("enableFlyTo", "true");
15920
+ iframe = document.createElement("iframe");
15921
+ iframe.src = "".concat(url, "?").concat(urlParams.toString());
15922
+ iframe.style.width = "100%";
15923
+ iframe.style.height = "100%";
15924
+ iframe.style.border = "none";
15925
+ this._element.innerHTML = "";
15926
+ this._element.appendChild(iframe);
15927
+ }
15928
+ catch (e) {
15929
+ console.error(e);
15930
+ }
15931
+ return [2 /*return*/];
15932
+ });
15933
+ });
15934
+ };
15935
+ WidgetEmbeddedInfoView.prototype._flyTo = function () {
15936
+ var _a, _b;
15937
+ return __awaiter(this, void 0, void 0, function () {
15938
+ var flew, ids, viewer, location_1, destination, centerCartographic, pos3d, e_1;
15939
+ return __generator(this, function (_c) {
15940
+ switch (_c.label) {
15941
+ case 0:
15942
+ flew = false;
15943
+ _c.label = 1;
15944
+ case 1:
15945
+ _c.trys.push([1, 3, , 4]);
15946
+ ids = this._manager.VisualsRegister.GetSelected();
15947
+ viewer = this._manager.Viewer;
15948
+ return [4 /*yield*/, EntityUtils.GetLocation({
15949
+ samples: ids.map(function (id) { return ({
15950
+ entityId: id,
15951
+ returnHeightRef: HeightReference.NONE,
15952
+ heightRef: HeightReference.RELATIVE_TO_GROUND
15953
+ }); }),
15954
+ viewer: viewer,
15955
+ visualRegister: this._manager.VisualsRegister,
15956
+ api: this._manager.Getters.GetBruceApi(),
15957
+ minimumAlt: 5,
15958
+ paddingAlt: 5
15959
+ })];
15960
+ case 2:
15961
+ location_1 = _c.sent();
15962
+ destination = null;
15963
+ if ((_a = location_1 === null || location_1 === void 0 ? void 0 : location_1.sphere) === null || _a === void 0 ? void 0 : _a.radius) {
15964
+ if (location_1.sphere.radius < 5) {
15965
+ location_1.sphere.radius = 5;
15966
+ }
15967
+ centerCartographic = Cartographic.fromCartesian(location_1.sphere.center);
15968
+ centerCartographic.height += (location_1.sphere.radius * 2);
15969
+ pos3d = Cartesian3.fromRadians(centerCartographic.longitude, centerCartographic.latitude, centerCartographic.height);
15970
+ destination = pos3d;
15971
+ }
15972
+ else if (location_1 === null || location_1 === void 0 ? void 0 : location_1.rectangle) {
15973
+ destination = location_1.rectangle;
15974
+ }
15975
+ else if ((_b = location_1 === null || location_1 === void 0 ? void 0 : location_1.pos3d) === null || _b === void 0 ? void 0 : _b.x) {
15976
+ destination = location_1.pos3d;
15977
+ }
15978
+ if (destination) {
15979
+ viewer.camera.flyTo({
15980
+ destination: destination,
15981
+ duration: 1,
15982
+ orientation: {
15983
+ heading: 0,
15984
+ pitch: -Math$1.PI_OVER_TWO,
15985
+ roll: 0
15986
+ }
15987
+ });
15988
+ flew = true;
15989
+ }
15990
+ else {
15991
+ flew = false;
15992
+ }
15993
+ return [3 /*break*/, 4];
15994
+ case 3:
15995
+ e_1 = _c.sent();
15996
+ console.error(e_1);
15997
+ return [3 /*break*/, 4];
15998
+ case 4:
15999
+ if (!flew) {
16000
+ window.alert("Could not fly to selection.");
16001
+ }
16002
+ return [2 /*return*/];
16003
+ }
16004
+ });
16005
+ });
16006
+ };
16007
+ return WidgetEmbeddedInfoView;
16008
+ }(Widget.AWidget));
16009
+
15816
16010
  var CESIUM_VIEWER_MANAGER_KEY = "_cesiumViewerManager";
15817
16011
  /**
15818
16012
  * Bug related to entities not being visible after they were added then a render was requested.
@@ -15948,7 +16142,7 @@ var ViewerUtils;
15948
16142
  * @param params
15949
16143
  */
15950
16144
  function CreateWidgets(params) {
15951
- var viewer = params.viewer, manager = params.manager, container = params.container, apiGetters = params.apiGetters, navCompass = params.navCompass, defaultState = params.defaultState, branding = params.branding, cursorBar = params.cursorBar, searchBar = params.searchBar, bookmarks = params.bookmarks, infoView = params.infoView;
16145
+ var viewer = params.viewer, manager = params.manager, container = params.container, apiGetters = params.apiGetters, navCompass = params.navCompass, defaultState = params.defaultState, branding = params.branding, cursorBar = params.cursorBar, searchBar = params.searchBar, bookmarks = params.bookmarks, infoView = params.infoView, embeddedInfoView = params.embeddedInfoView;
15952
16146
  var widgets = {};
15953
16147
  if (!viewer && manager) {
15954
16148
  viewer = manager.Viewer;
@@ -15986,9 +16180,12 @@ var ViewerUtils;
15986
16180
  if (bookmarks || defaultState) {
15987
16181
  widgets["bookmarks"] = new WidgetBookmarks(__assign(__assign({}, widgetParams), { viewId: params.viewId }));
15988
16182
  }
15989
- if (infoView || defaultState) {
16183
+ if (infoView || (defaultState && !embeddedInfoView)) {
15990
16184
  widgets["infoView"] = new WidgetInfoView(widgetParams);
15991
16185
  }
16186
+ if (!infoView && embeddedInfoView) {
16187
+ widgets["embeddedInfoView"] = new WidgetEmbeddedInfoView(__assign({}, widgetParams));
16188
+ }
15992
16189
  return widgets;
15993
16190
  }
15994
16191
  ViewerUtils.CreateWidgets = CreateWidgets;
@@ -18752,7 +18949,7 @@ var CesiumViewMonitor;
18752
18949
  CesiumViewMonitor$$1.Monitor = Monitor;
18753
18950
  })(CesiumViewMonitor || (CesiumViewMonitor = {}));
18754
18951
 
18755
- var VERSION$1 = "3.1.7";
18952
+ var VERSION$1 = "3.1.9";
18756
18953
 
18757
18954
  export { VERSION$1 as VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, Draw3dPolygon, Draw3dPolyline };
18758
18955
  //# sourceMappingURL=bruce-cesium.es5.js.map