bruce-cesium 0.0.8 → 0.1.0

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,4 +1,4 @@
1
- import { Cartesian2, Cartographic, Math as Math$1, Viewer, ArcGisMapServerImageryProvider, ScreenSpaceEventType, Color, HeightReference, Cartesian3, Entity, ClassificationType, ArcType, PolygonHierarchy, ShadowMode, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, HeadingPitchRange, Matrix4, Cesium3DTileset, EllipsoidGeodesic } from 'cesium';
1
+ import { Viewer, ArcGisMapServerImageryProvider, ScreenSpaceEventType, Cartesian2, Cartographic, Math as Math$1, Entity, Primitive, Cesium3DTileFeature, Color, HeightReference, Cartesian3, ClassificationType, ArcType, PolygonHierarchy, ShadowMode, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, HeadingPitchRange, Matrix4, Cesium3DTileset, EllipsoidGeodesic } from 'cesium';
2
2
  import { BruceEvent, Cartes, Carto, Geometry, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, DelayQueue, Entity as Entity$1, EntityFilterGetter, BatchedDataGetter, ObjectUtils, Tileset, MenuItem, ProjectView, ProjectViewBookmark } from 'bruce-models';
3
3
 
4
4
  var TIME_LAG = 300;
@@ -678,8 +678,7 @@ function getStyle(api, entity, styleId) {
678
678
  });
679
679
  }
680
680
  function getExistingCEntity(entityId, menuItemId, item, visualRegister) {
681
- var visuals = visualRegister.GetVisuals(entityId, menuItemId);
682
- return visuals.length > 0 ? visuals[0] : null;
681
+ return visualRegister.GetVisual(entityId, menuItemId);
683
682
  }
684
683
  function getRenderGroupId(zoomItem) {
685
684
  if (!zoomItem) {
@@ -1432,7 +1431,7 @@ var EntitiesRenderManager;
1432
1431
  };
1433
1432
  Manager.prototype.onGetterUpdate = function (entities) {
1434
1433
  return __awaiter(this, void 0, void 0, function () {
1435
- var cEntities, i, id, cEntity, visuals;
1434
+ var cEntities, i, id, cEntity, visual;
1436
1435
  return __generator(this, function (_a) {
1437
1436
  switch (_a.label) {
1438
1437
  case 0:
@@ -1454,8 +1453,8 @@ var EntitiesRenderManager;
1454
1453
  cEntity = cEntities[id];
1455
1454
  this.renderedEntities[id] = !!cEntity;
1456
1455
  if (cEntity) {
1457
- visuals = this.visualsManager.GetVisuals(id, this.item.id);
1458
- if (visuals.length != 1 || (visuals.length > 0 && visuals[0] != cEntity)) {
1456
+ visual = this.visualsManager.GetVisual(id, this.item.id);
1457
+ if (!visual || visual != cEntity) {
1459
1458
  this.visualsManager.Add({
1460
1459
  entityId: id,
1461
1460
  menuItemId: this.item.id,
@@ -1530,7 +1529,7 @@ var EntitiesLoadedRenderManager;
1530
1529
  };
1531
1530
  Manager.prototype.onGetterUpdate = function (entities) {
1532
1531
  return __awaiter(this, void 0, void 0, function () {
1533
- var cEntities, i, id, cEntity, visuals;
1532
+ var cEntities, i, id, cEntity, visual;
1534
1533
  return __generator(this, function (_a) {
1535
1534
  switch (_a.label) {
1536
1535
  case 0:
@@ -1552,8 +1551,8 @@ var EntitiesLoadedRenderManager;
1552
1551
  cEntity = cEntities[id];
1553
1552
  this.renderedEntities[id] = !!cEntity;
1554
1553
  if (cEntity) {
1555
- visuals = this.visualsManager.GetVisuals(id, this.item.id);
1556
- if (visuals.length != 1 || (visuals.length > 0 && visuals[0] != cEntity)) {
1554
+ visual = this.visualsManager.GetVisual(id, this.item.id);
1555
+ if (!visual || visual != cEntity) {
1557
1556
  this.visualsManager.Add({
1558
1557
  entityId: id,
1559
1558
  menuItemId: this.item.id,
@@ -1815,14 +1814,26 @@ var VisualsRegister;
1815
1814
  }
1816
1815
  (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ rego: rego, isAdding: true });
1817
1816
  };
1818
- Register.prototype.GetVisuals = function (entityId, menuItemId) {
1817
+ Register.prototype.GetVisual = function (entityId, menuItemId) {
1819
1818
  var _a;
1820
1819
  var entityRegos = this.rego[entityId];
1821
1820
  if (!entityRegos) {
1822
1821
  return [];
1823
1822
  }
1824
- var visuals = (_a = entityRegos.find(function (r) { return r.menuItemId === menuItemId; })) === null || _a === void 0 ? void 0 : _a.visual;
1825
- return visuals !== null && visuals !== void 0 ? visuals : [];
1823
+ return (_a = entityRegos.find(function (r) { return r.menuItemId === menuItemId; })) === null || _a === void 0 ? void 0 : _a.visual;
1824
+ };
1825
+ Register.prototype.GetMenuItemVisuals = function (menuItemId) {
1826
+ var visuals = [];
1827
+ for (var entityId in this.rego) {
1828
+ var entityRegos = this.rego[entityId];
1829
+ if (entityRegos) {
1830
+ var rego = entityRegos.find(function (r) { return r.menuItemId === menuItemId; });
1831
+ if (rego) {
1832
+ visuals.push(rego.visual);
1833
+ }
1834
+ }
1835
+ }
1836
+ return visuals;
1826
1837
  };
1827
1838
  Register.prototype.RemoveByEntityId = function (id) {
1828
1839
  var _a;
@@ -1951,7 +1962,7 @@ var EntitiesIdsRenderManager;
1951
1962
  };
1952
1963
  Manager.prototype.onGetterUpdate = function (entityIds) {
1953
1964
  return __awaiter(this, void 0, void 0, function () {
1954
- var entities, cEntities, i, id, cEntity, visuals;
1965
+ var entities, cEntities, i, id, cEntity, visual;
1955
1966
  return __generator(this, function (_a) {
1956
1967
  switch (_a.label) {
1957
1968
  case 0:
@@ -1976,8 +1987,8 @@ var EntitiesIdsRenderManager;
1976
1987
  cEntity = cEntities[id];
1977
1988
  this.renderedEntities[id] = !!cEntity;
1978
1989
  if (cEntity) {
1979
- visuals = this.visualsManager.GetVisuals(id, this.item.id);
1980
- if (visuals.length != 1 || (visuals.length > 0 && visuals[0] != cEntity)) {
1990
+ visual = this.visualsManager.GetVisual(id, this.item.id);
1991
+ if (!visual || visual != cEntity) {
1981
1992
  this.visualsManager.Add({
1982
1993
  entityId: id,
1983
1994
  menuItemId: this.item.id,
@@ -2049,7 +2060,7 @@ var EntityRenderManager;
2049
2060
  };
2050
2061
  Manager.prototype.onGetterUpdate = function (id) {
2051
2062
  return __awaiter(this, void 0, void 0, function () {
2052
- var entity, cEntities, cEntity, visuals;
2063
+ var entity, cEntities, cEntity, visual;
2053
2064
  return __generator(this, function (_a) {
2054
2065
  switch (_a.label) {
2055
2066
  case 0:
@@ -2071,8 +2082,8 @@ var EntityRenderManager;
2071
2082
  cEntities = _a.sent();
2072
2083
  cEntity = cEntities[id];
2073
2084
  if (cEntity) {
2074
- visuals = this.visualsManager.GetVisuals(id, this.item.id);
2075
- if (visuals.length != 1 || (visuals.length > 0 && visuals[0] != cEntity)) {
2085
+ visual = this.visualsManager.GetVisual(id, this.item.id);
2086
+ if (!visual || visual != cEntity) {
2076
2087
  this.visualsManager.Add({
2077
2088
  entityId: entity.Bruce.ID,
2078
2089
  menuItemId: this.item.id,
@@ -2802,7 +2813,6 @@ var MenuItemManager;
2802
2813
  default:
2803
2814
  console.error("Menu item type is not implemented.", item.Type);
2804
2815
  }
2805
- (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: true, itemId: rItem.id });
2806
2816
  if (!rItem.renderManager) return [3 /*break*/, 2];
2807
2817
  return [4 /*yield*/, rItem.renderManager.Init()];
2808
2818
  case 1:
@@ -2823,7 +2833,9 @@ var MenuItemManager;
2823
2833
  case 5:
2824
2834
  i++;
2825
2835
  return [3 /*break*/, 3];
2826
- case 6: return [2 /*return*/, rItem.id];
2836
+ case 6:
2837
+ (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: true, itemId: rItem.id });
2838
+ return [2 /*return*/, rItem.id];
2827
2839
  }
2828
2840
  });
2829
2841
  });
@@ -2834,15 +2846,14 @@ var MenuItemManager;
2834
2846
  * @param id
2835
2847
  */
2836
2848
  Manager.prototype.RemoveItemById = function (id) {
2837
- var _a;
2849
+ var _a, _b;
2838
2850
  return __awaiter(this, void 0, void 0, function () {
2839
2851
  var item, _loop_1, this_1, i;
2840
- return __generator(this, function (_b) {
2841
- switch (_b.label) {
2852
+ return __generator(this, function (_c) {
2853
+ switch (_c.label) {
2842
2854
  case 0:
2843
2855
  item = this.items.find(function (x) { return x.id === id; });
2844
2856
  if (!item) return [3 /*break*/, 5];
2845
- (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ isEnabling: false, itemId: item.id });
2846
2857
  _loop_1 = function (i) {
2847
2858
  var child;
2848
2859
  return __generator(this, function (_a) {
@@ -2860,25 +2871,26 @@ var MenuItemManager;
2860
2871
  };
2861
2872
  this_1 = this;
2862
2873
  i = 0;
2863
- _b.label = 1;
2874
+ _c.label = 1;
2864
2875
  case 1:
2865
2876
  if (!(i < item.childIds.length)) return [3 /*break*/, 4];
2866
2877
  return [5 /*yield**/, _loop_1(i)];
2867
2878
  case 2:
2868
- _b.sent();
2869
- _b.label = 3;
2879
+ _c.sent();
2880
+ _c.label = 3;
2870
2881
  case 3:
2871
2882
  i++;
2872
2883
  return [3 /*break*/, 1];
2873
2884
  case 4:
2874
2885
  try {
2875
- item.renderManager.Dispose();
2886
+ (_a = item.renderManager) === null || _a === void 0 ? void 0 : _a.Dispose();
2876
2887
  }
2877
2888
  catch (e) {
2878
2889
  console.error(e);
2879
2890
  }
2880
2891
  this.items = this.items.filter(function (x) { return x.id !== id; });
2881
- _b.label = 5;
2892
+ (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: false, itemId: item.id });
2893
+ _c.label = 5;
2882
2894
  case 5: return [2 /*return*/];
2883
2895
  }
2884
2896
  });