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
@@ -1,6 +1,6 @@
1
1
  import { Cartes, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ProjectViewTile, DelayQueue, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, EntityRelationType, ENVIRONMENT, BruceEvent, EntityCoords, Api, EntitySource, MenuItem, EntityRelation, ProgramKey, AbstractApi, ProjectViewBookmark, EntityAttachment, EntityAttachmentType, EntityAttribute, ProjectView, ProjectViewLegacyTile, Camera } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, DistanceDisplayCondition, NearFarScalar, Model, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, SceneMode, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidGeodesic, EllipsoidTerrainProvider, sampleTerrainMostDetailed, defined, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, BoundingSphere, GeometryInstance, PolygonPipeline, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ColorMaterialProperty } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, Entity, Primitive, Cesium3DTileFeature, JulianDate, DistanceDisplayCondition, NearFarScalar, Model, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, SceneMode, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, GeoJsonDataSource, ColorMaterialProperty, KmlDataSource, SceneTransforms, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, CesiumInspector, OrthographicFrustum, defined, PolygonPipeline, BoundingSphere, Matrix3, Matrix4, EasingFunction, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Cesium3DTileset, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, Intersect, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -742,6 +742,66 @@ var CesiumEntityStyler;
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 = 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 Cesium3DTileFeature) {
765
+ var opacity = getAppliedOpacity(part);
766
+ storeColor(viewer, "default", params.color, part);
767
+ refreshColor(viewer, part, opacity);
768
+ }
769
+ else if (part instanceof 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.
@@ -3052,7 +3112,7 @@ function runCullChecker(register) {
3052
3112
  var rego = register.GetRego({
3053
3113
  entityId: entityId
3054
3114
  });
3055
- if (!rego || !rego.visual || !(rego.visual instanceof Entity) || rego.relation != null || rego.overrideShow != null) {
3115
+ if (!rego || !rego.visual || !(rego.visual instanceof Entity) || rego.relation != null || rego.overrideShow != null || rego.collection) {
3056
3116
  continue;
3057
3117
  }
3058
3118
  var parts = EntityUtils.GatherEntity({
@@ -6181,8 +6241,14 @@ function removeEntity(viewer, visual) {
6181
6241
  }
6182
6242
  }
6183
6243
  }
6184
- function updateCEntityShow(viewer, isRelationship, visual, isShowOverriden, show, ignoreParent) {
6185
- if (show && !isRelationship && !isShowOverriden) {
6244
+ var MAX_SHOW_DEPTH = 10;
6245
+ function updateCEntityShow(viewer, visual, rego, show, ignoreParent, depth) {
6246
+ if (depth === void 0) { depth = 0; }
6247
+ if (depth > MAX_SHOW_DEPTH) {
6248
+ console.warn("updateCEntityShow(): Max show depth reached. EntityId = " + rego.entityId);
6249
+ return;
6250
+ }
6251
+ if (show && !rego.relation && !rego.overrideShow && !rego.collection) {
6186
6252
  // Culling is controlled by "visual-register-culler.ts".
6187
6253
  // When an object is unculled then the 'updateEntityShow' function is re-called to reveal it and related objects.
6188
6254
  // A sub-object can be culled while the siblings are not.
@@ -6190,31 +6256,42 @@ function updateCEntityShow(viewer, isRelationship, visual, isShowOverriden, show
6190
6256
  show = !isCulled;
6191
6257
  }
6192
6258
  if (visual._parentEntity && !ignoreParent) {
6193
- updateCEntityShow(viewer, isRelationship, visual._parentEntity, isShowOverriden, show, false);
6259
+ updateCEntityShow(viewer, visual._parentEntity, rego, show, false, depth + 1);
6194
6260
  }
6195
6261
  if (visual._siblingGraphics) {
6196
6262
  for (var i = 0; i < visual._siblingGraphics.length; i++) {
6197
6263
  var sibling = visual._siblingGraphics[i];
6198
- updateCEntityShow(viewer, isRelationship, sibling, isShowOverriden, show, true);
6264
+ updateCEntityShow(viewer, sibling, rego, show, true, depth + 1);
6199
6265
  }
6200
6266
  }
6201
6267
  /**
6202
6268
  * Do NOT use ".show" as it causes crashes in Cesium polylines that are clamped to ground.
6203
6269
  * We could target them specifically here but we may be getting overall performance gain by just removing stuff from the scene.
6204
6270
  */
6205
- if (!show && viewer.entities.contains(visual)) {
6206
- viewer.entities.remove(visual);
6271
+ if (rego.collection) {
6272
+ if (!show && rego.collection.contains(visual)) {
6273
+ rego.collection.remove(visual);
6274
+ }
6275
+ else if (show && !rego.collection.contains(visual)) {
6276
+ rego.collection.add(visual);
6277
+ }
6207
6278
  }
6208
- else if (show && !viewer.entities.contains(visual)) {
6209
- viewer.entities.add(visual);
6279
+ else {
6280
+ if (!show && viewer.entities.contains(visual)) {
6281
+ viewer.entities.remove(visual);
6282
+ }
6283
+ else if (show && !viewer.entities.contains(visual)) {
6284
+ viewer.entities.add(visual);
6285
+ }
6210
6286
  }
6211
6287
  }
6212
- function updateEntityShow(viewer, isRelationship, visual, isShowOverriden, show) {
6288
+ function updateEntityShow(viewer, rego, show) {
6289
+ var visual = rego.visual;
6213
6290
  if (visual instanceof Entity) {
6214
6291
  if (!(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
6215
6292
  return;
6216
6293
  }
6217
- updateCEntityShow(viewer, isRelationship, visual, isShowOverriden, show, false);
6294
+ updateCEntityShow(viewer, rego.visual, rego, show, false, 0);
6218
6295
  return;
6219
6296
  }
6220
6297
  if (!isAlive$1(viewer, visual)) {
@@ -6267,7 +6344,7 @@ function updateEntity(viewer, entityId, register) {
6267
6344
  if (visible == null) {
6268
6345
  visible = getShowState(rego);
6269
6346
  }
6270
- updateEntityShow(viewer, rego.relation != null, rego.visual, rego.overrideShow != null, visible);
6347
+ updateEntityShow(viewer, rego, visible);
6271
6348
  if (rego.best) {
6272
6349
  var isLabelled = register.GetIsLabelled({
6273
6350
  entityId: entityId
@@ -6389,6 +6466,10 @@ var VisualsRegister;
6389
6466
  enumerable: false,
6390
6467
  configurable: true
6391
6468
  });
6469
+ Register.prototype.RefreshMark = function (params) {
6470
+ var rego = params.rego;
6471
+ markEntity(this, rego, rego.visual, false);
6472
+ };
6392
6473
  Register.prototype.Dispose = function () {
6393
6474
  var _a;
6394
6475
  (_a = this.cameraCullerDispose) === null || _a === void 0 ? void 0 : _a.call(this, {
@@ -8011,6 +8092,15 @@ var PointClustering = /** @class */ (function () {
8011
8092
 
8012
8093
  var BATCH_SIZE = 500;
8013
8094
  var CHECK_BATCH_SIZE = 250;
8095
+ function getValue$3(viewer, obj) {
8096
+ if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
8097
+ return obj.getValue(viewer.scene.lastRenderTime);
8098
+ }
8099
+ return obj;
8100
+ }
8101
+ function colorToCColor$2(color) {
8102
+ return new Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
8103
+ }
8014
8104
  /**
8015
8105
  * Manager for rendering Bruce entities.
8016
8106
  * This will request entities based on setup menu item filter.
@@ -8030,6 +8120,10 @@ var EntitiesRenderManager;
8030
8120
  this.viewMonitorRemoval = null;
8031
8121
  this.renderQueue = [];
8032
8122
  this.renderQueueInterval = null;
8123
+ this.sources = [];
8124
+ // Highly experimental flag to try improve rendering large sets of polygons and polylines.
8125
+ // Many things are not supported when this is enabled.
8126
+ this.useGeojson = false;
8033
8127
  var viewer = params.viewer, apiGetter = params.apiGetter, monitor = params.monitor, item = params.item, visualsManager = params.register, sharedGetters = params.sharedGetters;
8034
8128
  this.viewer = viewer;
8035
8129
  this.sharedGetters = sharedGetters;
@@ -8037,6 +8131,7 @@ var EntitiesRenderManager;
8037
8131
  this.apiGetter = apiGetter;
8038
8132
  this.item = item;
8039
8133
  this.visualsManager = visualsManager;
8134
+ this.useGeojson = item.renderAsGeojson == true;
8040
8135
  if (item.enableClustering) {
8041
8136
  this.clustering = new PointClustering(this.visualsManager, this.item.id);
8042
8137
  }
@@ -8186,6 +8281,12 @@ var EntitiesRenderManager;
8186
8281
  clearInterval(this.renderQueueInterval);
8187
8282
  this.renderQueue = [];
8188
8283
  (_c = this.clustering) === null || _c === void 0 ? void 0 : _c.Dispose();
8284
+ this.clustering = null;
8285
+ for (var i = 0; i < this.sources.length; i++) {
8286
+ var source = this.sources[i];
8287
+ this.viewer.dataSources.remove(source);
8288
+ }
8289
+ this.sources = [];
8189
8290
  };
8190
8291
  Manager.prototype.ReRender = function (params) {
8191
8292
  return __awaiter(this, void 0, void 0, function () {
@@ -8337,14 +8438,14 @@ var EntitiesRenderManager;
8337
8438
  }
8338
8439
  };
8339
8440
  Manager.prototype.renderEntities = function (entities, force) {
8340
- var _a, _b, _c, _d;
8441
+ var _a;
8341
8442
  if (force === void 0) { force = false; }
8342
8443
  return __awaiter(this, void 0, void 0, function () {
8343
- var typeId_1, cEntities, i, entity, id, cEntity, visual, wasClustered, tagIds, rego, e_3;
8344
- return __generator(this, function (_e) {
8345
- switch (_e.label) {
8444
+ var typeId_1, e_3;
8445
+ return __generator(this, function (_b) {
8446
+ switch (_b.label) {
8346
8447
  case 0:
8347
- _e.trys.push([0, 2, , 3]);
8448
+ _b.trys.push([0, 5, , 6]);
8348
8449
  if (this.disposed || this.viewer.isDestroyed()) {
8349
8450
  return [2 /*return*/];
8350
8451
  }
@@ -8352,17 +8453,283 @@ var EntitiesRenderManager;
8352
8453
  if (typeId_1) {
8353
8454
  entities = entities.filter(function (x) { var _a; return ((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a["EntityType.ID"]) == typeId_1; });
8354
8455
  }
8355
- return [4 /*yield*/, EntityRenderEngine.Render({
8356
- viewer: this.viewer,
8357
- apiGetter: this.apiGetter,
8358
- entities: entities,
8359
- menuItemId: this.item.id,
8360
- visualRegister: this.visualsManager,
8361
- zoomControl: this.item.CameraZoomSettings,
8362
- force: force
8456
+ if (!this.useGeojson) return [3 /*break*/, 2];
8457
+ return [4 /*yield*/, this.renderAsGeojson(entities, force)];
8458
+ case 1:
8459
+ _b.sent();
8460
+ return [3 /*break*/, 4];
8461
+ case 2: return [4 /*yield*/, this.renderAsIndividuals(entities, force)];
8462
+ case 3:
8463
+ _b.sent();
8464
+ _b.label = 4;
8465
+ case 4: return [3 /*break*/, 6];
8466
+ case 5:
8467
+ e_3 = _b.sent();
8468
+ console.error(e_3);
8469
+ return [3 /*break*/, 6];
8470
+ case 6: return [2 /*return*/];
8471
+ }
8472
+ });
8473
+ });
8474
+ };
8475
+ /**
8476
+ * Our optimized and more stable path.
8477
+ * We construct a geojson that we draw in one go.
8478
+ * @param entities
8479
+ * @param force TODO: This should re-render entities that are already rendered.
8480
+ */
8481
+ Manager.prototype.renderAsGeojson = function (entities, force) {
8482
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
8483
+ return __awaiter(this, void 0, void 0, function () {
8484
+ var zoomItem, style, e_4, entityType, e_5, pStyle, lStyle, polygonsClamped, bFillColor, cFillColor, bLineColor, cLineColor, lineWidthPx, geojson, source, groups, applyStyle, register, sEntities, i, cEntity;
8485
+ var _this = this;
8486
+ return __generator(this, function (_k) {
8487
+ switch (_k.label) {
8488
+ case 0:
8489
+ entities = entities.filter(function (entity) {
8490
+ var _a;
8491
+ return !_this.renderedEntities[(_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID];
8492
+ });
8493
+ // Mark these as rendered.
8494
+ entities.forEach(function (entity) {
8495
+ var _a;
8496
+ _this.renderedEntities[(_a = entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID] = true;
8497
+ });
8498
+ zoomItem = this.item.CameraZoomSettings[0];
8499
+ style = null;
8500
+ if (!(zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID)) return [3 /*break*/, 4];
8501
+ _k.label = 1;
8502
+ case 1:
8503
+ _k.trys.push([1, 3, , 4]);
8504
+ return [4 /*yield*/, Style.Get({
8505
+ api: this.apiGetter.getApi(),
8506
+ styleId: zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.StyleID
8363
8507
  })];
8508
+ case 2:
8509
+ style = (_a = (_k.sent()).style) === null || _a === void 0 ? void 0 : _a.Settings;
8510
+ return [3 /*break*/, 4];
8511
+ case 3:
8512
+ e_4 = _k.sent();
8513
+ console.error(e_4);
8514
+ return [3 /*break*/, 4];
8515
+ case 4:
8516
+ _k.trys.push([4, 8, , 9]);
8517
+ return [4 /*yield*/, EntityType.Get({
8518
+ entityTypeId: this.item.BruceEntity["EntityType.ID"],
8519
+ api: this.apiGetter.getApi()
8520
+ })];
8521
+ case 5:
8522
+ entityType = (_b = (_k.sent())) === null || _b === void 0 ? void 0 : _b.entityType;
8523
+ if (!(!style && ((_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c["EntityType.ID"]))) return [3 /*break*/, 7];
8524
+ if (!entityType["DisplaySetting.ID"]) return [3 /*break*/, 7];
8525
+ return [4 /*yield*/, Style.Get({
8526
+ api: this.apiGetter.getApi(),
8527
+ styleId: entityType["DisplaySetting.ID"]
8528
+ })];
8529
+ case 6:
8530
+ style = (_d = (_k.sent()).style) === null || _d === void 0 ? void 0 : _d.Settings;
8531
+ _k.label = 7;
8532
+ case 7: return [3 /*break*/, 9];
8533
+ case 8:
8534
+ e_5 = _k.sent();
8535
+ console.error(e_5);
8536
+ return [3 /*break*/, 9];
8537
+ case 9:
8538
+ pStyle = (_e = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _e !== void 0 ? _e : {};
8539
+ lStyle = (_f = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _f !== void 0 ? _f : {};
8540
+ 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;
8541
+ bFillColor = Calculator.GetColor(pStyle.fillColor, {}, []);
8542
+ cFillColor = bFillColor ? colorToCColor$2(bFillColor) : Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
8543
+ bLineColor = Calculator.GetColor(pStyle.lineColor, {}, []);
8544
+ cLineColor = bLineColor ? colorToCColor$2(bLineColor) : Color.fromCssColorString("rgba(80, 80, 80, 0.8)");
8545
+ lineWidthPx = pStyle.lineWidth ? Calculator.GetNumber(pStyle.lineWidth, {}, []) : null;
8546
+ if (lineWidthPx == null) {
8547
+ lineWidthPx = 1;
8548
+ }
8549
+ lineWidthPx = EnsureNumber(lineWidthPx);
8550
+ if (lineWidthPx < 0.01) {
8551
+ lineWidthPx = 0;
8552
+ }
8553
+ lineWidthPx = Math.round(lineWidthPx);
8554
+ geojson = Entity$1.ToGeoJson({
8555
+ entities: entities,
8556
+ includeUserData: false,
8557
+ excludeAltitude: polygonsClamped && lineWidthPx <= 0,
8558
+ altitude: lineWidthPx > 0 && polygonsClamped ? 1 : null,
8559
+ // No points.
8560
+ allowedDisplayTypes: [ZoomControl.EDisplayType.Geometry]
8561
+ });
8562
+ if (!((_j = geojson === null || geojson === void 0 ? void 0 : geojson.features) === null || _j === void 0 ? void 0 : _j.length)) {
8563
+ return [2 /*return*/];
8564
+ }
8565
+ return [4 /*yield*/, GeoJsonDataSource.load(geojson, {
8566
+ stroke: cLineColor,
8567
+ fill: cFillColor,
8568
+ strokeWidth: lineWidthPx,
8569
+ clampToGround: lineWidthPx <= 0 && polygonsClamped
8570
+ })];
8571
+ case 10:
8572
+ source = _k.sent();
8573
+ this.viewer.dataSources.add(source);
8574
+ this.sources.push(source);
8575
+ if (this.disposed) {
8576
+ this.doDispose();
8577
+ return [2 /*return*/];
8578
+ }
8579
+ groups = [];
8580
+ applyStyle = function (thing, entityId, data) {
8581
+ if (thing.polygon) {
8582
+ var bFillColor_1 = Calculator.GetColor(pStyle.fillColor, data, []);
8583
+ var cFillColor_1 = bFillColor_1 ? colorToCColor$2(bFillColor_1) : Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
8584
+ var bLineColor_1 = Calculator.GetColor(pStyle.lineColor, data, []);
8585
+ var cLineColor_1 = bLineColor_1 ? colorToCColor$2(bLineColor_1) : Color.fromCssColorString("rgba(80, 80, 80, 0.8)");
8586
+ var width = pStyle.lineWidth ? Calculator.GetNumber(pStyle.lineWidth, data, []) : null;
8587
+ if (width == null) {
8588
+ width = 1;
8589
+ }
8590
+ width = EnsureNumber(width);
8591
+ if (width < 0.01) {
8592
+ width = 0;
8593
+ }
8594
+ var curFillColor = getValue$3(_this.viewer, thing.polygon.material);
8595
+ if (curFillColor && curFillColor instanceof ColorMaterialProperty) {
8596
+ curFillColor = curFillColor.color;
8597
+ }
8598
+ var curLineColor = getValue$3(_this.viewer, thing.polygon.outlineColor);
8599
+ if (curLineColor && curLineColor instanceof ColorMaterialProperty) {
8600
+ curLineColor = curLineColor.color;
8601
+ }
8602
+ var curWidth = getValue$3(_this.viewer, thing.polygon.outlineWidth);
8603
+ if ((curFillColor instanceof Color && curFillColor.equals(cFillColor_1)) &&
8604
+ (curLineColor instanceof Color && curLineColor.equals(cLineColor_1)) &&
8605
+ curWidth == width) {
8606
+ return;
8607
+ }
8608
+ thing.polygon.material = cFillColor_1;
8609
+ thing.polygon.outlineColor = cLineColor_1;
8610
+ thing.polygon.outlineWidth = width;
8611
+ }
8612
+ else if (thing.polyline) {
8613
+ var bColor = lStyle.lineColor ? Calculator.GetColor(lStyle.lineColor, data, []) : null;
8614
+ var cColor = bColor ? colorToCColor$2(bColor) : Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
8615
+ var width = lStyle.lineWidth ? Calculator.GetNumber(lStyle.lineWidth, data, []) : null;
8616
+ if (width == null) {
8617
+ width = 2;
8618
+ }
8619
+ width = EnsureNumber(width);
8620
+ if (width < 0.01) {
8621
+ width = 0;
8622
+ }
8623
+ var curColor = getValue$3(_this.viewer, thing.polyline.material);
8624
+ if (curColor && curColor instanceof ColorMaterialProperty) {
8625
+ curColor = curColor.color;
8626
+ }
8627
+ var curWidth = getValue$3(_this.viewer, thing.polyline.width);
8628
+ if ((curColor instanceof Color && curColor.equals(cColor)) &&
8629
+ curWidth == width) {
8630
+ return;
8631
+ }
8632
+ thing.polyline.material = cColor;
8633
+ thing.polyline.width = width;
8634
+ }
8635
+ };
8636
+ register = function (thing) {
8637
+ var _a, _b, _c, _d;
8638
+ // See if the cesium entity already exists in a group.
8639
+ 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; }); });
8640
+ if (group) {
8641
+ return;
8642
+ }
8643
+ var metadata = getValue$3(_this.viewer, thing === null || thing === void 0 ? void 0 : thing.properties);
8644
+ var entityId = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _a === void 0 ? void 0 : _a.ID;
8645
+ if (!entityId) {
8646
+ return;
8647
+ }
8648
+ // Find group for the nextspace entity ID.
8649
+ group = groups.find(function (x) { return x.entityId == entityId; });
8650
+ // No group yet. We can designate this as the primary entity and create a new group for it.
8651
+ if (!group) {
8652
+ group = {
8653
+ entityId: entityId,
8654
+ visual: thing,
8655
+ tagIds: (_b = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _b === void 0 ? void 0 : _b["Layer.ID"],
8656
+ entityTypeId: (_c = metadata === null || metadata === void 0 ? void 0 : metadata.Bruce) === null || _c === void 0 ? void 0 : _c["EntityType.ID"],
8657
+ siblings: [],
8658
+ data: entities.find(function (x) { var _a; return ((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.ID) == entityId; }),
8659
+ rego: null
8660
+ };
8661
+ groups.push(group);
8662
+ var rego = {
8663
+ entityId: entityId,
8664
+ menuItemId: _this.item.id,
8665
+ visual: thing,
8666
+ priority: 0,
8667
+ entityTypeId: group.entityTypeId,
8668
+ accountId: _this.apiGetter.accountId,
8669
+ tagIds: group.tagIds ? [].concat(group.tagIds) : [],
8670
+ name: (_d = Entity$1.CalculateName({
8671
+ entity: group.data,
8672
+ type: entityType,
8673
+ defaultToId: false
8674
+ })) !== null && _d !== void 0 ? _d : "Unnamed Entity",
8675
+ cdn: _this.item.cdnEnabled,
8676
+ collection: source.entities
8677
+ };
8678
+ group.rego = rego;
8679
+ _this.visualsManager.AddRego({
8680
+ rego: rego,
8681
+ requestRender: false
8682
+ });
8683
+ }
8684
+ // Found a group. We flag this as a sibling entity of the primary.
8685
+ else {
8686
+ group.siblings.push(thing);
8687
+ group.visual._siblingGraphics = group.siblings;
8688
+ thing._parentEntity = group.visual;
8689
+ if (group.rego) {
8690
+ _this.visualsManager.RefreshMark({
8691
+ rego: group.rego
8692
+ });
8693
+ }
8694
+ }
8695
+ applyStyle(thing, entityId, group.data);
8696
+ };
8697
+ sEntities = source.entities.values;
8698
+ for (i = 0; i < sEntities.length; i++) {
8699
+ cEntity = sEntities[i];
8700
+ register(cEntity);
8701
+ }
8702
+ this.viewer.scene.requestRender();
8703
+ return [2 /*return*/];
8704
+ }
8705
+ });
8706
+ });
8707
+ };
8708
+ /**
8709
+ * Our default path.
8710
+ * We render each entity individually.
8711
+ * @param entities
8712
+ * @param force
8713
+ * @returns
8714
+ */
8715
+ Manager.prototype.renderAsIndividuals = function (entities, force) {
8716
+ var _a, _b, _c;
8717
+ if (force === void 0) { force = false; }
8718
+ return __awaiter(this, void 0, void 0, function () {
8719
+ var cEntities, i, entity, id, cEntity, visual, wasClustered, tagIds, rego;
8720
+ return __generator(this, function (_d) {
8721
+ switch (_d.label) {
8722
+ case 0: return [4 /*yield*/, EntityRenderEngine.Render({
8723
+ viewer: this.viewer,
8724
+ apiGetter: this.apiGetter,
8725
+ entities: entities,
8726
+ menuItemId: this.item.id,
8727
+ visualRegister: this.visualsManager,
8728
+ zoomControl: this.item.CameraZoomSettings,
8729
+ force: force
8730
+ })];
8364
8731
  case 1:
8365
- cEntities = _e.sent();
8732
+ cEntities = _d.sent();
8366
8733
  if (this.disposed) {
8367
8734
  this.doDispose();
8368
8735
  return [2 /*return*/];
@@ -8373,13 +8740,13 @@ var EntitiesRenderManager;
8373
8740
  cEntity = cEntities[id];
8374
8741
  this.renderedEntities[id] = !!cEntity;
8375
8742
  if (cEntity) {
8376
- visual = (_b = this.visualsManager.GetRego({
8743
+ visual = (_a = this.visualsManager.GetRego({
8377
8744
  entityId: id,
8378
8745
  menuItemId: this.item.id
8379
- })) === null || _b === void 0 ? void 0 : _b.visual;
8746
+ })) === null || _a === void 0 ? void 0 : _a.visual;
8380
8747
  if (!visual || visual != cEntity) {
8381
8748
  wasClustered = this.clustering ? this.clustering.AddEntity(id, cEntity, false) : false;
8382
- tagIds = (_c = entity.Bruce) === null || _c === void 0 ? void 0 : _c["Layer.ID"];
8749
+ tagIds = (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["Layer.ID"];
8383
8750
  rego = {
8384
8751
  entityId: id,
8385
8752
  menuItemId: this.item.id,
@@ -8404,19 +8771,14 @@ var EntitiesRenderManager;
8404
8771
  menuItemId: this.item.id,
8405
8772
  requestRender: false
8406
8773
  });
8407
- (_d = this.clustering) === null || _d === void 0 ? void 0 : _d.RemoveEntity(id, false);
8774
+ (_c = this.clustering) === null || _c === void 0 ? void 0 : _c.RemoveEntity(id, false);
8408
8775
  }
8409
8776
  }
8410
8777
  this.viewer.scene.requestRender();
8411
8778
  if (this.clustering && entities.length) {
8412
8779
  this.clustering.Update();
8413
8780
  }
8414
- return [3 /*break*/, 3];
8415
- case 2:
8416
- e_3 = _e.sent();
8417
- console.error(e_3);
8418
- return [3 /*break*/, 3];
8419
- case 3: return [2 /*return*/];
8781
+ return [2 /*return*/];
8420
8782
  }
8421
8783
  });
8422
8784
  });
@@ -9300,7 +9662,7 @@ var EntityRenderManager;
9300
9662
  EntityRenderManager.Manager = Manager;
9301
9663
  })(EntityRenderManager || (EntityRenderManager = {}));
9302
9664
 
9303
- function colorToCColor$2(color) {
9665
+ function colorToCColor$3(color) {
9304
9666
  return new Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
9305
9667
  }
9306
9668
  /**
@@ -9762,6 +10124,7 @@ var TilesetRenderEngine;
9762
10124
  this.styleMappingLoaded = false;
9763
10125
  this.styleMappingsLoaded = {};
9764
10126
  this.fallbackStyle = null;
10127
+ this.loadingCounter = 0;
9765
10128
  this.runningQueues = 0;
9766
10129
  this.recordLoadQueue = [];
9767
10130
  this.recordCheckQueue = [];
@@ -9773,6 +10136,7 @@ var TilesetRenderEngine;
9773
10136
  // ND-1641. BOOKMARKS - (DEMO) View does not match bookmark.
9774
10137
  // We have some evil hard-coded style mappings that need to be fixed.
9775
10138
  // These exist within legacy project views.
10139
+ // Update: This now also lets people have a style mapping without a real style record.
9776
10140
  if ((_a = this.styleMapping) === null || _a === void 0 ? void 0 : _a.length) {
9777
10141
  for (var i = 0; i < this.styleMapping.length; i++) {
9778
10142
  var mapItem = this.styleMapping[i];
@@ -9791,6 +10155,42 @@ var TilesetRenderEngine;
9791
10155
  enumerable: false,
9792
10156
  configurable: true
9793
10157
  });
10158
+ /**
10159
+ * Updates style mapping and fallback style.
10160
+ * This will trigger a re-style of all entities, and will stop existing style loads.
10161
+ * @param params
10162
+ */
10163
+ Styler.prototype.UpdateStyleMapping = function (params) {
10164
+ var _a;
10165
+ if (params.styleMapping) {
10166
+ this.styleMapping = params.styleMapping;
10167
+ // ND-1641. BOOKMARKS - (DEMO) View does not match bookmark.
10168
+ // We have some evil hard-coded style mappings that need to be fixed.
10169
+ // These exist within legacy project views.
10170
+ // Update: This now also lets people have a style mapping without a real style record.
10171
+ if ((_a = this.styleMapping) === null || _a === void 0 ? void 0 : _a.length) {
10172
+ for (var i = 0; i < this.styleMapping.length; i++) {
10173
+ var mapItem = this.styleMapping[i];
10174
+ var mapStyle = mapItem.style ? mapItem.style : mapItem.Style;
10175
+ this.styleMapping[i].style = correctStyle(mapStyle);
10176
+ }
10177
+ }
10178
+ }
10179
+ if (isNaN(params.fallbackStyleId) && params.fallbackStyleId != null) {
10180
+ this.fallbackStyleId = params.fallbackStyleId;
10181
+ }
10182
+ // Empty queues.
10183
+ // Requeue all.
10184
+ this.recordLoadQueue = [];
10185
+ this.recordCheckQueue = [];
10186
+ var regos = this.register.GetRegos({
10187
+ menuItemId: this.menuItemId
10188
+ });
10189
+ this.styleMappingLoaded = false;
10190
+ this.styleMappingsLoaded = {};
10191
+ this.QueueEntities(regos);
10192
+ this.loadStyles();
10193
+ };
9794
10194
  Styler.prototype.QueueEntities = function (entities, highPriority) {
9795
10195
  if (highPriority === void 0) { highPriority = false; }
9796
10196
  for (var i = 0; i < entities.length; i++) {
@@ -9882,10 +10282,14 @@ var TilesetRenderEngine;
9882
10282
  Styler.prototype.loadStyles = function () {
9883
10283
  var _a, _b;
9884
10284
  return __awaiter(this, void 0, void 0, function () {
9885
- var fallbackStyleId, data, e_1, styleMapping, modelTree, entityTypeIds, _loop_2, i, i, styleMap, styleId, entityType, e_2, data, e_3;
10285
+ var counter, fallbackStyleId, data, e_1, styleMapping, modelTree, entityTypeIds, _loop_2, i, i, styleMap, styleId, entityType, e_2, data, e_3;
9886
10286
  return __generator(this, function (_c) {
9887
10287
  switch (_c.label) {
9888
10288
  case 0:
10289
+ counter = ++this.loadingCounter;
10290
+ this.styleMappingLoaded = false;
10291
+ this.styleMappingsLoaded = {};
10292
+ this.fallbackStyle = null;
9889
10293
  fallbackStyleId = this.fallbackStyleId;
9890
10294
  if (!(fallbackStyleId && fallbackStyleId > 0)) return [3 /*break*/, 4];
9891
10295
  _c.label = 1;
@@ -9904,6 +10308,9 @@ var TilesetRenderEngine;
9904
10308
  console.error(e_1);
9905
10309
  return [3 /*break*/, 4];
9906
10310
  case 4:
10311
+ if (this.loadingCounter != counter) {
10312
+ return [2 /*return*/];
10313
+ }
9907
10314
  styleMapping = this.styleMapping;
9908
10315
  if (!styleMapping) {
9909
10316
  styleMapping = [];
@@ -9936,12 +10343,12 @@ var TilesetRenderEngine;
9936
10343
  i = 0;
9937
10344
  _c.label = 5;
9938
10345
  case 5:
9939
- if (!(i < styleMapping.length)) return [3 /*break*/, 15];
10346
+ if (!(i < styleMapping.length)) return [3 /*break*/, 16];
9940
10347
  if (this.disposed) {
9941
- return [3 /*break*/, 15];
10348
+ return [3 /*break*/, 16];
9942
10349
  }
9943
10350
  styleMap = styleMapping[i];
9944
- if (!(!styleMap.style && styleMap.StyleID != -1)) return [3 /*break*/, 13];
10351
+ if (!(!styleMap.style && styleMap.StyleID != -1)) return [3 /*break*/, 14];
9945
10352
  styleId = styleMap.StyleID;
9946
10353
  if (!!styleId) return [3 /*break*/, 9];
9947
10354
  _c.label = 6;
@@ -9980,22 +10387,33 @@ var TilesetRenderEngine;
9980
10387
  console.error(e_3);
9981
10388
  return [3 /*break*/, 13];
9982
10389
  case 13:
10390
+ if (this.loadingCounter != counter) {
10391
+ return [2 /*return*/];
10392
+ }
10393
+ _c.label = 14;
10394
+ case 14:
9983
10395
  this.styleMappingsLoaded[styleMap.EntityTypeID] = true;
9984
10396
  this.processTilesetFeatureCheckQueue();
9985
10397
  this.processQueue();
9986
- _c.label = 14;
9987
- case 14:
10398
+ _c.label = 15;
10399
+ case 15:
9988
10400
  i++;
9989
10401
  return [3 /*break*/, 5];
9990
- case 15:
10402
+ case 16:
10403
+ if (this.loadingCounter != counter) {
10404
+ return [2 /*return*/];
10405
+ }
9991
10406
  this.styleMappingLoaded = true;
9992
- if (!!this.disposed) return [3 /*break*/, 17];
10407
+ if (!!this.disposed) return [3 /*break*/, 18];
9993
10408
  return [4 /*yield*/, this.processTilesetFeatureCheckQueue()];
9994
- case 16:
10409
+ case 17:
9995
10410
  _c.sent();
10411
+ if (this.loadingCounter != counter) {
10412
+ return [2 /*return*/];
10413
+ }
9996
10414
  this.processQueue();
9997
- _c.label = 17;
9998
- case 17: return [2 /*return*/];
10415
+ _c.label = 18;
10416
+ case 18: return [2 /*return*/];
9999
10417
  }
10000
10418
  });
10001
10419
  });
@@ -10110,18 +10528,24 @@ var TilesetRenderEngine;
10110
10528
  };
10111
10529
  Styler.prototype.styleTilesetFeatureFullData = function (entity, data) {
10112
10530
  var _a;
10113
- var style = this.getTilesetFeatureStyle(entity.entityId, entity.entityTypeId);
10114
- if (!style) {
10531
+ var visual = entity.visual;
10532
+ if (!visual || !(visual instanceof Cesium3DTileFeature)) {
10115
10533
  return;
10116
10534
  }
10117
- var bColor = ((_a = style.modelStyle) === null || _a === void 0 ? void 0 : _a.fillColor) ? Calculator.GetColor(style.modelStyle.fillColor, data, []) : null;
10118
- if (bColor != null) {
10119
- var cColor = colorToCColor$2(bColor);
10120
- var visual = entity.visual;
10121
- if (visual && visual instanceof Cesium3DTileFeature) {
10122
- visual.color = cColor;
10123
- }
10535
+ var style = this.getTilesetFeatureStyle(entity.entityId, entity.entityTypeId);
10536
+ var bColor = style && ((_a = style.modelStyle) === null || _a === void 0 ? void 0 : _a.fillColor) ? Calculator.GetColor(style.modelStyle.fillColor, data, []) : null;
10537
+ var cColor = null;
10538
+ if (bColor == null) {
10539
+ cColor = Color.WHITE;
10540
+ }
10541
+ else {
10542
+ cColor = colorToCColor$3(bColor);
10124
10543
  }
10544
+ CesiumEntityStyler.SetDefaultColor({
10545
+ color: cColor,
10546
+ entity: visual,
10547
+ viewer: this.viewer
10548
+ });
10125
10549
  };
10126
10550
  Styler.prototype.getTilesetFeatureStyle = function (entityId, entityTypeId) {
10127
10551
  var _a, _b, _c, _d;
@@ -10275,6 +10699,13 @@ var TilesetCadRenderManager;
10275
10699
  enumerable: false,
10276
10700
  configurable: true
10277
10701
  });
10702
+ Object.defineProperty(Manager.prototype, "Styler", {
10703
+ get: function () {
10704
+ return this.styler;
10705
+ },
10706
+ enumerable: false,
10707
+ configurable: true
10708
+ });
10278
10709
  Manager.prototype.Init = function () {
10279
10710
  var _this = this;
10280
10711
  var _a;
@@ -12106,6 +12537,13 @@ var TilesetArbRenderManager;
12106
12537
  enumerable: false,
12107
12538
  configurable: true
12108
12539
  });
12540
+ Object.defineProperty(Manager.prototype, "Styler", {
12541
+ get: function () {
12542
+ return this.styler;
12543
+ },
12544
+ enumerable: false,
12545
+ configurable: true
12546
+ });
12109
12547
  Manager.prototype.Init = function () {
12110
12548
  var _this = this;
12111
12549
  var _a, _b, _c;
@@ -20108,7 +20546,7 @@ var CesiumViewMonitor;
20108
20546
  CesiumViewMonitor$$1.Monitor = Monitor;
20109
20547
  })(CesiumViewMonitor || (CesiumViewMonitor = {}));
20110
20548
 
20111
- var VERSION$1 = "3.3.7";
20549
+ var VERSION$1 = "3.3.9";
20112
20550
 
20113
20551
  export { VERSION$1 as VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, Draw3dPolygon, Draw3dPolyline };
20114
20552
  //# sourceMappingURL=bruce-cesium.es5.js.map