bruce-cesium 3.3.8 → 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.
@@ -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.
@@ -8401,12 +8461,12 @@
8401
8461
  * @param force TODO: This should re-render entities that are already rendered.
8402
8462
  */
8403
8463
  Manager.prototype.renderAsGeojson = function (entities, force) {
8404
- var _a, _b, _c, _d, _e, _f, _g, _h;
8464
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
8405
8465
  return __awaiter(this, void 0, void 0, function () {
8406
- var zoomItem, style, e_4, entityType, e_5, pStyle, polygonsClamped, bFillColor, cFillColor, bLineColor, cLineColor, lineWidthPx, geojson, source, groups, register, sEntities, i, cEntity;
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;
8407
8467
  var _this = this;
8408
- return __generator(this, function (_j) {
8409
- switch (_j.label) {
8468
+ return __generator(this, function (_k) {
8469
+ switch (_k.label) {
8410
8470
  case 0:
8411
8471
  entities = entities.filter(function (entity) {
8412
8472
  var _a;
@@ -8420,28 +8480,28 @@
8420
8480
  zoomItem = this.item.CameraZoomSettings[0];
8421
8481
  style = null;
8422
8482
  if (!(zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID)) return [3 /*break*/, 4];
8423
- _j.label = 1;
8483
+ _k.label = 1;
8424
8484
  case 1:
8425
- _j.trys.push([1, 3, , 4]);
8485
+ _k.trys.push([1, 3, , 4]);
8426
8486
  return [4 /*yield*/, bruceModels.Style.Get({
8427
8487
  api: this.apiGetter.getApi(),
8428
8488
  styleId: zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID
8429
8489
  })];
8430
8490
  case 2:
8431
- style = (_a = (_j.sent()).style) === null || _a === void 0 ? void 0 : _a.Settings;
8491
+ style = (_a = (_k.sent()).style) === null || _a === void 0 ? void 0 : _a.Settings;
8432
8492
  return [3 /*break*/, 4];
8433
8493
  case 3:
8434
- e_4 = _j.sent();
8494
+ e_4 = _k.sent();
8435
8495
  console.error(e_4);
8436
8496
  return [3 /*break*/, 4];
8437
8497
  case 4:
8438
- _j.trys.push([4, 8, , 9]);
8498
+ _k.trys.push([4, 8, , 9]);
8439
8499
  return [4 /*yield*/, bruceModels.EntityType.Get({
8440
8500
  entityTypeId: this.item.BruceEntity["EntityType.ID"],
8441
8501
  api: this.apiGetter.getApi()
8442
8502
  })];
8443
8503
  case 5:
8444
- entityType = (_b = (_j.sent())) === null || _b === void 0 ? void 0 : _b.entityType;
8504
+ entityType = (_b = (_k.sent())) === null || _b === void 0 ? void 0 : _b.entityType;
8445
8505
  if (!(!style && ((_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c["EntityType.ID"]))) return [3 /*break*/, 7];
8446
8506
  if (!entityType["DisplaySetting.ID"]) return [3 /*break*/, 7];
8447
8507
  return [4 /*yield*/, bruceModels.Style.Get({
@@ -8449,16 +8509,17 @@
8449
8509
  styleId: entityType["DisplaySetting.ID"]
8450
8510
  })];
8451
8511
  case 6:
8452
- style = (_d = (_j.sent()).style) === null || _d === void 0 ? void 0 : _d.Settings;
8453
- _j.label = 7;
8512
+ style = (_d = (_k.sent()).style) === null || _d === void 0 ? void 0 : _d.Settings;
8513
+ _k.label = 7;
8454
8514
  case 7: return [3 /*break*/, 9];
8455
8515
  case 8:
8456
- e_5 = _j.sent();
8516
+ e_5 = _k.sent();
8457
8517
  console.error(e_5);
8458
8518
  return [3 /*break*/, 9];
8459
8519
  case 9:
8460
8520
  pStyle = (_e = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _e !== void 0 ? _e : {};
8461
- polygonsClamped = ((_f = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _f === void 0 ? void 0 : _f.id) == null ? true : ((_g = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _g === void 0 ? void 0 : _g.id) == 0;
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;
8462
8523
  bFillColor = bruceModels.Calculator.GetColor(pStyle.fillColor, {}, []);
8463
8524
  cFillColor = bFillColor ? colorToCColor$2(bFillColor) : Cesium.Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
8464
8525
  bLineColor = bruceModels.Calculator.GetColor(pStyle.lineColor, {}, []);
@@ -8480,7 +8541,7 @@
8480
8541
  // No points.
8481
8542
  allowedDisplayTypes: [bruceModels.ZoomControl.EDisplayType.Geometry]
8482
8543
  });
8483
- if (!((_h = geojson === null || geojson === void 0 ? void 0 : geojson.features) === null || _h === void 0 ? void 0 : _h.length)) {
8544
+ if (!((_j = geojson === null || geojson === void 0 ? void 0 : geojson.features) === null || _j === void 0 ? void 0 : _j.length)) {
8484
8545
  return [2 /*return*/];
8485
8546
  }
8486
8547
  return [4 /*yield*/, Cesium.GeoJsonDataSource.load(geojson, {
@@ -8490,7 +8551,7 @@
8490
8551
  clampToGround: lineWidthPx <= 0 && polygonsClamped
8491
8552
  })];
8492
8553
  case 10:
8493
- source = _j.sent();
8554
+ source = _k.sent();
8494
8555
  this.viewer.dataSources.add(source);
8495
8556
  this.sources.push(source);
8496
8557
  if (this.disposed) {
@@ -8498,6 +8559,62 @@
8498
8559
  return [2 /*return*/];
8499
8560
  }
8500
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
+ };
8501
8618
  register = function (thing) {
8502
8619
  var _a, _b, _c, _d;
8503
8620
  // See if the cesium entity already exists in a group.
@@ -8557,8 +8674,7 @@
8557
8674
  });
8558
8675
  }
8559
8676
  }
8560
- // Won't do individual styles for now. More stability that way.
8561
- // applyStyle(thing, entityId, group.data);
8677
+ applyStyle(thing, entityId, group.data);
8562
8678
  };
8563
8679
  sEntities = source.entities.values;
8564
8680
  for (i = 0; i < sEntities.length; i++) {
@@ -9974,6 +10090,7 @@
9974
10090
  this.styleMappingLoaded = false;
9975
10091
  this.styleMappingsLoaded = {};
9976
10092
  this.fallbackStyle = null;
10093
+ this.loadingCounter = 0;
9977
10094
  this.runningQueues = 0;
9978
10095
  this.recordLoadQueue = [];
9979
10096
  this.recordCheckQueue = [];
@@ -9985,6 +10102,7 @@
9985
10102
  // ND-1641. BOOKMARKS - (DEMO) View does not match bookmark.
9986
10103
  // We have some evil hard-coded style mappings that need to be fixed.
9987
10104
  // These exist within legacy project views.
10105
+ // Update: This now also lets people have a style mapping without a real style record.
9988
10106
  if ((_a = this.styleMapping) === null || _a === void 0 ? void 0 : _a.length) {
9989
10107
  for (var i = 0; i < this.styleMapping.length; i++) {
9990
10108
  var mapItem = this.styleMapping[i];
@@ -10003,6 +10121,42 @@
10003
10121
  enumerable: false,
10004
10122
  configurable: true
10005
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
+ };
10006
10160
  Styler.prototype.QueueEntities = function (entities, highPriority) {
10007
10161
  if (highPriority === void 0) { highPriority = false; }
10008
10162
  for (var i = 0; i < entities.length; i++) {
@@ -10094,10 +10248,14 @@
10094
10248
  Styler.prototype.loadStyles = function () {
10095
10249
  var _a, _b;
10096
10250
  return __awaiter(this, void 0, void 0, function () {
10097
- 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;
10098
10252
  return __generator(this, function (_c) {
10099
10253
  switch (_c.label) {
10100
10254
  case 0:
10255
+ counter = ++this.loadingCounter;
10256
+ this.styleMappingLoaded = false;
10257
+ this.styleMappingsLoaded = {};
10258
+ this.fallbackStyle = null;
10101
10259
  fallbackStyleId = this.fallbackStyleId;
10102
10260
  if (!(fallbackStyleId && fallbackStyleId > 0)) return [3 /*break*/, 4];
10103
10261
  _c.label = 1;
@@ -10116,6 +10274,9 @@
10116
10274
  console.error(e_1);
10117
10275
  return [3 /*break*/, 4];
10118
10276
  case 4:
10277
+ if (this.loadingCounter != counter) {
10278
+ return [2 /*return*/];
10279
+ }
10119
10280
  styleMapping = this.styleMapping;
10120
10281
  if (!styleMapping) {
10121
10282
  styleMapping = [];
@@ -10148,12 +10309,12 @@
10148
10309
  i = 0;
10149
10310
  _c.label = 5;
10150
10311
  case 5:
10151
- if (!(i < styleMapping.length)) return [3 /*break*/, 15];
10312
+ if (!(i < styleMapping.length)) return [3 /*break*/, 16];
10152
10313
  if (this.disposed) {
10153
- return [3 /*break*/, 15];
10314
+ return [3 /*break*/, 16];
10154
10315
  }
10155
10316
  styleMap = styleMapping[i];
10156
- if (!(!styleMap.style && styleMap.StyleID != -1)) return [3 /*break*/, 13];
10317
+ if (!(!styleMap.style && styleMap.StyleID != -1)) return [3 /*break*/, 14];
10157
10318
  styleId = styleMap.StyleID;
10158
10319
  if (!!styleId) return [3 /*break*/, 9];
10159
10320
  _c.label = 6;
@@ -10192,22 +10353,33 @@
10192
10353
  console.error(e_3);
10193
10354
  return [3 /*break*/, 13];
10194
10355
  case 13:
10356
+ if (this.loadingCounter != counter) {
10357
+ return [2 /*return*/];
10358
+ }
10359
+ _c.label = 14;
10360
+ case 14:
10195
10361
  this.styleMappingsLoaded[styleMap.EntityTypeID] = true;
10196
10362
  this.processTilesetFeatureCheckQueue();
10197
10363
  this.processQueue();
10198
- _c.label = 14;
10199
- case 14:
10364
+ _c.label = 15;
10365
+ case 15:
10200
10366
  i++;
10201
10367
  return [3 /*break*/, 5];
10202
- case 15:
10368
+ case 16:
10369
+ if (this.loadingCounter != counter) {
10370
+ return [2 /*return*/];
10371
+ }
10203
10372
  this.styleMappingLoaded = true;
10204
- if (!!this.disposed) return [3 /*break*/, 17];
10373
+ if (!!this.disposed) return [3 /*break*/, 18];
10205
10374
  return [4 /*yield*/, this.processTilesetFeatureCheckQueue()];
10206
- case 16:
10375
+ case 17:
10207
10376
  _c.sent();
10377
+ if (this.loadingCounter != counter) {
10378
+ return [2 /*return*/];
10379
+ }
10208
10380
  this.processQueue();
10209
- _c.label = 17;
10210
- case 17: return [2 /*return*/];
10381
+ _c.label = 18;
10382
+ case 18: return [2 /*return*/];
10211
10383
  }
10212
10384
  });
10213
10385
  });
@@ -10322,18 +10494,24 @@
10322
10494
  };
10323
10495
  Styler.prototype.styleTilesetFeatureFullData = function (entity, data) {
10324
10496
  var _a;
10325
- var style = this.getTilesetFeatureStyle(entity.entityId, entity.entityTypeId);
10326
- if (!style) {
10497
+ var visual = entity.visual;
10498
+ if (!visual || !(visual instanceof Cesium.Cesium3DTileFeature)) {
10327
10499
  return;
10328
10500
  }
10329
- var bColor = ((_a = style.modelStyle) === null || _a === void 0 ? void 0 : _a.fillColor) ? bruceModels.Calculator.GetColor(style.modelStyle.fillColor, data, []) : null;
10330
- if (bColor != null) {
10331
- var cColor = colorToCColor$3(bColor);
10332
- var visual = entity.visual;
10333
- if (visual && visual instanceof Cesium.Cesium3DTileFeature) {
10334
- visual.color = cColor;
10335
- }
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;
10336
10506
  }
10507
+ else {
10508
+ cColor = colorToCColor$3(bColor);
10509
+ }
10510
+ CesiumEntityStyler.SetDefaultColor({
10511
+ color: cColor,
10512
+ entity: visual,
10513
+ viewer: this.viewer
10514
+ });
10337
10515
  };
10338
10516
  Styler.prototype.getTilesetFeatureStyle = function (entityId, entityTypeId) {
10339
10517
  var _a, _b, _c, _d;
@@ -10482,6 +10660,13 @@
10482
10660
  enumerable: false,
10483
10661
  configurable: true
10484
10662
  });
10663
+ Object.defineProperty(Manager.prototype, "Styler", {
10664
+ get: function () {
10665
+ return this.styler;
10666
+ },
10667
+ enumerable: false,
10668
+ configurable: true
10669
+ });
10485
10670
  Manager.prototype.Init = function () {
10486
10671
  var _this = this;
10487
10672
  var _a;
@@ -12307,6 +12492,13 @@
12307
12492
  enumerable: false,
12308
12493
  configurable: true
12309
12494
  });
12495
+ Object.defineProperty(Manager.prototype, "Styler", {
12496
+ get: function () {
12497
+ return this.styler;
12498
+ },
12499
+ enumerable: false,
12500
+ configurable: true
12501
+ });
12310
12502
  Manager.prototype.Init = function () {
12311
12503
  var _this = this;
12312
12504
  var _a, _b, _c;
@@ -20295,7 +20487,7 @@
20295
20487
  CesiumViewMonitor.Monitor = Monitor;
20296
20488
  })(exports.CesiumViewMonitor || (exports.CesiumViewMonitor = {}));
20297
20489
 
20298
- var VERSION$1 = "3.3.8";
20490
+ var VERSION$1 = "3.3.9";
20299
20491
 
20300
20492
  exports.VERSION = VERSION$1;
20301
20493
  exports.CesiumParabola = CesiumParabola;