bruce-cesium 3.4.3 → 3.4.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.
@@ -1239,7 +1239,7 @@
1239
1239
  }
1240
1240
  // If the value is really small we'll assume it's in radians.
1241
1241
  // "cesium#blah" properties are always in degrees. No need to check.
1242
- if (value < 0.9 && !propName.startsWith("cesium#")) {
1242
+ if (value < 0.9 && value > -0.9 && !propName.startsWith("cesium#")) {
1243
1243
  value = Cesium.Math.toDegrees(value);
1244
1244
  }
1245
1245
  return value;
@@ -1399,7 +1399,7 @@
1399
1399
  });
1400
1400
  }); };
1401
1401
  getEntityPositions = function (sample) { return __awaiter(_this, void 0, void 0, function () {
1402
- var entityId, entity, tileset, tilesetId, evaluateRendered, evaluateRecord, renderedPosses, e_1, recordPosses, e_2, tSettings, pos3d, alt, alt, heading, pitch, roll, matrix4, offset, m1, hpr, transform, transformedOffset;
1402
+ var entityId, entity, tileset, tilesetId, evaluateRendered, evaluateRecord, renderedPosses, e_1, recordPosses, e_2, tSettings, pos3d, alt, alt, heading, pitch, roll, matrix4, offset, m1, hpr, transform, transformedOffset, sphere;
1403
1403
  var _this = this;
1404
1404
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1405
1405
  return __generator(this, function (_l) {
@@ -1695,7 +1695,7 @@
1695
1695
  case 12:
1696
1696
  tSettings = tileset === null || tileset === void 0 ? void 0 : tileset.settings;
1697
1697
  pos3d = null;
1698
- if (!(((_b = entity === null || entity === void 0 ? void 0 : entity.location) === null || _b === void 0 ? void 0 : _b.longitude) || ((_c = tSettings === null || tSettings === void 0 ? void 0 : tSettings.location) === null || _c === void 0 ? void 0 : _c.longitude))) return [3 /*break*/, 14];
1698
+ if (!(((_b = entity === null || entity === void 0 ? void 0 : entity.location) === null || _b === void 0 ? void 0 : _b.longitude) || ((_c = tSettings === null || tSettings === void 0 ? void 0 : tSettings.location) === null || _c === void 0 ? void 0 : _c.longitude))) return [3 /*break*/, 15];
1699
1699
  if ((_d = entity === null || entity === void 0 ? void 0 : entity.location) === null || _d === void 0 ? void 0 : _d.longitude) {
1700
1700
  alt = +entity.location.altitude;
1701
1701
  if (isNaN(alt)) {
@@ -1710,7 +1710,7 @@
1710
1710
  }
1711
1711
  pos3d = Cesium.Cartesian3.fromDegrees(+tSettings.location.longitude, +tSettings.location.latitude, alt);
1712
1712
  }
1713
- if (!(entity === null || entity === void 0 ? void 0 : entity.worldPosition)) return [3 /*break*/, 14];
1713
+ if (!(entity === null || entity === void 0 ? void 0 : entity.worldPosition)) return [3 /*break*/, 15];
1714
1714
  heading = 0;
1715
1715
  pitch = 0;
1716
1716
  roll = 0;
@@ -1761,6 +1761,16 @@
1761
1761
  pos3d = _l.sent();
1762
1762
  _l.label = 14;
1763
1763
  case 14:
1764
+ if ((entity === null || entity === void 0 ? void 0 : entity.geometryRadius) && (pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
1765
+ sphere = Cesium.BoundingSphere.fromPoints([pos3d]);
1766
+ // For now making sure it's less than x amount because we had a bug which made it huge.
1767
+ if (entity.geometryRadius && entity.geometryRadius < 100 && entity.geometryRadius > 1) {
1768
+ sphere.radius = entity.geometryRadius;
1769
+ spheres.push(sphere);
1770
+ }
1771
+ }
1772
+ _l.label = 15;
1773
+ case 15:
1764
1774
  if (pos3d) {
1765
1775
  return [2 /*return*/, [pos3d]];
1766
1776
  }
@@ -3129,6 +3139,54 @@
3129
3139
  }
3130
3140
  return recheck;
3131
3141
  }
3142
+ /**
3143
+ * Returns true if the given rego should be ignored from culling.
3144
+ * @param rego
3145
+ * @returns
3146
+ */
3147
+ function isCullingIgnored(viewer, rego) {
3148
+ if (
3149
+ // No rego or visual.
3150
+ // This is a safety check to avoid crashes.
3151
+ !rego ||
3152
+ !rego.visual ||
3153
+ // We will only touch entities. Not tileset stuff.
3154
+ !(rego.visual instanceof Cesium.Entity) ||
3155
+ // We won't touch relationship lines because they dynamically change shape.
3156
+ rego.relation != null ||
3157
+ // Explicitly being either shown or hidden.
3158
+ rego.overrideShow != null ||
3159
+ // Part of an independent collection.
3160
+ // Won't touch in case there is special logic.
3161
+ rego.collection) {
3162
+ return true;
3163
+ }
3164
+ var visual = rego.visual;
3165
+ // We will only cull clamped stuff since it seems that's where we get benefits from.
3166
+ var heightRef;
3167
+ if (visual.polygon) {
3168
+ heightRef = getValue(viewer, visual.polygon.heightReference);
3169
+ }
3170
+ else if (visual.polyline) {
3171
+ heightRef = getValue(viewer, visual.polyline.clampToGround) == false ? Cesium.HeightReference.NONE : Cesium.HeightReference.CLAMP_TO_GROUND;
3172
+ }
3173
+ else if (visual.corridor) {
3174
+ heightRef = getValue(viewer, visual.corridor.heightReference);
3175
+ }
3176
+ else if (visual.ellipse) {
3177
+ heightRef = getValue(viewer, visual.ellipse.heightReference);
3178
+ }
3179
+ else if (visual.model) {
3180
+ heightRef = getValue(viewer, visual.model.heightReference);
3181
+ }
3182
+ else if (visual.point) {
3183
+ heightRef = getValue(viewer, visual.point.heightReference);
3184
+ }
3185
+ else if (visual.billboard) {
3186
+ heightRef = getValue(viewer, visual.billboard.heightReference);
3187
+ }
3188
+ return heightRef != Cesium.HeightReference.CLAMP_TO_GROUND;
3189
+ }
3132
3190
  /**
3133
3191
  * Runs through all entities in the register and culls them if they are out of the viewport.
3134
3192
  * This will work in batches.
@@ -3155,7 +3213,7 @@
3155
3213
  var rego = register.GetRego({
3156
3214
  entityId: entityId
3157
3215
  });
3158
- if (!rego || !rego.visual || !(rego.visual instanceof Cesium.Entity) || rego.relation != null || rego.overrideShow != null || rego.collection) {
3216
+ if (isCullingIgnored(viewer, rego)) {
3159
3217
  continue;
3160
3218
  }
3161
3219
  var parts = exports.EntityUtils.GatherEntity({
@@ -3266,7 +3324,10 @@
3266
3324
  };
3267
3325
  }
3268
3326
  VisualRegisterCuller.Monitor = Monitor;
3269
- function IsCulled(viewer, visual) {
3327
+ function IsCulled(viewer, rego, visual) {
3328
+ if (isCullingIgnored(viewer, rego)) {
3329
+ return false;
3330
+ }
3270
3331
  if (!visual) {
3271
3332
  return false;
3272
3333
  }
@@ -6286,13 +6347,9 @@
6286
6347
  console.warn("updateCEntityShow(): Max show depth reached. EntityId = " + rego.entityId);
6287
6348
  return;
6288
6349
  }
6289
- if (show && !rego.relation && !rego.overrideShow && !rego.collection) {
6290
- // Culling is controlled by "visual-register-culler.ts".
6291
- // When an object is unculled then the 'updateEntityShow' function is re-called to reveal it and related objects.
6292
- // A sub-object can be culled while the siblings are not.
6293
- var isCulled = show ? VisualRegisterCuller.IsCulled(viewer, visual) : true;
6294
- show = !isCulled;
6295
- }
6350
+ // A sub-object can be culled while the siblings are not.
6351
+ // We only cull things that give us some benefit. For example clamped to ground graphics are expensive to keep rendered.
6352
+ show = show ? !VisualRegisterCuller.IsCulled(viewer, rego, visual) : true;
6296
6353
  if (visual._parentEntity && !ignoreParent) {
6297
6354
  updateCEntityShow(viewer, visual._parentEntity, rego, show, false, depth + 1);
6298
6355
  }
@@ -10997,6 +11054,10 @@
10997
11054
  this.cTileset = cTileset;
10998
11055
  this.fallbackStyleId = fallbackStyleId;
10999
11056
  this.styleMapping = styleMapping;
11057
+ if (styleMapping) {
11058
+ // Dereference.
11059
+ styleMapping = JSON.parse(JSON.stringify(styleMapping));
11060
+ }
11000
11061
  // ND-1641. BOOKMARKS - (DEMO) View does not match bookmark.
11001
11062
  // We have some evil hard-coded style mappings that need to be fixed.
11002
11063
  // These exist within legacy project views.
@@ -11027,6 +11088,8 @@
11027
11088
  Styler.prototype.UpdateStyleMapping = function (params) {
11028
11089
  var _a;
11029
11090
  if (params.styleMapping) {
11091
+ // Dereference.
11092
+ params.styleMapping = JSON.parse(JSON.stringify(params.styleMapping));
11030
11093
  this.styleMapping = params.styleMapping;
11031
11094
  // ND-1641. BOOKMARKS - (DEMO) View does not match bookmark.
11032
11095
  // We have some evil hard-coded style mappings that need to be fixed.
@@ -21386,7 +21449,7 @@
21386
21449
  CesiumViewMonitor.Monitor = Monitor;
21387
21450
  })(exports.CesiumViewMonitor || (exports.CesiumViewMonitor = {}));
21388
21451
 
21389
- var VERSION$1 = "3.4.3";
21452
+ var VERSION$1 = "3.4.5";
21390
21453
 
21391
21454
  exports.VERSION = VERSION$1;
21392
21455
  exports.CesiumParabola = CesiumParabola;