bruce-cesium 3.3.5 → 3.3.7

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
- import { Cartes, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ProjectViewTile, DelayQueue, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, EntityRelationType, BruceEvent, EntityCoords, Api, EntitySource, MenuItem, EntityRelation, ProgramKey, ENVIRONMENT, AbstractApi, ProjectViewBookmark, EntityAttachment, EntityAttachmentType, EntityAttribute, ProjectView, ProjectViewLegacyTile, Camera } from 'bruce-models';
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, Entity, Primitive, Cesium3DTileFeature, JulianDate, SceneMode, DistanceDisplayCondition, NearFarScalar, Model, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, Cesium3DTileColorBlendMode, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, CesiumInspector, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ColorMaterialProperty, Intersect } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, DistanceDisplayCondition, NearFarScalar, Model, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, SceneMode, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidGeodesic, EllipsoidTerrainProvider, sampleTerrainMostDetailed, defined, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, BoundingSphere, GeometryInstance, PolygonPipeline, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ColorMaterialProperty } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5615,12 +5615,19 @@ var EntityLabel;
5615
5615
  // Override to make it draw at a different position.
5616
5616
  this._pos3d = null;
5617
5617
  this.prePositioned = false;
5618
+ // If the entity name is not loaded-in, we'll wait a moment then request the information.
5619
+ // We wait a moment to avoid the user quickly dragging their mouse over entities and spamming requests.
5620
+ this.loadTimeout = null;
5621
+ this.loadedName = false;
5618
5622
  this.rego = params.rego;
5619
5623
  this.viewer = params.viewer;
5620
5624
  this.api = params.api;
5621
5625
  this.visualRegister = params.visualRegister;
5622
5626
  this.prePositioned = !isNaN((_a = params.pos3d) === null || _a === void 0 ? void 0 : _a.x);
5623
5627
  this.createLabel(params.pos3d);
5628
+ if (!params.api && !ENVIRONMENT.IS_SELF_MANAGED) {
5629
+ params.api = ENVIRONMENT.Api().GetBruceApi();
5630
+ }
5624
5631
  }
5625
5632
  Object.defineProperty(Label.prototype, "Rego", {
5626
5633
  get: function () {
@@ -5648,6 +5655,48 @@ var EntityLabel;
5648
5655
  enumerable: false,
5649
5656
  configurable: true
5650
5657
  });
5658
+ /**
5659
+ * Loads the Entity's name and updates the corresponding visual rego.
5660
+ */
5661
+ Label.prototype.loadName = function () {
5662
+ return __awaiter(this, void 0, void 0, function () {
5663
+ var rego, _a, e_1;
5664
+ return __generator(this, function (_b) {
5665
+ switch (_b.label) {
5666
+ case 0:
5667
+ if (this.loadedName) {
5668
+ return [2 /*return*/];
5669
+ }
5670
+ _b.label = 1;
5671
+ case 1:
5672
+ _b.trys.push([1, 4, , 5]);
5673
+ if (!this.api) return [3 /*break*/, 3];
5674
+ rego = this.rego;
5675
+ _a = this.rego;
5676
+ return [4 /*yield*/, Entity$1.CalculateNameAsync({
5677
+ api: this.api,
5678
+ entity: null,
5679
+ entityId: rego.entityId,
5680
+ defaultToId: false
5681
+ })];
5682
+ case 2:
5683
+ _a.name = _b.sent();
5684
+ if (!this.rego.name) {
5685
+ this.rego.name = "Unnamed Entity";
5686
+ }
5687
+ _b.label = 3;
5688
+ case 3: return [3 /*break*/, 5];
5689
+ case 4:
5690
+ e_1 = _b.sent();
5691
+ console.error(e_1);
5692
+ return [3 /*break*/, 5];
5693
+ case 5:
5694
+ this.loadedName = true;
5695
+ return [2 /*return*/];
5696
+ }
5697
+ });
5698
+ });
5699
+ };
5651
5700
  /**
5652
5701
  * Disposes label and marks instance as disposed.
5653
5702
  * Recalling will be ignored.
@@ -5658,6 +5707,8 @@ var EntityLabel;
5658
5707
  }
5659
5708
  this.disposed = true;
5660
5709
  this.removeLabel();
5710
+ clearTimeout(this.loadTimeout);
5711
+ this.loadTimeout = null;
5661
5712
  };
5662
5713
  /**
5663
5714
  * Creates cesium entity for the label if one does not exist.
@@ -5666,7 +5717,7 @@ var EntityLabel;
5666
5717
  Label.prototype.createLabel = function (starterPos3d) {
5667
5718
  var _a, _b, _c, _d, _e, _f, _g;
5668
5719
  return __awaiter(this, void 0, void 0, function () {
5669
- 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;
5720
+ 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_2, ele, _lastDistance, _lastCameraPos, getDistance, MAX_DISTANCE, updateLabel, terrTimeout;
5670
5721
  var _this = this;
5671
5722
  return __generator(this, function (_h) {
5672
5723
  switch (_h.label) {
@@ -5834,7 +5885,7 @@ var EntityLabel;
5834
5885
  }
5835
5886
  this._pos3d = pos3d;
5836
5887
  text = "Unknown Entity";
5837
- if (!this.rego) return [3 /*break*/, 8];
5888
+ if (!this.rego) return [3 /*break*/, 9];
5838
5889
  if (!this.rego.relation) return [3 /*break*/, 7];
5839
5890
  type = this.rego.relation.RelationType;
5840
5891
  if (!(!type && this.rego.relation["Relation.Type.ID"])) return [3 /*break*/, 6];
@@ -5849,8 +5900,8 @@ var EntityLabel;
5849
5900
  type = (_h.sent()).relationType;
5850
5901
  return [3 /*break*/, 6];
5851
5902
  case 5:
5852
- e_1 = _h.sent();
5853
- console.error(e_1);
5903
+ e_2 = _h.sent();
5904
+ console.error(e_2);
5854
5905
  return [3 /*break*/, 6];
5855
5906
  case 6:
5856
5907
  if (type) {
@@ -5869,6 +5920,30 @@ var EntityLabel;
5869
5920
  }
5870
5921
  _h.label = 8;
5871
5922
  case 8:
5923
+ if (text == "Unnamed Entity" && !this.loadedName) {
5924
+ text = "Loading...";
5925
+ clearTimeout(this.loadTimeout);
5926
+ this.loadTimeout = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
5927
+ return __generator(this, function (_a) {
5928
+ switch (_a.label) {
5929
+ case 0:
5930
+ if (this.disposed || this.counter != counter) {
5931
+ return [2 /*return*/];
5932
+ }
5933
+ return [4 /*yield*/, this.loadName()];
5934
+ case 1:
5935
+ _a.sent();
5936
+ if (this.disposed || this.counter != counter) {
5937
+ return [2 /*return*/];
5938
+ }
5939
+ this.createLabel(starterPos3d);
5940
+ return [2 /*return*/];
5941
+ }
5942
+ });
5943
+ }); }, 120);
5944
+ }
5945
+ _h.label = 9;
5946
+ case 9:
5872
5947
  if (this.disposed || this.counter != counter) {
5873
5948
  return [2 /*return*/];
5874
5949
  }
@@ -9866,7 +9941,7 @@ var TilesetRenderEngine;
9866
9941
  return [3 /*break*/, 15];
9867
9942
  }
9868
9943
  styleMap = styleMapping[i];
9869
- if (!(!styleMap.style && styleMap.StyleID > 0)) return [3 /*break*/, 13];
9944
+ if (!(!styleMap.style && styleMap.StyleID != -1)) return [3 /*break*/, 13];
9870
9945
  styleId = styleMap.StyleID;
9871
9946
  if (!!styleId) return [3 /*break*/, 9];
9872
9947
  _c.label = 6;
@@ -20033,7 +20108,7 @@ var CesiumViewMonitor;
20033
20108
  CesiumViewMonitor$$1.Monitor = Monitor;
20034
20109
  })(CesiumViewMonitor || (CesiumViewMonitor = {}));
20035
20110
 
20036
- var VERSION$1 = "3.3.5";
20111
+ var VERSION$1 = "3.3.7";
20037
20112
 
20038
20113
  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 };
20039
20114
  //# sourceMappingURL=bruce-cesium.es5.js.map