bruce-cesium 3.1.3 → 3.1.4

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, ProjectViewTile, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, DelayQueue, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, EntityRelationType, BruceEvent, EntityCoords, Api, EntitySource, MenuItem, EntityRelation, ENVIRONMENT, AbstractApi, ProjectViewBookmark, EntityAttachment, EntityAttachmentType, EntityAttribute, ProjectView, ProjectViewLegacyTile, ProgramKey, 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, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Model, SceneMode, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, Ion, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, ColorMaterialProperty, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, CesiumInspector, Intersect } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, Primitive, Cesium3DTileFeature, SceneMode, DistanceDisplayCondition, NearFarScalar, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Model, Cesium3DTileColorBlendMode, HeadingPitchRange, Cesium3DTileStyle, createOsmBuildings, KmlDataSource, OrthographicFrustum, EasingFunction, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, Ion, CesiumInspector, defined, SceneTransforms, EllipsoidGeodesic, sampleTerrainMostDetailed, ColorMaterialProperty, BoundingSphere, GeometryInstance, PolygonPipeline, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5000,7 +5000,7 @@ var EntityLabel;
5000
5000
  Label.prototype.createLabel = function (starterPos3d) {
5001
5001
  var _a, _b, _c, _d, _e, _f, _g;
5002
5002
  return __awaiter(this, void 0, void 0, function () {
5003
- var pos3d, counter, sizeInM, heightRef, pixelOffset, visual, hierarchy, posses, centerIndex, pos1, pos2, pos3, posses, isClamped, centerIndex, size, height, scale, posses, centerIndex, text, type, e_1, ele, _lastDistance, _lastCameraPos, getDistance, MAX_DISTANCE, updateLabel, terrTimeout;
5003
+ var pos3d, counter, sizeInM, heightRef, pixelOffset, visual, hierarchy, posses, centerIndex, pos1, pos2, pos3, posses, isClamped, centerIndex, model, size, height, scale, posses, centerIndex, text, type, e_1, ele, _lastDistance, _lastCameraPos, getDistance, MAX_DISTANCE, updateLabel, terrTimeout;
5004
5004
  var _this = this;
5005
5005
  return __generator(this, function (_h) {
5006
5006
  switch (_h.label) {
@@ -5028,7 +5028,7 @@ var EntityLabel;
5028
5028
  posses = [].concat(hierarchy.positions);
5029
5029
  try {
5030
5030
  sizeInM = (_c = MeasureUtils.MeasurePolygon({
5031
- posses: posses,
5031
+ posses: posses
5032
5032
  })) === null || _c === void 0 ? void 0 : _c.area;
5033
5033
  if (isNaN(sizeInM)) {
5034
5034
  sizeInM = 0;
@@ -5069,7 +5069,7 @@ var EntityLabel;
5069
5069
  }
5070
5070
  try {
5071
5071
  sizeInM = (_d = MeasureUtils.MeasurePolyline({
5072
- posses: posses,
5072
+ posses: posses
5073
5073
  })) === null || _d === void 0 ? void 0 : _d.totalLength;
5074
5074
  if (isNaN(sizeInM)) {
5075
5075
  sizeInM = 0;
@@ -5084,6 +5084,10 @@ var EntityLabel;
5084
5084
  if (isNaN(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
5085
5085
  heightRef = getValue$2(this.viewer, visual.model.heightReference);
5086
5086
  }
5087
+ model = visual.model;
5088
+ if (model._radiusLoaded && model._radius > 0) {
5089
+ sizeInM = model._radius;
5090
+ }
5087
5091
  }
5088
5092
  else if (visual.point) {
5089
5093
  heightRef = getValue$2(this.viewer, visual.point.heightReference);
@@ -5112,7 +5116,7 @@ var EntityLabel;
5112
5116
  }
5113
5117
  try {
5114
5118
  sizeInM = (_e = MeasureUtils.MeasurePolyline({
5115
- posses: posses,
5119
+ posses: posses
5116
5120
  })) === null || _e === void 0 ? void 0 : _e.totalLength;
5117
5121
  if (isNaN(sizeInM)) {
5118
5122
  sizeInM = 0;
@@ -5234,40 +5238,17 @@ var EntityLabel;
5234
5238
  return _lastDistance;
5235
5239
  }
5236
5240
  }
5237
- // Check if there is a raycast collision between camera and pos3d.
5238
- // We'll let the labels draw through a ground collision.
5239
- // Commented out while it is WIP.
5240
- // const direction = Cesium.Cartesian3.subtract(pos3d, cameraPos, new Cesium.Cartesian3());
5241
- // const ray = new Cesium.Ray(pos3d.clone(), direction);
5242
- // const objects = (this.viewer.scene as any).drillPickFromRay(ray, 1, [visuals]);
5243
- // if (objects && objects.length > 0) {
5244
- // for (let i = 0; i < objects.length; ++i) {
5245
- // const obj = objects[i];
5246
- // if (!visuals.find(x => x == obj?.id)) {
5247
- // let isGround = true;
5248
- // if (obj.object) {
5249
- // const url = obj.object?.primitive?._basePath;
5250
- // if (url && typeof url == "string") {
5251
- // isGround = url.includes("tile.googleapis.com");
5252
- // }
5253
- // else {
5254
- // isGround = false;
5255
- // }
5256
- // }
5257
- // if (!isGround) {
5258
- // return null;
5259
- // }
5260
- // }
5261
- // }
5262
- // }
5263
5241
  var distance = Cartesian3.distance(cameraPos, _this._pos3d);
5264
5242
  _lastDistance = distance;
5265
5243
  _lastCameraPos = cameraPos.clone();
5266
5244
  return distance;
5267
5245
  };
5268
- MAX_DISTANCE = 5000;
5269
- if (sizeInM > 30) {
5270
- MAX_DISTANCE = Math.max(MAX_DISTANCE, sizeInM / 2);
5246
+ MAX_DISTANCE = Math.max(5000, sizeInM * 10);
5247
+ if (visual && visual instanceof Entity) {
5248
+ // Consistent sized things.
5249
+ if (visual.polyline || visual.billboard || visual.point) {
5250
+ MAX_DISTANCE = Infinity;
5251
+ }
5271
5252
  }
5272
5253
  updateLabel = function () {
5273
5254
  var _a;
@@ -5297,7 +5278,7 @@ var EntityLabel;
5297
5278
  ele.style.display = "block";
5298
5279
  // Check scale to apply based on distance between camera and pos3d.
5299
5280
  // We'll make the label smaller and less transparent when further away.
5300
- var scale = _this.prePositioned ? 1 : 1 - (distance / MAX_DISTANCE);
5281
+ var scale = _this.prePositioned || MAX_DISTANCE == Infinity ? 1 : 1 - (distance / MAX_DISTANCE);
5301
5282
  if (scale && scale > 0.15) {
5302
5283
  ele.style.transform = "scale(".concat(scale, ")");
5303
5284
  ele.style.opacity = "".concat(scale);
@@ -18754,7 +18735,7 @@ var CesiumViewMonitor;
18754
18735
  CesiumViewMonitor$$1.Monitor = Monitor;
18755
18736
  })(CesiumViewMonitor || (CesiumViewMonitor = {}));
18756
18737
 
18757
- var VERSION$1 = "3.1.3";
18738
+ var VERSION$1 = "3.1.4";
18758
18739
 
18759
18740
  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 };
18760
18741
  //# sourceMappingURL=bruce-cesium.es5.js.map