bruce-cesium 2.8.7 → 2.8.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 { BruceEvent, Cartes, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, EntityRelationType, DelayQueue, BatchedDataGetter, EntityCoords, EntityFilterGetter, EntitySource, MenuItem, EntityRelation, ENVIRONMENT, ProjectView, ProjectViewBookmark, ProjectViewTile, ProjectViewLegacyTile, ProgramKey, Camera, AbstractApi, EntityAttachment, EntityAttachmentType, EntityAttribute } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, CallbackProperty, Cartesian3, Color, Rectangle, Math as Math$1, JulianDate, SceneMode, HeightReference, DistanceDisplayCondition, NearFarScalar, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, SceneTransforms, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, KmlDataSource, PolygonPipeline, OrthographicFrustum, EasingFunction, Cesium3DTileset, Matrix4, Matrix3, IonResource, Ion, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, Model, CesiumInspector, ScreenSpaceEventHandler, ScreenSpaceEventType, ColorMaterialProperty, GeometryInstance, BoundingSphere } from 'cesium';
3
+ import { Cartographic, Cartesian2, CallbackProperty, Cartesian3, Color, Rectangle, Math as Math$1, JulianDate, SceneMode, HeightReference, DistanceDisplayCondition, NearFarScalar, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, Cesium3DTileStyle, createOsmBuildings, SceneTransforms, KmlDataSource, OrthographicFrustum, EasingFunction, Cesium3DTileset, Matrix4, Matrix3, IonResource, Ion, EllipsoidTerrainProvider, CesiumInspector, defined, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, Model, createWorldTerrain, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, ScreenSpaceEventHandler, ScreenSpaceEventType, ColorMaterialProperty, GeometryInstance, BoundingSphere } from 'cesium';
4
4
 
5
5
  var TIME_LAG = 300;
6
6
  var POSITION_CHECK_TIMER = 950;
@@ -1939,6 +1939,34 @@ function getSizeOfPolygonEntity(entity) {
1939
1939
  }
1940
1940
  return length;
1941
1941
  }
1942
+ var _billboardCache = new LRUCache(100);
1943
+ var POINT_BILLBOARD_PADDING = 1;
1944
+ var createCircleBillboard = function (size, colorCss) {
1945
+ var key = size + "-" + colorCss;
1946
+ var cacheData = _billboardCache.Get(key);
1947
+ if ((cacheData === null || cacheData === void 0 ? void 0 : cacheData.canvas) instanceof HTMLCanvasElement) {
1948
+ return cacheData;
1949
+ }
1950
+ // Slight padding to avoid corners clipping.
1951
+ var canvasSize = size + (POINT_BILLBOARD_PADDING * 4);
1952
+ var canvas = document.createElement("canvas");
1953
+ canvas.width = canvasSize;
1954
+ canvas.height = canvasSize;
1955
+ var context = canvas.getContext("2d");
1956
+ context.beginPath();
1957
+ context.arc(canvasSize / 2, canvasSize / 2, size / 2, 0, 2 * Math.PI, false);
1958
+ context.fillStyle = colorCss;
1959
+ context.fill();
1960
+ var data = {
1961
+ canvas: canvas,
1962
+ colorCss: colorCss,
1963
+ size: size,
1964
+ height: canvasSize,
1965
+ width: canvasSize
1966
+ };
1967
+ _billboardCache.Set(key, data);
1968
+ return data;
1969
+ };
1942
1970
  var EntityRenderEngine;
1943
1971
  (function (EntityRenderEngine) {
1944
1972
  function Render(params) {
@@ -2199,7 +2227,7 @@ var EntityRenderEngine;
2199
2227
  (function (Point) {
2200
2228
  function Render(params) {
2201
2229
  return __awaiter(this, void 0, void 0, function () {
2202
- var entity, style, type, cEntity, siblings, iconUrlRows, icon, iconUrl_1, res, blob_1, e_4, e_5, iconScale, disableDepthTest, heightRef, radius, bFill, cFill, outline, cOutline, outlineWidth, bOutline, heightRef, pos3d, extrusion, outlineExtrusion, bColor, cColor, size, heightRef;
2230
+ var entity, style, type, cEntity, siblings, iconUrlRows, icon, iconUrl_1, res, blob_1, e_4, e_5, iconScale, disableDepthTest, heightRef, radius, bFill, cFill, outline, cOutline, outlineWidth, bOutline, heightRef, pos3d, extrusion, outlineExtrusion, bColor, cColor, size, heightRef, circleBillboard;
2203
2231
  return __generator(this, function (_a) {
2204
2232
  switch (_a.label) {
2205
2233
  case 0:
@@ -2297,8 +2325,7 @@ var EntityRenderEngine;
2297
2325
  heightReference: getHeightRef(style),
2298
2326
  scale: iconScale,
2299
2327
  disableDepthTestDistance: disableDepthTest ? Number.POSITIVE_INFINITY : undefined,
2300
- distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance),
2301
- height: _fileHeightCache[iconUrl_1]
2328
+ distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
2302
2329
  // Would be great once we have a setting for this.
2303
2330
  // translucencyByDistance: getTranslucencyByDistance(params.minDistance, params.maxDistance),
2304
2331
  },
@@ -2310,6 +2337,7 @@ var EntityRenderEngine;
2310
2337
  }),
2311
2338
  show: true
2312
2339
  });
2340
+ cEntity.billboard._billboardSize = _fileHeightCache[iconUrl_1];
2313
2341
  }
2314
2342
  }
2315
2343
  _a.label = 12;
@@ -2389,11 +2417,22 @@ var EntityRenderEngine;
2389
2417
  return [2 /*return*/, null];
2390
2418
  }
2391
2419
  heightRef = getHeightRef(style);
2420
+ circleBillboard = createCircleBillboard(size, cColor.toCssColorString());
2392
2421
  cEntity = new Entity({
2393
- point: {
2394
- pixelSize: size,
2395
- color: cColor,
2396
- heightReference: getHeightRef(style),
2422
+ // point: {
2423
+ // pixelSize: size,
2424
+ // color: cColor,
2425
+ // heightReference: getHeightRef(style),
2426
+ // distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
2427
+ // },
2428
+ // We are generating a billboard instead of using the point.
2429
+ // This is because points were behaving strangely where they would appear oblong shapes.
2430
+ // This occurred consistently when rendering many icons and points at the same time.
2431
+ billboard: {
2432
+ height: circleBillboard.height,
2433
+ width: circleBillboard.width,
2434
+ image: circleBillboard.canvas,
2435
+ heightReference: heightRef,
2397
2436
  distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
2398
2437
  },
2399
2438
  position: EntityUtils.GetPos({
@@ -2404,6 +2443,7 @@ var EntityRenderEngine;
2404
2443
  }),
2405
2444
  show: true
2406
2445
  });
2446
+ cEntity.billboard._billboardSize = Math.ceil(circleBillboard.height / 2);
2407
2447
  }
2408
2448
  if (cEntity) {
2409
2449
  cEntity._siblingGraphics = siblings;
@@ -3810,12 +3850,12 @@ var EntityLabel;
3810
3850
  return __generator(this, function (_h) {
3811
3851
  switch (_h.label) {
3812
3852
  case 0:
3853
+ this.removeLabel();
3813
3854
  pos3d = starterPos3d ? starterPos3d.clone() : null;
3814
3855
  counter = ++this.counter;
3815
3856
  if (this.disposed) {
3816
3857
  return [2 /*return*/];
3817
3858
  }
3818
- this.removeLabel();
3819
3859
  sizeInM = 0;
3820
3860
  heightRef = null;
3821
3861
  pixelOffset = new Cartesian2(0, -5);
@@ -3900,7 +3940,7 @@ var EntityLabel;
3900
3940
  }
3901
3941
  else if (visual.billboard) {
3902
3942
  heightRef = getValue$1(this.viewer, visual.billboard.heightReference);
3903
- height = getValue$1(this.viewer, visual.billboard.height);
3943
+ height = visual.billboard._billboardSize;
3904
3944
  if (height) {
3905
3945
  scale = EnsureNumber(getValue$1(this.viewer, visual.billboard.scale), 1);
3906
3946
  pixelOffset.y = -(height * scale);
@@ -3950,7 +3990,7 @@ var EntityLabel;
3950
3990
  case 1:
3951
3991
  pos3d = _h.sent();
3952
3992
  heightRef = HeightReference.NONE;
3953
- if (this.counter != counter) {
3993
+ if (this.counter != counter || this.disposed) {
3954
3994
  return [2 /*return*/];
3955
3995
  }
3956
3996
  _h.label = 2;
@@ -4007,11 +4047,17 @@ var EntityLabel;
4007
4047
  if (this.disposed || this.counter != counter) {
4008
4048
  return [2 /*return*/];
4009
4049
  }
4010
- ele = document.createElement("div");
4011
- ele.innerHTML = text;
4012
- ele.setAttribute("style", "\n position: absolute;\n z-index: 0;\n display: none;\n pointer-events: none;\n padding: 6px 8px;\n border-radius: 6px;\n font-family: Arial;\n font-size: 12px;\n -webkit-backdrop-filter: blur(20px);\n backdrop-filter: blur(20px);\n background: rgba(33,39,42,.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 color: #ffffff;\n }");
4013
- this.label = ele;
4014
- this.viewer.container.appendChild(ele);
4050
+ ele = null;
4051
+ if (this.label) {
4052
+ ele = this.label;
4053
+ }
4054
+ else {
4055
+ ele = document.createElement("div");
4056
+ ele.innerHTML = text;
4057
+ ele.setAttribute("style", "\n position: absolute;\n z-index: 0;\n display: none;\n pointer-events: none;\n padding: 6px 8px;\n border-radius: 6px;\n font-family: Arial;\n font-size: 12px;\n -webkit-backdrop-filter: blur(20px);\n backdrop-filter: blur(20px);\n background: rgba(33,39,42,.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 color: #ffffff;\n }");
4058
+ this.label = ele;
4059
+ this.viewer.container.appendChild(ele);
4060
+ }
4015
4061
  _lastDistance = null;
4016
4062
  _lastCameraPos = null;
4017
4063
  getDistance = function () {
@@ -4114,12 +4160,12 @@ var EntityLabel;
4114
4160
  updateLabel();
4115
4161
  terrTimeout = null;
4116
4162
  this.terrChangedRemoval = this.viewer.scene.terrainProviderChanged.addEventListener(function () {
4117
- if (_this.disposed) {
4163
+ clearTimeout(terrTimeout);
4164
+ if (_this.disposed || _this.counter != counter) {
4118
4165
  return;
4119
4166
  }
4120
- clearTimeout(terrTimeout);
4121
4167
  terrTimeout = setTimeout(function () {
4122
- if (counter != _this.counter) {
4168
+ if (_this.disposed || counter != _this.counter) {
4123
4169
  return;
4124
4170
  }
4125
4171
  _this.createLabel(starterPos3d);
@@ -4353,6 +4399,11 @@ function updateEntity(viewer, entityId, register) {
4353
4399
  });
4354
4400
  }
4355
4401
  }
4402
+ else {
4403
+ EntityLabel.Detatch({
4404
+ rego: rego
4405
+ });
4406
+ }
4356
4407
  }
4357
4408
  }
4358
4409
  function markEntity(register, rego, visual, ignoreParent) {
@@ -4952,6 +5003,9 @@ var VisualsRegister;
4952
5003
  if (shouldRetain) {
4953
5004
  continue;
4954
5005
  }
5006
+ EntityLabel.Detatch({
5007
+ rego: rego
5008
+ });
4955
5009
  removeEntity(this.viewer, rego.visual);
4956
5010
  var doesInclude = this.rego[entityId_4].find(function (r) { return r.menuItemId === menuItemId; });
4957
5011
  if (doesInclude) {
@@ -4980,6 +5034,9 @@ var VisualsRegister;
4980
5034
  if (!rego) {
4981
5035
  return { value: void 0 };
4982
5036
  }
5037
+ EntityLabel.Detatch({
5038
+ rego: rego
5039
+ });
4983
5040
  removeEntity(this_2.viewer, rego.visual);
4984
5041
  (_b = this_2.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({
4985
5042
  type: EVisualUpdateType.Remove,
@@ -5007,6 +5064,9 @@ var VisualsRegister;
5007
5064
  if (!rego) {
5008
5065
  continue;
5009
5066
  }
5067
+ EntityLabel.Detatch({
5068
+ rego: rego
5069
+ });
5010
5070
  removeEntity(this.viewer, rego.visual);
5011
5071
  this.rego[entityId_5] = entityRegos.filter(function (r) { return r.menuItemId !== menuItemId; });
5012
5072
  (_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger({
@@ -5027,7 +5087,7 @@ var VisualsRegister;
5027
5087
  /**
5028
5088
  * Returns an array of drilled visuals associated with this register.
5029
5089
  * The top array item is the first found.
5030
- * @param cursor
5090
+ * @param params
5031
5091
  * @returns
5032
5092
  */
5033
5093
  Register.prototype.GetRegosFromCursor = function (params) {
@@ -9951,11 +10011,17 @@ var RelationsRenderManager;
9951
10011
  * @param relation
9952
10012
  */
9953
10013
  Manager.prototype.shouldRenderRelation = function (relation) {
9954
- var _a, _b, _c;
9955
- if (((_a = this.item.relationTypeIds) === null || _a === void 0 ? void 0 : _a.length) && !this.item.relationTypeIds.includes(relation["Relation.Type.ID"])) {
9956
- return false;
10014
+ var _a, _b, _c, _d;
10015
+ if ((_a = this.item.relations) === null || _a === void 0 ? void 0 : _a.length) {
10016
+ // Find group for the same relationship type.
10017
+ var typeRelations = this.item.relations.find(function (x) { return x.relationTypeId == relation["Relation.Type.ID"]; });
10018
+ // See if group contains the parent entity ID.
10019
+ if ((_b = typeRelations === null || typeRelations === void 0 ? void 0 : typeRelations.entityIds) === null || _b === void 0 ? void 0 : _b.find(function (x) { return x == relation["Principal.Entity.ID"]; })) {
10020
+ return true;
10021
+ }
9957
10022
  }
9958
- var renderedIds = (_c = (_b = this.item) === null || _b === void 0 ? void 0 : _b.BruceEntity) === null || _c === void 0 ? void 0 : _c.EntityIds;
10023
+ // Backwards compatability.
10024
+ var renderedIds = (_d = (_c = this.item) === null || _c === void 0 ? void 0 : _c.BruceEntity) === null || _d === void 0 ? void 0 : _d.EntityIds;
9959
10025
  if (!renderedIds) {
9960
10026
  return false;
9961
10027
  }
@@ -10412,8 +10478,7 @@ var MenuItemManager;
10412
10478
  /**
10413
10479
  * Disables a menu item by its id.
10414
10480
  * This will disable all children as well.
10415
- * @param id
10416
- * @param recursive
10481
+ * @param params
10417
10482
  */
10418
10483
  Manager.prototype.RemoveItemById = function (params) {
10419
10484
  var _a, _b;
@@ -12741,6 +12806,7 @@ function assertIteration$1(viewer, iteration) {
12741
12806
  }
12742
12807
  /**
12743
12808
  * Renders DATA_VERSION = 1 navigator.
12809
+ * param iteration
12744
12810
  * @param params
12745
12811
  * @param bookmark
12746
12812
  * @param view
@@ -12864,33 +12930,32 @@ function renderLegacyNavigator(iteration, params, bookmark, view) {
12864
12930
  }
12865
12931
  _f.label = 3;
12866
12932
  case 3:
12867
- if (!((_e = bSettings === null || bSettings === void 0 ? void 0 : bSettings.drawnRelationEntityIDs) === null || _e === void 0 ? void 0 : _e.length)) return [3 /*break*/, 5];
12868
- menuItem = {
12869
- id: RELATION_MENU_ITEM_ID,
12870
- Caption: "Entity relations",
12871
- BruceEntity: {
12872
- EntityIds: bSettings.drawnRelationEntityIDs
12873
- },
12874
- Type: MenuItem.EType.Relations
12875
- };
12876
- return [4 /*yield*/, params.manager.RenderItem({
12933
+ if ((_e = bSettings === null || bSettings === void 0 ? void 0 : bSettings.drawnRelationEntityIDs) === null || _e === void 0 ? void 0 : _e.length) {
12934
+ menuItem = {
12935
+ id: RELATION_MENU_ITEM_ID,
12936
+ Caption: "Entity relations",
12937
+ BruceEntity: {
12938
+ EntityIds: bSettings.drawnRelationEntityIDs
12939
+ },
12940
+ Type: MenuItem.EType.Relations
12941
+ };
12942
+ params.manager.RenderItem({
12877
12943
  apiGetter: params.apiGetter,
12878
12944
  getters: params.getters,
12879
12945
  item: menuItem
12880
- })];
12881
- case 4:
12882
- _f.sent();
12883
- if (!assertIteration$1(params.viewer, iteration)) {
12884
- return [2 /*return*/];
12946
+ });
12947
+ if (!assertIteration$1(params.viewer, iteration)) {
12948
+ return [2 /*return*/];
12949
+ }
12885
12950
  }
12886
- _f.label = 5;
12887
- case 5: return [2 /*return*/];
12951
+ return [2 /*return*/];
12888
12952
  }
12889
12953
  });
12890
12954
  });
12891
12955
  }
12892
12956
  /**
12893
12957
  * Renders DATA_VERSION > 1 navigator.
12958
+ * @param iteration
12894
12959
  * @param params
12895
12960
  * @param bookmark
12896
12961
  * @param view
@@ -12898,7 +12963,7 @@ function renderLegacyNavigator(iteration, params, bookmark, view) {
12898
12963
  function renderNavigator(iteration, params, bookmark, view) {
12899
12964
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
12900
12965
  return __awaiter(this, void 0, void 0, function () {
12901
- var viewer, scene, vSettings, bSettings, defaults, camera, newLens, shouldBe2d, curIs2d, transition, pos, terrain, hillShades, baseColor, globeHidden, terrainWireframe, globeAlpha, shadows, size, ambientOcclusion, AO, lighting, light, quality, fxaa, dateTime, clock, selectedIds, hiddenIds, isolatedIds, labelledIds, entityOpacityMap, entityId, opacity, imagery, renderedRelationEntityIds, curEnabled, newItemIds, _i, curEnabled_1, id, menuItem, gOcclusion;
12966
+ var viewer, scene, vSettings, bSettings, defaults, camera, newLens, shouldBe2d, curIs2d, transition, pos, terrain, hillShades, baseColor, globeHidden, terrainWireframe, globeAlpha, shadows, size, ambientOcclusion, AO, lighting, light, quality, fxaa, dateTime, clock, selectedIds, hiddenIds, isolatedIds, labelledIds, curLabelledIds, toUnLabel, entityOpacityMap, entityId, opacity, imagery, legacyRelationIds, relations, curEnabled, newItemIds, _i, curEnabled_1, id, menuItem, gOcclusion;
12902
12967
  return __generator(this, function (_7) {
12903
12968
  switch (_7.label) {
12904
12969
  case 0:
@@ -13126,15 +13191,24 @@ function renderNavigator(iteration, params, bookmark, view) {
13126
13191
  entityIds: isolatedIds
13127
13192
  });
13128
13193
  }
13129
- params.manager.VisualsRegister.ClearLabelled();
13130
13194
  labelledIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.labelledEntityIds;
13131
13195
  if (labelledIds == null) {
13132
13196
  labelledIds = (_2 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _2 === void 0 ? void 0 : _2.labelledEntityIds;
13133
13197
  }
13134
- if (labelledIds != null) {
13198
+ if (!(labelledIds === null || labelledIds === void 0 ? void 0 : labelledIds.length)) {
13199
+ params.manager.VisualsRegister.ClearLabelled();
13200
+ }
13201
+ else {
13202
+ curLabelledIds = params.manager.VisualsRegister.GetLabelled();
13135
13203
  params.manager.VisualsRegister.SetLabelled({
13136
13204
  labelled: true,
13137
- entityIds: labelledIds
13205
+ entityIds: labelledIds,
13206
+ requestRender: false
13207
+ });
13208
+ toUnLabel = curLabelledIds.filter(function (id) { return labelledIds.indexOf(id) === -1; });
13209
+ params.manager.VisualsRegister.SetLabelled({
13210
+ labelled: false,
13211
+ entityIds: toUnLabel
13138
13212
  });
13139
13213
  }
13140
13214
  params.manager.VisualsRegister.ClearOpacity();
@@ -13175,16 +13249,20 @@ function renderNavigator(iteration, params, bookmark, view) {
13175
13249
  tiles: imagery,
13176
13250
  viewer: params.manager.Viewer,
13177
13251
  });
13178
- renderedRelationEntityIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.renderedEntityRelations;
13179
- if (!renderedRelationEntityIds) {
13180
- renderedRelationEntityIds = [];
13252
+ legacyRelationIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.renderedEntityRelations;
13253
+ if (!legacyRelationIds) {
13254
+ legacyRelationIds = [];
13255
+ }
13256
+ relations = bSettings === null || bSettings === void 0 ? void 0 : bSettings.renderedRelations;
13257
+ if (!relations) {
13258
+ relations = [];
13181
13259
  }
13182
13260
  curEnabled = params.manager.GetEnabledItemIds();
13183
13261
  newItemIds = (_5 = bSettings === null || bSettings === void 0 ? void 0 : bSettings.menuItemIds) !== null && _5 !== void 0 ? _5 : [];
13184
13262
  for (_i = 0, curEnabled_1 = curEnabled; _i < curEnabled_1.length; _i++) {
13185
13263
  id = curEnabled_1[_i];
13186
- if (newItemIds.indexOf(id) === -1 ||
13187
- (id == RELATION_MENU_ITEM_ID && !renderedRelationEntityIds.length)) {
13264
+ if ((newItemIds.indexOf(id) === -1 && id != RELATION_MENU_ITEM_ID) ||
13265
+ (id == RELATION_MENU_ITEM_ID && !legacyRelationIds.length && !relations.length)) {
13188
13266
  params.manager.RemoveItemById({
13189
13267
  menuItemId: id
13190
13268
  });
@@ -13204,26 +13282,24 @@ function renderNavigator(iteration, params, bookmark, view) {
13204
13282
  }
13205
13283
  _7.label = 4;
13206
13284
  case 4:
13207
- if (!renderedRelationEntityIds.length) return [3 /*break*/, 6];
13208
- menuItem = {
13209
- id: RELATION_MENU_ITEM_ID,
13210
- Caption: "Entity relations",
13211
- BruceEntity: {
13212
- EntityIds: renderedRelationEntityIds
13213
- },
13214
- Type: MenuItem.EType.Relations
13215
- };
13216
- return [4 /*yield*/, params.manager.RenderItem({
13285
+ if (legacyRelationIds.length || relations.length) {
13286
+ menuItem = {
13287
+ id: RELATION_MENU_ITEM_ID,
13288
+ Caption: "Entity relations",
13289
+ BruceEntity: {
13290
+ EntityIds: legacyRelationIds
13291
+ },
13292
+ relations: relations,
13293
+ Type: MenuItem.EType.Relations
13294
+ };
13295
+ params.manager.RenderItem({
13217
13296
  getters: params.getters,
13218
13297
  item: menuItem
13219
- })];
13220
- case 5:
13221
- _7.sent();
13222
- if (!assertIteration$1(params.viewer, iteration)) {
13223
- return [2 /*return*/];
13298
+ });
13299
+ if (!assertIteration$1(params.viewer, iteration)) {
13300
+ return [2 /*return*/];
13301
+ }
13224
13302
  }
13225
- _7.label = 6;
13226
- case 6:
13227
13303
  gOcclusion = bSettings === null || bSettings === void 0 ? void 0 : bSettings.groundOcclusion;
13228
13304
  if (gOcclusion == null) {
13229
13305
  gOcclusion = (_6 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _6 === void 0 ? void 0 : _6.groundOcclusion;
@@ -15977,9 +16053,13 @@ function backgroundRendering(viewer) {
15977
16053
  // We check in case something else is also requesting renders.
15978
16054
  var lastRenderTime = viewer.scene.lastRenderTime;
15979
16055
  if (!lastRenderTime || JulianDate.secondsDifference(JulianDate.now(), lastRenderTime) > 3) {
15980
- viewer.scene.requestRender();
16056
+ // Check if window is active/in focus.
16057
+ // TODO: Should render the moment it is in focus as well.
16058
+ if (document.hasFocus()) {
16059
+ viewer.scene.requestRender();
16060
+ }
15981
16061
  }
15982
- }, 3500);
16062
+ }, 1500);
15983
16063
  }
15984
16064
  var ViewerUtils;
15985
16065
  (function (ViewerUtils) {
@@ -16133,7 +16213,7 @@ var ViewerUtils;
16133
16213
  ViewerUtils.CreateWidgets = CreateWidgets;
16134
16214
  })(ViewerUtils || (ViewerUtils = {}));
16135
16215
 
16136
- var VERSION$1 = "2.8.7";
16216
+ var VERSION$1 = "2.8.9";
16137
16217
 
16138
16218
  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 };
16139
16219
  //# sourceMappingURL=bruce-cesium.es5.js.map