bruce-cesium 6.2.2 → 6.2.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.
@@ -20905,6 +20905,71 @@
20905
20905
  DataSourceStaticKmlManager.Manager = Manager;
20906
20906
  })(exports.DataSourceStaticKmlManager || (exports.DataSourceStaticKmlManager = {}));
20907
20907
 
20908
+ (function (XGridsRenderEngine) {
20909
+ function Render(params) {
20910
+ var _a, _b, _c;
20911
+ const { api, viewer, tileset } = params;
20912
+ if (!LCCRender) {
20913
+ console.warn("[XGridsRenderEngine] Render() LCCRender library not available.");
20914
+ return null;
20915
+ }
20916
+ const settings = tileset.settings;
20917
+ let position = settings === null || settings === void 0 ? void 0 : settings.origin;
20918
+ if (settings.dontTransform) {
20919
+ position = null;
20920
+ }
20921
+ let m1 = undefined;
20922
+ // Location matrix.
20923
+ if ((position === null || position === void 0 ? void 0 : position.latitude) || (position === null || position === void 0 ? void 0 : position.longitude) || (position === null || position === void 0 ? void 0 : position.altitude)) {
20924
+ m1 = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(EnsureNumber(position.longitude, 0), EnsureNumber(position.latitude, 0), EnsureNumber(position.altitude, 0)));
20925
+ }
20926
+ else {
20927
+ m1 = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(0, 0, 0));
20928
+ }
20929
+ // Apply HPR + scale.
20930
+ if (!settings.dontRotate && !settings.dontTransform) {
20931
+ const translationMatrix = Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(0, 0, 0), new Cesium.Matrix4());
20932
+ const hpr = Cesium.HeadingPitchRoll.fromDegrees(EnsureNumber((_a = settings.rotation) === null || _a === void 0 ? void 0 : _a.z), EnsureNumber((_b = settings.rotation) === null || _b === void 0 ? void 0 : _b.x), EnsureNumber((_c = settings.rotation) === null || _c === void 0 ? void 0 : _c.y), new Cesium.HeadingPitchRoll());
20933
+ const hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(hpr);
20934
+ const scaleMatrix = Cesium.Matrix4.fromUniformScale(EnsureNumber((position === null || position === void 0 ? void 0 : position.scale) || 1, 1), new Cesium.Matrix4());
20935
+ let combinedMatrix = Cesium.Matrix4.multiply(m1, translationMatrix, new Cesium.Matrix4());
20936
+ combinedMatrix = Cesium.Matrix4.multiply(combinedMatrix, Cesium.Matrix4.fromRotation(hprRotation), new Cesium.Matrix4());
20937
+ combinedMatrix = Cesium.Matrix4.multiply(combinedMatrix, scaleMatrix, new Cesium.Matrix4());
20938
+ m1 = combinedMatrix;
20939
+ }
20940
+ const loadUrl = BModels.Tileset.GetFileUrl({
20941
+ file: tileset.rootFileName || "meta.lcc",
20942
+ tilesetId: tileset.id,
20943
+ viaCdn: true,
20944
+ legacy: true,
20945
+ cacheToken: tileset.generateVersion,
20946
+ api: api
20947
+ });
20948
+ return window.LCCRender.load({
20949
+ camera: viewer.camera,
20950
+ scene: viewer.scene,
20951
+ dataPath: loadUrl,
20952
+ renderLib: Cesium,
20953
+ canvas: viewer.canvas,
20954
+ useEnv: false,
20955
+ modelMatrix: m1,
20956
+ useIndexDB: false,
20957
+ appKey: null
20958
+ });
20959
+ }
20960
+ XGridsRenderEngine.Render = Render;
20961
+ function Remove(viewer, renderObject) {
20962
+ if (!renderObject) {
20963
+ return;
20964
+ }
20965
+ if (!LCCRender) {
20966
+ console.warn("[XGridsRenderEngine] Remove() LCCRender library not available.");
20967
+ return;
20968
+ }
20969
+ }
20970
+ XGridsRenderEngine.Remove = Remove;
20971
+ })(exports.XGridsRenderEngine || (exports.XGridsRenderEngine = {}));
20972
+
20908
20973
  async function getLegacyTileset(params) {
20909
20974
  const { apiGetter, menuItem, tileset } = params;
20910
20975
  try {
@@ -20938,6 +21003,12 @@
20938
21003
  }
20939
21004
  }
20940
21005
  (function (TilesetArbRenderManager) {
21006
+ let ERenderType;
21007
+ (function (ERenderType) {
21008
+ ERenderType["CesiumTileset"] = "CesiumTileset";
21009
+ ERenderType["XGridsLCC"] = "XGridsLCC";
21010
+ ERenderType["Unknown"] = "Unknown";
21011
+ })(ERenderType = TilesetArbRenderManager.ERenderType || (TilesetArbRenderManager.ERenderType = {}));
20941
21012
  class Manager {
20942
21013
  get Disposed() {
20943
21014
  return this.disposed;
@@ -20948,6 +21019,12 @@
20948
21019
  get Styler() {
20949
21020
  return this.styler;
20950
21021
  }
21022
+ get RenderType() {
21023
+ return this.renderType;
21024
+ }
21025
+ get RenderTypeChanged() {
21026
+ return this.renderTypeChanged;
21027
+ }
20951
21028
  constructor(params) {
20952
21029
  this.disposed = false;
20953
21030
  this.cTileset = null;
@@ -20971,6 +21048,11 @@
20971
21048
  // Saves having to do a case-insensitive lookup every time.
20972
21049
  this.featurePropCache = new Map();
20973
21050
  this.featurePropsChecked = 0;
21051
+ // How we're rendering the data.
21052
+ this.renderType = ERenderType.Unknown;
21053
+ this.renderTypeChanged = new BModels.BruceEvent();
21054
+ // LCC object if we're using XGrids to render LCC data.
21055
+ this.lccObject = null;
20974
21056
  this.viewer = params.viewer;
20975
21057
  this.getters = params.getters;
20976
21058
  this.visualsManager = params.register;
@@ -21016,7 +21098,7 @@
21016
21098
  }
21017
21099
  const tilesetId = (_c = this.item.tileset) === null || _c === void 0 ? void 0 : _c.TilesetID;
21018
21100
  (async () => {
21019
- var _a, _b, _c, _d, _e, _f, _g;
21101
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
21020
21102
  if (tilesetId) {
21021
21103
  let canAccess = false;
21022
21104
  try {
@@ -21055,113 +21137,137 @@
21055
21137
  if (tileset && loadUrlOverride) {
21056
21138
  tileset.loadUrl = loadUrlOverride;
21057
21139
  }
21058
- const LEGACY_TYPES = [
21059
- BModels.Tileset.EType.LegacyEntitiesSet,
21060
- BModels.Tileset.EType.LegacyExternal,
21061
- BModels.Tileset.EType.LegacyStatic
21062
- ];
21063
- if (!type || LEGACY_TYPES.includes(type)) {
21064
- // Legacy type. We re-request using ui.tileset endpoint.
21065
- const legacyTileset = tileset ? await getLegacyTileset({
21066
- apiGetter: this.getters.GetBruceGetter(),
21067
- menuItem: this.item,
21068
- tileset
21069
- }) : null;
21070
- if (this.disposed) {
21071
- return;
21072
- }
21073
- let accountId = (_c = (_b = this.item) === null || _b === void 0 ? void 0 : _b.tileset) === null || _c === void 0 ? void 0 : _c.ClientAccountID;
21074
- if (!accountId) {
21075
- accountId = this.getters.GetAccountId();
21076
- }
21077
- this.cTileset = await exports.TilesetRenderEngine.RenderLegacy({
21078
- apiGetter: this.getters.GetBruceGetter(),
21079
- tileset: legacyTileset,
21080
- viewer: this.viewer,
21081
- ionId: (_d = this.item.IonResource) === null || _d === void 0 ? void 0 : _d.AssetID,
21082
- ionAccessToken: (_e = this.item.IonResource) === null || _e === void 0 ? void 0 : _e.AccessToken,
21083
- loadUrl: loadUrlOverride,
21084
- accountId: accountId,
21085
- viaCdn: this.item.cdnEnabled == null ? true : Boolean(this.item.cdnEnabled),
21086
- noMemoryLimit: this.item.noMaximumMemory,
21087
- backFaceCulling: this.item.backFaceCulling
21140
+ // LCC Tileset to load through XGrids libs if they're available.
21141
+ if (tileset.type === BModels.Tileset.EType.LegacyStatic && tileset.rootFileName && (tileset.rootFileName.toLowerCase()).endsWith(".lcc")) {
21142
+ this.renderType = ERenderType.XGridsLCC;
21143
+ this.renderTypeChanged.Trigger(this.renderType);
21144
+ const api = this.getters.GetBruceApi({
21145
+ accountId: ((_c = (_b = this.item) === null || _b === void 0 ? void 0 : _b.tileset) === null || _c === void 0 ? void 0 : _c.ClientAccountID) || this.getters.GetAccountId()
21088
21146
  });
21089
- }
21090
- else if (tileset) {
21091
- this.cTileset = await exports.TilesetRenderEngine.Render({
21092
- apiGetter: this.getters.GetBruceGetter(),
21093
- tileset: tileset,
21147
+ this.lccObject = exports.XGridsRenderEngine.Render({
21148
+ api: api,
21094
21149
  viewer: this.viewer,
21095
- coords: null,
21096
- accountId: (_g = (_f = this.item.tileset) === null || _f === void 0 ? void 0 : _f.ClientAccountID) !== null && _g !== void 0 ? _g : this.getters.GetAccountId(),
21097
- viaCdn: this.item.cdnEnabled == null ? true : Boolean(this.item.cdnEnabled)
21150
+ tileset: tileset
21098
21151
  });
21099
- }
21100
- if (this.disposed) {
21101
- this.doDispose();
21102
- return;
21103
- }
21104
- this.viewer.scene.requestRender();
21105
- exports.TilesetRenderEngine.OnTilesetReady(this.cTileset).then(() => {
21106
- if (this.disposed || this.viewer.isDestroyed()) {
21152
+ // Disposed while it was loading so we'll remove it now.
21153
+ if (this.Disposed && this.lccObject) {
21154
+ exports.XGridsRenderEngine.Remove(this.viewer, this.lccObject);
21155
+ this.lccObject = null;
21107
21156
  return;
21108
21157
  }
21109
- // Colour mask to apply to the Tileset as a whole.
21110
- // Individual Entities can override this.
21111
- // This is typically used for Tilesets without Entities to allow some sort of basic styling per-bookmark.
21112
- try {
21113
- const colorCss = this.item.colorMask;
21114
- if (colorCss) {
21115
- this.cTileset.style = new Cesium.Cesium3DTileStyle({
21116
- color: {
21117
- conditions: [
21118
- ["true", `color("${colorCss}")`]
21119
- ]
21120
- }
21121
- });
21158
+ }
21159
+ // Typical Cesium Tileset.
21160
+ else {
21161
+ this.renderType = ERenderType.CesiumTileset;
21162
+ this.renderTypeChanged.Trigger(this.renderType);
21163
+ const LEGACY_TYPES = [
21164
+ BModels.Tileset.EType.LegacyEntitiesSet,
21165
+ BModels.Tileset.EType.LegacyExternal,
21166
+ BModels.Tileset.EType.LegacyStatic
21167
+ ];
21168
+ if (!type || LEGACY_TYPES.includes(type)) {
21169
+ // Legacy type. We re-request using ui.tileset endpoint.
21170
+ const legacyTileset = tileset ? await getLegacyTileset({
21171
+ apiGetter: this.getters.GetBruceGetter(),
21172
+ menuItem: this.item,
21173
+ tileset
21174
+ }) : null;
21175
+ if (this.disposed) {
21176
+ return;
21122
21177
  }
21123
- }
21124
- catch (e) {
21125
- console.error(e);
21126
- }
21127
- try {
21128
- if (this.item.ApplyStyles ||
21129
- this.item.Type == BModels.MenuItem.EType.IonTileset) {
21130
- const api = this.getters.GetBruceApi();
21131
- this.styler.Init({
21132
- viewer: this.viewer,
21133
- api: api,
21134
- cTileset: this.cTileset,
21135
- fallbackStyleId: this.item.styleId,
21136
- styleMapping: this.item.StyleMapping,
21137
- expandSources: false,
21138
- menuItemId: this.item.id,
21139
- register: this.visualsManager,
21140
- });
21178
+ let accountId = (_e = (_d = this.item) === null || _d === void 0 ? void 0 : _d.tileset) === null || _e === void 0 ? void 0 : _e.ClientAccountID;
21179
+ if (!accountId) {
21180
+ accountId = this.getters.GetAccountId();
21141
21181
  }
21142
- this.onCTilesetLoad();
21143
- this.viewer.scene.requestRender();
21144
- }
21145
- catch (e) {
21146
- console.error(e);
21147
- }
21148
- });
21149
- this.cTileset.tileLoad.addEventListener((tile) => {
21150
- try {
21151
- this.queueTile(tile, true);
21152
- }
21153
- catch (e) {
21154
- console.error(e);
21182
+ this.cTileset = await exports.TilesetRenderEngine.RenderLegacy({
21183
+ apiGetter: this.getters.GetBruceGetter(),
21184
+ tileset: legacyTileset,
21185
+ viewer: this.viewer,
21186
+ ionId: (_f = this.item.IonResource) === null || _f === void 0 ? void 0 : _f.AssetID,
21187
+ ionAccessToken: (_g = this.item.IonResource) === null || _g === void 0 ? void 0 : _g.AccessToken,
21188
+ loadUrl: loadUrlOverride,
21189
+ accountId: accountId,
21190
+ viaCdn: this.item.cdnEnabled == null ? true : Boolean(this.item.cdnEnabled),
21191
+ noMemoryLimit: this.item.noMaximumMemory,
21192
+ backFaceCulling: this.item.backFaceCulling
21193
+ });
21155
21194
  }
21156
- });
21157
- this.cTileset.tileUnload.addEventListener((tile) => {
21158
- try {
21159
- this.queueTile(tile, false);
21195
+ else if (tileset) {
21196
+ this.cTileset = await exports.TilesetRenderEngine.Render({
21197
+ apiGetter: this.getters.GetBruceGetter(),
21198
+ tileset: tileset,
21199
+ viewer: this.viewer,
21200
+ coords: null,
21201
+ accountId: (_j = (_h = this.item.tileset) === null || _h === void 0 ? void 0 : _h.ClientAccountID) !== null && _j !== void 0 ? _j : this.getters.GetAccountId(),
21202
+ viaCdn: this.item.cdnEnabled == null ? true : Boolean(this.item.cdnEnabled)
21203
+ });
21160
21204
  }
21161
- catch (e) {
21162
- console.error(e);
21205
+ if (this.disposed) {
21206
+ this.doDispose();
21207
+ return;
21163
21208
  }
21164
- });
21209
+ this.viewer.scene.requestRender();
21210
+ exports.TilesetRenderEngine.OnTilesetReady(this.cTileset).then(() => {
21211
+ if (this.disposed || this.viewer.isDestroyed()) {
21212
+ return;
21213
+ }
21214
+ // Colour mask to apply to the Tileset as a whole.
21215
+ // Individual Entities can override this.
21216
+ // This is typically used for Tilesets without Entities to allow some sort of basic styling per-bookmark.
21217
+ try {
21218
+ const colorCss = this.item.colorMask;
21219
+ if (colorCss) {
21220
+ this.cTileset.style = new Cesium.Cesium3DTileStyle({
21221
+ color: {
21222
+ conditions: [
21223
+ ["true", `color("${colorCss}")`]
21224
+ ]
21225
+ }
21226
+ });
21227
+ }
21228
+ }
21229
+ catch (e) {
21230
+ console.error(e);
21231
+ }
21232
+ try {
21233
+ if (this.item.ApplyStyles ||
21234
+ this.item.Type == BModels.MenuItem.EType.IonTileset) {
21235
+ const api = this.getters.GetBruceApi();
21236
+ this.styler.Init({
21237
+ viewer: this.viewer,
21238
+ api: api,
21239
+ cTileset: this.cTileset,
21240
+ fallbackStyleId: this.item.styleId,
21241
+ styleMapping: this.item.StyleMapping,
21242
+ expandSources: false,
21243
+ menuItemId: this.item.id,
21244
+ register: this.visualsManager,
21245
+ });
21246
+ }
21247
+ this.onCTilesetLoad();
21248
+ this.viewer.scene.requestRender();
21249
+ }
21250
+ catch (e) {
21251
+ console.error(e);
21252
+ }
21253
+ });
21254
+ this.cTileset.tileLoad.addEventListener((tile) => {
21255
+ try {
21256
+ this.queueTile(tile, true);
21257
+ }
21258
+ catch (e) {
21259
+ console.error(e);
21260
+ }
21261
+ });
21262
+ this.cTileset.tileUnload.addEventListener((tile) => {
21263
+ try {
21264
+ this.queueTile(tile, false);
21265
+ }
21266
+ catch (e) {
21267
+ console.error(e);
21268
+ }
21269
+ });
21270
+ }
21165
21271
  })();
21166
21272
  }
21167
21273
  /**
@@ -21305,6 +21411,10 @@
21305
21411
  }
21306
21412
  this.cTileset = null;
21307
21413
  }
21414
+ if (this.lccObject) {
21415
+ exports.XGridsRenderEngine.Remove(this.viewer, this.lccObject);
21416
+ this.lccObject = null;
21417
+ }
21308
21418
  (_b = this.styler) === null || _b === void 0 ? void 0 : _b.Dispose();
21309
21419
  this.visualsManager.RemoveRegos({
21310
21420
  menuItemId: this.item.id
@@ -34361,7 +34471,7 @@
34361
34471
  }
34362
34472
  }
34363
34473
 
34364
- const VERSION = "6.2.2";
34474
+ const VERSION = "6.2.3";
34365
34475
 
34366
34476
  exports.VERSION = VERSION;
34367
34477
  exports.isOutlineChanged = isOutlineChanged;