@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
@@ -5,17 +5,15 @@
5
5
  /** @packageDocumentation
6
6
  * @module Utils
7
7
  */
8
- import { getJson, request } from "@bentley/itwin-client";
9
- import { assert, BentleyStatus, compareNumbers, compareStringsOrUndefined, CompressedId64Set, } from "@itwin/core-bentley";
10
- import { Cartographic, GeoCoordStatus, IModelError, PlanarClipMaskPriority, RealityDataProvider, } from "@itwin/core-common";
8
+ import { assert, compareNumbers, compareStringsOrUndefined, CompressedId64Set, } from "@itwin/core-bentley";
9
+ import { Cartographic, GeoCoordStatus, PlanarClipMaskPriority, RealityDataProvider, } from "@itwin/core-common";
11
10
  import { Angle, Constant, Ellipsoid, Matrix3d, Point3d, Range3d, Ray3d, Transform, Vector3d } from "@itwin/core-geometry";
12
11
  import { calculateEcefToDbTransformAtLocation } from "../BackgroundMapGeometry";
13
12
  import { IModelApp } from "../IModelApp";
14
13
  import { PlanarClipMaskState } from "../PlanarClipMaskState";
15
14
  import { DefaultSupportedTypes } from "../RealityDataAccessProps";
16
- import { RealityDataConnection } from "../RealityDataConnection";
17
15
  import { RealityDataSource } from "../RealityDataSource";
18
- import { BatchedTileIdMap, createClassifierTileTreeReference, createDefaultViewFlagOverrides, getCesiumAccessTokenAndEndpointUrl, getCesiumOSMBuildingsUrl, getGcsConverterAvailable, RealityTileLoader, RealityTileTree, TileLoadPriority, TileTreeReference, } from "./internal";
16
+ import { BatchedTileIdMap, CesiumIonAssetProvider, createClassifierTileTreeReference, createDefaultViewFlagOverrides, getCesiumOSMBuildingsUrl, getGcsConverterAvailable, RealityTileLoader, RealityTileTree, TileLoadPriority, TileTreeReference, } from "./internal";
19
17
  function getUrl(content) {
20
18
  return content ? (content.url ? content.url : content.uri) : undefined;
21
19
  }
@@ -188,12 +186,12 @@ var SMTextureType;
188
186
  })(SMTextureType || (SMTextureType = {}));
189
187
  /** @internal */
190
188
  class RealityModelTileTreeProps {
191
- constructor(json, root, client, tilesetToDbTransform, tilesetToEcef) {
189
+ constructor(json, root, rdSource, tilesetToDbTransform, tilesetToEcef) {
192
190
  this.tilesetToEcef = tilesetToEcef;
193
191
  this.doDrapeBackgroundMap = false;
194
192
  this.yAxisUp = false;
195
193
  this.tilesetJson = root;
196
- this.client = client;
194
+ this.rdSource = rdSource;
197
195
  this.location = tilesetToDbTransform;
198
196
  this.doDrapeBackgroundMap = (json.root && json.root.SMMasterHeader && SMTextureType.Streaming === json.root.SMMasterHeader.IsTextured);
199
197
  if (json.asset.gltfUpAxis === undefined || json.asset.gltfUpAxis === "y" || json.asset.gltfUpAxis === "Y")
@@ -201,12 +199,12 @@ class RealityModelTileTreeProps {
201
199
  }
202
200
  }
203
201
  class RealityModelTileTreeParams {
204
- constructor(url, iModel, modelId, loader, gcsConverterAvailable, rootToEcef) {
202
+ constructor(tileTreeId, iModel, modelId, loader, gcsConverterAvailable, rootToEcef) {
205
203
  this.gcsConverterAvailable = gcsConverterAvailable;
206
204
  this.rootToEcef = rootToEcef;
207
205
  this.is3d = true;
208
206
  this.loader = loader;
209
- this.id = url;
207
+ this.id = tileTreeId;
210
208
  this.modelId = modelId;
211
209
  this.iModel = iModel;
212
210
  this.rootTile = new RealityModelTileProps(loader.tree.tilesetJson, undefined, "", undefined, undefined === loader.tree.tilesetJson.refine ? undefined : loader.tree.tilesetJson.refine === "ADD");
@@ -286,10 +284,10 @@ function addUrlPrefix(subTree, prefix) {
286
284
  addUrlPrefix(child, prefix);
287
285
  }
288
286
  /** @internal */
289
- async function expandSubTree(root, client) {
287
+ async function expandSubTree(root, rdsource) {
290
288
  const childUrl = getUrl(root.content);
291
289
  if (undefined !== childUrl && childUrl.endsWith("json")) { // A child may contain a subTree...
292
- const subTree = await client.getTileJson(childUrl);
290
+ const subTree = await rdsource.getTileJson(childUrl);
293
291
  const prefixIndex = childUrl.lastIndexOf("/");
294
292
  if (prefixIndex > 0)
295
293
  addUrlPrefix(subTree.root, childUrl.substring(0, prefixIndex + 1));
@@ -352,7 +350,7 @@ class RealityModelTileLoader extends RealityTileLoader {
352
350
  const foundChild = await this.findTileInJson(this.tree.tilesetJson, tile.contentId, "");
353
351
  if (undefined === foundChild || undefined === foundChild.json.content || isCanceled())
354
352
  return undefined;
355
- return this.tree.client.getTileContent(getUrl(foundChild.json.content));
353
+ return this.tree.rdSource.getTileContent(getUrl(foundChild.json.content));
356
354
  }
357
355
  async findTileInJson(tilesetJson, id, parentId, transformToRoot) {
358
356
  if (id.length === 0)
@@ -373,7 +371,7 @@ class RealityModelTileLoader extends RealityTileLoader {
373
371
  if (separatorIndex >= 0) {
374
372
  return this.findTileInJson(foundChild, id.substring(separatorIndex + 1), thisParentId, transformToRoot);
375
373
  }
376
- tilesetJson.children[childIndex] = await expandSubTree(foundChild, this.tree.client);
374
+ tilesetJson.children[childIndex] = await expandSubTree(foundChild, this.tree.rdSource);
377
375
  return new FindChildResult(thisParentId, tilesetJson.children[childIndex], transformToRoot);
378
376
  }
379
377
  }
@@ -474,28 +472,25 @@ export class RealityModelTileTree extends RealityTileTree {
474
472
  }
475
473
  RealityModelTileTree.Reference = Reference;
476
474
  async function createRealityModelTileTree(rdSourceKey, iModel, modelId, tilesetToDb) {
477
- const rdConnection = await RealityDataConnection.fromSourceKey(rdSourceKey, iModel.iTwinId);
475
+ const rdSource = await RealityDataSource.fromKey(rdSourceKey, iModel.iTwinId);
478
476
  // If we can get a valid connection from sourceKey, returns the tile tree
479
- if (rdConnection) {
480
- const url = await rdConnection.getServiceUrl(iModel.iTwinId);
481
- if (url === undefined)
477
+ if (rdSource) {
478
+ // Serialize the reality data source key into a string to uniquely identify this tile tree
479
+ const tileTreeId = RealityDataSource.keyToString(rdSource.key);
480
+ if (tileTreeId === undefined)
482
481
  return undefined;
483
- const props = await getTileTreeProps(rdConnection, tilesetToDb, iModel);
482
+ const props = await getTileTreeProps(rdSource, tilesetToDb, iModel);
484
483
  const loader = new RealityModelTileLoader(props, new BatchedTileIdMap(iModel));
485
484
  const gcsConverterAvailable = await getGcsConverterAvailable(iModel);
486
- const params = new RealityModelTileTreeParams(url, iModel, modelId, loader, gcsConverterAvailable, props.tilesetToEcef);
485
+ const params = new RealityModelTileTreeParams(tileTreeId, iModel, modelId, loader, gcsConverterAvailable, props.tilesetToEcef);
487
486
  return new RealityModelTileTree(params);
488
487
  }
489
488
  return undefined;
490
489
  }
491
490
  RealityModelTileTree.createRealityModelTileTree = createRealityModelTileTree;
492
- async function getTileTreeProps(rdConnection, tilesetToDbJson, iModel) {
491
+ async function getTileTreeProps(rdSource, tilesetToDbJson, iModel) {
493
492
  var _a, _b;
494
- const url = await rdConnection.getServiceUrl(iModel.iTwinId);
495
- if (!url)
496
- throw new IModelError(BentleyStatus.ERROR, "Unable to read reality data");
497
- const tileClient = new RealityModelTileClient(rdConnection, iModel.iTwinId);
498
- const json = await tileClient.getRootDocument(url);
493
+ const json = await rdSource.getRootDocument(iModel.iTwinId);
499
494
  let rootTransform = iModel.ecefLocation ? iModel.getMapEcefToDb(0) : Transform.createIdentity();
500
495
  const geoConverter = iModel.noGcsDefined ? undefined : iModel.geoServices.getConverter("WGS84");
501
496
  if (geoConverter !== undefined) {
@@ -537,8 +532,8 @@ export class RealityModelTileTree extends RealityTileTree {
537
532
  }
538
533
  if (undefined !== tilesetToDbJson)
539
534
  rootTransform = Transform.fromJSON(tilesetToDbJson).multiplyTransformTransform(rootTransform);
540
- const root = await expandSubTree(json.root, tileClient);
541
- return new RealityModelTileTreeProps(json, root, tileClient, rootTransform, tilesetToEcef);
535
+ const root = await expandSubTree(json.root, rdSource);
536
+ return new RealityModelTileTreeProps(json, root, rdSource, rootTransform, tilesetToEcef);
542
537
  }
543
538
  })(RealityModelTileTree || (RealityModelTileTree = {}));
544
539
  /** Supplies a reality data [[TileTree]] from a URL. May be associated with a persistent [[GeometricModelState]], or attached at run-time via a [[ContextRealityModelState]].
@@ -548,8 +543,8 @@ class RealityTreeReference extends RealityModelTileTree.Reference {
548
543
  constructor(props) {
549
544
  super(props);
550
545
  // Maybe we should throw if both props.rdSourceKey && props.url are undefined
551
- this._rdSourceKey = props.rdSourceKey ? props.rdSourceKey : props.url ? RealityDataSource.createRealityDataSourceKeyFromUrl(props.url, RealityDataProvider.ContextShare) :
552
- RealityDataSource.createRealityDataSourceKeyFromUrl("", RealityDataProvider.ContextShare);
546
+ this._rdSourceKey = props.rdSourceKey ? props.rdSourceKey : props.url ? RealityDataSource.createKeyFromUrl(props.url, RealityDataProvider.ContextShare) :
547
+ RealityDataSource.createKeyFromUrl("", RealityDataProvider.ContextShare);
553
548
  }
554
549
  get treeOwner() {
555
550
  const treeId = { rdSourceKey: this._rdSourceKey, transform: this._transform, modelId: this.modelId, maskModelIds: this.maskModelIds };
@@ -595,7 +590,7 @@ class RealityTreeReference extends RealityModelTileTree.Reference {
595
590
  return undefined;
596
591
  const strings = [];
597
592
  const loader = tree.loader;
598
- const type = await loader.tree.client.getRealityDataType();
593
+ const type = loader.tree.rdSource.realityDataType;
599
594
  // If a type is specified, display it
600
595
  if (type !== undefined) {
601
596
  // Case insensitive
@@ -615,7 +610,7 @@ class RealityTreeReference extends RealityModelTileTree.Reference {
615
610
  strings.push(`${IModelApp.localization.getLocalizedString("iModelJs:TooltipInfo.Name")} ${this._name}`);
616
611
  }
617
612
  else {
618
- const cesiumAsset = this._rdSourceKey.provider === RealityDataProvider.CesiumIonAsset ? parseCesiumUrl(this._rdSourceKey.id) : undefined;
613
+ const cesiumAsset = this._rdSourceKey.provider === RealityDataProvider.CesiumIonAsset ? CesiumIonAssetProvider.parseCesiumUrl(this._rdSourceKey.id) : undefined;
619
614
  strings.push(cesiumAsset ? `Cesium Asset: ${cesiumAsset.id}` : this._rdSourceKey.id);
620
615
  }
621
616
  if (batch !== undefined)
@@ -632,191 +627,4 @@ class RealityTreeReference extends RealityModelTileTree.Reference {
632
627
  }
633
628
  }
634
629
  }
635
- // TBD - Allow an object to override the URL and provide its own authentication.
636
- function parseCesiumUrl(url) {
637
- const cesiumSuffix = "$CesiumIonAsset=";
638
- const cesiumIndex = url.indexOf(cesiumSuffix);
639
- if (cesiumIndex < 0)
640
- return undefined;
641
- const cesiumIonString = url.slice(cesiumIndex + cesiumSuffix.length);
642
- const cesiumParts = cesiumIonString.split(":");
643
- if (cesiumParts.length !== 2)
644
- return undefined;
645
- const id = parseInt(cesiumParts[0], 10);
646
- if (id === undefined)
647
- return undefined;
648
- return { id, key: cesiumParts[1] };
649
- }
650
- /**
651
- * ###TODO temporarily here for testing, needs to be moved to the clients repo
652
- * @internal
653
- * This class encapsulates access to a reality data wether it be from local access, http or RDS
654
- * The url provided at the creation is parsed to determine if this is a RDS (ProjectWise Context Share) reference.
655
- * If not then it is considered local (ex: C:\temp\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)
656
- * There is a one to one relationship between a reality data and the instances of present class.
657
- */
658
- export class RealityModelTileClient {
659
- // ###TODO we should be able to pass the iTwinId / tileId directly, instead of parsing the url
660
- // 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.
661
- constructor(rdConnection, iTwinId) {
662
- 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
663
- this._rdConnection = rdConnection;
664
- const rdSource = this._rdConnection.source;
665
- if (rdSource.isContextShare)
666
- this.rdsProps = this.getRDSClientPropsFromSource(rdSource); // Note that returned is undefined if url does not refer to a PW Context Share reality data.
667
- if (iTwinId && this.rdsProps)
668
- this.rdsProps.iTwinId = iTwinId;
669
- }
670
- initializeRDSRealityData() {
671
- var _a;
672
- if (undefined !== this.rdsProps) {
673
- if (!this._realityData) {
674
- this._realityData = this._rdConnection.realityData;
675
- if (!this._realityData)
676
- throw new IModelError(BentleyStatus.ERROR, "Unable to read reality data");
677
- // A reality data that has not root document set should not be considered.
678
- const rootDocument = (_a = this._realityData.rootDocument) !== null && _a !== void 0 ? _a : "";
679
- this.setBaseUrl(rootDocument);
680
- }
681
- }
682
- }
683
- // ###TODO temporary means of extracting the tileId and projectId from the given url
684
- // This is the method that determines if the url refers to Reality Data stored on PW Context Share. If not then undefined is returned.
685
- // ###TODO This method should be replaced by realityDataServiceClient.getRealityDataIdFromUrl()
686
- // We obtain the projectId from URL but it should be used normally. The iModel context should be used everywhere: verify!
687
- getRDSClientPropsFromSource(rdSource, iTwinIdFromApp) {
688
- // 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.
689
- const tilesId = rdSource.realityDataId;
690
- const iTwinIdFromSrc = rdSource.iTwinId;
691
- let props;
692
- if (undefined !== tilesId) {
693
- const iTwinId = iTwinIdFromSrc ? iTwinIdFromSrc : iTwinIdFromApp ? iTwinIdFromApp : "server";
694
- props = { iTwinId, tilesId };
695
- }
696
- return props;
697
- }
698
- // This is to set the root url from the provided root document path.
699
- // If the root document is stored on PW Context Share then the root document property of the Reality Data is provided,
700
- // otherwise the full path to root document is given.
701
- // The base URL contains the base URL from which tile relative path are constructed.
702
- // The tile's path root will need to be reinserted for child tiles to return a 200
703
- setBaseUrl(url) {
704
- const urlParts = url.split("/");
705
- urlParts.pop();
706
- if (urlParts.length === 0)
707
- this._baseUrl = "";
708
- else
709
- this._baseUrl = `${urlParts.join("/")}/`;
710
- }
711
- async _doRequest(url, responseType) {
712
- let options = {
713
- method: "GET",
714
- responseType,
715
- };
716
- const authToken = this._requestAuthorization;
717
- if (authToken) {
718
- options = {
719
- ...options,
720
- headers: {
721
- authorization: authToken,
722
- },
723
- };
724
- }
725
- const data = await request(url, options);
726
- return data.body;
727
- }
728
- /**
729
- * Gets a tileset's app data json
730
- * @param name name or path of tile
731
- * @returns app data json object
732
- * @internal
733
- */
734
- async getRealityDataTileJson(accessToken, name, realityData) {
735
- const url = await realityData.getBlobUrl(accessToken, name);
736
- const data = await getJson(url.toString());
737
- return data;
738
- }
739
- // ### TODO. Technically the url should not be required. If the reality data encapsulated is stored on PW Context Share then
740
- // the relative path to root document is extracted from the reality data. Otherwise the full url to root document should have been provided at
741
- // the construction of the instance.
742
- async getRootDocument(url) {
743
- const token = await IModelApp.getAccessToken();
744
- if (this.rdsProps && token) {
745
- this.initializeRDSRealityData(); // Only needed for PW Context Share data ... return immediately otherwise.
746
- const realityData = this._realityData;
747
- if (!realityData)
748
- throw new Error(`Reality Data not defined`);
749
- if (!realityData.rootDocument)
750
- throw new Error(`Root document not defined for reality data: ${realityData.id}`);
751
- return this.getRealityDataTileJson(token, realityData.rootDocument, realityData);
752
- }
753
- // The following is only if the reality data is not stored on PW Context Share.
754
- const cesiumAsset = parseCesiumUrl(url);
755
- if (cesiumAsset) {
756
- const tokenAndUrl = await getCesiumAccessTokenAndEndpointUrl(cesiumAsset.id, cesiumAsset.key);
757
- if (tokenAndUrl.url && tokenAndUrl.token) {
758
- url = tokenAndUrl.url;
759
- this._requestAuthorization = `Bearer ${tokenAndUrl.token}`;
760
- }
761
- }
762
- // The following is only if the reality data is not stored on PW Context Share.
763
- this.setBaseUrl(url);
764
- return this._doRequest(url, "json");
765
- }
766
- /**
767
- * Gets tile content
768
- * @param name name or path of tile
769
- * @returns array buffer of tile content
770
- */
771
- async getRealityDataTileContent(accessToken, name, realityData) {
772
- const url = await realityData.getBlobUrl(accessToken, name);
773
- const options = {
774
- method: "GET",
775
- responseType: "arraybuffer",
776
- };
777
- const data = await request(url.toString(), options);
778
- return data.body;
779
- }
780
- /**
781
- * Returns the tile content. The path to the tile is relative to the base url of present reality data whatever the type.
782
- */
783
- async getTileContent(url) {
784
- assert(url !== undefined);
785
- const token = await IModelApp.getAccessToken();
786
- const useRds = this.rdsProps !== undefined && token !== undefined;
787
- if (useRds) {
788
- this.initializeRDSRealityData(); // Only needed for PW Context Share data ... return immediately otherwise.
789
- }
790
- const tileUrl = this._baseUrl + url;
791
- if (useRds && this._realityData)
792
- return this.getRealityDataTileContent(token, tileUrl, this._realityData);
793
- return this._doRequest(tileUrl, "arraybuffer");
794
- }
795
- /**
796
- * 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.
797
- */
798
- async getTileJson(url) {
799
- assert(url !== undefined);
800
- const token = await IModelApp.getAccessToken();
801
- if (this.rdsProps && token) {
802
- this.initializeRDSRealityData(); // Only needed for PW Context Share data ... return immediately otherwise.
803
- }
804
- const tileUrl = this._baseUrl + url;
805
- if (undefined !== this.rdsProps && undefined !== token && this._realityData)
806
- return this.getRealityDataTileJson(token, tileUrl, this._realityData);
807
- return this._doRequest(tileUrl, "json");
808
- }
809
- /**
810
- * Returns Reality Data type if available
811
- */
812
- async getRealityDataType() {
813
- const token = await IModelApp.getAccessToken();
814
- if (this.rdsProps && token) {
815
- this.initializeRDSRealityData(); // Only needed for PW Context Share data
816
- return this._realityData.type;
817
- }
818
- // The reality data type is not available if not stored on PW Context Share.
819
- return undefined;
820
- }
821
- }
822
630
  //# sourceMappingURL=RealityModelTileTree.js.map