bruce-cesium 5.6.8 → 5.7.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.
@@ -13682,7 +13682,7 @@
13682
13682
  * @returns
13683
13683
  */
13684
13684
  async renderAsIndividuals(entities, force = false) {
13685
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
13685
+ var _a, _b, _c, _d, _e, _f, _g, _h;
13686
13686
  // Entity ID -> historic records array.
13687
13687
  // We load this as extra information when rendering historic records.
13688
13688
  // This way we know what to animate towards as time changes.
@@ -13765,14 +13765,16 @@
13765
13765
  entityId: id,
13766
13766
  menuItemId: this.item.id
13767
13767
  });
13768
+ // The baseline data source must be editable.
13769
+ const canEdit = !((_e = entity.Bruce.Outline) === null || _e === void 0 ? void 0 : _e.find(x => x.Baseline && !x.Editable));
13768
13770
  const visual = rego === null || rego === void 0 ? void 0 : rego.visual;
13769
13771
  if (!visual || visual != cEntity) {
13770
13772
  const wasClustered = this.clustering ? this.clustering.AddEntity(id, cEntity, false) : false;
13771
- const tagIds = (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e["Layer.ID"];
13773
+ const tagIds = entity.Bruce["Layer.ID"];
13772
13774
  const rego = {
13773
- canEdit: true,
13775
+ canEdit: canEdit,
13774
13776
  entityId: id,
13775
- schema: (_f = entity.Bruce) === null || _f === void 0 ? void 0 : _f.Schema,
13777
+ schema: entity.Bruce.Schema,
13776
13778
  menuItemId: this.item.id,
13777
13779
  menuItemType: this.item.Type,
13778
13780
  visual: cEntity,
@@ -13783,7 +13785,7 @@
13783
13785
  overrideShow: wasClustered ? false : null,
13784
13786
  name: cEntity.name,
13785
13787
  cdn: this.item.cdnEnabled,
13786
- outline: (_g = entity.Bruce) === null || _g === void 0 ? void 0 : _g.Outline
13788
+ outline: entity.Bruce.Outline
13787
13789
  };
13788
13790
  this.visualsManager.AddRego({
13789
13791
  rego,
@@ -13794,10 +13796,11 @@
13794
13796
  rego.name = cEntity.name;
13795
13797
  rego.visual = cEntity;
13796
13798
  rego.entityTypeId = entity.Bruce["EntityType.ID"];
13797
- rego.tagIds = ((_h = entity.Bruce) === null || _h === void 0 ? void 0 : _h["Layer.ID"]) ? [].concat(entity.Bruce["Layer.ID"]) : [];
13798
- rego.outline = (_j = entity.Bruce) === null || _j === void 0 ? void 0 : _j.Outline;
13799
+ rego.tagIds = entity.Bruce["Layer.ID"] ? [].concat(entity.Bruce["Layer.ID"]) : [];
13800
+ rego.outline = (_f = entity.Bruce) === null || _f === void 0 ? void 0 : _f.Outline;
13799
13801
  rego.cdn = this.item.cdnEnabled;
13800
- rego.schema = (_k = entity.Bruce) === null || _k === void 0 ? void 0 : _k.Schema;
13802
+ rego.schema = (_g = entity.Bruce) === null || _g === void 0 ? void 0 : _g.Schema;
13803
+ rego.canEdit = canEdit;
13801
13804
  // Marked as stale meaning some change was performed that requires a refresh.
13802
13805
  // This usually means a new sibling was added that we need to update.
13803
13806
  if (rego.stale) {
@@ -13827,7 +13830,7 @@
13827
13830
  menuItemId: this.item.id,
13828
13831
  requestRender: false
13829
13832
  });
13830
- (_l = this.clustering) === null || _l === void 0 ? void 0 : _l.RemoveEntity(id, false);
13833
+ (_h = this.clustering) === null || _h === void 0 ? void 0 : _h.RemoveEntity(id, false);
13831
13834
  }
13832
13835
  }
13833
13836
  this.viewer.scene.requestRender();
@@ -25322,6 +25325,50 @@
25322
25325
  function assertIteration$1(viewer, iteration) {
25323
25326
  return viewer[ITERATION_KEY$1] == iteration;
25324
25327
  }
25328
+ function modelSpaceToPosition(point) {
25329
+ let lat = 0;
25330
+ let lon = 0;
25331
+ let alt = 0;
25332
+ {
25333
+ if (point) {
25334
+ if (isNaN(point.x) || point.x == null) {
25335
+ point.x = 0;
25336
+ }
25337
+ if (isNaN(point.y) || point.y == null) {
25338
+ point.y = 0;
25339
+ }
25340
+ if (isNaN(point.z) || point.z == null) {
25341
+ point.z = 0;
25342
+ }
25343
+ }
25344
+ if (point && (point.x !== 0 || point.y !== 0 || point.z !== 0)) {
25345
+ try {
25346
+ // Create a reference position at 0,0,0 - matching the origin used in PositionToModelSpace.
25347
+ const originPosition = Cesium.Cartesian3.fromDegrees(0, 0, 0);
25348
+ // Get the east-north-up (ENU) reference frame at the origin.
25349
+ const enuTransform = Cesium.Transforms.eastNorthUpToFixedFrame(originPosition);
25350
+ // Create the relative position.
25351
+ const relativePosition = new Cesium.Cartesian3(point.x, point.y, point.z);
25352
+ // Transform the relative position to the model's lat/lon/alt.
25353
+ const modelPosition = new Cesium.Cartesian3();
25354
+ Cesium.Matrix4.multiplyByPoint(enuTransform, relativePosition, modelPosition);
25355
+ // Convert the Cartesian3 position to lat/lon/alt.
25356
+ const carto = Cesium.Cartographic.fromCartesian(modelPosition);
25357
+ lat = Cesium.Math.toDegrees(carto.latitude);
25358
+ lon = Cesium.Math.toDegrees(carto.longitude);
25359
+ alt = carto.height;
25360
+ }
25361
+ catch (e) {
25362
+ console.error("Error converting model space to position:", e);
25363
+ }
25364
+ }
25365
+ }
25366
+ return {
25367
+ latitude: lat,
25368
+ longitude: lon,
25369
+ altitude: alt
25370
+ };
25371
+ }
25325
25372
  /**
25326
25373
  * Renders DATA_VERSION = 1 navigator.
25327
25374
  * param iteration
@@ -25512,16 +25559,32 @@
25512
25559
  contentType = BModels.ProjectViewBookmark.EContentType.WEB_3D;
25513
25560
  }
25514
25561
  let camera = ((_d = bookmark === null || bookmark === void 0 ? void 0 : bookmark.Camera) !== null && _d !== void 0 ? _d : {});
25515
- if (!BModels.Carto.ValidateCarto(camera)) {
25516
- camera = {
25517
- ...camera,
25518
- altitude: (_e = defaults.camera) === null || _e === void 0 ? void 0 : _e.altitude,
25519
- latitude: (_f = defaults.camera) === null || _f === void 0 ? void 0 : _f.latitude,
25520
- longitude: (_g = defaults.camera) === null || _g === void 0 ? void 0 : _g.longitude,
25521
- heading: (_h = defaults.camera) === null || _h === void 0 ? void 0 : _h.heading,
25522
- pitch: (_j = defaults.camera) === null || _j === void 0 ? void 0 : _j.pitch,
25523
- roll: (_k = defaults.camera) === null || _k === void 0 ? void 0 : _k.roll
25524
- };
25562
+ if (contentType == BModels.ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE) {
25563
+ if (!BModels.Cartes.ValidateCartes3(camera)) {
25564
+ camera = {
25565
+ altitude: 500,
25566
+ latitude: 0,
25567
+ longitude: 0,
25568
+ heading: 0,
25569
+ pitch: -90,
25570
+ roll: 0,
25571
+ cameraFrustum: BModels.Camera.EFrustum.Perspective,
25572
+ transition: 2000
25573
+ };
25574
+ }
25575
+ }
25576
+ else {
25577
+ if (!BModels.Carto.ValidateCarto(camera)) {
25578
+ camera = {
25579
+ ...camera,
25580
+ altitude: (_e = defaults.camera) === null || _e === void 0 ? void 0 : _e.altitude,
25581
+ latitude: (_f = defaults.camera) === null || _f === void 0 ? void 0 : _f.latitude,
25582
+ longitude: (_g = defaults.camera) === null || _g === void 0 ? void 0 : _g.longitude,
25583
+ heading: (_h = defaults.camera) === null || _h === void 0 ? void 0 : _h.heading,
25584
+ pitch: (_j = defaults.camera) === null || _j === void 0 ? void 0 : _j.pitch,
25585
+ roll: (_k = defaults.camera) === null || _k === void 0 ? void 0 : _k.roll
25586
+ };
25587
+ }
25525
25588
  }
25526
25589
  let newLens = camera.cameraFrustum;
25527
25590
  if (newLens == null) {
@@ -25551,8 +25614,24 @@
25551
25614
  // TODO: Need global default.
25552
25615
  transition = 2000;
25553
25616
  }
25554
- if (BModels.Carto.ValidateCarto(camera)) {
25555
- const pos = Cesium.Cartesian3.fromDegrees(+camera.longitude, +camera.latitude, +camera.altitude);
25617
+ let pos3d;
25618
+ if (contentType == BModels.ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE) {
25619
+ if (BModels.Cartes.ValidateCartes3(camera)) {
25620
+ const point = modelSpaceToPosition(camera);
25621
+ if (point && BModels.Carto.ValidateCarto(point)) {
25622
+ pos3d = Cesium.Cartesian3.fromDegrees(+point.longitude, +point.latitude, +point.altitude);
25623
+ }
25624
+ }
25625
+ else if (BModels.Carto.ValidateCarto(camera)) {
25626
+ pos3d = Cesium.Cartesian3.fromDegrees(+camera.longitude, +camera.latitude, +camera.altitude);
25627
+ }
25628
+ }
25629
+ else {
25630
+ if (BModels.Carto.ValidateCarto(camera)) {
25631
+ pos3d = Cesium.Cartesian3.fromDegrees(+camera.longitude, +camera.latitude, +camera.altitude);
25632
+ }
25633
+ }
25634
+ if (pos3d) {
25556
25635
  if (
25557
25636
  // Moving into model-space.
25558
25637
  (contentType == BModels.ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE) ||
@@ -25563,12 +25642,12 @@
25563
25642
  if (!cameraPos3d || (cameraPos3d.x == 0 && cameraPos3d.y == 0 && cameraPos3d.z == 0)) {
25564
25643
  transition = 0;
25565
25644
  }
25566
- else if (Cesium.Cartesian3.distance(cameraPos3d, pos) > 10000) {
25645
+ else if (Cesium.Cartesian3.distance(cameraPos3d, pos3d) > 10000) {
25567
25646
  transition = 0;
25568
25647
  }
25569
25648
  }
25570
25649
  scene.camera.flyTo({
25571
- destination: pos,
25650
+ destination: pos3d,
25572
25651
  orientation: {
25573
25652
  heading: Cesium.Math.toRadians(+camera.heading),
25574
25653
  pitch: Cesium.Math.toRadians(+camera.pitch),
@@ -26048,7 +26127,7 @@
26048
26127
  * @param params
26049
26128
  */
26050
26129
  async function FlyTo(params) {
26051
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
26130
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
26052
26131
  if (!params.manager && params.viewer) {
26053
26132
  params.manager = exports.ViewerUtils.GetManager({
26054
26133
  viewer: params.viewer,
@@ -26082,21 +26161,45 @@
26082
26161
  const scene = viewer.scene;
26083
26162
  const vSettings = view.Settings;
26084
26163
  const defaults = (_a = vSettings.defaults) !== null && _a !== void 0 ? _a : {};
26085
- let camera = ((_b = bookmark === null || bookmark === void 0 ? void 0 : bookmark.Camera) !== null && _b !== void 0 ? _b : {});
26086
- if (!BModels.Carto.ValidateCarto(camera)) {
26087
- camera = {
26088
- ...camera,
26089
- altitude: (_c = defaults.camera) === null || _c === void 0 ? void 0 : _c.altitude,
26090
- latitude: (_d = defaults.camera) === null || _d === void 0 ? void 0 : _d.latitude,
26091
- longitude: (_e = defaults.camera) === null || _e === void 0 ? void 0 : _e.longitude,
26092
- heading: (_f = defaults.camera) === null || _f === void 0 ? void 0 : _f.heading,
26093
- pitch: (_g = defaults.camera) === null || _g === void 0 ? void 0 : _g.pitch,
26094
- roll: (_h = defaults.camera) === null || _h === void 0 ? void 0 : _h.roll
26095
- };
26164
+ const bSettings = ((_b = bookmark === null || bookmark === void 0 ? void 0 : bookmark.Settings) !== null && _b !== void 0 ? _b : {});
26165
+ let contentType = bSettings.contentType;
26166
+ if (!contentType && ((_c = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _c === void 0 ? void 0 : _c.contentType)) {
26167
+ contentType = defaults.settings.contentType;
26168
+ }
26169
+ if (contentType == null) {
26170
+ contentType = BModels.ProjectViewBookmark.EContentType.WEB_3D;
26171
+ }
26172
+ let camera = ((_d = bookmark === null || bookmark === void 0 ? void 0 : bookmark.Camera) !== null && _d !== void 0 ? _d : {});
26173
+ if (contentType == BModels.ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE) {
26174
+ if (!BModels.Cartes.ValidateCartes3(camera)) {
26175
+ camera = {
26176
+ altitude: 500,
26177
+ latitude: 0,
26178
+ longitude: 0,
26179
+ heading: 0,
26180
+ pitch: -90,
26181
+ roll: 0,
26182
+ cameraFrustum: BModels.Camera.EFrustum.Perspective,
26183
+ transition: 2000
26184
+ };
26185
+ }
26186
+ }
26187
+ else {
26188
+ if (!BModels.Carto.ValidateCarto(camera)) {
26189
+ camera = {
26190
+ ...camera,
26191
+ altitude: (_e = defaults.camera) === null || _e === void 0 ? void 0 : _e.altitude,
26192
+ latitude: (_f = defaults.camera) === null || _f === void 0 ? void 0 : _f.latitude,
26193
+ longitude: (_g = defaults.camera) === null || _g === void 0 ? void 0 : _g.longitude,
26194
+ heading: (_h = defaults.camera) === null || _h === void 0 ? void 0 : _h.heading,
26195
+ pitch: (_j = defaults.camera) === null || _j === void 0 ? void 0 : _j.pitch,
26196
+ roll: (_k = defaults.camera) === null || _k === void 0 ? void 0 : _k.roll
26197
+ };
26198
+ }
26096
26199
  }
26097
26200
  let newLens = camera.cameraFrustum;
26098
26201
  if (newLens == null) {
26099
- newLens = (_j = defaults.camera) === null || _j === void 0 ? void 0 : _j.cameraFrustum;
26202
+ newLens = (_l = defaults.camera) === null || _l === void 0 ? void 0 : _l.cameraFrustum;
26100
26203
  }
26101
26204
  if (newLens == null) {
26102
26205
  // TODO: Need global default.
@@ -26115,16 +26218,46 @@
26115
26218
  }
26116
26219
  let transition = params.skipTransition ? 0 : shouldBe2d === curIs2d ? camera.transition : 0;
26117
26220
  if (transition == null) {
26118
- transition = (_k = defaults.camera) === null || _k === void 0 ? void 0 : _k.transition;
26221
+ transition = (_m = defaults.camera) === null || _m === void 0 ? void 0 : _m.transition;
26119
26222
  }
26120
26223
  if (transition == null) {
26121
26224
  // TODO: Need global default.
26122
26225
  transition = 2000;
26123
26226
  }
26124
- if (BModels.Carto.ValidateCarto(camera)) {
26125
- const pos = Cesium.Cartesian3.fromDegrees(+camera.longitude, +camera.latitude, +camera.altitude);
26227
+ let pos3d;
26228
+ if (contentType == BModels.ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE) {
26229
+ if (BModels.Cartes.ValidateCartes3(camera)) {
26230
+ const point = modelSpaceToPosition(camera);
26231
+ if (point && BModels.Carto.ValidateCarto(point)) {
26232
+ pos3d = Cesium.Cartesian3.fromDegrees(+point.longitude, +point.latitude, +point.altitude);
26233
+ }
26234
+ }
26235
+ else if (BModels.Carto.ValidateCarto(camera)) {
26236
+ pos3d = Cesium.Cartesian3.fromDegrees(+camera.longitude, +camera.latitude, +camera.altitude);
26237
+ }
26238
+ }
26239
+ else {
26240
+ if (BModels.Carto.ValidateCarto(camera)) {
26241
+ pos3d = Cesium.Cartesian3.fromDegrees(+camera.longitude, +camera.latitude, +camera.altitude);
26242
+ }
26243
+ }
26244
+ if (pos3d) {
26245
+ if (
26246
+ // Moving into model-space.
26247
+ (contentType == BModels.ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE) ||
26248
+ // Moving away from model-space.
26249
+ // @ts-expect-error
26250
+ (contentType != BModels.ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE && viewer[MODEL_SPACE_FLAG] == true)) {
26251
+ const cameraPos3d = viewer.camera.position;
26252
+ if (!cameraPos3d || (cameraPos3d.x == 0 && cameraPos3d.y == 0 && cameraPos3d.z == 0)) {
26253
+ transition = 0;
26254
+ }
26255
+ else if (Cesium.Cartesian3.distance(cameraPos3d, pos3d) > 10000) {
26256
+ transition = 0;
26257
+ }
26258
+ }
26126
26259
  scene.camera.flyTo({
26127
- destination: pos,
26260
+ destination: pos3d,
26128
26261
  orientation: {
26129
26262
  heading: Cesium.Math.toRadians(+camera.heading),
26130
26263
  pitch: Cesium.Math.toRadians(+camera.pitch),
@@ -31857,7 +31990,7 @@
31857
31990
  }
31858
31991
  }
31859
31992
 
31860
- const VERSION = "5.6.8";
31993
+ const VERSION = "5.7.0";
31861
31994
 
31862
31995
  exports.VERSION = VERSION;
31863
31996
  exports.isOutlineChanged = isOutlineChanged;