bruce-cesium 0.7.1 → 0.7.3

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,5 +1,5 @@
1
1
  import { BruceEvent, Cartes, Carto, Geometry, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, DelayQueue, Entity as Entity$1, BatchedDataGetter, ObjectUtils, Tileset, EntityCoords, EntityFilterGetter, EntitySource, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewTile, ProjectViewLegacyTile, TilesetExtMapTiles, ProgramKey, Camera } from 'bruce-models';
2
- import { Cartesian2, Cartographic, Math as Math$1, Cartesian3, Entity, Primitive, Cesium3DTileFeature, Color, EllipsoidGeodesic, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, ColorMaterialProperty, Rectangle, Matrix3, Matrix4, EasingFunction, GeometryInstance, JulianDate, HeightReference, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, PolygonHierarchy, ShadowMode, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Cesium3DTileset, HeadingPitchRange, OrthographicFrustum, createOsmBuildings, Cesium3DTileStyle, KmlDataSource } from 'cesium';
2
+ import { Cartesian2, Cartographic, Math as Math$1, Color, HeightReference, Cartesian3, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, PolygonHierarchy, ShadowMode, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, HeadingPitchRange, OrthographicFrustum, JulianDate, Matrix4, Cesium3DTileset, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, EllipsoidGeodesic, ColorMaterialProperty, Rectangle, Matrix3, EasingFunction, GeometryInstance, createOsmBuildings, Cesium3DTileStyle, KmlDataSource } from 'cesium';
3
3
 
4
4
  var TIME_LAG = 300;
5
5
  var POSITION_CHECK_TIMER = 950;
@@ -1100,9 +1100,22 @@ var EntityRenderEngine;
1100
1100
  var entity = params.entity;
1101
1101
  var style = params.style;
1102
1102
  var type = style.Type;
1103
+ if (type == null) {
1104
+ // Very old backward compatibility.
1105
+ if (style.useIcon == true) {
1106
+ type = Style.EPointType.Icon;
1107
+ }
1108
+ }
1103
1109
  var cEntity = null;
1104
1110
  if (type == Style.EPointType.Icon) {
1105
- var icon = Calculator.GetValue(style.iconUrl, entity, params.tags);
1111
+ // Fixing poor data.
1112
+ var iconUrlRows = style.iconUrl == null ? [] : style.iconUrl;
1113
+ iconUrlRows.forEach(function (row) {
1114
+ if (row.type == Calculator.EValueType.Color) {
1115
+ row.type = Calculator.EValueType.Input;
1116
+ }
1117
+ });
1118
+ var icon = Calculator.GetValue(iconUrlRows, entity, params.tags);
1106
1119
  var iconUrl = null;
1107
1120
  if (typeof icon == "string") {
1108
1121
  iconUrl = icon;
@@ -1938,9 +1951,11 @@ function removeEntity(viewer, visual) {
1938
1951
  }
1939
1952
  }
1940
1953
  else if (visual instanceof Cesium3DTileFeature) {
1941
- // No way to tell if changing show will crash it!
1942
1954
  try {
1943
- visual.show = false;
1955
+ var tileset = visual === null || visual === void 0 ? void 0 : visual.tileset;
1956
+ if (tileset && viewer.scene.primitives.contains(tileset)) {
1957
+ visual.show = false;
1958
+ }
1944
1959
  }
1945
1960
  catch (e) {
1946
1961
  console.error(e);
@@ -5385,11 +5400,11 @@ function renderV1(params, bookmark, view) {
5385
5400
  });
5386
5401
  }
5387
5402
  function renderV2(params, bookmark, view) {
5388
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
5403
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
5389
5404
  return __awaiter(this, void 0, void 0, function () {
5390
- var viewer, scene, vSettings, bSettings, defaults, camera, newLens, curLens, transition, pos, gOcclusion, shadows, size, ambientOcclusion, AO, lighting, light, quality, fxaa, dateTime, clock, terrain, selectedIds, i, id, imagery, curEnabled, newItemIds, _i, curEnabled_1, id;
5391
- return __generator(this, function (_z) {
5392
- switch (_z.label) {
5405
+ var viewer, scene, vSettings, bSettings, defaults, camera, newLens, curLens, transition, pos, gOcclusion, baseColor, shadows, size, ambientOcclusion, AO, lighting, light, quality, fxaa, dateTime, clock, terrain, selectedIds, i, id, imagery, curEnabled, newItemIds, _i, curEnabled_1, id;
5406
+ return __generator(this, function (_0) {
5407
+ switch (_0.label) {
5393
5408
  case 0:
5394
5409
  viewer = params.manager.Viewer;
5395
5410
  scene = viewer.scene;
@@ -5450,9 +5465,18 @@ function renderV2(params, bookmark, view) {
5450
5465
  gOcclusion = true;
5451
5466
  }
5452
5467
  scene.globe.depthTestAgainstTerrain = Boolean(gOcclusion);
5468
+ baseColor = bSettings === null || bSettings === void 0 ? void 0 : bSettings.globeColor;
5469
+ if (baseColor == null) {
5470
+ baseColor = (_o = defaults.settings) === null || _o === void 0 ? void 0 : _o.globeColor;
5471
+ }
5472
+ if (baseColor == null) {
5473
+ // TODO: Need global default.
5474
+ baseColor = "#0326BE";
5475
+ }
5476
+ scene.globe.baseColor = Color.fromCssColorString(baseColor);
5453
5477
  shadows = bSettings === null || bSettings === void 0 ? void 0 : bSettings.shadows;
5454
5478
  if (shadows == null) {
5455
- shadows = (_o = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _o === void 0 ? void 0 : _o.shadows;
5479
+ shadows = (_p = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _p === void 0 ? void 0 : _p.shadows;
5456
5480
  }
5457
5481
  if (shadows == null) {
5458
5482
  shadows = {
@@ -5478,7 +5502,7 @@ function renderV2(params, bookmark, view) {
5478
5502
  }
5479
5503
  ambientOcclusion = bSettings === null || bSettings === void 0 ? void 0 : bSettings.ambientOcclusion;
5480
5504
  if (ambientOcclusion == null) {
5481
- ambientOcclusion = (_p = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _p === void 0 ? void 0 : _p.ambientOcclusion;
5505
+ ambientOcclusion = (_q = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _q === void 0 ? void 0 : _q.ambientOcclusion;
5482
5506
  }
5483
5507
  if (ambientOcclusion == null) {
5484
5508
  ambientOcclusion = {
@@ -5499,7 +5523,7 @@ function renderV2(params, bookmark, view) {
5499
5523
  }
5500
5524
  lighting = bSettings === null || bSettings === void 0 ? void 0 : bSettings.lighting;
5501
5525
  if (lighting == null) {
5502
- lighting = (_q = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _q === void 0 ? void 0 : _q.lighting;
5526
+ lighting = (_r = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _r === void 0 ? void 0 : _r.lighting;
5503
5527
  }
5504
5528
  if (lighting == null) {
5505
5529
  lighting = {
@@ -5514,7 +5538,7 @@ function renderV2(params, bookmark, view) {
5514
5538
  }
5515
5539
  quality = bSettings === null || bSettings === void 0 ? void 0 : bSettings.quality;
5516
5540
  if (quality == null) {
5517
- quality = (_r = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _r === void 0 ? void 0 : _r.quality;
5541
+ quality = (_s = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _s === void 0 ? void 0 : _s.quality;
5518
5542
  }
5519
5543
  if (quality == null) {
5520
5544
  quality = {
@@ -5525,13 +5549,13 @@ function renderV2(params, bookmark, view) {
5525
5549
  fxaa.enabled = Boolean(quality.fxaa);
5526
5550
  dateTime = bSettings === null || bSettings === void 0 ? void 0 : bSettings.dateTime;
5527
5551
  if (dateTime == null) {
5528
- dateTime = (_s = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _s === void 0 ? void 0 : _s.dateTime;
5552
+ dateTime = (_t = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _t === void 0 ? void 0 : _t.dateTime;
5529
5553
  }
5530
5554
  if (dateTime != null) {
5531
5555
  clock = viewer.clock;
5532
5556
  clock.currentTime = JulianDate.fromIso8601(dateTime);
5533
5557
  }
5534
- terrain = (_t = bSettings === null || bSettings === void 0 ? void 0 : bSettings.terrain) !== null && _t !== void 0 ? _t : (_u = defaults.settings) === null || _u === void 0 ? void 0 : _u.terrain;
5558
+ terrain = (_u = bSettings === null || bSettings === void 0 ? void 0 : bSettings.terrain) !== null && _u !== void 0 ? _u : (_v = defaults.settings) === null || _v === void 0 ? void 0 : _v.terrain;
5535
5559
  if (!terrain) return [3 /*break*/, 2];
5536
5560
  return [4 /*yield*/, TileRenderEngine.Terrain.V2.Render({
5537
5561
  apiGetter: params.apiGetter,
@@ -5539,12 +5563,12 @@ function renderV2(params, bookmark, view) {
5539
5563
  viewer: params.manager.Viewer,
5540
5564
  })];
5541
5565
  case 1:
5542
- _z.sent();
5543
- _z.label = 2;
5566
+ _0.sent();
5567
+ _0.label = 2;
5544
5568
  case 2:
5545
5569
  selectedIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.selectedEntityIds;
5546
5570
  if (selectedIds == null) {
5547
- selectedIds = (_v = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _v === void 0 ? void 0 : _v.selectedEntityIds;
5571
+ selectedIds = (_w = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _w === void 0 ? void 0 : _w.selectedEntityIds;
5548
5572
  }
5549
5573
  if (selectedIds != null) {
5550
5574
  params.manager.VisualsRegister.ClearSelected();
@@ -5553,7 +5577,7 @@ function renderV2(params, bookmark, view) {
5553
5577
  params.manager.VisualsRegister.Select(id, false);
5554
5578
  }
5555
5579
  }
5556
- imagery = (_w = bSettings.imagery) !== null && _w !== void 0 ? _w : (_x = defaults.settings) === null || _x === void 0 ? void 0 : _x.imagery;
5580
+ imagery = (_x = bSettings.imagery) !== null && _x !== void 0 ? _x : (_y = defaults.settings) === null || _y === void 0 ? void 0 : _y.imagery;
5557
5581
  if (imagery == null) {
5558
5582
  // TODO: Need global default.
5559
5583
  imagery = [
@@ -5575,19 +5599,19 @@ function renderV2(params, bookmark, view) {
5575
5599
  viewer: params.manager.Viewer,
5576
5600
  })];
5577
5601
  case 3:
5578
- _z.sent();
5602
+ _0.sent();
5579
5603
  curEnabled = params.manager.GetEnabledItemIds();
5580
- newItemIds = (_y = bSettings === null || bSettings === void 0 ? void 0 : bSettings.menuItemIds) !== null && _y !== void 0 ? _y : [];
5604
+ newItemIds = (_z = bSettings === null || bSettings === void 0 ? void 0 : bSettings.menuItemIds) !== null && _z !== void 0 ? _z : [];
5581
5605
  _i = 0, curEnabled_1 = curEnabled;
5582
- _z.label = 4;
5606
+ _0.label = 4;
5583
5607
  case 4:
5584
5608
  if (!(_i < curEnabled_1.length)) return [3 /*break*/, 7];
5585
5609
  id = curEnabled_1[_i];
5586
5610
  if (!(newItemIds.indexOf(id) === -1)) return [3 /*break*/, 6];
5587
5611
  return [4 /*yield*/, params.manager.RemoveItemById(id)];
5588
5612
  case 5:
5589
- _z.sent();
5590
- _z.label = 6;
5613
+ _0.sent();
5614
+ _0.label = 6;
5591
5615
  case 6:
5592
5616
  _i++;
5593
5617
  return [3 /*break*/, 4];
@@ -5598,8 +5622,8 @@ function renderV2(params, bookmark, view) {
5598
5622
  manager: params.manager,
5599
5623
  }, params.viewId, params.bookmarkId)];
5600
5624
  case 8:
5601
- _z.sent();
5602
- _z.label = 9;
5625
+ _0.sent();
5626
+ _0.label = 9;
5603
5627
  case 9: return [2 /*return*/];
5604
5628
  }
5605
5629
  });