bruce-cesium 3.0.1 → 3.0.2

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.
@@ -548,6 +548,9 @@
548
548
  function EnsurePosHeight(params) {
549
549
  var pos3d = params.pos3d, viewer = params.viewer, desiredHeightRef = params.desiredHeightRef, heightRef = params.heightRef;
550
550
  var carto = bruceModels.Cartes.ValidateCartes3(pos3d) ? Cesium.Cartographic.fromCartesian(pos3d) : null;
551
+ if (!(carto === null || carto === void 0 ? void 0 : carto.latitude)) {
552
+ return pos3d;
553
+ }
551
554
  if (heightRef == null) {
552
555
  heightRef = Cesium.HeightReference.CLAMP_TO_GROUND;
553
556
  }
@@ -5019,36 +5022,50 @@
5019
5022
  }
5020
5023
  return obj;
5021
5024
  }
5025
+ function isFlatTerrain(viewer) {
5026
+ var _a;
5027
+ if (!viewer) {
5028
+ return false;
5029
+ }
5030
+ return ((_a = exports.ViewUtils.GatherTerrainTile({
5031
+ viewer: viewer
5032
+ }).terrain) === null || _a === void 0 ? void 0 : _a.tilesetId) == bruceModels.ProjectViewTile.EDefaultTerrain.FlatTerrain;
5033
+ }
5022
5034
  var boundingSphereCache = {};
5023
5035
  function getPositionsFromEntity(viewer, entity) {
5036
+ var positions = [];
5037
+ var heightRef;
5024
5038
  if (entity.billboard) {
5025
5039
  var pos3d = getValue$2(viewer, entity.position);
5026
5040
  if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
5027
5041
  return null;
5028
5042
  }
5029
- return [pos3d];
5043
+ positions.push(pos3d);
5044
+ heightRef = getValue$2(viewer, entity.billboard.heightReference);
5030
5045
  }
5031
5046
  else if (entity.polyline) {
5032
- return getValue$2(viewer, entity.polyline.positions);
5047
+ positions = getValue$2(viewer, entity.polyline.positions);
5048
+ heightRef = getValue$2(viewer, entity.polyline.clampToGround) == false ? Cesium.HeightReference.NONE : Cesium.HeightReference.CLAMP_TO_GROUND;
5033
5049
  }
5034
5050
  else if (entity.polygon) {
5035
5051
  var hierarchy = getValue$2(viewer, entity.polygon.hierarchy);
5036
- return hierarchy.positions;
5052
+ positions = hierarchy.positions;
5053
+ heightRef = getValue$2(viewer, entity.polygon.heightReference);
5037
5054
  }
5038
5055
  else if (entity.corridor) {
5039
- return getValue$2(viewer, entity.corridor.positions);
5056
+ positions = getValue$2(viewer, entity.corridor.positions);
5040
5057
  }
5041
5058
  else if (entity.ellipse) {
5042
5059
  var position = getValue$2(viewer, entity.position);
5043
5060
  if (!(position === null || position === void 0 ? void 0 : position.x)) {
5044
5061
  return null;
5045
5062
  }
5063
+ heightRef = getValue$2(viewer, entity.ellipse.heightReference);
5046
5064
  var semiMajorAxis = getValue$2(viewer, entity.ellipse.semiMajorAxis);
5047
5065
  var semiMinorAxis = getValue$2(viewer, entity.ellipse.semiMinorAxis);
5048
5066
  var rotation = getValue$2(viewer, entity.ellipse.rotation);
5049
5067
  // More subdivisions means a more accurate ellipse but worse performance.
5050
5068
  var numberOfSubdivisions = 5;
5051
- var positions = [];
5052
5069
  for (var i = 0; i < numberOfSubdivisions; i++) {
5053
5070
  var theta = i * (2 * Math.PI / numberOfSubdivisions);
5054
5071
  var x = semiMajorAxis * Math.cos(theta);
@@ -5060,23 +5077,36 @@
5060
5077
  var point = new Cesium.Cartesian3(position.x + rotatedX, position.y + rotatedY, position.z);
5061
5078
  positions.push(point);
5062
5079
  }
5063
- return positions;
5064
5080
  }
5065
5081
  else if (entity.model) {
5066
5082
  var pos3d = getValue$2(viewer, entity.position);
5067
5083
  if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
5068
5084
  return null;
5069
5085
  }
5070
- return [pos3d];
5086
+ positions.push(pos3d);
5087
+ heightRef = getValue$2(viewer, entity.model.heightReference);
5071
5088
  }
5072
5089
  else if (entity.point) {
5073
5090
  var pos3d = getValue$2(viewer, entity.position);
5074
5091
  if (!(pos3d === null || pos3d === void 0 ? void 0 : pos3d.x)) {
5075
5092
  return null;
5076
5093
  }
5077
- return [pos3d];
5094
+ positions.push(pos3d);
5095
+ heightRef = getValue$2(viewer, entity.point.heightReference);
5078
5096
  }
5079
- return null;
5097
+ if (!(positions === null || positions === void 0 ? void 0 : positions.length)) {
5098
+ return;
5099
+ }
5100
+ // We need to zero the heights.
5101
+ if (heightRef == Cesium.HeightReference.CLAMP_TO_GROUND && isFlatTerrain(viewer)) {
5102
+ for (var i = 0; i < positions.length; i++) {
5103
+ var pos = positions[i];
5104
+ var carto = Cesium.Cartographic.fromCartesian(pos);
5105
+ carto.height = 0;
5106
+ positions[i] = Cesium.Cartographic.toCartesian(carto);
5107
+ }
5108
+ }
5109
+ return positions;
5080
5110
  }
5081
5111
  function computeBoundingSphereFromPositions(positions) {
5082
5112
  return Cesium.BoundingSphere.fromPoints(positions);
@@ -5325,8 +5355,8 @@
5325
5355
  }
5326
5356
  }
5327
5357
  }
5328
- function updateCEntityShow(viewer, visual, show, ignoreParent) {
5329
- if (show) {
5358
+ function updateCEntityShow(viewer, isRelationship, visual, show, ignoreParent) {
5359
+ if (show && !isRelationship) {
5330
5360
  // Culling is controlled by "visual-register-culler.ts".
5331
5361
  // When an object is unculled then the 'updateEntityShow' function is re-called to reveal it and related objects.
5332
5362
  // A sub-object can be culled while the siblings are not.
@@ -5334,12 +5364,12 @@
5334
5364
  show = !isCulled;
5335
5365
  }
5336
5366
  if (visual._parentEntity && !ignoreParent) {
5337
- updateCEntityShow(viewer, visual._parentEntity, show, false);
5367
+ updateCEntityShow(viewer, isRelationship, visual._parentEntity, show, false);
5338
5368
  }
5339
5369
  if (visual._siblingGraphics) {
5340
5370
  for (var i = 0; i < visual._siblingGraphics.length; i++) {
5341
5371
  var sibling = visual._siblingGraphics[i];
5342
- updateCEntityShow(viewer, sibling, show, true);
5372
+ updateCEntityShow(viewer, isRelationship, sibling, show, true);
5343
5373
  }
5344
5374
  }
5345
5375
  /**
@@ -5353,12 +5383,12 @@
5353
5383
  viewer.entities.add(visual);
5354
5384
  }
5355
5385
  }
5356
- function updateEntityShow(viewer, visual, show) {
5386
+ function updateEntityShow(viewer, isRelationship, visual, show) {
5357
5387
  if (visual instanceof Cesium.Entity) {
5358
5388
  if (!(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
5359
5389
  return;
5360
5390
  }
5361
- updateCEntityShow(viewer, visual, show, false);
5391
+ updateCEntityShow(viewer, isRelationship, visual, show, false);
5362
5392
  return;
5363
5393
  }
5364
5394
  if (!isAlive$1(viewer, visual)) {
@@ -5408,7 +5438,7 @@
5408
5438
  var rego = regos[i];
5409
5439
  rego.best = rego === highestPriority;
5410
5440
  var visible = rego.suppressShow ? false : getShowState(rego);
5411
- updateEntityShow(viewer, rego.visual, visible);
5441
+ updateEntityShow(viewer, rego.relation != null, rego.visual, visible);
5412
5442
  if (rego.best) {
5413
5443
  var isLabelled = register.GetIsLabelled({
5414
5444
  entityId: entityId
@@ -18122,7 +18152,7 @@
18122
18152
  ViewerUtils.CreateWidgets = CreateWidgets;
18123
18153
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
18124
18154
 
18125
- var VERSION$1 = "3.0.1";
18155
+ var VERSION$1 = "3.0.2";
18126
18156
 
18127
18157
  exports.VERSION = VERSION$1;
18128
18158
  exports.CesiumParabola = CesiumParabola;