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.
@@ -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, Entity, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, NearFarScalar, Model, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, GeoJsonDataSource, ColorMaterialProperty, SceneMode, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, CesiumInspector, PolygonPipeline, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, Intersect } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, GeoJsonDataSource, ColorMaterialProperty, JulianDate, DistanceDisplayCondition, NearFarScalar, Model, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, SceneMode, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, SceneTransforms, CesiumInspector, OrthographicFrustum, defined, Cesium3DTileset, Matrix4, Matrix3, IonResource, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, ScreenSpaceEventHandler, ScreenSpaceEventType, EasingFunction, BoundingSphere, GeometryInstance, Intersect, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1239,7 +1239,7 @@ var getLocationFromFeature = function (feature) {
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 = Math$1.toDegrees(value);
1244
1244
  }
1245
1245
  return value;
@@ -1400,7 +1400,7 @@ var EntityUtils;
1400
1400
  });
1401
1401
  }); };
1402
1402
  getEntityPositions = function (sample) { return __awaiter(_this, void 0, void 0, function () {
1403
- 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;
1403
+ 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;
1404
1404
  var _this = this;
1405
1405
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1406
1406
  return __generator(this, function (_l) {
@@ -1696,7 +1696,7 @@ var EntityUtils;
1696
1696
  case 12:
1697
1697
  tSettings = tileset === null || tileset === void 0 ? void 0 : tileset.settings;
1698
1698
  pos3d = null;
1699
- 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];
1699
+ 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];
1700
1700
  if ((_d = entity === null || entity === void 0 ? void 0 : entity.location) === null || _d === void 0 ? void 0 : _d.longitude) {
1701
1701
  alt = +entity.location.altitude;
1702
1702
  if (isNaN(alt)) {
@@ -1711,7 +1711,7 @@ var EntityUtils;
1711
1711
  }
1712
1712
  pos3d = Cartesian3.fromDegrees(+tSettings.location.longitude, +tSettings.location.latitude, alt);
1713
1713
  }
1714
- if (!(entity === null || entity === void 0 ? void 0 : entity.worldPosition)) return [3 /*break*/, 14];
1714
+ if (!(entity === null || entity === void 0 ? void 0 : entity.worldPosition)) return [3 /*break*/, 15];
1715
1715
  heading = 0;
1716
1716
  pitch = 0;
1717
1717
  roll = 0;
@@ -1762,6 +1762,16 @@ var EntityUtils;
1762
1762
  pos3d = _l.sent();
1763
1763
  _l.label = 14;
1764
1764
  case 14:
1765
+ if ((entity === null || entity === void 0 ? void 0 : entity.geometryRadius) && (pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
1766
+ sphere = BoundingSphere.fromPoints([pos3d]);
1767
+ // For now making sure it's less than x amount because we had a bug which made it huge.
1768
+ if (entity.geometryRadius && entity.geometryRadius < 100 && entity.geometryRadius > 1) {
1769
+ sphere.radius = entity.geometryRadius;
1770
+ spheres.push(sphere);
1771
+ }
1772
+ }
1773
+ _l.label = 15;
1774
+ case 15:
1765
1775
  if (pos3d) {
1766
1776
  return [2 /*return*/, [pos3d]];
1767
1777
  }
@@ -3132,6 +3142,54 @@ function shouldRecheck(viewer) {
3132
3142
  }
3133
3143
  return recheck;
3134
3144
  }
3145
+ /**
3146
+ * Returns true if the given rego should be ignored from culling.
3147
+ * @param rego
3148
+ * @returns
3149
+ */
3150
+ function isCullingIgnored(viewer, rego) {
3151
+ if (
3152
+ // No rego or visual.
3153
+ // This is a safety check to avoid crashes.
3154
+ !rego ||
3155
+ !rego.visual ||
3156
+ // We will only touch entities. Not tileset stuff.
3157
+ !(rego.visual instanceof Entity) ||
3158
+ // We won't touch relationship lines because they dynamically change shape.
3159
+ rego.relation != null ||
3160
+ // Explicitly being either shown or hidden.
3161
+ rego.overrideShow != null ||
3162
+ // Part of an independent collection.
3163
+ // Won't touch in case there is special logic.
3164
+ rego.collection) {
3165
+ return true;
3166
+ }
3167
+ var visual = rego.visual;
3168
+ // We will only cull clamped stuff since it seems that's where we get benefits from.
3169
+ var heightRef;
3170
+ if (visual.polygon) {
3171
+ heightRef = getValue(viewer, visual.polygon.heightReference);
3172
+ }
3173
+ else if (visual.polyline) {
3174
+ heightRef = getValue(viewer, visual.polyline.clampToGround) == false ? HeightReference.NONE : HeightReference.CLAMP_TO_GROUND;
3175
+ }
3176
+ else if (visual.corridor) {
3177
+ heightRef = getValue(viewer, visual.corridor.heightReference);
3178
+ }
3179
+ else if (visual.ellipse) {
3180
+ heightRef = getValue(viewer, visual.ellipse.heightReference);
3181
+ }
3182
+ else if (visual.model) {
3183
+ heightRef = getValue(viewer, visual.model.heightReference);
3184
+ }
3185
+ else if (visual.point) {
3186
+ heightRef = getValue(viewer, visual.point.heightReference);
3187
+ }
3188
+ else if (visual.billboard) {
3189
+ heightRef = getValue(viewer, visual.billboard.heightReference);
3190
+ }
3191
+ return heightRef != HeightReference.CLAMP_TO_GROUND;
3192
+ }
3135
3193
  /**
3136
3194
  * Runs through all entities in the register and culls them if they are out of the viewport.
3137
3195
  * This will work in batches.
@@ -3158,7 +3216,7 @@ function runCullChecker(register) {
3158
3216
  var rego = register.GetRego({
3159
3217
  entityId: entityId
3160
3218
  });
3161
- if (!rego || !rego.visual || !(rego.visual instanceof Entity) || rego.relation != null || rego.overrideShow != null || rego.collection) {
3219
+ if (isCullingIgnored(viewer, rego)) {
3162
3220
  continue;
3163
3221
  }
3164
3222
  var parts = EntityUtils.GatherEntity({
@@ -3269,7 +3327,10 @@ var VisualRegisterCuller;
3269
3327
  };
3270
3328
  }
3271
3329
  VisualRegisterCuller.Monitor = Monitor;
3272
- function IsCulled(viewer, visual) {
3330
+ function IsCulled(viewer, rego, visual) {
3331
+ if (isCullingIgnored(viewer, rego)) {
3332
+ return false;
3333
+ }
3273
3334
  if (!visual) {
3274
3335
  return false;
3275
3336
  }
@@ -6294,13 +6355,9 @@ function updateCEntityShow(viewer, visual, rego, show, ignoreParent, depth) {
6294
6355
  console.warn("updateCEntityShow(): Max show depth reached. EntityId = " + rego.entityId);
6295
6356
  return;
6296
6357
  }
6297
- if (show && !rego.relation && !rego.overrideShow && !rego.collection) {
6298
- // Culling is controlled by "visual-register-culler.ts".
6299
- // When an object is unculled then the 'updateEntityShow' function is re-called to reveal it and related objects.
6300
- // A sub-object can be culled while the siblings are not.
6301
- var isCulled = show ? VisualRegisterCuller.IsCulled(viewer, visual) : true;
6302
- show = !isCulled;
6303
- }
6358
+ // A sub-object can be culled while the siblings are not.
6359
+ // We only cull things that give us some benefit. For example clamped to ground graphics are expensive to keep rendered.
6360
+ show = show ? !VisualRegisterCuller.IsCulled(viewer, rego, visual) : true;
6304
6361
  if (visual._parentEntity && !ignoreParent) {
6305
6362
  updateCEntityShow(viewer, visual._parentEntity, rego, show, false, depth + 1);
6306
6363
  }
@@ -11031,6 +11088,10 @@ var TilesetRenderEngine;
11031
11088
  this.cTileset = cTileset;
11032
11089
  this.fallbackStyleId = fallbackStyleId;
11033
11090
  this.styleMapping = styleMapping;
11091
+ if (styleMapping) {
11092
+ // Dereference.
11093
+ styleMapping = JSON.parse(JSON.stringify(styleMapping));
11094
+ }
11034
11095
  // ND-1641. BOOKMARKS - (DEMO) View does not match bookmark.
11035
11096
  // We have some evil hard-coded style mappings that need to be fixed.
11036
11097
  // These exist within legacy project views.
@@ -11061,6 +11122,8 @@ var TilesetRenderEngine;
11061
11122
  Styler.prototype.UpdateStyleMapping = function (params) {
11062
11123
  var _a;
11063
11124
  if (params.styleMapping) {
11125
+ // Dereference.
11126
+ params.styleMapping = JSON.parse(JSON.stringify(params.styleMapping));
11064
11127
  this.styleMapping = params.styleMapping;
11065
11128
  // ND-1641. BOOKMARKS - (DEMO) View does not match bookmark.
11066
11129
  // We have some evil hard-coded style mappings that need to be fixed.
@@ -21445,7 +21508,7 @@ var CesiumViewMonitor;
21445
21508
  CesiumViewMonitor$$1.Monitor = Monitor;
21446
21509
  })(CesiumViewMonitor || (CesiumViewMonitor = {}));
21447
21510
 
21448
- var VERSION$1 = "3.4.3";
21511
+ var VERSION$1 = "3.4.5";
21449
21512
 
21450
21513
  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 };
21451
21514
  //# sourceMappingURL=bruce-cesium.es5.js.map