bruce-cesium 3.3.6 → 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.
@@ -5607,12 +5607,19 @@
5607
5607
  // Override to make it draw at a different position.
5608
5608
  this._pos3d = null;
5609
5609
  this.prePositioned = false;
5610
+ // If the entity name is not loaded-in, we'll wait a moment then request the information.
5611
+ // We wait a moment to avoid the user quickly dragging their mouse over entities and spamming requests.
5612
+ this.loadTimeout = null;
5613
+ this.loadedName = false;
5610
5614
  this.rego = params.rego;
5611
5615
  this.viewer = params.viewer;
5612
5616
  this.api = params.api;
5613
5617
  this.visualRegister = params.visualRegister;
5614
5618
  this.prePositioned = !isNaN((_a = params.pos3d) === null || _a === void 0 ? void 0 : _a.x);
5615
5619
  this.createLabel(params.pos3d);
5620
+ if (!params.api && !bruceModels.ENVIRONMENT.IS_SELF_MANAGED) {
5621
+ params.api = bruceModels.ENVIRONMENT.Api().GetBruceApi();
5622
+ }
5616
5623
  }
5617
5624
  Object.defineProperty(Label.prototype, "Rego", {
5618
5625
  get: function () {
@@ -5640,6 +5647,48 @@
5640
5647
  enumerable: false,
5641
5648
  configurable: true
5642
5649
  });
5650
+ /**
5651
+ * Loads the Entity's name and updates the corresponding visual rego.
5652
+ */
5653
+ Label.prototype.loadName = function () {
5654
+ return __awaiter(this, void 0, void 0, function () {
5655
+ var rego, _a, e_1;
5656
+ return __generator(this, function (_b) {
5657
+ switch (_b.label) {
5658
+ case 0:
5659
+ if (this.loadedName) {
5660
+ return [2 /*return*/];
5661
+ }
5662
+ _b.label = 1;
5663
+ case 1:
5664
+ _b.trys.push([1, 4, , 5]);
5665
+ if (!this.api) return [3 /*break*/, 3];
5666
+ rego = this.rego;
5667
+ _a = this.rego;
5668
+ return [4 /*yield*/, bruceModels.Entity.CalculateNameAsync({
5669
+ api: this.api,
5670
+ entity: null,
5671
+ entityId: rego.entityId,
5672
+ defaultToId: false
5673
+ })];
5674
+ case 2:
5675
+ _a.name = _b.sent();
5676
+ if (!this.rego.name) {
5677
+ this.rego.name = "Unnamed Entity";
5678
+ }
5679
+ _b.label = 3;
5680
+ case 3: return [3 /*break*/, 5];
5681
+ case 4:
5682
+ e_1 = _b.sent();
5683
+ console.error(e_1);
5684
+ return [3 /*break*/, 5];
5685
+ case 5:
5686
+ this.loadedName = true;
5687
+ return [2 /*return*/];
5688
+ }
5689
+ });
5690
+ });
5691
+ };
5643
5692
  /**
5644
5693
  * Disposes label and marks instance as disposed.
5645
5694
  * Recalling will be ignored.
@@ -5650,6 +5699,8 @@
5650
5699
  }
5651
5700
  this.disposed = true;
5652
5701
  this.removeLabel();
5702
+ clearTimeout(this.loadTimeout);
5703
+ this.loadTimeout = null;
5653
5704
  };
5654
5705
  /**
5655
5706
  * Creates cesium entity for the label if one does not exist.
@@ -5658,7 +5709,7 @@
5658
5709
  Label.prototype.createLabel = function (starterPos3d) {
5659
5710
  var _a, _b, _c, _d, _e, _f, _g;
5660
5711
  return __awaiter(this, void 0, void 0, function () {
5661
- 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;
5712
+ 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;
5662
5713
  var _this = this;
5663
5714
  return __generator(this, function (_h) {
5664
5715
  switch (_h.label) {
@@ -5826,7 +5877,7 @@
5826
5877
  }
5827
5878
  this._pos3d = pos3d;
5828
5879
  text = "Unknown Entity";
5829
- if (!this.rego) return [3 /*break*/, 8];
5880
+ if (!this.rego) return [3 /*break*/, 9];
5830
5881
  if (!this.rego.relation) return [3 /*break*/, 7];
5831
5882
  type = this.rego.relation.RelationType;
5832
5883
  if (!(!type && this.rego.relation["Relation.Type.ID"])) return [3 /*break*/, 6];
@@ -5841,8 +5892,8 @@
5841
5892
  type = (_h.sent()).relationType;
5842
5893
  return [3 /*break*/, 6];
5843
5894
  case 5:
5844
- e_1 = _h.sent();
5845
- console.error(e_1);
5895
+ e_2 = _h.sent();
5896
+ console.error(e_2);
5846
5897
  return [3 /*break*/, 6];
5847
5898
  case 6:
5848
5899
  if (type) {
@@ -5861,6 +5912,30 @@
5861
5912
  }
5862
5913
  _h.label = 8;
5863
5914
  case 8:
5915
+ if (text == "Unnamed Entity" && !this.loadedName) {
5916
+ text = "Loading...";
5917
+ clearTimeout(this.loadTimeout);
5918
+ this.loadTimeout = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
5919
+ return __generator(this, function (_a) {
5920
+ switch (_a.label) {
5921
+ case 0:
5922
+ if (this.disposed || this.counter != counter) {
5923
+ return [2 /*return*/];
5924
+ }
5925
+ return [4 /*yield*/, this.loadName()];
5926
+ case 1:
5927
+ _a.sent();
5928
+ if (this.disposed || this.counter != counter) {
5929
+ return [2 /*return*/];
5930
+ }
5931
+ this.createLabel(starterPos3d);
5932
+ return [2 /*return*/];
5933
+ }
5934
+ });
5935
+ }); }, 120);
5936
+ }
5937
+ _h.label = 9;
5938
+ case 9:
5864
5939
  if (this.disposed || this.counter != counter) {
5865
5940
  return [2 /*return*/];
5866
5941
  }
@@ -19974,7 +20049,7 @@
19974
20049
  CesiumViewMonitor.Monitor = Monitor;
19975
20050
  })(exports.CesiumViewMonitor || (exports.CesiumViewMonitor = {}));
19976
20051
 
19977
- var VERSION$1 = "3.3.6";
20052
+ var VERSION$1 = "3.3.7";
19978
20053
 
19979
20054
  exports.VERSION = VERSION$1;
19980
20055
  exports.CesiumParabola = CesiumParabola;