bruce-cesium 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { BruceEvent, Cartes, ProjectViewTile, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, EntityRelationType, DelayQueue, EntityCoords, Api, EntitySource, MenuItem, EntityRelation, ENVIRONMENT, ProjectView, ProjectViewBookmark, ProjectViewLegacyTile, ProgramKey, Camera, AbstractApi, EntityAttachment, EntityAttachmentType, EntityAttribute } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, CallbackProperty, Cartesian3, Color, Rectangle, Math as Math$1, JulianDate, SceneMode, HeightReference, DistanceDisplayCondition, NearFarScalar, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, EllipsoidTerrainProvider, CesiumInspector, OrthographicFrustum, defined, createWorldTerrain, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, Ion, EllipsoidGeodesic, sampleTerrainMostDetailed, Model, PolygonPipeline, SceneTransforms, EasingFunction, ColorMaterialProperty, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere, Intersect } from 'cesium';
3
+ import { Cartographic, Cartesian2, CallbackProperty, Cartesian3, Color, Rectangle, Math as Math$1, JulianDate, SceneMode, Entity, Primitive, Cesium3DTileFeature, HeightReference, DistanceDisplayCondition, NearFarScalar, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Model, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, CesiumInspector, defined, createWorldTerrain, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, Ion, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ColorMaterialProperty, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere, Intersect } from 'cesium';
4
4
 
5
5
  var TIME_LAG = 300;
6
6
  var POSITION_CHECK_TIMER = 950;
@@ -2589,6 +2589,8 @@ function getRenderGroupId(zoomItem, terrain) {
2589
2589
  }
2590
2590
  var _fileValidationCache = {};
2591
2591
  var _fileHeightCache = {};
2592
+ // Key = url + scale.
2593
+ var _fileRadiusCache = new LRUCache(1000);
2592
2594
  /**
2593
2595
  * @param min
2594
2596
  * @param max
@@ -2869,7 +2871,9 @@ var EntityRenderEngine;
2869
2871
  case 4:
2870
2872
  rendered = rendered.filter(function (x) { return x != null; });
2871
2873
  if (rendered.length) {
2872
- rootEntity_1 = new Entity({});
2874
+ rootEntity_1 = new Entity({
2875
+ id: ObjectUtils.UId(10)
2876
+ });
2873
2877
  rootEntity_1._siblingGraphics = [];
2874
2878
  rootEntity_1._renderGroup = getRenderGroupId(zoomItem, (_h = params.viewer) === null || _h === void 0 ? void 0 : _h.terrainProvider);
2875
2879
  rootEntity_1._siblingGraphics = rootEntity_1._siblingGraphics.concat(rendered);
@@ -3083,6 +3087,7 @@ var EntityRenderEngine;
3083
3087
  if (iconScale > 0) {
3084
3088
  heightRef = getHeightRef(style);
3085
3089
  cEntity = new Entity({
3090
+ id: ObjectUtils.UId(10),
3086
3091
  billboard: {
3087
3092
  horizontalOrigin: HorizontalOrigin.CENTER,
3088
3093
  verticalOrigin: VerticalOrigin.BOTTOM,
@@ -3131,6 +3136,7 @@ var EntityRenderEngine;
3131
3136
  });
3132
3137
  extrusion = getCylinderExtrusion(entity, params.tags, heightRef, style.CylinderFillExtrusion);
3133
3138
  cEntity = new Entity({
3139
+ id: ObjectUtils.UId(10),
3134
3140
  ellipse: {
3135
3141
  semiMajorAxis: radius,
3136
3142
  semiMinorAxis: radius,
@@ -3154,6 +3160,7 @@ var EntityRenderEngine;
3154
3160
  outlineExtrusion.exHeightRef = extrusion.exHeightRef;
3155
3161
  }
3156
3162
  siblings.push(new Entity({
3163
+ id: ObjectUtils.UId(10),
3157
3164
  ellipse: {
3158
3165
  semiMajorAxis: radius + outlineWidth,
3159
3166
  semiMinorAxis: radius + outlineWidth,
@@ -3184,6 +3191,7 @@ var EntityRenderEngine;
3184
3191
  heightRef = getHeightRef(style);
3185
3192
  circleBillboard = createCircleBillboard(size, cColor.toCssColorString());
3186
3193
  cEntity = new Entity({
3194
+ id: ObjectUtils.UId(10),
3187
3195
  // point: {
3188
3196
  // pixelSize: size,
3189
3197
  // color: cColor,
@@ -3362,6 +3370,7 @@ var EntityRenderEngine;
3362
3370
  classification = ClassificationType.BOTH;
3363
3371
  }
3364
3372
  var cEntity = new Entity({
3373
+ id: ObjectUtils.UId(10),
3365
3374
  polyline: units == "px" ? {
3366
3375
  positions: posses,
3367
3376
  material: cColor,
@@ -3519,6 +3528,7 @@ var EntityRenderEngine;
3519
3528
  classification = ClassificationType.BOTH;
3520
3529
  }
3521
3530
  var cEntity = new Entity({
3531
+ id: ObjectUtils.UId(10),
3522
3532
  polygon: {
3523
3533
  hierarchy: new PolygonHierarchy(posses, holePosses.map(function (x) { return new PolygonHierarchy(x); })),
3524
3534
  material: cFillColor,
@@ -3565,6 +3575,7 @@ var EntityRenderEngine;
3565
3575
  borderPosses = posses.map(function (x) { return x.clone ? x.clone() : __assign({}, x); });
3566
3576
  }
3567
3577
  var cEntityBorder = new Entity({
3578
+ id: ObjectUtils.UId(10),
3568
3579
  polyline: units == "px" ? new PolylineGraphics({
3569
3580
  positions: borderPosses,
3570
3581
  material: cLineColor,
@@ -3596,6 +3607,7 @@ var EntityRenderEngine;
3596
3607
  var posses_1 = holePosses[i];
3597
3608
  Cartes.CloseRing3(posses_1);
3598
3609
  var cEntityHole = new Entity({
3610
+ id: ObjectUtils.UId(10),
3599
3611
  polyline: units == "px" ? new PolylineGraphics({
3600
3612
  positions: posses_1,
3601
3613
  material: cLineColor,
@@ -3744,6 +3756,7 @@ var EntityRenderEngine;
3744
3756
  }
3745
3757
  }
3746
3758
  var cEntity = new Entity({
3759
+ id: ObjectUtils.UId(10),
3747
3760
  model: {
3748
3761
  uri: params.lodUrl,
3749
3762
  heightReference: heightRef,
@@ -3758,6 +3771,61 @@ var EntityRenderEngine;
3758
3771
  position: pos,
3759
3772
  show: true
3760
3773
  });
3774
+ var fileRadiusKey = "model3d_".concat(params.lodUrl, "_").concat(scale * styleScale, "_radius");
3775
+ var heightProm = _fileRadiusCache.Get(fileRadiusKey);
3776
+ if (!heightProm) {
3777
+ heightProm = new Promise(function (res) {
3778
+ try {
3779
+ // We'll have an async secondary model created for calculating boundaries.
3780
+ // Once calculated we remove it.
3781
+ var modelPrim_1 = Model.fromGltf({
3782
+ url: params.lodUrl,
3783
+ asynchronous: true,
3784
+ scale: scale * styleScale
3785
+ });
3786
+ modelPrim_1.readyPromise.then(function (loaded) {
3787
+ var kill = function () {
3788
+ if (params.viewer && !params.viewer.isDestroyed() && params.viewer.scene.primitives.contains(modelPrim_1)) {
3789
+ params.viewer.scene.primitives.remove(modelPrim_1);
3790
+ }
3791
+ if (!modelPrim_1.isDestroyed()) {
3792
+ modelPrim_1.destroy();
3793
+ }
3794
+ };
3795
+ if (!cEntity || !(loaded === null || loaded === void 0 ? void 0 : loaded.boundingSphere)) {
3796
+ kill();
3797
+ res(null);
3798
+ return;
3799
+ }
3800
+ var radius = loaded.boundingSphere.radius;
3801
+ var centerOffset = loaded.boundingSphere.center;
3802
+ if (centerOffset) {
3803
+ // Add the center offset to the radius because I am not good at math.
3804
+ var magnitude = Cartesian3.magnitude(centerOffset);
3805
+ radius += magnitude;
3806
+ // Extra padding if the model is super not centered.
3807
+ // I saw some strange boundaries for some bad models.
3808
+ if (magnitude > 100) {
3809
+ radius += 100;
3810
+ }
3811
+ }
3812
+ kill();
3813
+ res(radius);
3814
+ });
3815
+ params.viewer.scene.primitives.add(modelPrim_1);
3816
+ }
3817
+ catch (e) {
3818
+ console.error(e);
3819
+ res(null);
3820
+ }
3821
+ });
3822
+ _fileRadiusCache.Set(fileRadiusKey, heightProm);
3823
+ }
3824
+ heightProm.then(function (radius) {
3825
+ if (model) {
3826
+ model._radius = radius;
3827
+ }
3828
+ });
3761
3829
  var model = cEntity.model;
3762
3830
  model._clientFileId = params.lodClientFileId;
3763
3831
  model._entityScale = {
@@ -5023,8 +5091,84 @@ var EntityLabel;
5023
5091
  EntityLabel.GetLabel = GetLabel;
5024
5092
  })(EntityLabel || (EntityLabel = {}));
5025
5093
 
5026
- // Area in m^2 for 3D model visibility check.
5027
- var MODEL_SIZE_TOLERANCE = 1000;
5094
+ var MODEL_MIN_RADIUS = 1;
5095
+ var POINT_MIN_RADIUS = 15;
5096
+ // If a shape has more than this amount of points, we'll avoid checking it because it will take too long.
5097
+ // We will put responsibility on the bookmark creator to view shapes they can see.
5098
+ var DO_NOT_CULL_AT_LEN_POINTS = 5000;
5099
+ // Returns terrain height at a given position.
5100
+ // This will cache the results based on the terrain provider and position.
5101
+ var _terrainCache = new LRUCache(1000);
5102
+ // Positions within this tolerance from each-other will be re-used.
5103
+ var TERRAIN_HEIGHT_TOLERANCE = 500;
5104
+ var getTerrainOffset = function (viewer, pos3d) {
5105
+ var terrain = ViewUtils.GatherTerrainTile({
5106
+ viewer: viewer
5107
+ }).terrain;
5108
+ if (!terrain || terrain.tilesetId == ProjectViewTile.EDefaultTerrain.FlatTerrain) {
5109
+ return 0;
5110
+ }
5111
+ var terrainId = terrain.tilesetId;
5112
+ // Check for existing values within TOLERANCE distance.
5113
+ var keys = Array.from(_terrainCache.Entries());
5114
+ for (var i = 0; i < keys.length; i++) {
5115
+ var _a = keys[i], key_1 = _a[0], offset_1 = _a[1];
5116
+ var _b = key_1.split("_"), terrainId2 = _b[0], x = _b[1], y = _b[2], z = _b[3];
5117
+ if (terrainId2 != terrainId) {
5118
+ continue;
5119
+ }
5120
+ var pos3d2 = new Cartesian3(parseFloat(x), parseFloat(y), parseFloat(z));
5121
+ var distance = Cartesian3.distance(pos3d, pos3d2);
5122
+ if (distance < TERRAIN_HEIGHT_TOLERANCE) {
5123
+ return offset_1;
5124
+ }
5125
+ }
5126
+ var key = terrainId + "_" + pos3d.x + "_" + pos3d.y + "_" + pos3d.z;
5127
+ var offset = _terrainCache.Get(key);
5128
+ if (offset == null) {
5129
+ var carto = Cartographic.fromCartesian(pos3d);
5130
+ var height = 0;
5131
+ try {
5132
+ height = viewer.scene.globe.getHeight(carto);
5133
+ }
5134
+ catch (e) {
5135
+ // Likely out of rendered area.
5136
+ // This means it's not our problem since the user isn't looking there :)
5137
+ }
5138
+ offset = height;
5139
+ _terrainCache.Set(key, offset);
5140
+ }
5141
+ return offset;
5142
+ };
5143
+ /**
5144
+ * Converts given pos3d into a an absolute position.
5145
+ * This means either setting it to terrain height or adding the height offset.
5146
+ * @param viewer
5147
+ * @param heightRef
5148
+ * @param pos3d
5149
+ * @returns
5150
+ */
5151
+ var adjustPos3d = function (viewer, heightRef, pos3d) {
5152
+ if (heightRef == HeightReference.NONE) {
5153
+ return pos3d;
5154
+ }
5155
+ var offset = getTerrainOffset(viewer, pos3d);
5156
+ if (!offset) {
5157
+ return pos3d;
5158
+ }
5159
+ var carto = Cartographic.fromCartesian(pos3d);
5160
+ if (heightRef == HeightReference.CLAMP_TO_GROUND) {
5161
+ carto.height = offset;
5162
+ }
5163
+ else {
5164
+ carto.height += offset;
5165
+ }
5166
+ var newPos3d = Cartographic.toCartesian(carto);
5167
+ if (!(newPos3d === null || newPos3d === void 0 ? void 0 : newPos3d.x)) {
5168
+ return pos3d;
5169
+ }
5170
+ return newPos3d;
5171
+ };
5028
5172
  function getValue$2(viewer, obj) {
5029
5173
  if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
5030
5174
  return obj.getValue(viewer.scene.lastRenderTime);
@@ -5040,7 +5184,7 @@ function isFlatTerrain(viewer) {
5040
5184
  viewer: viewer
5041
5185
  }).terrain) === null || _a === void 0 ? void 0 : _a.tilesetId) == ProjectViewTile.EDefaultTerrain.FlatTerrain;
5042
5186
  }
5043
- var boundingSphereCache = {};
5187
+ var boundingSphereCache = new LRUCache(100000);
5044
5188
  function getPositionsFromEntity(viewer, entity) {
5045
5189
  var positions = [];
5046
5190
  var heightRef;
@@ -5049,59 +5193,94 @@ function getPositionsFromEntity(viewer, entity) {
5049
5193
  if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
5050
5194
  return null;
5051
5195
  }
5052
- positions.push(pos3d);
5053
5196
  heightRef = getValue$2(viewer, entity.billboard.heightReference);
5197
+ pos3d = adjustPos3d(viewer, heightRef, pos3d);
5198
+ positions.push(pos3d);
5054
5199
  }
5055
5200
  else if (entity.polyline) {
5056
- positions = getValue$2(viewer, entity.polyline.positions);
5201
+ var posses = getValue$2(viewer, entity.polyline.positions);
5202
+ if (!(posses === null || posses === void 0 ? void 0 : posses.length) || posses.length >= DO_NOT_CULL_AT_LEN_POINTS) {
5203
+ return null;
5204
+ }
5205
+ // Get the first, last, and every forth point.
5206
+ // This is to reduce the amount of points we need to check.
5207
+ if (posses.length > 10) {
5208
+ var first = posses[0];
5209
+ var last = posses[posses.length - 1];
5210
+ var everyForth = posses.filter(function (_, index) { return index % 4 == 0; });
5211
+ posses = [first, last].concat(everyForth);
5212
+ }
5057
5213
  heightRef = getValue$2(viewer, entity.polyline.clampToGround) == false ? HeightReference.NONE : HeightReference.CLAMP_TO_GROUND;
5214
+ for (var i = 0; i < posses.length; i++) {
5215
+ var pos3d = adjustPos3d(viewer, heightRef, posses[i]);
5216
+ positions.push(pos3d);
5217
+ }
5058
5218
  }
5059
5219
  else if (entity.polygon) {
5060
5220
  var hierarchy = getValue$2(viewer, entity.polygon.hierarchy);
5061
- positions = hierarchy.positions;
5221
+ var posses = hierarchy.positions;
5222
+ if (!(posses === null || posses === void 0 ? void 0 : posses.length) || posses.length >= DO_NOT_CULL_AT_LEN_POINTS) {
5223
+ return null;
5224
+ }
5225
+ // Get the first, last, and every forth point.
5226
+ // This is to reduce the amount of points we need to check.
5227
+ if (posses.length > 10) {
5228
+ var first = posses[0];
5229
+ var last = posses[posses.length - 1];
5230
+ var everyForth = posses.filter(function (_, index) { return index % 4 == 0; });
5231
+ posses = [first, last].concat(everyForth);
5232
+ }
5062
5233
  heightRef = getValue$2(viewer, entity.polygon.heightReference);
5234
+ for (var i = 0; i < posses.length; i++) {
5235
+ var pos3d = adjustPos3d(viewer, heightRef, posses[i]);
5236
+ positions.push(pos3d);
5237
+ }
5063
5238
  }
5064
5239
  else if (entity.corridor) {
5065
- positions = getValue$2(viewer, entity.corridor.positions);
5240
+ var posses = getValue$2(viewer, entity.corridor.positions);
5241
+ if (!(posses === null || posses === void 0 ? void 0 : posses.length) || posses.length >= DO_NOT_CULL_AT_LEN_POINTS) {
5242
+ return null;
5243
+ }
5244
+ // Get the first, last, and every forth point.
5245
+ // This is to reduce the amount of points we need to check.
5246
+ if (posses.length > 10) {
5247
+ var first = posses[0];
5248
+ var last = posses[posses.length - 1];
5249
+ var everyForth = posses.filter(function (_, index) { return index % 4 == 0; });
5250
+ posses = [first, last].concat(everyForth);
5251
+ }
5252
+ heightRef = getValue$2(viewer, entity.corridor.heightReference);
5253
+ for (var i = 0; i < posses.length; i++) {
5254
+ var pos3d = adjustPos3d(viewer, heightRef, posses[i]);
5255
+ positions.push(pos3d);
5256
+ }
5066
5257
  }
5067
5258
  else if (entity.ellipse) {
5068
- var position = getValue$2(viewer, entity.position);
5069
- if (!(position === null || position === void 0 ? void 0 : position.x)) {
5259
+ var pos3d = getValue$2(viewer, entity.position);
5260
+ if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
5070
5261
  return null;
5071
5262
  }
5072
5263
  heightRef = getValue$2(viewer, entity.ellipse.heightReference);
5073
- var semiMajorAxis = getValue$2(viewer, entity.ellipse.semiMajorAxis);
5074
- var semiMinorAxis = getValue$2(viewer, entity.ellipse.semiMinorAxis);
5075
- var rotation = getValue$2(viewer, entity.ellipse.rotation);
5076
- // More subdivisions means a more accurate ellipse but worse performance.
5077
- var numberOfSubdivisions = 5;
5078
- for (var i = 0; i < numberOfSubdivisions; i++) {
5079
- var theta = i * (2 * Math.PI / numberOfSubdivisions);
5080
- var x = semiMajorAxis * Math.cos(theta);
5081
- var y = semiMinorAxis * Math.sin(theta);
5082
- // Apply rotation.
5083
- var rotatedX = x * Math.cos(rotation) - y * Math.sin(rotation);
5084
- var rotatedY = x * Math.sin(rotation) + y * Math.cos(rotation);
5085
- // Translate by the ellipse's position.
5086
- var point = new Cartesian3(position.x + rotatedX, position.y + rotatedY, position.z);
5087
- positions.push(point);
5088
- }
5264
+ pos3d = adjustPos3d(viewer, heightRef, pos3d);
5265
+ positions.push(pos3d);
5089
5266
  }
5090
5267
  else if (entity.model) {
5091
5268
  var pos3d = getValue$2(viewer, entity.position);
5092
5269
  if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
5093
5270
  return null;
5094
5271
  }
5095
- positions.push(pos3d);
5096
5272
  heightRef = getValue$2(viewer, entity.model.heightReference);
5273
+ pos3d = adjustPos3d(viewer, heightRef, pos3d);
5274
+ positions.push(pos3d);
5097
5275
  }
5098
5276
  else if (entity.point) {
5099
5277
  var pos3d = getValue$2(viewer, entity.position);
5100
5278
  if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
5101
5279
  return null;
5102
5280
  }
5103
- positions.push(pos3d);
5104
5281
  heightRef = getValue$2(viewer, entity.point.heightReference);
5282
+ pos3d = adjustPos3d(viewer, heightRef, pos3d);
5283
+ positions.push(pos3d);
5105
5284
  }
5106
5285
  if (!(positions === null || positions === void 0 ? void 0 : positions.length)) {
5107
5286
  return;
@@ -5121,27 +5300,81 @@ function computeBoundingSphereFromPositions(positions) {
5121
5300
  return BoundingSphere.fromPoints(positions);
5122
5301
  }
5123
5302
  function shouldCullEntity(viewer, cEntity) {
5303
+ var _a, _b;
5124
5304
  var camera = viewer.scene.camera;
5125
5305
  var boundingSphere;
5126
- if (boundingSphereCache[cEntity.id]) {
5127
- boundingSphere = boundingSphereCache[cEntity.id];
5306
+ var terrainId = (_b = (_a = ViewUtils.GatherTerrainTile({
5307
+ viewer: viewer
5308
+ }).terrain) === null || _a === void 0 ? void 0 : _a.tilesetId) !== null && _b !== void 0 ? _b : ProjectViewTile.EDefaultTerrain.FlatTerrain;
5309
+ var cullSphere;
5310
+ var cacheKey = terrainId + cEntity.id;
5311
+ var cacheData = boundingSphereCache.Get(cacheKey);
5312
+ if (cacheData) {
5313
+ boundingSphere = cacheData;
5128
5314
  }
5129
5315
  else {
5130
5316
  var positions = getPositionsFromEntity(viewer, cEntity);
5131
5317
  if (positions) {
5132
5318
  boundingSphere = computeBoundingSphereFromPositions(positions);
5133
5319
  if (cEntity.model) {
5134
- // We don't know how large models are so we'll just add a tolerance.
5135
- boundingSphere.radius += Math.sqrt(MODEL_SIZE_TOLERANCE);
5320
+ var model = cEntity.model;
5321
+ if (model._radius && !isNaN(model._radius)) {
5322
+ boundingSphere.radius = Math.max(model._radius, MODEL_MIN_RADIUS);
5323
+ }
5324
+ else {
5325
+ // Unknown size. Ignoring.
5326
+ boundingSphere = -1;
5327
+ }
5328
+ }
5329
+ // Check for radius and extrusion.
5330
+ else if (cEntity.ellipse) {
5331
+ var radius = getValue$2(viewer, cEntity.ellipse.semiMajorAxis);
5332
+ var extrusion = getValue$2(viewer, cEntity.ellipse.extrudedHeight);
5333
+ if (extrusion && !isNaN(extrusion)) {
5334
+ if (!radius) {
5335
+ radius = extrusion;
5336
+ }
5337
+ else if (extrusion > radius / 2) {
5338
+ radius = extrusion;
5339
+ }
5340
+ }
5341
+ if (radius && !isNaN(radius)) {
5342
+ boundingSphere.radius = radius;
5343
+ }
5344
+ }
5345
+ // Check for extrusion.
5346
+ else if (cEntity.polygon) {
5347
+ var extrusion = getValue$2(viewer, cEntity.polygon.extrudedHeight);
5348
+ if (extrusion && !isNaN(extrusion)) {
5349
+ if (!boundingSphere.radius) {
5350
+ boundingSphere.radius = extrusion;
5351
+ }
5352
+ else if (extrusion > boundingSphere.radius / 2) {
5353
+ boundingSphere.radius = extrusion;
5354
+ }
5355
+ }
5136
5356
  }
5137
- boundingSphereCache[cEntity.id] = boundingSphere;
5357
+ else if (cEntity.point || cEntity.billboard) {
5358
+ boundingSphere.radius = Math.max(boundingSphere.radius, POINT_MIN_RADIUS);
5359
+ }
5360
+ boundingSphereCache.Set(cacheKey, boundingSphere);
5361
+ }
5362
+ else {
5363
+ boundingSphereCache.Set(cacheKey, -1);
5138
5364
  }
5139
5365
  }
5140
- if (!boundingSphere) {
5366
+ if (!boundingSphere || boundingSphere == -1) {
5141
5367
  return false;
5142
5368
  }
5143
5369
  var cullingVolume = camera.frustum.computeCullingVolume(camera.position, camera.direction, camera.up);
5144
5370
  var visibility = cullingVolume.computeVisibility(boundingSphere);
5371
+ if (cullSphere) {
5372
+ cullSphere.ellipsoid.material =
5373
+ (visibility == Intersect.INSIDE ||
5374
+ visibility == Intersect.INTERSECTING) ? Color.GREEN.withAlpha(0.1) :
5375
+ Color.RED.withAlpha(0.1);
5376
+ viewer.scene.requestRender();
5377
+ }
5145
5378
  return visibility !== Intersect.INSIDE && visibility !== Intersect.INTERSECTING;
5146
5379
  }
5147
5380
  // Amount of entities to check per interval.
@@ -5206,7 +5439,7 @@ function runCullChecker(register) {
5206
5439
  var rego = register.GetRego({
5207
5440
  entityId: entityId
5208
5441
  });
5209
- if (!rego || !rego.visual || !(rego.visual instanceof Entity)) {
5442
+ if (!rego || !rego.visual || !(rego.visual instanceof Entity) || rego.relation != null) {
5210
5443
  continue;
5211
5444
  }
5212
5445
  var parts = EntityUtils.GatherEntity({
@@ -18211,7 +18444,7 @@ var ViewerUtils;
18211
18444
  ViewerUtils.CreateWidgets = CreateWidgets;
18212
18445
  })(ViewerUtils || (ViewerUtils = {}));
18213
18446
 
18214
- var VERSION$1 = "3.0.3";
18447
+ var VERSION$1 = "3.0.5";
18215
18448
 
18216
18449
  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 };
18217
18450
  //# sourceMappingURL=bruce-cesium.es5.js.map