@itwin/core-frontend 3.0.0-dev.102 → 3.0.0-dev.106

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.
Files changed (205) hide show
  1. package/lib/cjs/ApproximateTerrainHeights.js +3 -3
  2. package/lib/cjs/ApproximateTerrainHeights.js.map +1 -1
  3. package/lib/cjs/ContextRealityModelState.js +1 -1
  4. package/lib/cjs/ContextRealityModelState.js.map +1 -1
  5. package/lib/cjs/ElementLocateManager.d.ts +5 -0
  6. package/lib/cjs/ElementLocateManager.d.ts.map +1 -1
  7. package/lib/cjs/ElementLocateManager.js +12 -2
  8. package/lib/cjs/ElementLocateManager.js.map +1 -1
  9. package/lib/cjs/ModelState.js +1 -1
  10. package/lib/cjs/ModelState.js.map +1 -1
  11. package/lib/cjs/RealityDataSource.d.ts +53 -29
  12. package/lib/cjs/RealityDataSource.d.ts.map +1 -1
  13. package/lib/cjs/RealityDataSource.js +245 -91
  14. package/lib/cjs/RealityDataSource.js.map +1 -1
  15. package/lib/cjs/TwoWayViewportSync.d.ts +35 -6
  16. package/lib/cjs/TwoWayViewportSync.d.ts.map +1 -1
  17. package/lib/cjs/TwoWayViewportSync.js +51 -11
  18. package/lib/cjs/TwoWayViewportSync.js.map +1 -1
  19. package/lib/cjs/Viewport.d.ts +23 -5
  20. package/lib/cjs/Viewport.d.ts.map +1 -1
  21. package/lib/cjs/Viewport.js +13 -9
  22. package/lib/cjs/Viewport.js.map +1 -1
  23. package/lib/cjs/core-frontend.d.ts +0 -1
  24. package/lib/cjs/core-frontend.d.ts.map +1 -1
  25. package/lib/cjs/core-frontend.js +0 -1
  26. package/lib/cjs/core-frontend.js.map +1 -1
  27. package/lib/cjs/render/webgl/PlanarClassifier.d.ts.map +1 -1
  28. package/lib/cjs/render/webgl/PlanarClassifier.js +4 -2
  29. package/lib/cjs/render/webgl/PlanarClassifier.js.map +1 -1
  30. package/lib/cjs/render/webgl/glsl/PlanarClassification.d.ts.map +1 -1
  31. package/lib/cjs/render/webgl/glsl/PlanarClassification.js +10 -1
  32. package/lib/cjs/render/webgl/glsl/PlanarClassification.js.map +1 -1
  33. package/lib/cjs/tile/CesiumAssetProvider.d.ts +13 -0
  34. package/lib/cjs/tile/CesiumAssetProvider.d.ts.map +1 -0
  35. package/lib/cjs/tile/CesiumAssetProvider.js +34 -0
  36. package/lib/cjs/tile/CesiumAssetProvider.js.map +1 -0
  37. package/lib/cjs/tile/ContextShareProvider.d.ts +22 -0
  38. package/lib/cjs/tile/ContextShareProvider.d.ts.map +1 -0
  39. package/lib/cjs/tile/ContextShareProvider.js +110 -0
  40. package/lib/cjs/tile/ContextShareProvider.js.map +1 -0
  41. package/lib/cjs/tile/OrbitGtTileTree.d.ts.map +1 -1
  42. package/lib/cjs/tile/OrbitGtTileTree.js +8 -5
  43. package/lib/cjs/tile/OrbitGtTileTree.js.map +1 -1
  44. package/lib/cjs/tile/RealityModelTileTree.d.ts +1 -54
  45. package/lib/cjs/tile/RealityModelTileTree.d.ts.map +1 -1
  46. package/lib/cjs/tile/RealityModelTileTree.js +24 -217
  47. package/lib/cjs/tile/RealityModelTileTree.js.map +1 -1
  48. package/lib/cjs/tile/internal.d.ts +3 -0
  49. package/lib/cjs/tile/internal.d.ts.map +1 -1
  50. package/lib/cjs/tile/internal.js +3 -0
  51. package/lib/cjs/tile/internal.js.map +1 -1
  52. package/lib/cjs/tile/map/ArcGISTileMap.d.ts +22 -0
  53. package/lib/cjs/tile/map/ArcGISTileMap.d.ts.map +1 -0
  54. package/lib/cjs/tile/map/ArcGISTileMap.js +173 -0
  55. package/lib/cjs/tile/map/ArcGISTileMap.js.map +1 -0
  56. package/lib/cjs/tile/map/CesiumTerrainProvider.js +5 -4
  57. package/lib/cjs/tile/map/CesiumTerrainProvider.js.map +1 -1
  58. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts +2 -2
  59. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
  60. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +18 -40
  61. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
  62. package/lib/cjs/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts +6 -1
  63. package/lib/cjs/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts.map +1 -1
  64. package/lib/cjs/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js +63 -21
  65. package/lib/cjs/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js.map +1 -1
  66. package/lib/cjs/tile/map/ImageryTileTree.d.ts +4 -4
  67. package/lib/cjs/tile/map/ImageryTileTree.d.ts.map +1 -1
  68. package/lib/cjs/tile/map/ImageryTileTree.js +20 -24
  69. package/lib/cjs/tile/map/ImageryTileTree.js.map +1 -1
  70. package/lib/cjs/tile/map/MapCartoRectangle.js +1 -1
  71. package/lib/cjs/tile/map/MapCartoRectangle.js.map +1 -1
  72. package/lib/cjs/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
  73. package/lib/cjs/tile/map/MapLayerImageryFormats.js +17 -6
  74. package/lib/cjs/tile/map/MapLayerImageryFormats.js.map +1 -1
  75. package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts +9 -4
  76. package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
  77. package/lib/cjs/tile/map/MapLayerImageryProvider.js +22 -4
  78. package/lib/cjs/tile/map/MapLayerImageryProvider.js.map +1 -1
  79. package/lib/cjs/tile/map/MapTile.d.ts.map +1 -1
  80. package/lib/cjs/tile/map/MapTile.js +4 -3
  81. package/lib/cjs/tile/map/MapTile.js.map +1 -1
  82. package/lib/cjs/tile/map/MapTileTree.js +1 -1
  83. package/lib/cjs/tile/map/MapTileTree.js.map +1 -1
  84. package/lib/cjs/tile/map/MapTilingScheme.d.ts +7 -2
  85. package/lib/cjs/tile/map/MapTilingScheme.d.ts.map +1 -1
  86. package/lib/cjs/tile/map/MapTilingScheme.js +21 -8
  87. package/lib/cjs/tile/map/MapTilingScheme.js.map +1 -1
  88. package/lib/cjs/tile/map/QuadId.d.ts +1 -0
  89. package/lib/cjs/tile/map/QuadId.d.ts.map +1 -1
  90. package/lib/cjs/tile/map/QuadId.js +2 -1
  91. package/lib/cjs/tile/map/QuadId.js.map +1 -1
  92. package/lib/cjs/tile/map/WmtsCapabilities.d.ts +7 -0
  93. package/lib/cjs/tile/map/WmtsCapabilities.d.ts.map +1 -1
  94. package/lib/cjs/tile/map/WmtsCapabilities.js +16 -2
  95. package/lib/cjs/tile/map/WmtsCapabilities.js.map +1 -1
  96. package/lib/cjs/tools/ViewTool.d.ts.map +1 -1
  97. package/lib/cjs/tools/ViewTool.js +2 -10
  98. package/lib/cjs/tools/ViewTool.js.map +1 -1
  99. package/lib/esm/ApproximateTerrainHeights.js +3 -3
  100. package/lib/esm/ApproximateTerrainHeights.js.map +1 -1
  101. package/lib/esm/ContextRealityModelState.js +1 -1
  102. package/lib/esm/ContextRealityModelState.js.map +1 -1
  103. package/lib/esm/ElementLocateManager.d.ts +5 -0
  104. package/lib/esm/ElementLocateManager.d.ts.map +1 -1
  105. package/lib/esm/ElementLocateManager.js +12 -2
  106. package/lib/esm/ElementLocateManager.js.map +1 -1
  107. package/lib/esm/ModelState.js +1 -1
  108. package/lib/esm/ModelState.js.map +1 -1
  109. package/lib/esm/RealityDataSource.d.ts +53 -29
  110. package/lib/esm/RealityDataSource.d.ts.map +1 -1
  111. package/lib/esm/RealityDataSource.js +246 -90
  112. package/lib/esm/RealityDataSource.js.map +1 -1
  113. package/lib/esm/TwoWayViewportSync.d.ts +35 -6
  114. package/lib/esm/TwoWayViewportSync.d.ts.map +1 -1
  115. package/lib/esm/TwoWayViewportSync.js +49 -10
  116. package/lib/esm/TwoWayViewportSync.js.map +1 -1
  117. package/lib/esm/Viewport.d.ts +23 -5
  118. package/lib/esm/Viewport.d.ts.map +1 -1
  119. package/lib/esm/Viewport.js +13 -9
  120. package/lib/esm/Viewport.js.map +1 -1
  121. package/lib/esm/core-frontend.d.ts +0 -1
  122. package/lib/esm/core-frontend.d.ts.map +1 -1
  123. package/lib/esm/core-frontend.js +0 -1
  124. package/lib/esm/core-frontend.js.map +1 -1
  125. package/lib/esm/render/webgl/PlanarClassifier.d.ts.map +1 -1
  126. package/lib/esm/render/webgl/PlanarClassifier.js +4 -2
  127. package/lib/esm/render/webgl/PlanarClassifier.js.map +1 -1
  128. package/lib/esm/render/webgl/glsl/PlanarClassification.d.ts.map +1 -1
  129. package/lib/esm/render/webgl/glsl/PlanarClassification.js +10 -1
  130. package/lib/esm/render/webgl/glsl/PlanarClassification.js.map +1 -1
  131. package/lib/esm/tile/CesiumAssetProvider.d.ts +13 -0
  132. package/lib/esm/tile/CesiumAssetProvider.d.ts.map +1 -0
  133. package/lib/esm/tile/CesiumAssetProvider.js +30 -0
  134. package/lib/esm/tile/CesiumAssetProvider.js.map +1 -0
  135. package/lib/esm/tile/ContextShareProvider.d.ts +22 -0
  136. package/lib/esm/tile/ContextShareProvider.d.ts.map +1 -0
  137. package/lib/esm/tile/ContextShareProvider.js +106 -0
  138. package/lib/esm/tile/ContextShareProvider.js.map +1 -0
  139. package/lib/esm/tile/OrbitGtTileTree.d.ts.map +1 -1
  140. package/lib/esm/tile/OrbitGtTileTree.js +8 -5
  141. package/lib/esm/tile/OrbitGtTileTree.js.map +1 -1
  142. package/lib/esm/tile/RealityModelTileTree.d.ts +1 -54
  143. package/lib/esm/tile/RealityModelTileTree.d.ts.map +1 -1
  144. package/lib/esm/tile/RealityModelTileTree.js +26 -218
  145. package/lib/esm/tile/RealityModelTileTree.js.map +1 -1
  146. package/lib/esm/tile/internal.d.ts +3 -0
  147. package/lib/esm/tile/internal.d.ts.map +1 -1
  148. package/lib/esm/tile/internal.js +3 -0
  149. package/lib/esm/tile/internal.js.map +1 -1
  150. package/lib/esm/tile/map/ArcGISTileMap.d.ts +22 -0
  151. package/lib/esm/tile/map/ArcGISTileMap.d.ts.map +1 -0
  152. package/lib/esm/tile/map/ArcGISTileMap.js +169 -0
  153. package/lib/esm/tile/map/ArcGISTileMap.js.map +1 -0
  154. package/lib/esm/tile/map/CesiumTerrainProvider.js +5 -4
  155. package/lib/esm/tile/map/CesiumTerrainProvider.js.map +1 -1
  156. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts +2 -2
  157. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
  158. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +19 -41
  159. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
  160. package/lib/esm/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts +6 -1
  161. package/lib/esm/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts.map +1 -1
  162. package/lib/esm/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js +63 -21
  163. package/lib/esm/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js.map +1 -1
  164. package/lib/esm/tile/map/ImageryTileTree.d.ts +4 -4
  165. package/lib/esm/tile/map/ImageryTileTree.d.ts.map +1 -1
  166. package/lib/esm/tile/map/ImageryTileTree.js +21 -25
  167. package/lib/esm/tile/map/ImageryTileTree.js.map +1 -1
  168. package/lib/esm/tile/map/MapCartoRectangle.js +1 -1
  169. package/lib/esm/tile/map/MapCartoRectangle.js.map +1 -1
  170. package/lib/esm/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
  171. package/lib/esm/tile/map/MapLayerImageryFormats.js +17 -6
  172. package/lib/esm/tile/map/MapLayerImageryFormats.js.map +1 -1
  173. package/lib/esm/tile/map/MapLayerImageryProvider.d.ts +9 -4
  174. package/lib/esm/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
  175. package/lib/esm/tile/map/MapLayerImageryProvider.js +22 -4
  176. package/lib/esm/tile/map/MapLayerImageryProvider.js.map +1 -1
  177. package/lib/esm/tile/map/MapTile.d.ts.map +1 -1
  178. package/lib/esm/tile/map/MapTile.js +4 -3
  179. package/lib/esm/tile/map/MapTile.js.map +1 -1
  180. package/lib/esm/tile/map/MapTileTree.js +1 -1
  181. package/lib/esm/tile/map/MapTileTree.js.map +1 -1
  182. package/lib/esm/tile/map/MapTilingScheme.d.ts +7 -2
  183. package/lib/esm/tile/map/MapTilingScheme.d.ts.map +1 -1
  184. package/lib/esm/tile/map/MapTilingScheme.js +22 -9
  185. package/lib/esm/tile/map/MapTilingScheme.js.map +1 -1
  186. package/lib/esm/tile/map/QuadId.d.ts +1 -0
  187. package/lib/esm/tile/map/QuadId.d.ts.map +1 -1
  188. package/lib/esm/tile/map/QuadId.js +2 -1
  189. package/lib/esm/tile/map/QuadId.js.map +1 -1
  190. package/lib/esm/tile/map/WmtsCapabilities.d.ts +7 -0
  191. package/lib/esm/tile/map/WmtsCapabilities.d.ts.map +1 -1
  192. package/lib/esm/tile/map/WmtsCapabilities.js +16 -2
  193. package/lib/esm/tile/map/WmtsCapabilities.js.map +1 -1
  194. package/lib/esm/tools/ViewTool.d.ts.map +1 -1
  195. package/lib/esm/tools/ViewTool.js +2 -10
  196. package/lib/esm/tools/ViewTool.js.map +1 -1
  197. package/package.json +24 -24
  198. package/lib/cjs/RealityDataConnection.d.ts +0 -31
  199. package/lib/cjs/RealityDataConnection.d.ts.map +0 -1
  200. package/lib/cjs/RealityDataConnection.js +0 -101
  201. package/lib/cjs/RealityDataConnection.js.map +0 -1
  202. package/lib/esm/RealityDataConnection.d.ts +0 -31
  203. package/lib/esm/RealityDataConnection.d.ts.map +0 -1
  204. package/lib/esm/RealityDataConnection.js +0 -98
  205. package/lib/esm/RealityDataConnection.js.map +0 -1
@@ -7,8 +7,7 @@
7
7
  * @module Utils
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.RealityModelTileClient = exports.RealityModelTileTree = exports.RealityModelTileUtils = exports.RealityTileRegion = exports.createRealityTileTreeReference = void 0;
11
- const itwin_client_1 = require("@bentley/itwin-client");
10
+ exports.RealityModelTileTree = exports.RealityModelTileUtils = exports.RealityTileRegion = exports.createRealityTileTreeReference = void 0;
12
11
  const core_bentley_1 = require("@itwin/core-bentley");
13
12
  const core_common_1 = require("@itwin/core-common");
14
13
  const core_geometry_1 = require("@itwin/core-geometry");
@@ -16,7 +15,6 @@ const BackgroundMapGeometry_1 = require("../BackgroundMapGeometry");
16
15
  const IModelApp_1 = require("../IModelApp");
17
16
  const PlanarClipMaskState_1 = require("../PlanarClipMaskState");
18
17
  const RealityDataAccessProps_1 = require("../RealityDataAccessProps");
19
- const RealityDataConnection_1 = require("../RealityDataConnection");
20
18
  const RealityDataSource_1 = require("../RealityDataSource");
21
19
  const internal_1 = require("./internal");
22
20
  function getUrl(content) {
@@ -194,12 +192,12 @@ var SMTextureType;
194
192
  })(SMTextureType || (SMTextureType = {}));
195
193
  /** @internal */
196
194
  class RealityModelTileTreeProps {
197
- constructor(json, root, client, tilesetToDbTransform, tilesetToEcef) {
195
+ constructor(json, root, rdSource, tilesetToDbTransform, tilesetToEcef) {
198
196
  this.tilesetToEcef = tilesetToEcef;
199
197
  this.doDrapeBackgroundMap = false;
200
198
  this.yAxisUp = false;
201
199
  this.tilesetJson = root;
202
- this.client = client;
200
+ this.rdSource = rdSource;
203
201
  this.location = tilesetToDbTransform;
204
202
  this.doDrapeBackgroundMap = (json.root && json.root.SMMasterHeader && SMTextureType.Streaming === json.root.SMMasterHeader.IsTextured);
205
203
  if (json.asset.gltfUpAxis === undefined || json.asset.gltfUpAxis === "y" || json.asset.gltfUpAxis === "Y")
@@ -207,12 +205,12 @@ class RealityModelTileTreeProps {
207
205
  }
208
206
  }
209
207
  class RealityModelTileTreeParams {
210
- constructor(url, iModel, modelId, loader, gcsConverterAvailable, rootToEcef) {
208
+ constructor(tileTreeId, iModel, modelId, loader, gcsConverterAvailable, rootToEcef) {
211
209
  this.gcsConverterAvailable = gcsConverterAvailable;
212
210
  this.rootToEcef = rootToEcef;
213
211
  this.is3d = true;
214
212
  this.loader = loader;
215
- this.id = url;
213
+ this.id = tileTreeId;
216
214
  this.modelId = modelId;
217
215
  this.iModel = iModel;
218
216
  this.rootTile = new RealityModelTileProps(loader.tree.tilesetJson, undefined, "", undefined, undefined === loader.tree.tilesetJson.refine ? undefined : loader.tree.tilesetJson.refine === "ADD");
@@ -292,10 +290,10 @@ function addUrlPrefix(subTree, prefix) {
292
290
  addUrlPrefix(child, prefix);
293
291
  }
294
292
  /** @internal */
295
- async function expandSubTree(root, client) {
293
+ async function expandSubTree(root, rdsource) {
296
294
  const childUrl = getUrl(root.content);
297
295
  if (undefined !== childUrl && childUrl.endsWith("json")) { // A child may contain a subTree...
298
- const subTree = await client.getTileJson(childUrl);
296
+ const subTree = await rdsource.getTileJson(childUrl);
299
297
  const prefixIndex = childUrl.lastIndexOf("/");
300
298
  if (prefixIndex > 0)
301
299
  addUrlPrefix(subTree.root, childUrl.substring(0, prefixIndex + 1));
@@ -358,7 +356,7 @@ class RealityModelTileLoader extends internal_1.RealityTileLoader {
358
356
  const foundChild = await this.findTileInJson(this.tree.tilesetJson, tile.contentId, "");
359
357
  if (undefined === foundChild || undefined === foundChild.json.content || isCanceled())
360
358
  return undefined;
361
- return this.tree.client.getTileContent(getUrl(foundChild.json.content));
359
+ return this.tree.rdSource.getTileContent(getUrl(foundChild.json.content));
362
360
  }
363
361
  async findTileInJson(tilesetJson, id, parentId, transformToRoot) {
364
362
  if (id.length === 0)
@@ -379,7 +377,7 @@ class RealityModelTileLoader extends internal_1.RealityTileLoader {
379
377
  if (separatorIndex >= 0) {
380
378
  return this.findTileInJson(foundChild, id.substring(separatorIndex + 1), thisParentId, transformToRoot);
381
379
  }
382
- tilesetJson.children[childIndex] = await expandSubTree(foundChild, this.tree.client);
380
+ tilesetJson.children[childIndex] = await expandSubTree(foundChild, this.tree.rdSource);
383
381
  return new FindChildResult(thisParentId, tilesetJson.children[childIndex], transformToRoot);
384
382
  }
385
383
  }
@@ -481,28 +479,25 @@ exports.RealityModelTileTree = RealityModelTileTree;
481
479
  }
482
480
  RealityModelTileTree.Reference = Reference;
483
481
  async function createRealityModelTileTree(rdSourceKey, iModel, modelId, tilesetToDb) {
484
- const rdConnection = await RealityDataConnection_1.RealityDataConnection.fromSourceKey(rdSourceKey, iModel.iTwinId);
482
+ const rdSource = await RealityDataSource_1.RealityDataSource.fromKey(rdSourceKey, iModel.iTwinId);
485
483
  // If we can get a valid connection from sourceKey, returns the tile tree
486
- if (rdConnection) {
487
- const url = await rdConnection.getServiceUrl(iModel.iTwinId);
488
- if (url === undefined)
484
+ if (rdSource) {
485
+ // Serialize the reality data source key into a string to uniquely identify this tile tree
486
+ const tileTreeId = RealityDataSource_1.RealityDataSource.keyToString(rdSource.key);
487
+ if (tileTreeId === undefined)
489
488
  return undefined;
490
- const props = await getTileTreeProps(rdConnection, tilesetToDb, iModel);
489
+ const props = await getTileTreeProps(rdSource, tilesetToDb, iModel);
491
490
  const loader = new RealityModelTileLoader(props, new internal_1.BatchedTileIdMap(iModel));
492
491
  const gcsConverterAvailable = await (0, internal_1.getGcsConverterAvailable)(iModel);
493
- const params = new RealityModelTileTreeParams(url, iModel, modelId, loader, gcsConverterAvailable, props.tilesetToEcef);
492
+ const params = new RealityModelTileTreeParams(tileTreeId, iModel, modelId, loader, gcsConverterAvailable, props.tilesetToEcef);
494
493
  return new RealityModelTileTree(params);
495
494
  }
496
495
  return undefined;
497
496
  }
498
497
  RealityModelTileTree.createRealityModelTileTree = createRealityModelTileTree;
499
- async function getTileTreeProps(rdConnection, tilesetToDbJson, iModel) {
498
+ async function getTileTreeProps(rdSource, tilesetToDbJson, iModel) {
500
499
  var _a, _b;
501
- const url = await rdConnection.getServiceUrl(iModel.iTwinId);
502
- if (!url)
503
- throw new core_common_1.IModelError(core_bentley_1.BentleyStatus.ERROR, "Unable to read reality data");
504
- const tileClient = new RealityModelTileClient(rdConnection, iModel.iTwinId);
505
- const json = await tileClient.getRootDocument(url);
500
+ const json = await rdSource.getRootDocument(iModel.iTwinId);
506
501
  let rootTransform = iModel.ecefLocation ? iModel.getMapEcefToDb(0) : core_geometry_1.Transform.createIdentity();
507
502
  const geoConverter = iModel.noGcsDefined ? undefined : iModel.geoServices.getConverter("WGS84");
508
503
  if (geoConverter !== undefined) {
@@ -544,8 +539,8 @@ exports.RealityModelTileTree = RealityModelTileTree;
544
539
  }
545
540
  if (undefined !== tilesetToDbJson)
546
541
  rootTransform = core_geometry_1.Transform.fromJSON(tilesetToDbJson).multiplyTransformTransform(rootTransform);
547
- const root = await expandSubTree(json.root, tileClient);
548
- return new RealityModelTileTreeProps(json, root, tileClient, rootTransform, tilesetToEcef);
542
+ const root = await expandSubTree(json.root, rdSource);
543
+ return new RealityModelTileTreeProps(json, root, rdSource, rootTransform, tilesetToEcef);
549
544
  }
550
545
  })(RealityModelTileTree = exports.RealityModelTileTree || (exports.RealityModelTileTree = {}));
551
546
  /** Supplies a reality data [[TileTree]] from a URL. May be associated with a persistent [[GeometricModelState]], or attached at run-time via a [[ContextRealityModelState]].
@@ -555,8 +550,8 @@ class RealityTreeReference extends RealityModelTileTree.Reference {
555
550
  constructor(props) {
556
551
  super(props);
557
552
  // Maybe we should throw if both props.rdSourceKey && props.url are undefined
558
- this._rdSourceKey = props.rdSourceKey ? props.rdSourceKey : props.url ? RealityDataSource_1.RealityDataSource.createRealityDataSourceKeyFromUrl(props.url, core_common_1.RealityDataProvider.ContextShare) :
559
- RealityDataSource_1.RealityDataSource.createRealityDataSourceKeyFromUrl("", core_common_1.RealityDataProvider.ContextShare);
553
+ this._rdSourceKey = props.rdSourceKey ? props.rdSourceKey : props.url ? RealityDataSource_1.RealityDataSource.createKeyFromUrl(props.url, core_common_1.RealityDataProvider.ContextShare) :
554
+ RealityDataSource_1.RealityDataSource.createKeyFromUrl("", core_common_1.RealityDataProvider.ContextShare);
560
555
  }
561
556
  get treeOwner() {
562
557
  const treeId = { rdSourceKey: this._rdSourceKey, transform: this._transform, modelId: this.modelId, maskModelIds: this.maskModelIds };
@@ -602,7 +597,7 @@ class RealityTreeReference extends RealityModelTileTree.Reference {
602
597
  return undefined;
603
598
  const strings = [];
604
599
  const loader = tree.loader;
605
- const type = await loader.tree.client.getRealityDataType();
600
+ const type = loader.tree.rdSource.realityDataType;
606
601
  // If a type is specified, display it
607
602
  if (type !== undefined) {
608
603
  // Case insensitive
@@ -622,7 +617,7 @@ class RealityTreeReference extends RealityModelTileTree.Reference {
622
617
  strings.push(`${IModelApp_1.IModelApp.localization.getLocalizedString("iModelJs:TooltipInfo.Name")} ${this._name}`);
623
618
  }
624
619
  else {
625
- const cesiumAsset = this._rdSourceKey.provider === core_common_1.RealityDataProvider.CesiumIonAsset ? parseCesiumUrl(this._rdSourceKey.id) : undefined;
620
+ const cesiumAsset = this._rdSourceKey.provider === core_common_1.RealityDataProvider.CesiumIonAsset ? internal_1.CesiumIonAssetProvider.parseCesiumUrl(this._rdSourceKey.id) : undefined;
626
621
  strings.push(cesiumAsset ? `Cesium Asset: ${cesiumAsset.id}` : this._rdSourceKey.id);
627
622
  }
628
623
  if (batch !== undefined)
@@ -639,192 +634,4 @@ class RealityTreeReference extends RealityModelTileTree.Reference {
639
634
  }
640
635
  }
641
636
  }
642
- // TBD - Allow an object to override the URL and provide its own authentication.
643
- function parseCesiumUrl(url) {
644
- const cesiumSuffix = "$CesiumIonAsset=";
645
- const cesiumIndex = url.indexOf(cesiumSuffix);
646
- if (cesiumIndex < 0)
647
- return undefined;
648
- const cesiumIonString = url.slice(cesiumIndex + cesiumSuffix.length);
649
- const cesiumParts = cesiumIonString.split(":");
650
- if (cesiumParts.length !== 2)
651
- return undefined;
652
- const id = parseInt(cesiumParts[0], 10);
653
- if (id === undefined)
654
- return undefined;
655
- return { id, key: cesiumParts[1] };
656
- }
657
- /**
658
- * ###TODO temporarily here for testing, needs to be moved to the clients repo
659
- * @internal
660
- * This class encapsulates access to a reality data wether it be from local access, http or RDS
661
- * The url provided at the creation is parsed to determine if this is a RDS (ProjectWise Context Share) reference.
662
- * If not then it is considered local (ex: C:\temp\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)
663
- * There is a one to one relationship between a reality data and the instances of present class.
664
- */
665
- class RealityModelTileClient {
666
- // ###TODO we should be able to pass the iTwinId / tileId directly, instead of parsing the url
667
- // But if the present can also be used by non PW Context Share stored data then the url is required and token is not. Possibly two classes inheriting from common interface.
668
- constructor(rdConnection, iTwinId) {
669
- this._baseUrl = ""; // For use by all Reality Data. For RD stored on PW Context Share, represents the portion from the root of the Azure Blob Container
670
- this._rdConnection = rdConnection;
671
- const rdSource = this._rdConnection.source;
672
- if (rdSource.isContextShare)
673
- this.rdsProps = this.getRDSClientPropsFromSource(rdSource); // Note that returned is undefined if url does not refer to a PW Context Share reality data.
674
- if (iTwinId && this.rdsProps)
675
- this.rdsProps.iTwinId = iTwinId;
676
- }
677
- initializeRDSRealityData() {
678
- var _a;
679
- if (undefined !== this.rdsProps) {
680
- if (!this._realityData) {
681
- this._realityData = this._rdConnection.realityData;
682
- if (!this._realityData)
683
- throw new core_common_1.IModelError(core_bentley_1.BentleyStatus.ERROR, "Unable to read reality data");
684
- // A reality data that has not root document set should not be considered.
685
- const rootDocument = (_a = this._realityData.rootDocument) !== null && _a !== void 0 ? _a : "";
686
- this.setBaseUrl(rootDocument);
687
- }
688
- }
689
- }
690
- // ###TODO temporary means of extracting the tileId and projectId from the given url
691
- // This is the method that determines if the url refers to Reality Data stored on PW Context Share. If not then undefined is returned.
692
- // ###TODO This method should be replaced by realityDataServiceClient.getRealityDataIdFromUrl()
693
- // We obtain the projectId from URL but it should be used normally. The iModel context should be used everywhere: verify!
694
- getRDSClientPropsFromSource(rdSource, iTwinIdFromApp) {
695
- // We have URLs with incorrect slashes that must be supported. The ~2F are WSG encoded slashes and may prevent parsing out the reality data id.
696
- const tilesId = rdSource.realityDataId;
697
- const iTwinIdFromSrc = rdSource.iTwinId;
698
- let props;
699
- if (undefined !== tilesId) {
700
- const iTwinId = iTwinIdFromSrc ? iTwinIdFromSrc : iTwinIdFromApp ? iTwinIdFromApp : "server";
701
- props = { iTwinId, tilesId };
702
- }
703
- return props;
704
- }
705
- // This is to set the root url from the provided root document path.
706
- // If the root document is stored on PW Context Share then the root document property of the Reality Data is provided,
707
- // otherwise the full path to root document is given.
708
- // The base URL contains the base URL from which tile relative path are constructed.
709
- // The tile's path root will need to be reinserted for child tiles to return a 200
710
- setBaseUrl(url) {
711
- const urlParts = url.split("/");
712
- urlParts.pop();
713
- if (urlParts.length === 0)
714
- this._baseUrl = "";
715
- else
716
- this._baseUrl = `${urlParts.join("/")}/`;
717
- }
718
- async _doRequest(url, responseType) {
719
- let options = {
720
- method: "GET",
721
- responseType,
722
- };
723
- const authToken = this._requestAuthorization;
724
- if (authToken) {
725
- options = {
726
- ...options,
727
- headers: {
728
- authorization: authToken,
729
- },
730
- };
731
- }
732
- const data = await (0, itwin_client_1.request)(url, options);
733
- return data.body;
734
- }
735
- /**
736
- * Gets a tileset's app data json
737
- * @param name name or path of tile
738
- * @returns app data json object
739
- * @internal
740
- */
741
- async getRealityDataTileJson(accessToken, name, realityData) {
742
- const url = await realityData.getBlobUrl(accessToken, name);
743
- const data = await (0, itwin_client_1.getJson)(url.toString());
744
- return data;
745
- }
746
- // ### TODO. Technically the url should not be required. If the reality data encapsulated is stored on PW Context Share then
747
- // the relative path to root document is extracted from the reality data. Otherwise the full url to root document should have been provided at
748
- // the construction of the instance.
749
- async getRootDocument(url) {
750
- const token = await IModelApp_1.IModelApp.getAccessToken();
751
- if (this.rdsProps && token) {
752
- this.initializeRDSRealityData(); // Only needed for PW Context Share data ... return immediately otherwise.
753
- const realityData = this._realityData;
754
- if (!realityData)
755
- throw new Error(`Reality Data not defined`);
756
- if (!realityData.rootDocument)
757
- throw new Error(`Root document not defined for reality data: ${realityData.id}`);
758
- return this.getRealityDataTileJson(token, realityData.rootDocument, realityData);
759
- }
760
- // The following is only if the reality data is not stored on PW Context Share.
761
- const cesiumAsset = parseCesiumUrl(url);
762
- if (cesiumAsset) {
763
- const tokenAndUrl = await (0, internal_1.getCesiumAccessTokenAndEndpointUrl)(cesiumAsset.id, cesiumAsset.key);
764
- if (tokenAndUrl.url && tokenAndUrl.token) {
765
- url = tokenAndUrl.url;
766
- this._requestAuthorization = `Bearer ${tokenAndUrl.token}`;
767
- }
768
- }
769
- // The following is only if the reality data is not stored on PW Context Share.
770
- this.setBaseUrl(url);
771
- return this._doRequest(url, "json");
772
- }
773
- /**
774
- * Gets tile content
775
- * @param name name or path of tile
776
- * @returns array buffer of tile content
777
- */
778
- async getRealityDataTileContent(accessToken, name, realityData) {
779
- const url = await realityData.getBlobUrl(accessToken, name);
780
- const options = {
781
- method: "GET",
782
- responseType: "arraybuffer",
783
- };
784
- const data = await (0, itwin_client_1.request)(url.toString(), options);
785
- return data.body;
786
- }
787
- /**
788
- * Returns the tile content. The path to the tile is relative to the base url of present reality data whatever the type.
789
- */
790
- async getTileContent(url) {
791
- (0, core_bentley_1.assert)(url !== undefined);
792
- const token = await IModelApp_1.IModelApp.getAccessToken();
793
- const useRds = this.rdsProps !== undefined && token !== undefined;
794
- if (useRds) {
795
- this.initializeRDSRealityData(); // Only needed for PW Context Share data ... return immediately otherwise.
796
- }
797
- const tileUrl = this._baseUrl + url;
798
- if (useRds && this._realityData)
799
- return this.getRealityDataTileContent(token, tileUrl, this._realityData);
800
- return this._doRequest(tileUrl, "arraybuffer");
801
- }
802
- /**
803
- * Returns the tile content in json format. The path to the tile is relative to the base url of present reality data whatever the type.
804
- */
805
- async getTileJson(url) {
806
- (0, core_bentley_1.assert)(url !== undefined);
807
- const token = await IModelApp_1.IModelApp.getAccessToken();
808
- if (this.rdsProps && token) {
809
- this.initializeRDSRealityData(); // Only needed for PW Context Share data ... return immediately otherwise.
810
- }
811
- const tileUrl = this._baseUrl + url;
812
- if (undefined !== this.rdsProps && undefined !== token && this._realityData)
813
- return this.getRealityDataTileJson(token, tileUrl, this._realityData);
814
- return this._doRequest(tileUrl, "json");
815
- }
816
- /**
817
- * Returns Reality Data type if available
818
- */
819
- async getRealityDataType() {
820
- const token = await IModelApp_1.IModelApp.getAccessToken();
821
- if (this.rdsProps && token) {
822
- this.initializeRDSRealityData(); // Only needed for PW Context Share data
823
- return this._realityData.type;
824
- }
825
- // The reality data type is not available if not stored on PW Context Share.
826
- return undefined;
827
- }
828
- }
829
- exports.RealityModelTileClient = RealityModelTileClient;
830
637
  //# sourceMappingURL=RealityModelTileTree.js.map