bruce-cesium 3.4.0 → 3.4.2

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.
@@ -8146,6 +8146,10 @@
8146
8146
  }
8147
8147
  ];
8148
8148
  }
8149
+ if (this.renderAsGeojson && this.item.CameraZoomSettings.length > 1) {
8150
+ console.warn("Geojson rendering does not support multiple zoom controls. Only the first one will be used.");
8151
+ this.item.CameraZoomSettings = [this.item.CameraZoomSettings[0]];
8152
+ }
8149
8153
  var isTagItem = Boolean(this.item.BruceEntity.ExpandLayers);
8150
8154
  var tagsToRender = isTagItem ? this.item.BruceEntity.SelectedExpandLayers : null;
8151
8155
  if (!tagsToRender) {
@@ -8329,6 +8333,10 @@
8329
8333
  }
8330
8334
  if (CameraZoomSettings === null || CameraZoomSettings === void 0 ? void 0 : CameraZoomSettings.length) {
8331
8335
  this.item.CameraZoomSettings = CameraZoomSettings;
8336
+ if (this.renderAsGeojson && this.item.CameraZoomSettings.length > 1) {
8337
+ console.warn("Geojson rendering does not support multiple zoom controls. Only the first one will be used.");
8338
+ this.item.CameraZoomSettings = [this.item.CameraZoomSettings[0]];
8339
+ }
8332
8340
  this.setGetter();
8333
8341
  }
8334
8342
  if (queueRerender != false) {
@@ -8423,11 +8431,11 @@
8423
8431
  var _a;
8424
8432
  if (force === void 0) { force = false; }
8425
8433
  return __awaiter(this, void 0, void 0, function () {
8426
- var typeId_1, e_3;
8434
+ var typeId_1, zoomItem, e_3;
8427
8435
  return __generator(this, function (_b) {
8428
8436
  switch (_b.label) {
8429
8437
  case 0:
8430
- _b.trys.push([0, 5, , 6]);
8438
+ _b.trys.push([0, 8, , 9]);
8431
8439
  if (this.disposed || this.viewer.isDestroyed()) {
8432
8440
  return [2 /*return*/];
8433
8441
  }
@@ -8435,21 +8443,30 @@
8435
8443
  if (typeId_1) {
8436
8444
  entities = entities.filter(function (x) { var _a; return ((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"]) == typeId_1; });
8437
8445
  }
8438
- if (!this.useGeojson) return [3 /*break*/, 2];
8439
- return [4 /*yield*/, this.renderAsGeojson(entities, force)];
8446
+ if (!this.useGeojson) return [3 /*break*/, 5];
8447
+ zoomItem = this.item.CameraZoomSettings[0];
8448
+ if (!(zoomItem.DisplayType == bruceModels.ZoomControl.EDisplayType.Point)) return [3 /*break*/, 2];
8449
+ // We'll just render these as individuals since we don't support point geojson.
8450
+ return [4 /*yield*/, this.renderAsIndividuals(entities, force)];
8440
8451
  case 1:
8452
+ // We'll just render these as individuals since we don't support point geojson.
8441
8453
  _b.sent();
8442
8454
  return [3 /*break*/, 4];
8443
- case 2: return [4 /*yield*/, this.renderAsIndividuals(entities, force)];
8455
+ case 2: return [4 /*yield*/, this.renderAsGeojson(entities, force)];
8444
8456
  case 3:
8445
8457
  _b.sent();
8446
8458
  _b.label = 4;
8447
- case 4: return [3 /*break*/, 6];
8448
- case 5:
8459
+ case 4: return [3 /*break*/, 7];
8460
+ case 5: return [4 /*yield*/, this.renderAsIndividuals(entities, force)];
8461
+ case 6:
8462
+ _b.sent();
8463
+ _b.label = 7;
8464
+ case 7: return [3 /*break*/, 9];
8465
+ case 8:
8449
8466
  e_3 = _b.sent();
8450
8467
  console.error(e_3);
8451
- return [3 /*break*/, 6];
8452
- case 6: return [2 /*return*/];
8468
+ return [3 /*break*/, 9];
8469
+ case 9: return [2 /*return*/];
8453
8470
  }
8454
8471
  });
8455
8472
  });
@@ -8461,12 +8478,12 @@
8461
8478
  * @param force TODO: This should re-render entities that are already rendered.
8462
8479
  */
8463
8480
  Manager.prototype.renderAsGeojson = function (entities, force) {
8464
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
8481
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
8465
8482
  return __awaiter(this, void 0, void 0, function () {
8466
- var zoomItem, style, e_4, entityType, e_5, pStyle, lStyle, polygonsClamped, bFillColor, cFillColor, bLineColor, cLineColor, lineWidthPx, geojson, source, groups, applyStyle, register, sEntities, i, cEntity;
8483
+ var zoomItem, lods, withLods_1, individuals, style, e_4, entityTypeId, entityType, e_5, pStyle, lStyle, polygonsClamped, bFillColor, cFillColor, bLineColor, cLineColor, lineWidthPx, geojson, notRendered, source, groups, applyStyle, register, sEntities, i, cEntity;
8467
8484
  var _this = this;
8468
- return __generator(this, function (_k) {
8469
- switch (_k.label) {
8485
+ return __generator(this, function (_o) {
8486
+ switch (_o.label) {
8470
8487
  case 0:
8471
8488
  entities = entities.filter(function (entity) {
8472
8489
  var _a;
@@ -8478,48 +8495,96 @@
8478
8495
  _this.renderedEntities[(_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID] = true;
8479
8496
  });
8480
8497
  zoomItem = this.item.CameraZoomSettings[0];
8481
- style = null;
8482
- if (!(zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID)) return [3 /*break*/, 4];
8483
- _k.label = 1;
8498
+ if (!(zoomItem.DisplayType == bruceModels.ZoomControl.EDisplayType.Model3D && entities.length)) return [3 /*break*/, 2];
8499
+ return [4 /*yield*/, bruceModels.EntityLod.GetLods({
8500
+ api: this.apiGetter.getApi(),
8501
+ filter: {
8502
+ externalSources: false,
8503
+ Items: entities.map(function (x) {
8504
+ var _a, _b;
8505
+ return {
8506
+ entityId: (_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID,
8507
+ categoryId: (_b = zoomItem.LODCategoryID) !== null && _b !== void 0 ? _b : "GLB",
8508
+ group: "DEFAULT",
8509
+ level: Number(zoomItem.LODLevel)
8510
+ };
8511
+ }),
8512
+ strict: false
8513
+ }
8514
+ })];
8484
8515
  case 1:
8485
- _k.trys.push([1, 3, , 4]);
8516
+ lods = (_o.sent()).lods;
8517
+ if (this.disposed) {
8518
+ this.doDispose();
8519
+ return [2 /*return*/];
8520
+ }
8521
+ withLods_1 = lods.filter(function (x) { return x.entityId && !!x.clientFileId; }).map(function (x) { return x.entityId; });
8522
+ individuals = entities.filter(function (entity) {
8523
+ var _a;
8524
+ return withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
8525
+ });
8526
+ if (individuals.length) {
8527
+ this.renderAsIndividuals(individuals, force);
8528
+ }
8529
+ // Now we proceed with what is left.
8530
+ entities = entities.filter(function (entity) {
8531
+ var _a;
8532
+ return !withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
8533
+ });
8534
+ _o.label = 2;
8535
+ case 2:
8536
+ if (!entities.length) {
8537
+ return [2 /*return*/];
8538
+ }
8539
+ style = null;
8540
+ if (!((zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) && (zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) > -1)) return [3 /*break*/, 6];
8541
+ _o.label = 3;
8542
+ case 3:
8543
+ _o.trys.push([3, 5, , 6]);
8486
8544
  return [4 /*yield*/, bruceModels.Style.Get({
8487
8545
  api: this.apiGetter.getApi(),
8488
8546
  styleId: zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID
8489
8547
  })];
8490
- case 2:
8491
- style = (_a = (_k.sent()).style) === null || _a === void 0 ? void 0 : _a.Settings;
8492
- return [3 /*break*/, 4];
8493
- case 3:
8494
- e_4 = _k.sent();
8495
- console.error(e_4);
8496
- return [3 /*break*/, 4];
8497
8548
  case 4:
8498
- _k.trys.push([4, 8, , 9]);
8549
+ style = (_a = (_o.sent()).style) === null || _a === void 0 ? void 0 : _a.Settings;
8550
+ return [3 /*break*/, 6];
8551
+ case 5:
8552
+ e_4 = _o.sent();
8553
+ console.error(e_4);
8554
+ return [3 /*break*/, 6];
8555
+ case 6:
8556
+ entityTypeId = (_b = this.item.BruceEntity) === null || _b === void 0 ? void 0 : _b["EntityType.ID"];
8557
+ if (!entityTypeId) {
8558
+ entityTypeId = (_d = (_c = entities.find(function (x) { var _a; return !!((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"]); })) === null || _c === void 0 ? void 0 : _c.Bruce) === null || _d === void 0 ? void 0 : _d["EntityType.ID"];
8559
+ }
8560
+ if (!entityTypeId) return [3 /*break*/, 12];
8561
+ _o.label = 7;
8562
+ case 7:
8563
+ _o.trys.push([7, 11, , 12]);
8499
8564
  return [4 /*yield*/, bruceModels.EntityType.Get({
8500
- entityTypeId: this.item.BruceEntity["EntityType.ID"],
8565
+ entityTypeId: entityTypeId,
8501
8566
  api: this.apiGetter.getApi()
8502
8567
  })];
8503
- case 5:
8504
- entityType = (_b = (_k.sent())) === null || _b === void 0 ? void 0 : _b.entityType;
8505
- if (!(!style && ((_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c["EntityType.ID"]))) return [3 /*break*/, 7];
8506
- if (!entityType["DisplaySetting.ID"]) return [3 /*break*/, 7];
8568
+ case 8:
8569
+ entityType = (_e = (_o.sent())) === null || _e === void 0 ? void 0 : _e.entityType;
8570
+ if (!(!style && entityType)) return [3 /*break*/, 10];
8571
+ if (!(entityType["DisplaySetting.ID"] && entityType["DisplaySetting.ID"] > 0)) return [3 /*break*/, 10];
8507
8572
  return [4 /*yield*/, bruceModels.Style.Get({
8508
8573
  api: this.apiGetter.getApi(),
8509
8574
  styleId: entityType["DisplaySetting.ID"]
8510
8575
  })];
8511
- case 6:
8512
- style = (_d = (_k.sent()).style) === null || _d === void 0 ? void 0 : _d.Settings;
8513
- _k.label = 7;
8514
- case 7: return [3 /*break*/, 9];
8515
- case 8:
8516
- e_5 = _k.sent();
8517
- console.error(e_5);
8518
- return [3 /*break*/, 9];
8519
8576
  case 9:
8520
- pStyle = (_e = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _e !== void 0 ? _e : {};
8521
- lStyle = (_f = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _f !== void 0 ? _f : {};
8522
- polygonsClamped = ((_g = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _g === void 0 ? void 0 : _g.id) == null ? true : ((_h = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _h === void 0 ? void 0 : _h.id) == 0;
8577
+ style = (_f = (_o.sent()).style) === null || _f === void 0 ? void 0 : _f.Settings;
8578
+ _o.label = 10;
8579
+ case 10: return [3 /*break*/, 12];
8580
+ case 11:
8581
+ e_5 = _o.sent();
8582
+ console.error(e_5);
8583
+ return [3 /*break*/, 12];
8584
+ case 12:
8585
+ pStyle = (_g = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _g !== void 0 ? _g : {};
8586
+ lStyle = (_h = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _h !== void 0 ? _h : {};
8587
+ polygonsClamped = ((_j = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _j === void 0 ? void 0 : _j.id) == null ? true : ((_k = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _k === void 0 ? void 0 : _k.id) == 0;
8523
8588
  bFillColor = bruceModels.Calculator.GetColor(pStyle.fillColor, {}, []);
8524
8589
  cFillColor = bFillColor ? colorToCColor$2(bFillColor) : Cesium.Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
8525
8590
  bLineColor = bruceModels.Calculator.GetColor(pStyle.lineColor, {}, []);
@@ -8541,7 +8606,16 @@
8541
8606
  // No points.
8542
8607
  allowedDisplayTypes: [bruceModels.ZoomControl.EDisplayType.Geometry]
8543
8608
  });
8544
- if (!((_j = geojson === null || geojson === void 0 ? void 0 : geojson.features) === null || _j === void 0 ? void 0 : _j.length)) {
8609
+ notRendered = !((_l = geojson === null || geojson === void 0 ? void 0 : geojson.features) === null || _l === void 0 ? void 0 : _l.length) ? entities : entities.filter(function (entity) {
8610
+ return !geojson.features.some(function (feature) {
8611
+ var _a, _b, _c;
8612
+ return ((_b = (_a = feature.properties) === null || _a === void 0 ? void 0 : _a.Bruce) === null || _b === void 0 ? void 0 : _b.ID) == ((_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c.ID);
8613
+ });
8614
+ });
8615
+ if (notRendered.length) {
8616
+ this.renderAsIndividuals(notRendered, force);
8617
+ }
8618
+ if (!((_m = geojson === null || geojson === void 0 ? void 0 : geojson.features) === null || _m === void 0 ? void 0 : _m.length)) {
8545
8619
  return [2 /*return*/];
8546
8620
  }
8547
8621
  return [4 /*yield*/, Cesium.GeoJsonDataSource.load(geojson, {
@@ -8550,8 +8624,8 @@
8550
8624
  strokeWidth: lineWidthPx,
8551
8625
  clampToGround: lineWidthPx <= 0 && polygonsClamped
8552
8626
  })];
8553
- case 10:
8554
- source = _k.sent();
8627
+ case 13:
8628
+ source = _o.sent();
8555
8629
  this.viewer.dataSources.add(source);
8556
8630
  this.sources.push(source);
8557
8631
  if (this.disposed) {
@@ -8627,6 +8701,7 @@
8627
8701
  if (!entityId) {
8628
8702
  return;
8629
8703
  }
8704
+ var needsUpdate = false;
8630
8705
  // Find group for the nextspace entity ID.
8631
8706
  group = groups.find(function (x) { return x.entityId == entityId; });
8632
8707
  // No group yet. We can designate this as the primary entity and create a new group for it.
@@ -8649,11 +8724,11 @@
8649
8724
  entityTypeId: group.entityTypeId,
8650
8725
  accountId: _this.apiGetter.accountId,
8651
8726
  tagIds: group.tagIds ? [].concat(group.tagIds) : [],
8652
- name: (_d = bruceModels.Entity.CalculateName({
8727
+ name: entityType ? (_d = bruceModels.Entity.CalculateName({
8653
8728
  entity: group.data,
8654
8729
  type: entityType,
8655
8730
  defaultToId: false
8656
- })) !== null && _d !== void 0 ? _d : "Unnamed Entity",
8731
+ })) !== null && _d !== void 0 ? _d : "Unnamed Entity" : "Unnamed Entity",
8657
8732
  cdn: _this.item.cdnEnabled,
8658
8733
  collection: source.entities
8659
8734
  };
@@ -8672,9 +8747,15 @@
8672
8747
  _this.visualsManager.RefreshMark({
8673
8748
  rego: group.rego
8674
8749
  });
8750
+ needsUpdate = true;
8675
8751
  }
8676
8752
  }
8677
8753
  applyStyle(thing, entityId, group.data);
8754
+ if (needsUpdate) {
8755
+ _this.visualsManager.ForceUpdate({
8756
+ entityIds: [entityId],
8757
+ });
8758
+ }
8678
8759
  };
8679
8760
  sEntities = source.entities.values;
8680
8761
  for (i = 0; i < sEntities.length; i++) {
@@ -8860,6 +8941,15 @@
8860
8941
 
8861
8942
  var BATCH_SIZE$1 = 500;
8862
8943
  var CHECK_BATCH_SIZE$1 = 250;
8944
+ function getValue$4(viewer, obj) {
8945
+ if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
8946
+ return obj.getValue(viewer.scene.lastRenderTime);
8947
+ }
8948
+ return obj;
8949
+ }
8950
+ function colorToCColor$3(color) {
8951
+ return new Cesium.Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
8952
+ }
8863
8953
  (function (EntitiesLoadedRenderManager) {
8864
8954
  var Manager = /** @class */ (function () {
8865
8955
  function Manager(params) {
@@ -8868,12 +8958,17 @@
8868
8958
  this.getterSub = null;
8869
8959
  this.disposed = false;
8870
8960
  this.renderedEntities = {};
8961
+ this.sources = [];
8962
+ // Highly experimental flag to try improve rendering large sets of polygons and polylines.
8963
+ // Many things are not supported when this is enabled.
8964
+ this.useGeojson = false;
8871
8965
  var viewer = params.viewer, apiGetter = params.apiGetter, monitor = params.monitor, item = params.item, visualsManager = params.register;
8872
8966
  this.viewer = viewer;
8873
8967
  this.apiGetter = apiGetter;
8874
8968
  this.monitor = monitor;
8875
8969
  this.item = item;
8876
8970
  this.visualsManager = visualsManager;
8971
+ this.useGeojson = item.renderAsGeojson == true;
8877
8972
  if (!((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.Entities)) {
8878
8973
  this.item.BruceEntity = __assign(__assign({}, this.item.BruceEntity), { Entities: [] });
8879
8974
  }
@@ -8970,6 +9065,10 @@
8970
9065
  }
8971
9066
  ];
8972
9067
  }
9068
+ if (this.renderAsGeojson && this.item.CameraZoomSettings.length > 1) {
9069
+ console.warn("Geojson rendering does not support multiple zoom controls. Only the first one will be used.");
9070
+ this.item.CameraZoomSettings = [this.item.CameraZoomSettings[0]];
9071
+ }
8973
9072
  this.recreateGetter();
8974
9073
  };
8975
9074
  /**
@@ -8995,16 +9094,24 @@
8995
9094
  this.getter.Start();
8996
9095
  };
8997
9096
  Manager.prototype.Dispose = function () {
8998
- var _a;
8999
9097
  if (this.disposed) {
9000
9098
  return;
9001
9099
  }
9100
+ this.doDispose();
9101
+ };
9102
+ Manager.prototype.doDispose = function () {
9103
+ var _a;
9002
9104
  (_a = this.getterSub) === null || _a === void 0 ? void 0 : _a.call(this);
9003
9105
  this.getterSub = null;
9004
9106
  this.disposed = true;
9005
9107
  this.visualsManager.RemoveRegos({
9006
9108
  menuItemId: this.item.id
9007
9109
  });
9110
+ for (var i = 0; i < this.sources.length; i++) {
9111
+ var source = this.sources[i];
9112
+ this.viewer.dataSources.remove(source);
9113
+ }
9114
+ this.sources = [];
9008
9115
  };
9009
9116
  Manager.prototype.ReRender = function (params) {
9010
9117
  return __awaiter(this, void 0, void 0, function () {
@@ -9049,6 +9156,10 @@
9049
9156
  }
9050
9157
  if (CameraZoomSettings === null || CameraZoomSettings === void 0 ? void 0 : CameraZoomSettings.length) {
9051
9158
  this.item.CameraZoomSettings = CameraZoomSettings;
9159
+ if (this.renderAsGeojson && this.item.CameraZoomSettings.length > 1) {
9160
+ console.warn("Geojson rendering does not support multiple zoom controls. Only the first one will be used.");
9161
+ this.item.CameraZoomSettings = [this.item.CameraZoomSettings[0]];
9162
+ }
9052
9163
  }
9053
9164
  if (queueRerender != false) {
9054
9165
  var entityIds = Object.keys(this.renderedEntities);
@@ -9113,15 +9224,14 @@
9113
9224
  });
9114
9225
  };
9115
9226
  Manager.prototype.onGetterUpdate = function (entities, force) {
9116
- var _a;
9117
9227
  if (force === void 0) { force = false; }
9118
9228
  return __awaiter(this, void 0, void 0, function () {
9119
- var isEntityInItem_1, cEntities, i, entity, id, cEntity, visual, e_2;
9229
+ var isEntityInItem_1, zoomItem, e_2;
9120
9230
  var _this = this;
9121
- return __generator(this, function (_b) {
9122
- switch (_b.label) {
9231
+ return __generator(this, function (_a) {
9232
+ switch (_a.label) {
9123
9233
  case 0:
9124
- _b.trys.push([0, 2, , 3]);
9234
+ _a.trys.push([0, 8, , 9]);
9125
9235
  if (this.disposed || this.viewer.isDestroyed()) {
9126
9236
  return [2 /*return*/];
9127
9237
  }
@@ -9135,157 +9245,523 @@
9135
9245
  var _a;
9136
9246
  return isEntityInItem_1((_a = x === null || x === void 0 ? void 0 : x.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
9137
9247
  });
9138
- return [4 /*yield*/, exports.EntityRenderEngine.Render({
9139
- viewer: this.viewer,
9140
- apiGetter: this.apiGetter,
9141
- entities: entities,
9142
- menuItemId: this.item.id,
9143
- visualRegister: this.visualsManager,
9144
- zoomControl: this.item.CameraZoomSettings,
9145
- force: force
9146
- })];
9248
+ if (!this.useGeojson) return [3 /*break*/, 5];
9249
+ zoomItem = this.item.CameraZoomSettings[0];
9250
+ if (!(zoomItem.DisplayType == bruceModels.ZoomControl.EDisplayType.Point)) return [3 /*break*/, 2];
9251
+ // We'll just render these as individuals since we don't support point geojson.
9252
+ return [4 /*yield*/, this.renderAsIndividuals(entities, force)];
9147
9253
  case 1:
9148
- cEntities = _b.sent();
9149
- if (this.disposed) {
9150
- this.visualsManager.RemoveRegos({
9151
- menuItemId: this.item.id
9152
- });
9153
- return [2 /*return*/];
9154
- }
9155
- for (i = 0; i < entities.length; i++) {
9156
- entity = entities[i];
9157
- id = entity.Bruce.ID;
9158
- cEntity = cEntities[id];
9159
- this.renderedEntities[id] = !!cEntity;
9160
- if (cEntity && isEntityInItem_1(id)) {
9161
- visual = (_a = this.visualsManager.GetRego({
9162
- entityId: id,
9163
- menuItemId: this.item.id
9164
- })) === null || _a === void 0 ? void 0 : _a.visual;
9165
- if (!visual || visual != cEntity) {
9166
- this.visualsManager.AddRego({
9167
- rego: {
9168
- entityId: id,
9169
- menuItemId: this.item.id,
9170
- visual: cEntity,
9171
- priority: 0,
9172
- entityTypeId: entity.Bruce["EntityType.ID"],
9173
- accountId: this.apiGetter.accountId,
9174
- name: cEntity.name
9175
- },
9176
- requestRender: false
9177
- });
9178
- }
9179
- }
9180
- else {
9181
- this.visualsManager.RemoveRegos({
9182
- entityId: id,
9183
- menuItemId: this.item.id,
9184
- requestRender: false
9185
- });
9186
- }
9187
- }
9188
- this.viewer.scene.requestRender();
9189
- return [3 /*break*/, 3];
9190
- case 2:
9191
- e_2 = _b.sent();
9254
+ // We'll just render these as individuals since we don't support point geojson.
9255
+ _a.sent();
9256
+ return [3 /*break*/, 4];
9257
+ case 2: return [4 /*yield*/, this.renderAsGeojson(entities, force)];
9258
+ case 3:
9259
+ _a.sent();
9260
+ _a.label = 4;
9261
+ case 4: return [3 /*break*/, 7];
9262
+ case 5: return [4 /*yield*/, this.renderAsIndividuals(entities, force)];
9263
+ case 6:
9264
+ _a.sent();
9265
+ _a.label = 7;
9266
+ case 7: return [3 /*break*/, 9];
9267
+ case 8:
9268
+ e_2 = _a.sent();
9192
9269
  console.error(e_2);
9193
- return [3 /*break*/, 3];
9194
- case 3: return [2 /*return*/];
9270
+ return [3 /*break*/, 9];
9271
+ case 9: return [2 /*return*/];
9195
9272
  }
9196
9273
  });
9197
9274
  });
9198
9275
  };
9199
- return Manager;
9200
- }());
9201
- EntitiesLoadedRenderManager.Manager = Manager;
9202
- })(exports.EntitiesLoadedRenderManager || (exports.EntitiesLoadedRenderManager = {}));
9203
-
9204
- var BATCH_SIZE$2 = 500;
9205
- (function (EntitiesIdsRenderManager) {
9206
- var Manager = /** @class */ (function () {
9207
- function Manager(params) {
9208
- var _a;
9209
- this.getter = null;
9210
- this.getterSub = null;
9211
- this.disposed = false;
9212
- this.renderedEntities = {};
9213
- var viewer = params.viewer, apiGetter = params.apiGetter, monitor = params.monitor, item = params.item, visualsManager = params.register;
9214
- this.viewer = viewer;
9215
- this.apiGetter = apiGetter;
9216
- this.monitor = monitor;
9217
- this.item = item;
9218
- this.visualsManager = visualsManager;
9219
- if (this.item.enableClustering) {
9220
- this.clustering = new PointClustering(visualsManager, this.item.id, (_a = this.item) === null || _a === void 0 ? void 0 : _a.clustering);
9221
- }
9222
- }
9223
- Object.defineProperty(Manager.prototype, "Disposed", {
9224
- get: function () {
9225
- return this.disposed;
9226
- },
9227
- enumerable: false,
9228
- configurable: true
9229
- });
9230
- Manager.prototype.Init = function () {
9231
- var _this = this;
9232
- var _a;
9233
- if (this.disposed) {
9234
- throw (new Error("This item is disposed."));
9235
- }
9236
- if (!((_a = this.item.CameraZoomSettings) === null || _a === void 0 ? void 0 : _a.length)) {
9237
- this.item.CameraZoomSettings = [
9238
- {
9239
- MinZoom: 0,
9240
- MaxZoom: 100000,
9241
- DisplayType: bruceModels.ZoomControl.EDisplayType.Model3D,
9242
- LODCategoryID: "glb",
9243
- LODLevel: 0,
9244
- StyleID: 0
9245
- }
9246
- ];
9247
- }
9248
- this.getter = new BatchedDataGetter.Getter(this.item.BruceEntity.EntityIds, this.monitor, BATCH_SIZE$2);
9249
- this.getterSub = this.getter.OnUpdate.Subscribe(function (ids) {
9250
- _this.onGetterUpdate(ids);
9251
- });
9252
- this.getter.Start();
9253
- };
9254
- Manager.prototype.Dispose = function () {
9255
- var _a, _b;
9256
- if (this.disposed) {
9257
- return;
9258
- }
9259
- (_a = this.getterSub) === null || _a === void 0 ? void 0 : _a.call(this);
9260
- this.getterSub = null;
9261
- this.disposed = true;
9262
- this.visualsManager.RemoveRegos({
9263
- menuItemId: this.item.id
9264
- });
9265
- (_b = this.clustering) === null || _b === void 0 ? void 0 : _b.Dispose();
9266
- };
9267
- Manager.prototype.ReRender = function (params) {
9276
+ /**
9277
+ * Our optimized and more stable path.
9278
+ * We construct a geojson that we draw in one go.
9279
+ * @param entities
9280
+ * @param force TODO: This should re-render entities that are already rendered.
9281
+ */
9282
+ Manager.prototype.renderAsGeojson = function (entities, force) {
9283
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
9268
9284
  return __awaiter(this, void 0, void 0, function () {
9269
- var entityIds, force, entities;
9285
+ var zoomItem, lods, withLods_1, individuals, style, e_3, entityTypeId, entityType, e_4, pStyle, lStyle, polygonsClamped, bFillColor, cFillColor, bLineColor, cLineColor, lineWidthPx, geojson, notRendered, source, groups, applyStyle, register, sEntities, i, cEntity;
9270
9286
  var _this = this;
9271
- return __generator(this, function (_a) {
9272
- entityIds = params.entityIds, force = params.force, entities = params.entities;
9273
- if (entities && !entityIds) {
9274
- entityIds = entities.map(function (x) { var _a; return (_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID; });
9275
- }
9276
- if (entityIds == null) {
9277
- entityIds = Object.keys(this.renderedEntities);
9278
- }
9279
- else {
9280
- // ensure entity ids are part of menu item.
9281
- entityIds = entityIds.filter(function (x) {
9282
- var _a;
9283
- return (_a = _this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.EntityIds.includes(x);
9284
- });
9285
- }
9286
- this.visualsManager.MarkStale({
9287
- entityIds: entityIds,
9288
- menuItemIds: [this.item.id]
9287
+ return __generator(this, function (_o) {
9288
+ switch (_o.label) {
9289
+ case 0:
9290
+ entities = entities.filter(function (entity) {
9291
+ var _a;
9292
+ return !_this.renderedEntities[(_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID];
9293
+ });
9294
+ // Mark these as rendered.
9295
+ entities.forEach(function (entity) {
9296
+ var _a;
9297
+ _this.renderedEntities[(_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID] = true;
9298
+ });
9299
+ zoomItem = this.item.CameraZoomSettings[0];
9300
+ if (!(zoomItem.DisplayType == bruceModels.ZoomControl.EDisplayType.Model3D && entities.length)) return [3 /*break*/, 2];
9301
+ return [4 /*yield*/, bruceModels.EntityLod.GetLods({
9302
+ api: this.apiGetter.getApi(),
9303
+ filter: {
9304
+ externalSources: false,
9305
+ Items: entities.map(function (x) {
9306
+ var _a, _b;
9307
+ return {
9308
+ entityId: (_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID,
9309
+ categoryId: (_b = zoomItem.LODCategoryID) !== null && _b !== void 0 ? _b : "GLB",
9310
+ group: "DEFAULT",
9311
+ level: Number(zoomItem.LODLevel)
9312
+ };
9313
+ }),
9314
+ strict: false
9315
+ }
9316
+ })];
9317
+ case 1:
9318
+ lods = (_o.sent()).lods;
9319
+ if (this.disposed) {
9320
+ this.doDispose();
9321
+ return [2 /*return*/];
9322
+ }
9323
+ withLods_1 = lods.filter(function (x) { return x.entityId && !!x.clientFileId; }).map(function (x) { return x.entityId; });
9324
+ individuals = entities.filter(function (entity) {
9325
+ var _a;
9326
+ return withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
9327
+ });
9328
+ if (individuals.length) {
9329
+ this.renderAsIndividuals(individuals, force);
9330
+ }
9331
+ // Now we proceed with what is left.
9332
+ entities = entities.filter(function (entity) {
9333
+ var _a;
9334
+ return !withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
9335
+ });
9336
+ _o.label = 2;
9337
+ case 2:
9338
+ if (!entities.length) {
9339
+ return [2 /*return*/];
9340
+ }
9341
+ style = null;
9342
+ if (!((zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) && (zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) > -1)) return [3 /*break*/, 6];
9343
+ _o.label = 3;
9344
+ case 3:
9345
+ _o.trys.push([3, 5, , 6]);
9346
+ return [4 /*yield*/, bruceModels.Style.Get({
9347
+ api: this.apiGetter.getApi(),
9348
+ styleId: zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID
9349
+ })];
9350
+ case 4:
9351
+ style = (_a = (_o.sent()).style) === null || _a === void 0 ? void 0 : _a.Settings;
9352
+ return [3 /*break*/, 6];
9353
+ case 5:
9354
+ e_3 = _o.sent();
9355
+ console.error(e_3);
9356
+ return [3 /*break*/, 6];
9357
+ case 6:
9358
+ entityTypeId = (_b = this.item.BruceEntity) === null || _b === void 0 ? void 0 : _b["EntityType.ID"];
9359
+ if (!entityTypeId) {
9360
+ entityTypeId = (_d = (_c = entities.find(function (x) { var _a; return !!((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"]); })) === null || _c === void 0 ? void 0 : _c.Bruce) === null || _d === void 0 ? void 0 : _d["EntityType.ID"];
9361
+ }
9362
+ if (!entityTypeId) return [3 /*break*/, 12];
9363
+ _o.label = 7;
9364
+ case 7:
9365
+ _o.trys.push([7, 11, , 12]);
9366
+ return [4 /*yield*/, bruceModels.EntityType.Get({
9367
+ entityTypeId: entityTypeId,
9368
+ api: this.apiGetter.getApi()
9369
+ })];
9370
+ case 8:
9371
+ entityType = (_e = (_o.sent())) === null || _e === void 0 ? void 0 : _e.entityType;
9372
+ if (!(!style && entityType)) return [3 /*break*/, 10];
9373
+ if (!(entityType["DisplaySetting.ID"] && entityType["DisplaySetting.ID"] > 0)) return [3 /*break*/, 10];
9374
+ return [4 /*yield*/, bruceModels.Style.Get({
9375
+ api: this.apiGetter.getApi(),
9376
+ styleId: entityType["DisplaySetting.ID"]
9377
+ })];
9378
+ case 9:
9379
+ style = (_f = (_o.sent()).style) === null || _f === void 0 ? void 0 : _f.Settings;
9380
+ _o.label = 10;
9381
+ case 10: return [3 /*break*/, 12];
9382
+ case 11:
9383
+ e_4 = _o.sent();
9384
+ console.error(e_4);
9385
+ return [3 /*break*/, 12];
9386
+ case 12:
9387
+ pStyle = (_g = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _g !== void 0 ? _g : {};
9388
+ lStyle = (_h = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _h !== void 0 ? _h : {};
9389
+ polygonsClamped = ((_j = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _j === void 0 ? void 0 : _j.id) == null ? true : ((_k = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _k === void 0 ? void 0 : _k.id) == 0;
9390
+ bFillColor = bruceModels.Calculator.GetColor(pStyle.fillColor, {}, []);
9391
+ cFillColor = bFillColor ? colorToCColor$3(bFillColor) : Cesium.Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
9392
+ bLineColor = bruceModels.Calculator.GetColor(pStyle.lineColor, {}, []);
9393
+ cLineColor = bLineColor ? colorToCColor$3(bLineColor) : Cesium.Color.fromCssColorString("rgba(80, 80, 80, 0.8)");
9394
+ lineWidthPx = pStyle.lineWidth ? bruceModels.Calculator.GetNumber(pStyle.lineWidth, {}, []) : null;
9395
+ if (lineWidthPx == null) {
9396
+ lineWidthPx = 1;
9397
+ }
9398
+ lineWidthPx = EnsureNumber(lineWidthPx);
9399
+ if (lineWidthPx < 0.01) {
9400
+ lineWidthPx = 0;
9401
+ }
9402
+ lineWidthPx = Math.round(lineWidthPx);
9403
+ geojson = bruceModels.Entity.ToGeoJson({
9404
+ entities: entities,
9405
+ includeUserData: false,
9406
+ excludeAltitude: polygonsClamped && lineWidthPx <= 0,
9407
+ altitude: lineWidthPx > 0 && polygonsClamped ? 1 : null,
9408
+ // No points.
9409
+ allowedDisplayTypes: [bruceModels.ZoomControl.EDisplayType.Geometry]
9410
+ });
9411
+ notRendered = !((_l = geojson === null || geojson === void 0 ? void 0 : geojson.features) === null || _l === void 0 ? void 0 : _l.length) ? entities : entities.filter(function (entity) {
9412
+ return !geojson.features.some(function (feature) {
9413
+ var _a, _b, _c;
9414
+ return ((_b = (_a = feature.properties) === null || _a === void 0 ? void 0 : _a.Bruce) === null || _b === void 0 ? void 0 : _b.ID) == ((_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c.ID);
9415
+ });
9416
+ });
9417
+ if (notRendered.length) {
9418
+ this.renderAsIndividuals(notRendered, force);
9419
+ }
9420
+ if (!((_m = geojson === null || geojson === void 0 ? void 0 : geojson.features) === null || _m === void 0 ? void 0 : _m.length)) {
9421
+ return [2 /*return*/];
9422
+ }
9423
+ return [4 /*yield*/, Cesium.GeoJsonDataSource.load(geojson, {
9424
+ stroke: cLineColor,
9425
+ fill: cFillColor,
9426
+ strokeWidth: lineWidthPx,
9427
+ clampToGround: lineWidthPx <= 0 && polygonsClamped
9428
+ })];
9429
+ case 13:
9430
+ source = _o.sent();
9431
+ this.viewer.dataSources.add(source);
9432
+ this.sources.push(source);
9433
+ if (this.disposed) {
9434
+ this.doDispose();
9435
+ return [2 /*return*/];
9436
+ }
9437
+ groups = [];
9438
+ applyStyle = function (thing, entityId, data) {
9439
+ if (thing.polygon) {
9440
+ var bFillColor_1 = bruceModels.Calculator.GetColor(pStyle.fillColor, data, []);
9441
+ var cFillColor_1 = bFillColor_1 ? colorToCColor$3(bFillColor_1) : Cesium.Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
9442
+ var bLineColor_1 = bruceModels.Calculator.GetColor(pStyle.lineColor, data, []);
9443
+ var cLineColor_1 = bLineColor_1 ? colorToCColor$3(bLineColor_1) : Cesium.Color.fromCssColorString("rgba(80, 80, 80, 0.8)");
9444
+ var width = pStyle.lineWidth ? bruceModels.Calculator.GetNumber(pStyle.lineWidth, data, []) : null;
9445
+ if (width == null) {
9446
+ width = 1;
9447
+ }
9448
+ width = EnsureNumber(width);
9449
+ if (width < 0.01) {
9450
+ width = 0;
9451
+ }
9452
+ var curFillColor = getValue$4(_this.viewer, thing.polygon.material);
9453
+ if (curFillColor && curFillColor instanceof Cesium.ColorMaterialProperty) {
9454
+ curFillColor = curFillColor.color;
9455
+ }
9456
+ var curLineColor = getValue$4(_this.viewer, thing.polygon.outlineColor);
9457
+ if (curLineColor && curLineColor instanceof Cesium.ColorMaterialProperty) {
9458
+ curLineColor = curLineColor.color;
9459
+ }
9460
+ var curWidth = getValue$4(_this.viewer, thing.polygon.outlineWidth);
9461
+ if ((curFillColor instanceof Cesium.Color && curFillColor.equals(cFillColor_1)) &&
9462
+ (curLineColor instanceof Cesium.Color && curLineColor.equals(cLineColor_1)) &&
9463
+ curWidth == width) {
9464
+ return;
9465
+ }
9466
+ thing.polygon.material = cFillColor_1;
9467
+ thing.polygon.outlineColor = cLineColor_1;
9468
+ thing.polygon.outlineWidth = width;
9469
+ }
9470
+ else if (thing.polyline) {
9471
+ var bColor = lStyle.lineColor ? bruceModels.Calculator.GetColor(lStyle.lineColor, data, []) : null;
9472
+ var cColor = bColor ? colorToCColor$3(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
9473
+ var width = lStyle.lineWidth ? bruceModels.Calculator.GetNumber(lStyle.lineWidth, data, []) : null;
9474
+ if (width == null) {
9475
+ width = 2;
9476
+ }
9477
+ width = EnsureNumber(width);
9478
+ if (width < 0.01) {
9479
+ width = 0;
9480
+ }
9481
+ var curColor = getValue$4(_this.viewer, thing.polyline.material);
9482
+ if (curColor && curColor instanceof Cesium.ColorMaterialProperty) {
9483
+ curColor = curColor.color;
9484
+ }
9485
+ var curWidth = getValue$4(_this.viewer, thing.polyline.width);
9486
+ if ((curColor instanceof Cesium.Color && curColor.equals(cColor)) &&
9487
+ curWidth == width) {
9488
+ return;
9489
+ }
9490
+ thing.polyline.material = cColor;
9491
+ thing.polyline.width = width;
9492
+ }
9493
+ };
9494
+ register = function (thing) {
9495
+ var _a, _b, _c, _d;
9496
+ // See if the cesium entity already exists in a group.
9497
+ var group = groups.find(function (x) { var _a; return ((_a = x.visual) === null || _a === void 0 ? void 0 : _a.id) == thing.id || x.siblings.find(function (x) { return (x === null || x === void 0 ? void 0 : x.id) == thing.id; }); });
9498
+ if (group) {
9499
+ return;
9500
+ }
9501
+ var metadata = getValue$4(_this.viewer, thing === null || thing === void 0 ? void 0 : thing.properties);
9502
+ var entityId = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _a === void 0 ? void 0 : _a.ID;
9503
+ if (!entityId) {
9504
+ return;
9505
+ }
9506
+ var needsUpdate = false;
9507
+ // Find group for the nextspace entity ID.
9508
+ group = groups.find(function (x) { return x.entityId == entityId; });
9509
+ // No group yet. We can designate this as the primary entity and create a new group for it.
9510
+ if (!group) {
9511
+ group = {
9512
+ entityId: entityId,
9513
+ visual: thing,
9514
+ tagIds: (_b = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _b === void 0 ? void 0 : _b["Layer.ID"],
9515
+ entityTypeId: (_c = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _c === void 0 ? void 0 : _c["EntityType.ID"],
9516
+ siblings: [],
9517
+ data: entities.find(function (x) { var _a; return ((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID) == entityId; }),
9518
+ rego: null
9519
+ };
9520
+ groups.push(group);
9521
+ var rego = {
9522
+ entityId: entityId,
9523
+ menuItemId: _this.item.id,
9524
+ visual: thing,
9525
+ priority: 0,
9526
+ entityTypeId: group.entityTypeId,
9527
+ accountId: _this.apiGetter.accountId,
9528
+ tagIds: group.tagIds ? [].concat(group.tagIds) : [],
9529
+ name: entityType ? (_d = bruceModels.Entity.CalculateName({
9530
+ entity: group.data,
9531
+ type: entityType,
9532
+ defaultToId: false
9533
+ })) !== null && _d !== void 0 ? _d : "Unnamed Entity" : "Unnamed Entity",
9534
+ cdn: _this.item.cdnEnabled,
9535
+ collection: source.entities
9536
+ };
9537
+ group.rego = rego;
9538
+ _this.visualsManager.AddRego({
9539
+ rego: rego,
9540
+ requestRender: false
9541
+ });
9542
+ }
9543
+ // Found a group. We flag this as a sibling entity of the primary.
9544
+ else {
9545
+ group.siblings.push(thing);
9546
+ group.visual._siblingGraphics = group.siblings;
9547
+ thing._parentEntity = group.visual;
9548
+ if (group.rego) {
9549
+ _this.visualsManager.RefreshMark({
9550
+ rego: group.rego
9551
+ });
9552
+ needsUpdate = true;
9553
+ }
9554
+ }
9555
+ applyStyle(thing, entityId, group.data);
9556
+ if (needsUpdate) {
9557
+ _this.visualsManager.ForceUpdate({
9558
+ entityIds: [entityId],
9559
+ });
9560
+ }
9561
+ };
9562
+ sEntities = source.entities.values;
9563
+ for (i = 0; i < sEntities.length; i++) {
9564
+ cEntity = sEntities[i];
9565
+ register(cEntity);
9566
+ }
9567
+ this.viewer.scene.requestRender();
9568
+ return [2 /*return*/];
9569
+ }
9570
+ });
9571
+ });
9572
+ };
9573
+ /**
9574
+ * Our default path.
9575
+ * We render each entity individually.
9576
+ * @param entities
9577
+ * @param force
9578
+ * @returns
9579
+ */
9580
+ Manager.prototype.renderAsIndividuals = function (entities, force) {
9581
+ var _a;
9582
+ if (force === void 0) { force = false; }
9583
+ return __awaiter(this, void 0, void 0, function () {
9584
+ var cEntities, isEntityInItem, i, entity, id, cEntity, visual;
9585
+ var _this = this;
9586
+ return __generator(this, function (_b) {
9587
+ switch (_b.label) {
9588
+ case 0: return [4 /*yield*/, exports.EntityRenderEngine.Render({
9589
+ viewer: this.viewer,
9590
+ apiGetter: this.apiGetter,
9591
+ entities: entities,
9592
+ menuItemId: this.item.id,
9593
+ visualRegister: this.visualsManager,
9594
+ zoomControl: this.item.CameraZoomSettings,
9595
+ force: force
9596
+ })];
9597
+ case 1:
9598
+ cEntities = _b.sent();
9599
+ if (this.disposed) {
9600
+ this.visualsManager.RemoveRegos({
9601
+ menuItemId: this.item.id
9602
+ });
9603
+ return [2 /*return*/];
9604
+ }
9605
+ isEntityInItem = function (entityId) {
9606
+ var _a, _b;
9607
+ return (_b = (_a = _this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.Entities) === null || _b === void 0 ? void 0 : _b.find(function (y) { var _a; return ((_a = y === null || y === void 0 ? void 0 : y.Bruce) === null || _a === void 0 ? void 0 : _a.ID) == entityId; });
9608
+ };
9609
+ for (i = 0; i < entities.length; i++) {
9610
+ entity = entities[i];
9611
+ id = entity.Bruce.ID;
9612
+ cEntity = cEntities[id];
9613
+ this.renderedEntities[id] = !!cEntity;
9614
+ if (cEntity && isEntityInItem(id)) {
9615
+ visual = (_a = this.visualsManager.GetRego({
9616
+ entityId: id,
9617
+ menuItemId: this.item.id
9618
+ })) === null || _a === void 0 ? void 0 : _a.visual;
9619
+ if (!visual || visual != cEntity) {
9620
+ this.visualsManager.AddRego({
9621
+ rego: {
9622
+ entityId: id,
9623
+ menuItemId: this.item.id,
9624
+ visual: cEntity,
9625
+ priority: 0,
9626
+ entityTypeId: entity.Bruce["EntityType.ID"],
9627
+ accountId: this.apiGetter.accountId,
9628
+ name: cEntity.name
9629
+ },
9630
+ requestRender: false
9631
+ });
9632
+ }
9633
+ }
9634
+ else {
9635
+ this.visualsManager.RemoveRegos({
9636
+ entityId: id,
9637
+ menuItemId: this.item.id,
9638
+ requestRender: false
9639
+ });
9640
+ }
9641
+ }
9642
+ this.viewer.scene.requestRender();
9643
+ return [2 /*return*/];
9644
+ }
9645
+ });
9646
+ });
9647
+ };
9648
+ return Manager;
9649
+ }());
9650
+ EntitiesLoadedRenderManager.Manager = Manager;
9651
+ })(exports.EntitiesLoadedRenderManager || (exports.EntitiesLoadedRenderManager = {}));
9652
+
9653
+ var BATCH_SIZE$2 = 500;
9654
+ function getValue$5(viewer, obj) {
9655
+ if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
9656
+ return obj.getValue(viewer.scene.lastRenderTime);
9657
+ }
9658
+ return obj;
9659
+ }
9660
+ function colorToCColor$4(color) {
9661
+ return new Cesium.Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
9662
+ }
9663
+ (function (EntitiesIdsRenderManager) {
9664
+ var Manager = /** @class */ (function () {
9665
+ function Manager(params) {
9666
+ var _a;
9667
+ this.getter = null;
9668
+ this.getterSub = null;
9669
+ this.disposed = false;
9670
+ this.renderedEntities = {};
9671
+ this.sources = [];
9672
+ // Highly experimental flag to try improve rendering large sets of polygons and polylines.
9673
+ // Many things are not supported when this is enabled.
9674
+ this.useGeojson = false;
9675
+ var viewer = params.viewer, apiGetter = params.apiGetter, monitor = params.monitor, item = params.item, visualsManager = params.register;
9676
+ this.viewer = viewer;
9677
+ this.apiGetter = apiGetter;
9678
+ this.monitor = monitor;
9679
+ this.item = item;
9680
+ this.visualsManager = visualsManager;
9681
+ this.useGeojson = item.renderAsGeojson == true;
9682
+ if (this.item.enableClustering) {
9683
+ this.clustering = new PointClustering(visualsManager, this.item.id, (_a = this.item) === null || _a === void 0 ? void 0 : _a.clustering);
9684
+ }
9685
+ }
9686
+ Object.defineProperty(Manager.prototype, "Disposed", {
9687
+ get: function () {
9688
+ return this.disposed;
9689
+ },
9690
+ enumerable: false,
9691
+ configurable: true
9692
+ });
9693
+ Manager.prototype.Init = function () {
9694
+ var _this = this;
9695
+ var _a;
9696
+ if (this.disposed) {
9697
+ throw (new Error("This item is disposed."));
9698
+ }
9699
+ if (!((_a = this.item.CameraZoomSettings) === null || _a === void 0 ? void 0 : _a.length)) {
9700
+ this.item.CameraZoomSettings = [
9701
+ {
9702
+ MinZoom: 0,
9703
+ MaxZoom: 100000,
9704
+ DisplayType: bruceModels.ZoomControl.EDisplayType.Model3D,
9705
+ LODCategoryID: "glb",
9706
+ LODLevel: 0,
9707
+ StyleID: 0
9708
+ }
9709
+ ];
9710
+ }
9711
+ if (this.renderAsGeojson && this.item.CameraZoomSettings.length > 1) {
9712
+ console.warn("Geojson rendering does not support multiple zoom controls. Only the first one will be used.");
9713
+ this.item.CameraZoomSettings = [this.item.CameraZoomSettings[0]];
9714
+ }
9715
+ this.getter = new BatchedDataGetter.Getter(this.item.BruceEntity.EntityIds, this.monitor, BATCH_SIZE$2);
9716
+ this.getterSub = this.getter.OnUpdate.Subscribe(function (ids) {
9717
+ _this.onGetterUpdate(ids);
9718
+ });
9719
+ this.getter.Start();
9720
+ };
9721
+ Manager.prototype.Dispose = function () {
9722
+ if (this.disposed) {
9723
+ return;
9724
+ }
9725
+ this.doDispose();
9726
+ };
9727
+ Manager.prototype.doDispose = function () {
9728
+ var _a, _b;
9729
+ (_a = this.getterSub) === null || _a === void 0 ? void 0 : _a.call(this);
9730
+ this.getterSub = null;
9731
+ this.disposed = true;
9732
+ this.visualsManager.RemoveRegos({
9733
+ menuItemId: this.item.id
9734
+ });
9735
+ (_b = this.clustering) === null || _b === void 0 ? void 0 : _b.Dispose();
9736
+ this.clustering = null;
9737
+ for (var i = 0; i < this.sources.length; i++) {
9738
+ var source = this.sources[i];
9739
+ this.viewer.dataSources.remove(source);
9740
+ }
9741
+ this.sources = [];
9742
+ };
9743
+ Manager.prototype.ReRender = function (params) {
9744
+ return __awaiter(this, void 0, void 0, function () {
9745
+ var entityIds, force, entities;
9746
+ var _this = this;
9747
+ return __generator(this, function (_a) {
9748
+ entityIds = params.entityIds, force = params.force, entities = params.entities;
9749
+ if (entities && !entityIds) {
9750
+ entityIds = entities.map(function (x) { var _a; return (_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID; });
9751
+ }
9752
+ if (entityIds == null) {
9753
+ entityIds = Object.keys(this.renderedEntities);
9754
+ }
9755
+ else {
9756
+ // ensure entity ids are part of menu item.
9757
+ entityIds = entityIds.filter(function (x) {
9758
+ var _a;
9759
+ return (_a = _this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.EntityIds.includes(x);
9760
+ });
9761
+ }
9762
+ this.visualsManager.MarkStale({
9763
+ entityIds: entityIds,
9764
+ menuItemIds: [this.item.id]
9289
9765
  });
9290
9766
  if (entities === null || entities === void 0 ? void 0 : entities.length) {
9291
9767
  this.renderEntities([].concat(entities).filter(function (x) { var _a; return entityIds.includes((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID); }), force);
@@ -9304,6 +9780,10 @@
9304
9780
  }
9305
9781
  if (CameraZoomSettings === null || CameraZoomSettings === void 0 ? void 0 : CameraZoomSettings.length) {
9306
9782
  this.item.CameraZoomSettings = CameraZoomSettings;
9783
+ if (this.renderAsGeojson && this.item.CameraZoomSettings.length > 1) {
9784
+ console.warn("Geojson rendering does not support multiple zoom controls. Only the first one will be used.");
9785
+ this.item.CameraZoomSettings = [this.item.CameraZoomSettings[0]];
9786
+ }
9307
9787
  }
9308
9788
  if (queueRerender != false) {
9309
9789
  var entityIds = Object.keys(this.renderedEntities);
@@ -9324,53 +9804,391 @@
9324
9804
  if (this.disposed || this.viewer.isDestroyed()) {
9325
9805
  return [2 /*return*/];
9326
9806
  }
9327
- _a.label = 1;
9328
- case 1:
9329
- _a.trys.push([1, 4, , 5]);
9330
- api = this.apiGetter.getApi();
9331
- return [4 /*yield*/, bruceModels.Entity.GetListByIds({
9332
- api: api,
9333
- entityIds: entityIds
9334
- })];
9807
+ _a.label = 1;
9808
+ case 1:
9809
+ _a.trys.push([1, 4, , 5]);
9810
+ api = this.apiGetter.getApi();
9811
+ return [4 /*yield*/, bruceModels.Entity.GetListByIds({
9812
+ api: api,
9813
+ entityIds: entityIds
9814
+ })];
9815
+ case 2:
9816
+ entities = (_a.sent()).entities;
9817
+ return [4 /*yield*/, this.renderEntities(entities, force)];
9818
+ case 3:
9819
+ _a.sent();
9820
+ return [3 /*break*/, 5];
9821
+ case 4:
9822
+ e_1 = _a.sent();
9823
+ console.error(e_1);
9824
+ return [3 /*break*/, 5];
9825
+ case 5: return [2 /*return*/];
9826
+ }
9827
+ });
9828
+ });
9829
+ };
9830
+ Manager.prototype.renderEntities = function (entities, force) {
9831
+ if (force === void 0) { force = false; }
9832
+ return __awaiter(this, void 0, void 0, function () {
9833
+ var zoomItem, e_2;
9834
+ return __generator(this, function (_a) {
9835
+ switch (_a.label) {
9836
+ case 0:
9837
+ if (this.disposed || this.viewer.isDestroyed()) {
9838
+ return [2 /*return*/];
9839
+ }
9840
+ _a.label = 1;
9841
+ case 1:
9842
+ _a.trys.push([1, 9, , 10]);
9843
+ if (!this.useGeojson) return [3 /*break*/, 6];
9844
+ zoomItem = this.item.CameraZoomSettings[0];
9845
+ if (!(zoomItem.DisplayType == bruceModels.ZoomControl.EDisplayType.Point)) return [3 /*break*/, 3];
9846
+ // We'll just render these as individuals since we don't support point geojson.
9847
+ return [4 /*yield*/, this.renderAsIndividuals(entities, force)];
9848
+ case 2:
9849
+ // We'll just render these as individuals since we don't support point geojson.
9850
+ _a.sent();
9851
+ return [3 /*break*/, 5];
9852
+ case 3: return [4 /*yield*/, this.renderAsGeojson(entities, force)];
9853
+ case 4:
9854
+ _a.sent();
9855
+ _a.label = 5;
9856
+ case 5: return [3 /*break*/, 8];
9857
+ case 6: return [4 /*yield*/, this.renderAsIndividuals(entities, force)];
9858
+ case 7:
9859
+ _a.sent();
9860
+ _a.label = 8;
9861
+ case 8: return [3 /*break*/, 10];
9862
+ case 9:
9863
+ e_2 = _a.sent();
9864
+ console.error(e_2);
9865
+ return [3 /*break*/, 10];
9866
+ case 10: return [2 /*return*/];
9867
+ }
9868
+ });
9869
+ });
9870
+ };
9871
+ /**
9872
+ * Our optimized and more stable path.
9873
+ * We construct a geojson that we draw in one go.
9874
+ * @param entities
9875
+ * @param force TODO: This should re-render entities that are already rendered.
9876
+ */
9877
+ Manager.prototype.renderAsGeojson = function (entities, force) {
9878
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
9879
+ return __awaiter(this, void 0, void 0, function () {
9880
+ var zoomItem, lods, withLods_1, individuals, style, e_3, entityTypeId, entityType, e_4, pStyle, lStyle, polygonsClamped, bFillColor, cFillColor, bLineColor, cLineColor, lineWidthPx, geojson, notRendered, source, groups, applyStyle, register, sEntities, i, cEntity;
9881
+ var _this = this;
9882
+ return __generator(this, function (_o) {
9883
+ switch (_o.label) {
9884
+ case 0:
9885
+ entities = entities.filter(function (entity) {
9886
+ var _a;
9887
+ return !_this.renderedEntities[(_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID];
9888
+ });
9889
+ // Mark these as rendered.
9890
+ entities.forEach(function (entity) {
9891
+ var _a;
9892
+ _this.renderedEntities[(_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID] = true;
9893
+ });
9894
+ zoomItem = this.item.CameraZoomSettings[0];
9895
+ if (!(zoomItem.DisplayType == bruceModels.ZoomControl.EDisplayType.Model3D && entities.length)) return [3 /*break*/, 2];
9896
+ return [4 /*yield*/, bruceModels.EntityLod.GetLods({
9897
+ api: this.apiGetter.getApi(),
9898
+ filter: {
9899
+ externalSources: false,
9900
+ Items: entities.map(function (x) {
9901
+ var _a, _b;
9902
+ return {
9903
+ entityId: (_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID,
9904
+ categoryId: (_b = zoomItem.LODCategoryID) !== null && _b !== void 0 ? _b : "GLB",
9905
+ group: "DEFAULT",
9906
+ level: Number(zoomItem.LODLevel)
9907
+ };
9908
+ }),
9909
+ strict: false
9910
+ }
9911
+ })];
9912
+ case 1:
9913
+ lods = (_o.sent()).lods;
9914
+ if (this.disposed) {
9915
+ this.doDispose();
9916
+ return [2 /*return*/];
9917
+ }
9918
+ withLods_1 = lods.filter(function (x) { return x.entityId && !!x.clientFileId; }).map(function (x) { return x.entityId; });
9919
+ individuals = entities.filter(function (entity) {
9920
+ var _a;
9921
+ return withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
9922
+ });
9923
+ if (individuals.length) {
9924
+ this.renderAsIndividuals(individuals, force);
9925
+ }
9926
+ // Now we proceed with what is left.
9927
+ entities = entities.filter(function (entity) {
9928
+ var _a;
9929
+ return !withLods_1.includes((_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID);
9930
+ });
9931
+ _o.label = 2;
9335
9932
  case 2:
9336
- entities = (_a.sent()).entities;
9337
- return [4 /*yield*/, this.renderEntities(entities, force)];
9933
+ if (!entities.length) {
9934
+ return [2 /*return*/];
9935
+ }
9936
+ style = null;
9937
+ if (!((zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) && (zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID) > -1)) return [3 /*break*/, 6];
9938
+ _o.label = 3;
9338
9939
  case 3:
9339
- _a.sent();
9340
- return [3 /*break*/, 5];
9940
+ _o.trys.push([3, 5, , 6]);
9941
+ return [4 /*yield*/, bruceModels.Style.Get({
9942
+ api: this.apiGetter.getApi(),
9943
+ styleId: zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID
9944
+ })];
9341
9945
  case 4:
9342
- e_1 = _a.sent();
9343
- console.error(e_1);
9344
- return [3 /*break*/, 5];
9345
- case 5: return [2 /*return*/];
9946
+ style = (_a = (_o.sent()).style) === null || _a === void 0 ? void 0 : _a.Settings;
9947
+ return [3 /*break*/, 6];
9948
+ case 5:
9949
+ e_3 = _o.sent();
9950
+ console.error(e_3);
9951
+ return [3 /*break*/, 6];
9952
+ case 6:
9953
+ entityTypeId = (_b = this.item.BruceEntity) === null || _b === void 0 ? void 0 : _b["EntityType.ID"];
9954
+ if (!entityTypeId) {
9955
+ entityTypeId = (_d = (_c = entities.find(function (x) { var _a; return !!((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"]); })) === null || _c === void 0 ? void 0 : _c.Bruce) === null || _d === void 0 ? void 0 : _d["EntityType.ID"];
9956
+ }
9957
+ if (!entityTypeId) return [3 /*break*/, 12];
9958
+ _o.label = 7;
9959
+ case 7:
9960
+ _o.trys.push([7, 11, , 12]);
9961
+ return [4 /*yield*/, bruceModels.EntityType.Get({
9962
+ entityTypeId: entityTypeId,
9963
+ api: this.apiGetter.getApi()
9964
+ })];
9965
+ case 8:
9966
+ entityType = (_e = (_o.sent())) === null || _e === void 0 ? void 0 : _e.entityType;
9967
+ if (!(!style && entityType)) return [3 /*break*/, 10];
9968
+ if (!(entityType["DisplaySetting.ID"] && entityType["DisplaySetting.ID"] > 0)) return [3 /*break*/, 10];
9969
+ return [4 /*yield*/, bruceModels.Style.Get({
9970
+ api: this.apiGetter.getApi(),
9971
+ styleId: entityType["DisplaySetting.ID"]
9972
+ })];
9973
+ case 9:
9974
+ style = (_f = (_o.sent()).style) === null || _f === void 0 ? void 0 : _f.Settings;
9975
+ _o.label = 10;
9976
+ case 10: return [3 /*break*/, 12];
9977
+ case 11:
9978
+ e_4 = _o.sent();
9979
+ console.error(e_4);
9980
+ return [3 /*break*/, 12];
9981
+ case 12:
9982
+ pStyle = (_g = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _g !== void 0 ? _g : {};
9983
+ lStyle = (_h = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _h !== void 0 ? _h : {};
9984
+ polygonsClamped = ((_j = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _j === void 0 ? void 0 : _j.id) == null ? true : ((_k = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _k === void 0 ? void 0 : _k.id) == 0;
9985
+ bFillColor = bruceModels.Calculator.GetColor(pStyle.fillColor, {}, []);
9986
+ cFillColor = bFillColor ? colorToCColor$4(bFillColor) : Cesium.Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
9987
+ bLineColor = bruceModels.Calculator.GetColor(pStyle.lineColor, {}, []);
9988
+ cLineColor = bLineColor ? colorToCColor$4(bLineColor) : Cesium.Color.fromCssColorString("rgba(80, 80, 80, 0.8)");
9989
+ lineWidthPx = pStyle.lineWidth ? bruceModels.Calculator.GetNumber(pStyle.lineWidth, {}, []) : null;
9990
+ if (lineWidthPx == null) {
9991
+ lineWidthPx = 1;
9992
+ }
9993
+ lineWidthPx = EnsureNumber(lineWidthPx);
9994
+ if (lineWidthPx < 0.01) {
9995
+ lineWidthPx = 0;
9996
+ }
9997
+ lineWidthPx = Math.round(lineWidthPx);
9998
+ geojson = bruceModels.Entity.ToGeoJson({
9999
+ entities: entities,
10000
+ includeUserData: false,
10001
+ excludeAltitude: polygonsClamped && lineWidthPx <= 0,
10002
+ altitude: lineWidthPx > 0 && polygonsClamped ? 1 : null,
10003
+ // No points.
10004
+ allowedDisplayTypes: [bruceModels.ZoomControl.EDisplayType.Geometry]
10005
+ });
10006
+ notRendered = !((_l = geojson === null || geojson === void 0 ? void 0 : geojson.features) === null || _l === void 0 ? void 0 : _l.length) ? entities : entities.filter(function (entity) {
10007
+ return !geojson.features.some(function (feature) {
10008
+ var _a, _b, _c;
10009
+ return ((_b = (_a = feature.properties) === null || _a === void 0 ? void 0 : _a.Bruce) === null || _b === void 0 ? void 0 : _b.ID) == ((_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c.ID);
10010
+ });
10011
+ });
10012
+ if (notRendered.length) {
10013
+ this.renderAsIndividuals(notRendered, force);
10014
+ }
10015
+ if (!((_m = geojson === null || geojson === void 0 ? void 0 : geojson.features) === null || _m === void 0 ? void 0 : _m.length)) {
10016
+ return [2 /*return*/];
10017
+ }
10018
+ return [4 /*yield*/, Cesium.GeoJsonDataSource.load(geojson, {
10019
+ stroke: cLineColor,
10020
+ fill: cFillColor,
10021
+ strokeWidth: lineWidthPx,
10022
+ clampToGround: lineWidthPx <= 0 && polygonsClamped
10023
+ })];
10024
+ case 13:
10025
+ source = _o.sent();
10026
+ this.viewer.dataSources.add(source);
10027
+ this.sources.push(source);
10028
+ if (this.disposed) {
10029
+ this.doDispose();
10030
+ return [2 /*return*/];
10031
+ }
10032
+ groups = [];
10033
+ applyStyle = function (thing, entityId, data) {
10034
+ if (thing.polygon) {
10035
+ var bFillColor_1 = bruceModels.Calculator.GetColor(pStyle.fillColor, data, []);
10036
+ var cFillColor_1 = bFillColor_1 ? colorToCColor$4(bFillColor_1) : Cesium.Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
10037
+ var bLineColor_1 = bruceModels.Calculator.GetColor(pStyle.lineColor, data, []);
10038
+ var cLineColor_1 = bLineColor_1 ? colorToCColor$4(bLineColor_1) : Cesium.Color.fromCssColorString("rgba(80, 80, 80, 0.8)");
10039
+ var width = pStyle.lineWidth ? bruceModels.Calculator.GetNumber(pStyle.lineWidth, data, []) : null;
10040
+ if (width == null) {
10041
+ width = 1;
10042
+ }
10043
+ width = EnsureNumber(width);
10044
+ if (width < 0.01) {
10045
+ width = 0;
10046
+ }
10047
+ var curFillColor = getValue$5(_this.viewer, thing.polygon.material);
10048
+ if (curFillColor && curFillColor instanceof Cesium.ColorMaterialProperty) {
10049
+ curFillColor = curFillColor.color;
10050
+ }
10051
+ var curLineColor = getValue$5(_this.viewer, thing.polygon.outlineColor);
10052
+ if (curLineColor && curLineColor instanceof Cesium.ColorMaterialProperty) {
10053
+ curLineColor = curLineColor.color;
10054
+ }
10055
+ var curWidth = getValue$5(_this.viewer, thing.polygon.outlineWidth);
10056
+ if ((curFillColor instanceof Cesium.Color && curFillColor.equals(cFillColor_1)) &&
10057
+ (curLineColor instanceof Cesium.Color && curLineColor.equals(cLineColor_1)) &&
10058
+ curWidth == width) {
10059
+ return;
10060
+ }
10061
+ thing.polygon.material = cFillColor_1;
10062
+ thing.polygon.outlineColor = cLineColor_1;
10063
+ thing.polygon.outlineWidth = width;
10064
+ }
10065
+ else if (thing.polyline) {
10066
+ var bColor = lStyle.lineColor ? bruceModels.Calculator.GetColor(lStyle.lineColor, data, []) : null;
10067
+ var cColor = bColor ? colorToCColor$4(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
10068
+ var width = lStyle.lineWidth ? bruceModels.Calculator.GetNumber(lStyle.lineWidth, data, []) : null;
10069
+ if (width == null) {
10070
+ width = 2;
10071
+ }
10072
+ width = EnsureNumber(width);
10073
+ if (width < 0.01) {
10074
+ width = 0;
10075
+ }
10076
+ var curColor = getValue$5(_this.viewer, thing.polyline.material);
10077
+ if (curColor && curColor instanceof Cesium.ColorMaterialProperty) {
10078
+ curColor = curColor.color;
10079
+ }
10080
+ var curWidth = getValue$5(_this.viewer, thing.polyline.width);
10081
+ if ((curColor instanceof Cesium.Color && curColor.equals(cColor)) &&
10082
+ curWidth == width) {
10083
+ return;
10084
+ }
10085
+ thing.polyline.material = cColor;
10086
+ thing.polyline.width = width;
10087
+ }
10088
+ };
10089
+ register = function (thing) {
10090
+ var _a, _b, _c, _d;
10091
+ // See if the cesium entity already exists in a group.
10092
+ var group = groups.find(function (x) { var _a; return ((_a = x.visual) === null || _a === void 0 ? void 0 : _a.id) == thing.id || x.siblings.find(function (x) { return (x === null || x === void 0 ? void 0 : x.id) == thing.id; }); });
10093
+ if (group) {
10094
+ return;
10095
+ }
10096
+ var metadata = getValue$5(_this.viewer, thing === null || thing === void 0 ? void 0 : thing.properties);
10097
+ var entityId = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _a === void 0 ? void 0 : _a.ID;
10098
+ if (!entityId) {
10099
+ return;
10100
+ }
10101
+ var needsUpdate = false;
10102
+ // Find group for the nextspace entity ID.
10103
+ group = groups.find(function (x) { return x.entityId == entityId; });
10104
+ // No group yet. We can designate this as the primary entity and create a new group for it.
10105
+ if (!group) {
10106
+ group = {
10107
+ entityId: entityId,
10108
+ visual: thing,
10109
+ tagIds: (_b = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _b === void 0 ? void 0 : _b["Layer.ID"],
10110
+ entityTypeId: (_c = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _c === void 0 ? void 0 : _c["EntityType.ID"],
10111
+ siblings: [],
10112
+ data: entities.find(function (x) { var _a; return ((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID) == entityId; }),
10113
+ rego: null
10114
+ };
10115
+ groups.push(group);
10116
+ var rego = {
10117
+ entityId: entityId,
10118
+ menuItemId: _this.item.id,
10119
+ visual: thing,
10120
+ priority: 0,
10121
+ entityTypeId: group.entityTypeId,
10122
+ accountId: _this.apiGetter.accountId,
10123
+ tagIds: group.tagIds ? [].concat(group.tagIds) : [],
10124
+ name: entityType ? (_d = bruceModels.Entity.CalculateName({
10125
+ entity: group.data,
10126
+ type: entityType,
10127
+ defaultToId: false
10128
+ })) !== null && _d !== void 0 ? _d : "Unnamed Entity" : "Unnamed Entity",
10129
+ cdn: _this.item.cdnEnabled,
10130
+ collection: source.entities
10131
+ };
10132
+ group.rego = rego;
10133
+ _this.visualsManager.AddRego({
10134
+ rego: rego,
10135
+ requestRender: false
10136
+ });
10137
+ }
10138
+ // Found a group. We flag this as a sibling entity of the primary.
10139
+ else {
10140
+ group.siblings.push(thing);
10141
+ group.visual._siblingGraphics = group.siblings;
10142
+ thing._parentEntity = group.visual;
10143
+ if (group.rego) {
10144
+ _this.visualsManager.RefreshMark({
10145
+ rego: group.rego
10146
+ });
10147
+ needsUpdate = true;
10148
+ }
10149
+ }
10150
+ applyStyle(thing, entityId, group.data);
10151
+ if (needsUpdate) {
10152
+ _this.visualsManager.ForceUpdate({
10153
+ entityIds: [entityId],
10154
+ });
10155
+ }
10156
+ };
10157
+ sEntities = source.entities.values;
10158
+ for (i = 0; i < sEntities.length; i++) {
10159
+ cEntity = sEntities[i];
10160
+ register(cEntity);
10161
+ }
10162
+ this.viewer.scene.requestRender();
10163
+ return [2 /*return*/];
9346
10164
  }
9347
10165
  });
9348
10166
  });
9349
10167
  };
9350
- Manager.prototype.renderEntities = function (entities, force) {
10168
+ /**
10169
+ * Our default path.
10170
+ * We render each entity individually.
10171
+ * @param entities
10172
+ * @param force
10173
+ * @returns
10174
+ */
10175
+ Manager.prototype.renderAsIndividuals = function (entities, force) {
9351
10176
  var _a, _b;
9352
10177
  if (force === void 0) { force = false; }
9353
10178
  return __awaiter(this, void 0, void 0, function () {
9354
- var cEntities, i, entity, id, cEntity, visual, clustered, e_2;
10179
+ var cEntities, i, entity, id, cEntity, visual, clustered;
9355
10180
  return __generator(this, function (_c) {
9356
10181
  switch (_c.label) {
9357
- case 0:
9358
- if (this.disposed || this.viewer.isDestroyed()) {
9359
- return [2 /*return*/];
9360
- }
9361
- _c.label = 1;
10182
+ case 0: return [4 /*yield*/, exports.EntityRenderEngine.Render({
10183
+ viewer: this.viewer,
10184
+ apiGetter: this.apiGetter,
10185
+ entities: entities,
10186
+ menuItemId: this.item.id,
10187
+ visualRegister: this.visualsManager,
10188
+ zoomControl: this.item.CameraZoomSettings,
10189
+ force: force
10190
+ })];
9362
10191
  case 1:
9363
- _c.trys.push([1, 3, , 4]);
9364
- return [4 /*yield*/, exports.EntityRenderEngine.Render({
9365
- viewer: this.viewer,
9366
- apiGetter: this.apiGetter,
9367
- entities: entities,
9368
- menuItemId: this.item.id,
9369
- visualRegister: this.visualsManager,
9370
- zoomControl: this.item.CameraZoomSettings,
9371
- force: force
9372
- })];
9373
- case 2:
9374
10192
  cEntities = _c.sent();
9375
10193
  for (i = 0; i < entities.length; i++) {
9376
10194
  entity = entities[i];
@@ -9412,12 +10230,7 @@
9412
10230
  if (this.clustering && entities.length) {
9413
10231
  this.clustering.Update();
9414
10232
  }
9415
- return [3 /*break*/, 4];
9416
- case 3:
9417
- e_2 = _c.sent();
9418
- console.error(e_2);
9419
- return [3 /*break*/, 4];
9420
- case 4: return [2 /*return*/];
10233
+ return [2 /*return*/];
9421
10234
  }
9422
10235
  });
9423
10236
  });
@@ -9629,7 +10442,7 @@
9629
10442
  EntityRenderManager.Manager = Manager;
9630
10443
  })(exports.EntityRenderManager || (exports.EntityRenderManager = {}));
9631
10444
 
9632
- function colorToCColor$3(color) {
10445
+ function colorToCColor$5(color) {
9633
10446
  return new Cesium.Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
9634
10447
  }
9635
10448
  /**
@@ -10506,7 +11319,7 @@
10506
11319
  cColor = Cesium.Color.WHITE;
10507
11320
  }
10508
11321
  else {
10509
- cColor = colorToCColor$3(bColor);
11322
+ cColor = colorToCColor$5(bColor);
10510
11323
  }
10511
11324
  CesiumEntityStyler.SetDefaultColor({
10512
11325
  color: cColor,
@@ -20488,7 +21301,7 @@
20488
21301
  CesiumViewMonitor.Monitor = Monitor;
20489
21302
  })(exports.CesiumViewMonitor || (exports.CesiumViewMonitor = {}));
20490
21303
 
20491
- var VERSION$1 = "3.4.0";
21304
+ var VERSION$1 = "3.4.2";
20492
21305
 
20493
21306
  exports.VERSION = VERSION$1;
20494
21307
  exports.CesiumParabola = CesiumParabola;