bruce-cesium 3.3.7 → 3.3.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.
Files changed (27) hide show
  1. package/dist/bruce-cesium.es5.js +497 -59
  2. package/dist/bruce-cesium.es5.js.map +1 -1
  3. package/dist/bruce-cesium.umd.js +496 -58
  4. package/dist/bruce-cesium.umd.js.map +1 -1
  5. package/dist/lib/bruce-cesium.js +1 -1
  6. package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +307 -24
  7. package/dist/lib/rendering/render-managers/entities/entities-render-manager.js.map +1 -1
  8. package/dist/lib/rendering/render-managers/tilesets/tileset-arb-render-manager.js +7 -0
  9. package/dist/lib/rendering/render-managers/tilesets/tileset-arb-render-manager.js.map +1 -1
  10. package/dist/lib/rendering/render-managers/tilesets/tileset-cad-render-manager.js +7 -0
  11. package/dist/lib/rendering/render-managers/tilesets/tileset-cad-render-manager.js.map +1 -1
  12. package/dist/lib/rendering/tileset-render-engine.js +83 -20
  13. package/dist/lib/rendering/tileset-render-engine.js.map +1 -1
  14. package/dist/lib/rendering/visual-register-culler.js +1 -1
  15. package/dist/lib/rendering/visual-register-culler.js.map +1 -1
  16. package/dist/lib/rendering/visuals-register.js +32 -11
  17. package/dist/lib/rendering/visuals-register.js.map +1 -1
  18. package/dist/lib/utils/cesium-entity-styler.js +60 -0
  19. package/dist/lib/utils/cesium-entity-styler.js.map +1 -1
  20. package/dist/types/bruce-cesium.d.ts +1 -1
  21. package/dist/types/rendering/render-managers/entities/entities-render-manager.d.ts +17 -0
  22. package/dist/types/rendering/render-managers/tilesets/tileset-arb-render-manager.d.ts +2 -0
  23. package/dist/types/rendering/render-managers/tilesets/tileset-cad-render-manager.d.ts +2 -0
  24. package/dist/types/rendering/tileset-render-engine.d.ts +10 -0
  25. package/dist/types/rendering/visuals-register.d.ts +4 -0
  26. package/dist/types/utils/cesium-entity-styler.d.ts +12 -0
  27. package/package.json +2 -2
@@ -742,6 +742,66 @@
742
742
  }
743
743
  }
744
744
  CesiumEntityStyler.UpdateColorSetting = UpdateColorSetting;
745
+ /**
746
+ * Updates the default colour of a graphic.
747
+ * This will not change the graphic's state to use it if the entity is selected/highlighted.
748
+ * @param params
749
+ * @returns
750
+ */
751
+ function SetDefaultColor(params) {
752
+ var viewer = params.viewer, entity = params.entity, requestRender = params.requestRender;
753
+ if (!entity) {
754
+ return;
755
+ }
756
+ var parts = exports.EntityUtils.GatherEntity({
757
+ entity: entity
758
+ });
759
+ for (var i = 0; i < parts.length; i++) {
760
+ var part = parts[i];
761
+ if (!isAlive(viewer, part)) {
762
+ continue;
763
+ }
764
+ if (part instanceof Cesium.Cesium3DTileFeature) {
765
+ var opacity = getAppliedOpacity(part);
766
+ storeColor(viewer, "default", params.color, part);
767
+ refreshColor(viewer, part, opacity);
768
+ }
769
+ else if (part instanceof Cesium.Entity) {
770
+ if (part.billboard) {
771
+ storeColor(viewer, "default", params.color, part.billboard);
772
+ refreshColor(viewer, part.billboard, getAppliedOpacity(part.billboard));
773
+ }
774
+ if (part.model) {
775
+ storeColor(viewer, "default", params.color, part.model);
776
+ refreshColor(viewer, part.model, getAppliedOpacity(part.model));
777
+ }
778
+ if (part.polyline) {
779
+ storeColor(viewer, "default", params.color, part.polyline);
780
+ refreshColor(viewer, part.polyline, getAppliedOpacity(part.polyline));
781
+ }
782
+ if (part.polygon) {
783
+ storeColor(viewer, "default", params.color, part.polygon);
784
+ refreshColor(viewer, part.polygon, getAppliedOpacity(part.polygon));
785
+ }
786
+ if (part.corridor) {
787
+ storeColor(viewer, "default", params.color, part.corridor);
788
+ refreshColor(viewer, part.corridor, getAppliedOpacity(part.corridor));
789
+ }
790
+ if (part.point) {
791
+ storeColor(viewer, "default", params.color, part.point);
792
+ refreshColor(viewer, part.point, getAppliedOpacity(part.point));
793
+ }
794
+ if (part.ellipse) {
795
+ storeColor(viewer, "default", params.color, part.ellipse);
796
+ refreshColor(viewer, part.ellipse, getAppliedOpacity(part.ellipse));
797
+ }
798
+ }
799
+ }
800
+ if (requestRender != false) {
801
+ viewer.scene.requestRender();
802
+ }
803
+ }
804
+ CesiumEntityStyler.SetDefaultColor = SetDefaultColor;
745
805
  /**
746
806
  * Updates the opacity of the graphic.
747
807
  * This will multiply against the current colour's opacity before applying.
@@ -3049,7 +3109,7 @@
3049
3109
  var rego = register.GetRego({
3050
3110
  entityId: entityId
3051
3111
  });
3052
- if (!rego || !rego.visual || !(rego.visual instanceof Cesium.Entity) || rego.relation != null || rego.overrideShow != null) {
3112
+ if (!rego || !rego.visual || !(rego.visual instanceof Cesium.Entity) || rego.relation != null || rego.overrideShow != null || rego.collection) {
3053
3113
  continue;
3054
3114
  }
3055
3115
  var parts = exports.EntityUtils.GatherEntity({
@@ -6173,8 +6233,14 @@
6173
6233
  }
6174
6234
  }
6175
6235
  }
6176
- function updateCEntityShow(viewer, isRelationship, visual, isShowOverriden, show, ignoreParent) {
6177
- if (show && !isRelationship && !isShowOverriden) {
6236
+ var MAX_SHOW_DEPTH = 10;
6237
+ function updateCEntityShow(viewer, visual, rego, show, ignoreParent, depth) {
6238
+ if (depth === void 0) { depth = 0; }
6239
+ if (depth > MAX_SHOW_DEPTH) {
6240
+ console.warn("updateCEntityShow(): Max show depth reached. EntityId = " + rego.entityId);
6241
+ return;
6242
+ }
6243
+ if (show && !rego.relation && !rego.overrideShow && !rego.collection) {
6178
6244
  // Culling is controlled by "visual-register-culler.ts".
6179
6245
  // When an object is unculled then the 'updateEntityShow' function is re-called to reveal it and related objects.
6180
6246
  // A sub-object can be culled while the siblings are not.
@@ -6182,31 +6248,42 @@
6182
6248
  show = !isCulled;
6183
6249
  }
6184
6250
  if (visual._parentEntity && !ignoreParent) {
6185
- updateCEntityShow(viewer, isRelationship, visual._parentEntity, isShowOverriden, show, false);
6251
+ updateCEntityShow(viewer, visual._parentEntity, rego, show, false, depth + 1);
6186
6252
  }
6187
6253
  if (visual._siblingGraphics) {
6188
6254
  for (var i = 0; i < visual._siblingGraphics.length; i++) {
6189
6255
  var sibling = visual._siblingGraphics[i];
6190
- updateCEntityShow(viewer, isRelationship, sibling, isShowOverriden, show, true);
6256
+ updateCEntityShow(viewer, sibling, rego, show, true, depth + 1);
6191
6257
  }
6192
6258
  }
6193
6259
  /**
6194
6260
  * Do NOT use ".show" as it causes crashes in Cesium polylines that are clamped to ground.
6195
6261
  * We could target them specifically here but we may be getting overall performance gain by just removing stuff from the scene.
6196
6262
  */
6197
- if (!show && viewer.entities.contains(visual)) {
6198
- viewer.entities.remove(visual);
6263
+ if (rego.collection) {
6264
+ if (!show && rego.collection.contains(visual)) {
6265
+ rego.collection.remove(visual);
6266
+ }
6267
+ else if (show && !rego.collection.contains(visual)) {
6268
+ rego.collection.add(visual);
6269
+ }
6199
6270
  }
6200
- else if (show && !viewer.entities.contains(visual)) {
6201
- viewer.entities.add(visual);
6271
+ else {
6272
+ if (!show && viewer.entities.contains(visual)) {
6273
+ viewer.entities.remove(visual);
6274
+ }
6275
+ else if (show && !viewer.entities.contains(visual)) {
6276
+ viewer.entities.add(visual);
6277
+ }
6202
6278
  }
6203
6279
  }
6204
- function updateEntityShow(viewer, isRelationship, visual, isShowOverriden, show) {
6280
+ function updateEntityShow(viewer, rego, show) {
6281
+ var visual = rego.visual;
6205
6282
  if (visual instanceof Cesium.Entity) {
6206
6283
  if (!(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
6207
6284
  return;
6208
6285
  }
6209
- updateCEntityShow(viewer, isRelationship, visual, isShowOverriden, show, false);
6286
+ updateCEntityShow(viewer, rego.visual, rego, show, false, 0);
6210
6287
  return;
6211
6288
  }
6212
6289
  if (!isAlive$1(viewer, visual)) {
@@ -6259,7 +6336,7 @@
6259
6336
  if (visible == null) {
6260
6337
  visible = getShowState(rego);
6261
6338
  }
6262
- updateEntityShow(viewer, rego.relation != null, rego.visual, rego.overrideShow != null, visible);
6339
+ updateEntityShow(viewer, rego, visible);
6263
6340
  if (rego.best) {
6264
6341
  var isLabelled = register.GetIsLabelled({
6265
6342
  entityId: entityId
@@ -6376,6 +6453,10 @@
6376
6453
  enumerable: false,
6377
6454
  configurable: true
6378
6455
  });
6456
+ Register.prototype.RefreshMark = function (params) {
6457
+ var rego = params.rego;
6458
+ markEntity(this, rego, rego.visual, false);
6459
+ };
6379
6460
  Register.prototype.Dispose = function () {
6380
6461
  var _a;
6381
6462
  (_a = this.cameraCullerDispose) === null || _a === void 0 ? void 0 : _a.call(this, {
@@ -7998,6 +8079,15 @@
7998
8079
 
7999
8080
  var BATCH_SIZE = 500;
8000
8081
  var CHECK_BATCH_SIZE = 250;
8082
+ function getValue$3(viewer, obj) {
8083
+ if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
8084
+ return obj.getValue(viewer.scene.lastRenderTime);
8085
+ }
8086
+ return obj;
8087
+ }
8088
+ function colorToCColor$2(color) {
8089
+ return new Cesium.Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
8090
+ }
8001
8091
  (function (EntitiesRenderManager) {
8002
8092
  var Manager = /** @class */ (function () {
8003
8093
  function Manager(params) {
@@ -8012,6 +8102,10 @@
8012
8102
  this.viewMonitorRemoval = null;
8013
8103
  this.renderQueue = [];
8014
8104
  this.renderQueueInterval = null;
8105
+ this.sources = [];
8106
+ // Highly experimental flag to try improve rendering large sets of polygons and polylines.
8107
+ // Many things are not supported when this is enabled.
8108
+ this.useGeojson = false;
8015
8109
  var viewer = params.viewer, apiGetter = params.apiGetter, monitor = params.monitor, item = params.item, visualsManager = params.register, sharedGetters = params.sharedGetters;
8016
8110
  this.viewer = viewer;
8017
8111
  this.sharedGetters = sharedGetters;
@@ -8019,6 +8113,7 @@
8019
8113
  this.apiGetter = apiGetter;
8020
8114
  this.item = item;
8021
8115
  this.visualsManager = visualsManager;
8116
+ this.useGeojson = item.renderAsGeojson == true;
8022
8117
  if (item.enableClustering) {
8023
8118
  this.clustering = new PointClustering(this.visualsManager, this.item.id);
8024
8119
  }
@@ -8168,6 +8263,12 @@
8168
8263
  clearInterval(this.renderQueueInterval);
8169
8264
  this.renderQueue = [];
8170
8265
  (_c = this.clustering) === null || _c === void 0 ? void 0 : _c.Dispose();
8266
+ this.clustering = null;
8267
+ for (var i = 0; i < this.sources.length; i++) {
8268
+ var source = this.sources[i];
8269
+ this.viewer.dataSources.remove(source);
8270
+ }
8271
+ this.sources = [];
8171
8272
  };
8172
8273
  Manager.prototype.ReRender = function (params) {
8173
8274
  return __awaiter(this, void 0, void 0, function () {
@@ -8319,14 +8420,14 @@
8319
8420
  }
8320
8421
  };
8321
8422
  Manager.prototype.renderEntities = function (entities, force) {
8322
- var _a, _b, _c, _d;
8423
+ var _a;
8323
8424
  if (force === void 0) { force = false; }
8324
8425
  return __awaiter(this, void 0, void 0, function () {
8325
- var typeId_1, cEntities, i, entity, id, cEntity, visual, wasClustered, tagIds, rego, e_3;
8326
- return __generator(this, function (_e) {
8327
- switch (_e.label) {
8426
+ var typeId_1, e_3;
8427
+ return __generator(this, function (_b) {
8428
+ switch (_b.label) {
8328
8429
  case 0:
8329
- _e.trys.push([0, 2, , 3]);
8430
+ _b.trys.push([0, 5, , 6]);
8330
8431
  if (this.disposed || this.viewer.isDestroyed()) {
8331
8432
  return [2 /*return*/];
8332
8433
  }
@@ -8334,17 +8435,283 @@
8334
8435
  if (typeId_1) {
8335
8436
  entities = entities.filter(function (x) { var _a; return ((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"]) == typeId_1; });
8336
8437
  }
8337
- return [4 /*yield*/, exports.EntityRenderEngine.Render({
8338
- viewer: this.viewer,
8339
- apiGetter: this.apiGetter,
8340
- entities: entities,
8341
- menuItemId: this.item.id,
8342
- visualRegister: this.visualsManager,
8343
- zoomControl: this.item.CameraZoomSettings,
8344
- force: force
8438
+ if (!this.useGeojson) return [3 /*break*/, 2];
8439
+ return [4 /*yield*/, this.renderAsGeojson(entities, force)];
8440
+ case 1:
8441
+ _b.sent();
8442
+ return [3 /*break*/, 4];
8443
+ case 2: return [4 /*yield*/, this.renderAsIndividuals(entities, force)];
8444
+ case 3:
8445
+ _b.sent();
8446
+ _b.label = 4;
8447
+ case 4: return [3 /*break*/, 6];
8448
+ case 5:
8449
+ e_3 = _b.sent();
8450
+ console.error(e_3);
8451
+ return [3 /*break*/, 6];
8452
+ case 6: return [2 /*return*/];
8453
+ }
8454
+ });
8455
+ });
8456
+ };
8457
+ /**
8458
+ * Our optimized and more stable path.
8459
+ * We construct a geojson that we draw in one go.
8460
+ * @param entities
8461
+ * @param force TODO: This should re-render entities that are already rendered.
8462
+ */
8463
+ Manager.prototype.renderAsGeojson = function (entities, force) {
8464
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
8465
+ 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;
8467
+ var _this = this;
8468
+ return __generator(this, function (_k) {
8469
+ switch (_k.label) {
8470
+ case 0:
8471
+ entities = entities.filter(function (entity) {
8472
+ var _a;
8473
+ return !_this.renderedEntities[(_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID];
8474
+ });
8475
+ // Mark these as rendered.
8476
+ entities.forEach(function (entity) {
8477
+ var _a;
8478
+ _this.renderedEntities[(_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID] = true;
8479
+ });
8480
+ 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;
8484
+ case 1:
8485
+ _k.trys.push([1, 3, , 4]);
8486
+ return [4 /*yield*/, bruceModels.Style.Get({
8487
+ api: this.apiGetter.getApi(),
8488
+ styleId: zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID
8345
8489
  })];
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
+ case 4:
8498
+ _k.trys.push([4, 8, , 9]);
8499
+ return [4 /*yield*/, bruceModels.EntityType.Get({
8500
+ entityTypeId: this.item.BruceEntity["EntityType.ID"],
8501
+ api: this.apiGetter.getApi()
8502
+ })];
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];
8507
+ return [4 /*yield*/, bruceModels.Style.Get({
8508
+ api: this.apiGetter.getApi(),
8509
+ styleId: entityType["DisplaySetting.ID"]
8510
+ })];
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
+ 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;
8523
+ bFillColor = bruceModels.Calculator.GetColor(pStyle.fillColor, {}, []);
8524
+ cFillColor = bFillColor ? colorToCColor$2(bFillColor) : Cesium.Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
8525
+ bLineColor = bruceModels.Calculator.GetColor(pStyle.lineColor, {}, []);
8526
+ cLineColor = bLineColor ? colorToCColor$2(bLineColor) : Cesium.Color.fromCssColorString("rgba(80, 80, 80, 0.8)");
8527
+ lineWidthPx = pStyle.lineWidth ? bruceModels.Calculator.GetNumber(pStyle.lineWidth, {}, []) : null;
8528
+ if (lineWidthPx == null) {
8529
+ lineWidthPx = 1;
8530
+ }
8531
+ lineWidthPx = EnsureNumber(lineWidthPx);
8532
+ if (lineWidthPx < 0.01) {
8533
+ lineWidthPx = 0;
8534
+ }
8535
+ lineWidthPx = Math.round(lineWidthPx);
8536
+ geojson = bruceModels.Entity.ToGeoJson({
8537
+ entities: entities,
8538
+ includeUserData: false,
8539
+ excludeAltitude: polygonsClamped && lineWidthPx <= 0,
8540
+ altitude: lineWidthPx > 0 && polygonsClamped ? 1 : null,
8541
+ // No points.
8542
+ allowedDisplayTypes: [bruceModels.ZoomControl.EDisplayType.Geometry]
8543
+ });
8544
+ if (!((_j = geojson === null || geojson === void 0 ? void 0 : geojson.features) === null || _j === void 0 ? void 0 : _j.length)) {
8545
+ return [2 /*return*/];
8546
+ }
8547
+ return [4 /*yield*/, Cesium.GeoJsonDataSource.load(geojson, {
8548
+ stroke: cLineColor,
8549
+ fill: cFillColor,
8550
+ strokeWidth: lineWidthPx,
8551
+ clampToGround: lineWidthPx <= 0 && polygonsClamped
8552
+ })];
8553
+ case 10:
8554
+ source = _k.sent();
8555
+ this.viewer.dataSources.add(source);
8556
+ this.sources.push(source);
8557
+ if (this.disposed) {
8558
+ this.doDispose();
8559
+ return [2 /*return*/];
8560
+ }
8561
+ groups = [];
8562
+ applyStyle = function (thing, entityId, data) {
8563
+ if (thing.polygon) {
8564
+ var bFillColor_1 = bruceModels.Calculator.GetColor(pStyle.fillColor, data, []);
8565
+ var cFillColor_1 = bFillColor_1 ? colorToCColor$2(bFillColor_1) : Cesium.Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
8566
+ var bLineColor_1 = bruceModels.Calculator.GetColor(pStyle.lineColor, data, []);
8567
+ var cLineColor_1 = bLineColor_1 ? colorToCColor$2(bLineColor_1) : Cesium.Color.fromCssColorString("rgba(80, 80, 80, 0.8)");
8568
+ var width = pStyle.lineWidth ? bruceModels.Calculator.GetNumber(pStyle.lineWidth, data, []) : null;
8569
+ if (width == null) {
8570
+ width = 1;
8571
+ }
8572
+ width = EnsureNumber(width);
8573
+ if (width < 0.01) {
8574
+ width = 0;
8575
+ }
8576
+ var curFillColor = getValue$3(_this.viewer, thing.polygon.material);
8577
+ if (curFillColor && curFillColor instanceof Cesium.ColorMaterialProperty) {
8578
+ curFillColor = curFillColor.color;
8579
+ }
8580
+ var curLineColor = getValue$3(_this.viewer, thing.polygon.outlineColor);
8581
+ if (curLineColor && curLineColor instanceof Cesium.ColorMaterialProperty) {
8582
+ curLineColor = curLineColor.color;
8583
+ }
8584
+ var curWidth = getValue$3(_this.viewer, thing.polygon.outlineWidth);
8585
+ if ((curFillColor instanceof Cesium.Color && curFillColor.equals(cFillColor_1)) &&
8586
+ (curLineColor instanceof Cesium.Color && curLineColor.equals(cLineColor_1)) &&
8587
+ curWidth == width) {
8588
+ return;
8589
+ }
8590
+ thing.polygon.material = cFillColor_1;
8591
+ thing.polygon.outlineColor = cLineColor_1;
8592
+ thing.polygon.outlineWidth = width;
8593
+ }
8594
+ else if (thing.polyline) {
8595
+ var bColor = lStyle.lineColor ? bruceModels.Calculator.GetColor(lStyle.lineColor, data, []) : null;
8596
+ var cColor = bColor ? colorToCColor$2(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
8597
+ var width = lStyle.lineWidth ? bruceModels.Calculator.GetNumber(lStyle.lineWidth, data, []) : null;
8598
+ if (width == null) {
8599
+ width = 2;
8600
+ }
8601
+ width = EnsureNumber(width);
8602
+ if (width < 0.01) {
8603
+ width = 0;
8604
+ }
8605
+ var curColor = getValue$3(_this.viewer, thing.polyline.material);
8606
+ if (curColor && curColor instanceof Cesium.ColorMaterialProperty) {
8607
+ curColor = curColor.color;
8608
+ }
8609
+ var curWidth = getValue$3(_this.viewer, thing.polyline.width);
8610
+ if ((curColor instanceof Cesium.Color && curColor.equals(cColor)) &&
8611
+ curWidth == width) {
8612
+ return;
8613
+ }
8614
+ thing.polyline.material = cColor;
8615
+ thing.polyline.width = width;
8616
+ }
8617
+ };
8618
+ register = function (thing) {
8619
+ var _a, _b, _c, _d;
8620
+ // See if the cesium entity already exists in a group.
8621
+ 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; }); });
8622
+ if (group) {
8623
+ return;
8624
+ }
8625
+ var metadata = getValue$3(_this.viewer, thing === null || thing === void 0 ? void 0 : thing.properties);
8626
+ var entityId = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _a === void 0 ? void 0 : _a.ID;
8627
+ if (!entityId) {
8628
+ return;
8629
+ }
8630
+ // Find group for the nextspace entity ID.
8631
+ group = groups.find(function (x) { return x.entityId == entityId; });
8632
+ // No group yet. We can designate this as the primary entity and create a new group for it.
8633
+ if (!group) {
8634
+ group = {
8635
+ entityId: entityId,
8636
+ visual: thing,
8637
+ tagIds: (_b = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _b === void 0 ? void 0 : _b["Layer.ID"],
8638
+ entityTypeId: (_c = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _c === void 0 ? void 0 : _c["EntityType.ID"],
8639
+ siblings: [],
8640
+ data: entities.find(function (x) { var _a; return ((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID) == entityId; }),
8641
+ rego: null
8642
+ };
8643
+ groups.push(group);
8644
+ var rego = {
8645
+ entityId: entityId,
8646
+ menuItemId: _this.item.id,
8647
+ visual: thing,
8648
+ priority: 0,
8649
+ entityTypeId: group.entityTypeId,
8650
+ accountId: _this.apiGetter.accountId,
8651
+ tagIds: group.tagIds ? [].concat(group.tagIds) : [],
8652
+ name: (_d = bruceModels.Entity.CalculateName({
8653
+ entity: group.data,
8654
+ type: entityType,
8655
+ defaultToId: false
8656
+ })) !== null && _d !== void 0 ? _d : "Unnamed Entity",
8657
+ cdn: _this.item.cdnEnabled,
8658
+ collection: source.entities
8659
+ };
8660
+ group.rego = rego;
8661
+ _this.visualsManager.AddRego({
8662
+ rego: rego,
8663
+ requestRender: false
8664
+ });
8665
+ }
8666
+ // Found a group. We flag this as a sibling entity of the primary.
8667
+ else {
8668
+ group.siblings.push(thing);
8669
+ group.visual._siblingGraphics = group.siblings;
8670
+ thing._parentEntity = group.visual;
8671
+ if (group.rego) {
8672
+ _this.visualsManager.RefreshMark({
8673
+ rego: group.rego
8674
+ });
8675
+ }
8676
+ }
8677
+ applyStyle(thing, entityId, group.data);
8678
+ };
8679
+ sEntities = source.entities.values;
8680
+ for (i = 0; i < sEntities.length; i++) {
8681
+ cEntity = sEntities[i];
8682
+ register(cEntity);
8683
+ }
8684
+ this.viewer.scene.requestRender();
8685
+ return [2 /*return*/];
8686
+ }
8687
+ });
8688
+ });
8689
+ };
8690
+ /**
8691
+ * Our default path.
8692
+ * We render each entity individually.
8693
+ * @param entities
8694
+ * @param force
8695
+ * @returns
8696
+ */
8697
+ Manager.prototype.renderAsIndividuals = function (entities, force) {
8698
+ var _a, _b, _c;
8699
+ if (force === void 0) { force = false; }
8700
+ return __awaiter(this, void 0, void 0, function () {
8701
+ var cEntities, i, entity, id, cEntity, visual, wasClustered, tagIds, rego;
8702
+ return __generator(this, function (_d) {
8703
+ switch (_d.label) {
8704
+ case 0: return [4 /*yield*/, exports.EntityRenderEngine.Render({
8705
+ viewer: this.viewer,
8706
+ apiGetter: this.apiGetter,
8707
+ entities: entities,
8708
+ menuItemId: this.item.id,
8709
+ visualRegister: this.visualsManager,
8710
+ zoomControl: this.item.CameraZoomSettings,
8711
+ force: force
8712
+ })];
8346
8713
  case 1:
8347
- cEntities = _e.sent();
8714
+ cEntities = _d.sent();
8348
8715
  if (this.disposed) {
8349
8716
  this.doDispose();
8350
8717
  return [2 /*return*/];
@@ -8355,13 +8722,13 @@
8355
8722
  cEntity = cEntities[id];
8356
8723
  this.renderedEntities[id] = !!cEntity;
8357
8724
  if (cEntity) {
8358
- visual = (_b = this.visualsManager.GetRego({
8725
+ visual = (_a = this.visualsManager.GetRego({
8359
8726
  entityId: id,
8360
8727
  menuItemId: this.item.id
8361
- })) === null || _b === void 0 ? void 0 : _b.visual;
8728
+ })) === null || _a === void 0 ? void 0 : _a.visual;
8362
8729
  if (!visual || visual != cEntity) {
8363
8730
  wasClustered = this.clustering ? this.clustering.AddEntity(id, cEntity, false) : false;
8364
- tagIds = (_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c["Layer.ID"];
8731
+ tagIds = (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["Layer.ID"];
8365
8732
  rego = {
8366
8733
  entityId: id,
8367
8734
  menuItemId: this.item.id,
@@ -8386,19 +8753,14 @@
8386
8753
  menuItemId: this.item.id,
8387
8754
  requestRender: false
8388
8755
  });
8389
- (_d = this.clustering) === null || _d === void 0 ? void 0 : _d.RemoveEntity(id, false);
8756
+ (_c = this.clustering) === null || _c === void 0 ? void 0 : _c.RemoveEntity(id, false);
8390
8757
  }
8391
8758
  }
8392
8759
  this.viewer.scene.requestRender();
8393
8760
  if (this.clustering && entities.length) {
8394
8761
  this.clustering.Update();
8395
8762
  }
8396
- return [3 /*break*/, 3];
8397
- case 2:
8398
- e_3 = _e.sent();
8399
- console.error(e_3);
8400
- return [3 /*break*/, 3];
8401
- case 3: return [2 /*return*/];
8763
+ return [2 /*return*/];
8402
8764
  }
8403
8765
  });
8404
8766
  });
@@ -9267,7 +9629,7 @@
9267
9629
  EntityRenderManager.Manager = Manager;
9268
9630
  })(exports.EntityRenderManager || (exports.EntityRenderManager = {}));
9269
9631
 
9270
- function colorToCColor$2(color) {
9632
+ function colorToCColor$3(color) {
9271
9633
  return new Cesium.Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
9272
9634
  }
9273
9635
  /**
@@ -9728,6 +10090,7 @@
9728
10090
  this.styleMappingLoaded = false;
9729
10091
  this.styleMappingsLoaded = {};
9730
10092
  this.fallbackStyle = null;
10093
+ this.loadingCounter = 0;
9731
10094
  this.runningQueues = 0;
9732
10095
  this.recordLoadQueue = [];
9733
10096
  this.recordCheckQueue = [];
@@ -9739,6 +10102,7 @@
9739
10102
  // ND-1641. BOOKMARKS - (DEMO) View does not match bookmark.
9740
10103
  // We have some evil hard-coded style mappings that need to be fixed.
9741
10104
  // These exist within legacy project views.
10105
+ // Update: This now also lets people have a style mapping without a real style record.
9742
10106
  if ((_a = this.styleMapping) === null || _a === void 0 ? void 0 : _a.length) {
9743
10107
  for (var i = 0; i < this.styleMapping.length; i++) {
9744
10108
  var mapItem = this.styleMapping[i];
@@ -9757,6 +10121,42 @@
9757
10121
  enumerable: false,
9758
10122
  configurable: true
9759
10123
  });
10124
+ /**
10125
+ * Updates style mapping and fallback style.
10126
+ * This will trigger a re-style of all entities, and will stop existing style loads.
10127
+ * @param params
10128
+ */
10129
+ Styler.prototype.UpdateStyleMapping = function (params) {
10130
+ var _a;
10131
+ if (params.styleMapping) {
10132
+ this.styleMapping = params.styleMapping;
10133
+ // ND-1641. BOOKMARKS - (DEMO) View does not match bookmark.
10134
+ // We have some evil hard-coded style mappings that need to be fixed.
10135
+ // These exist within legacy project views.
10136
+ // Update: This now also lets people have a style mapping without a real style record.
10137
+ if ((_a = this.styleMapping) === null || _a === void 0 ? void 0 : _a.length) {
10138
+ for (var i = 0; i < this.styleMapping.length; i++) {
10139
+ var mapItem = this.styleMapping[i];
10140
+ var mapStyle = mapItem.style ? mapItem.style : mapItem.Style;
10141
+ this.styleMapping[i].style = correctStyle(mapStyle);
10142
+ }
10143
+ }
10144
+ }
10145
+ if (isNaN(params.fallbackStyleId) && params.fallbackStyleId != null) {
10146
+ this.fallbackStyleId = params.fallbackStyleId;
10147
+ }
10148
+ // Empty queues.
10149
+ // Requeue all.
10150
+ this.recordLoadQueue = [];
10151
+ this.recordCheckQueue = [];
10152
+ var regos = this.register.GetRegos({
10153
+ menuItemId: this.menuItemId
10154
+ });
10155
+ this.styleMappingLoaded = false;
10156
+ this.styleMappingsLoaded = {};
10157
+ this.QueueEntities(regos);
10158
+ this.loadStyles();
10159
+ };
9760
10160
  Styler.prototype.QueueEntities = function (entities, highPriority) {
9761
10161
  if (highPriority === void 0) { highPriority = false; }
9762
10162
  for (var i = 0; i < entities.length; i++) {
@@ -9848,10 +10248,14 @@
9848
10248
  Styler.prototype.loadStyles = function () {
9849
10249
  var _a, _b;
9850
10250
  return __awaiter(this, void 0, void 0, function () {
9851
- var fallbackStyleId, data, e_1, styleMapping, modelTree, entityTypeIds, _loop_2, i, i, styleMap, styleId, entityType, e_2, data, e_3;
10251
+ var counter, fallbackStyleId, data, e_1, styleMapping, modelTree, entityTypeIds, _loop_2, i, i, styleMap, styleId, entityType, e_2, data, e_3;
9852
10252
  return __generator(this, function (_c) {
9853
10253
  switch (_c.label) {
9854
10254
  case 0:
10255
+ counter = ++this.loadingCounter;
10256
+ this.styleMappingLoaded = false;
10257
+ this.styleMappingsLoaded = {};
10258
+ this.fallbackStyle = null;
9855
10259
  fallbackStyleId = this.fallbackStyleId;
9856
10260
  if (!(fallbackStyleId && fallbackStyleId > 0)) return [3 /*break*/, 4];
9857
10261
  _c.label = 1;
@@ -9870,6 +10274,9 @@
9870
10274
  console.error(e_1);
9871
10275
  return [3 /*break*/, 4];
9872
10276
  case 4:
10277
+ if (this.loadingCounter != counter) {
10278
+ return [2 /*return*/];
10279
+ }
9873
10280
  styleMapping = this.styleMapping;
9874
10281
  if (!styleMapping) {
9875
10282
  styleMapping = [];
@@ -9902,12 +10309,12 @@
9902
10309
  i = 0;
9903
10310
  _c.label = 5;
9904
10311
  case 5:
9905
- if (!(i < styleMapping.length)) return [3 /*break*/, 15];
10312
+ if (!(i < styleMapping.length)) return [3 /*break*/, 16];
9906
10313
  if (this.disposed) {
9907
- return [3 /*break*/, 15];
10314
+ return [3 /*break*/, 16];
9908
10315
  }
9909
10316
  styleMap = styleMapping[i];
9910
- if (!(!styleMap.style && styleMap.StyleID != -1)) return [3 /*break*/, 13];
10317
+ if (!(!styleMap.style && styleMap.StyleID != -1)) return [3 /*break*/, 14];
9911
10318
  styleId = styleMap.StyleID;
9912
10319
  if (!!styleId) return [3 /*break*/, 9];
9913
10320
  _c.label = 6;
@@ -9946,22 +10353,33 @@
9946
10353
  console.error(e_3);
9947
10354
  return [3 /*break*/, 13];
9948
10355
  case 13:
10356
+ if (this.loadingCounter != counter) {
10357
+ return [2 /*return*/];
10358
+ }
10359
+ _c.label = 14;
10360
+ case 14:
9949
10361
  this.styleMappingsLoaded[styleMap.EntityTypeID] = true;
9950
10362
  this.processTilesetFeatureCheckQueue();
9951
10363
  this.processQueue();
9952
- _c.label = 14;
9953
- case 14:
10364
+ _c.label = 15;
10365
+ case 15:
9954
10366
  i++;
9955
10367
  return [3 /*break*/, 5];
9956
- case 15:
10368
+ case 16:
10369
+ if (this.loadingCounter != counter) {
10370
+ return [2 /*return*/];
10371
+ }
9957
10372
  this.styleMappingLoaded = true;
9958
- if (!!this.disposed) return [3 /*break*/, 17];
10373
+ if (!!this.disposed) return [3 /*break*/, 18];
9959
10374
  return [4 /*yield*/, this.processTilesetFeatureCheckQueue()];
9960
- case 16:
10375
+ case 17:
9961
10376
  _c.sent();
10377
+ if (this.loadingCounter != counter) {
10378
+ return [2 /*return*/];
10379
+ }
9962
10380
  this.processQueue();
9963
- _c.label = 17;
9964
- case 17: return [2 /*return*/];
10381
+ _c.label = 18;
10382
+ case 18: return [2 /*return*/];
9965
10383
  }
9966
10384
  });
9967
10385
  });
@@ -10076,18 +10494,24 @@
10076
10494
  };
10077
10495
  Styler.prototype.styleTilesetFeatureFullData = function (entity, data) {
10078
10496
  var _a;
10079
- var style = this.getTilesetFeatureStyle(entity.entityId, entity.entityTypeId);
10080
- if (!style) {
10497
+ var visual = entity.visual;
10498
+ if (!visual || !(visual instanceof Cesium.Cesium3DTileFeature)) {
10081
10499
  return;
10082
10500
  }
10083
- var bColor = ((_a = style.modelStyle) === null || _a === void 0 ? void 0 : _a.fillColor) ? bruceModels.Calculator.GetColor(style.modelStyle.fillColor, data, []) : null;
10084
- if (bColor != null) {
10085
- var cColor = colorToCColor$2(bColor);
10086
- var visual = entity.visual;
10087
- if (visual && visual instanceof Cesium.Cesium3DTileFeature) {
10088
- visual.color = cColor;
10089
- }
10501
+ var style = this.getTilesetFeatureStyle(entity.entityId, entity.entityTypeId);
10502
+ var bColor = style && ((_a = style.modelStyle) === null || _a === void 0 ? void 0 : _a.fillColor) ? bruceModels.Calculator.GetColor(style.modelStyle.fillColor, data, []) : null;
10503
+ var cColor = null;
10504
+ if (bColor == null) {
10505
+ cColor = Cesium.Color.WHITE;
10506
+ }
10507
+ else {
10508
+ cColor = colorToCColor$3(bColor);
10090
10509
  }
10510
+ CesiumEntityStyler.SetDefaultColor({
10511
+ color: cColor,
10512
+ entity: visual,
10513
+ viewer: this.viewer
10514
+ });
10091
10515
  };
10092
10516
  Styler.prototype.getTilesetFeatureStyle = function (entityId, entityTypeId) {
10093
10517
  var _a, _b, _c, _d;
@@ -10236,6 +10660,13 @@
10236
10660
  enumerable: false,
10237
10661
  configurable: true
10238
10662
  });
10663
+ Object.defineProperty(Manager.prototype, "Styler", {
10664
+ get: function () {
10665
+ return this.styler;
10666
+ },
10667
+ enumerable: false,
10668
+ configurable: true
10669
+ });
10239
10670
  Manager.prototype.Init = function () {
10240
10671
  var _this = this;
10241
10672
  var _a;
@@ -12061,6 +12492,13 @@
12061
12492
  enumerable: false,
12062
12493
  configurable: true
12063
12494
  });
12495
+ Object.defineProperty(Manager.prototype, "Styler", {
12496
+ get: function () {
12497
+ return this.styler;
12498
+ },
12499
+ enumerable: false,
12500
+ configurable: true
12501
+ });
12064
12502
  Manager.prototype.Init = function () {
12065
12503
  var _this = this;
12066
12504
  var _a, _b, _c;
@@ -20049,7 +20487,7 @@
20049
20487
  CesiumViewMonitor.Monitor = Monitor;
20050
20488
  })(exports.CesiumViewMonitor || (exports.CesiumViewMonitor = {}));
20051
20489
 
20052
- var VERSION$1 = "3.3.7";
20490
+ var VERSION$1 = "3.3.9";
20053
20491
 
20054
20492
  exports.VERSION = VERSION$1;
20055
20493
  exports.CesiumParabola = CesiumParabola;