@itwin/frontend-tiles 3.7.0-dev.6 → 3.7.0-dev.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  {
2
- "nonCachedDurationMs": 18308.03290003538
2
+ "nonCachedDurationMs": 19511.942399978638
3
3
  }
@@ -4,15 +4,15 @@
4
4
  "extensions/frontend-tiles/LICENSE.md": "77dfb5043040cc16a3611930daba56d86ef54334",
5
5
  "extensions/frontend-tiles/README.md": "4ea38e83e862cdfa6fab08adc92eb62bcb2fe238",
6
6
  "extensions/frontend-tiles/config/rush-project.json": "10683a57d3bd2b8ae364fbe8f844c01619f1a821",
7
- "extensions/frontend-tiles/package.json": "a824dc1f48483b2d57e4505147140e84857da0b4",
8
- "extensions/frontend-tiles/src/BatchedSpatialTileTreeRefs.ts": "6e3311dba4539560b7585d640676d98f0c33912a",
7
+ "extensions/frontend-tiles/package.json": "7216343e4afe61f33eb3896923035a6ca0b14c1a",
8
+ "extensions/frontend-tiles/src/BatchedSpatialTileTreeRefs.ts": "7c696e9b315d871bc22bbbf84f66419dc6c65d10",
9
9
  "extensions/frontend-tiles/src/BatchedTile.ts": "b67686d0bcea3a6a1a9c563a1574d82e546ee9fa",
10
10
  "extensions/frontend-tiles/src/BatchedTileContentReader.ts": "7a1392a3e55882eedd68f0fb098db9009f190a3e",
11
11
  "extensions/frontend-tiles/src/BatchedTileTree.ts": "bc27ba7b54de36cfe58ce3ecd62c7795569d3509",
12
12
  "extensions/frontend-tiles/src/BatchedTileTreeReference.ts": "0c57e84a7d361ef6d81c1c7c419e9f5891683843",
13
13
  "extensions/frontend-tiles/src/BatchedTileTreeSupplier.ts": "916587d978864b4f9595b560ee1bac3033a123f5",
14
14
  "extensions/frontend-tiles/src/BatchedTilesetReader.ts": "0cc90a58fc8f4cafab8c2bbdac6dc1186337b4f0",
15
- "extensions/frontend-tiles/src/FrontendTiles.ts": "441dade9ada6338bf2e4db805b2af944f8f17a36",
15
+ "extensions/frontend-tiles/src/FrontendTiles.ts": "e274242958517a7819433778c33f756fda03ccba",
16
16
  "extensions/frontend-tiles/src/LoggerCategory.ts": "458e67157ea150f6bff37674320dfc8cf5886049",
17
17
  "extensions/frontend-tiles/src/frontend-tiles.ts": "2778da0ad9afc43273e7105641ef1213edc47a83",
18
18
  "extensions/frontend-tiles/tsconfig.json": "67be9deac4eea3b76c3e1a66b0e9004ed0f6255e"
@@ -1,4 +1,5 @@
1
- import { IModelConnection, SpatialTileTreeReferences, SpatialViewState } from "@itwin/core-frontend";
1
+ import { SpatialTileTreeReferences, SpatialViewState } from "@itwin/core-frontend";
2
+ import { ComputeSpatialTilesetBaseUrl } from "./FrontendTiles";
2
3
  /** @internal */
3
- export declare function createBatchedSpatialTileTreeReferences(view: SpatialViewState, computeBaseUrl: (iModel: IModelConnection) => URL): SpatialTileTreeReferences;
4
+ export declare function createBatchedSpatialTileTreeReferences(view: SpatialViewState, computeBaseUrl: ComputeSpatialTilesetBaseUrl): SpatialTileTreeReferences;
4
5
  //# sourceMappingURL=BatchedSpatialTileTreeRefs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BatchedSpatialTileTreeRefs.d.ts","sourceRoot":"","sources":["../../src/BatchedSpatialTileTreeRefs.ts"],"names":[],"mappings":"AAKA,OAAO,EACiB,gBAAgB,EAAE,yBAAyB,EAAE,gBAAgB,EACpF,MAAM,sBAAsB,CAAC;AA+B9B,gBAAgB;AAChB,wBAAgB,sCAAsC,CAAC,IAAI,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,GAAG,GAAG,yBAAyB,CAG3J"}
1
+ {"version":3,"file":"BatchedSpatialTileTreeRefs.d.ts","sourceRoot":"","sources":["../../src/BatchedSpatialTileTreeRefs.ts"],"names":[],"mappings":"AAKA,OAAO,EACmC,yBAAyB,EAAE,gBAAgB,EACpF,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,4BAA4B,EAA2C,MAAM,iBAAiB,CAAC;AAyHxG,gBAAgB;AAChB,wBAAgB,sCAAsC,CAAC,IAAI,EAAE,gBAAgB,EAAE,cAAc,EAAE,4BAA4B,GAAG,yBAAyB,CA0BtJ"}
@@ -5,8 +5,11 @@
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.createBatchedSpatialTileTreeReferences = void 0;
8
+ const core_frontend_1 = require("@itwin/core-frontend");
8
9
  const BatchedTileTreeReference_1 = require("./BatchedTileTreeReference");
9
- class TreeRefs {
10
+ const FrontendTiles_1 = require("./FrontendTiles");
11
+ // Obtains tiles pre-published by mesh export service.
12
+ class BatchedSpatialTileTreeReferences {
10
13
  constructor(treeRef) {
11
14
  this._treeRef = treeRef;
12
15
  }
@@ -26,10 +29,102 @@ class TreeRefs {
26
29
  // This exists chiefly for debugging. Unimplemented here.
27
30
  }
28
31
  }
32
+ // A placeholder used by [[ProxySpatialTileTreeReferences]] until asynchronous loading completes.
33
+ // It provides a TileTreeOwner that never loads a tile tree.
34
+ // This ensures that [ViewState.areAllTileTreesLoaded]($frontend) will not return `true` while we are loading.
35
+ class ProxyTileTreeReference extends core_frontend_1.TileTreeReference {
36
+ constructor(iModel) {
37
+ super();
38
+ this._treeOwner = {
39
+ iModel,
40
+ tileTree: undefined,
41
+ loadStatus: core_frontend_1.TileTreeLoadStatus.NotLoaded,
42
+ load: () => undefined,
43
+ dispose: () => { },
44
+ loadTree: async () => Promise.resolve(undefined),
45
+ };
46
+ }
47
+ get treeOwner() {
48
+ return this._treeOwner;
49
+ }
50
+ // eslint-disable-next-line @typescript-eslint/naming-convention
51
+ get _isLoadingComplete() {
52
+ return false;
53
+ }
54
+ }
55
+ // Serves as a placeholder while we asynchronously obtain the base URL for a pre-published tileset (or asynchronously determine
56
+ // that no such tileset exists).
57
+ class ProxySpatialTileTreeReferences {
58
+ constructor(view, getBaseUrl) {
59
+ this._proxyRef = new ProxyTileTreeReference(view.iModel);
60
+ getBaseUrl.then((url) => {
61
+ if (url) {
62
+ const ref = BatchedTileTreeReference_1.BatchedTileTreeReference.create(view, url);
63
+ this.setTreeRefs(new BatchedSpatialTileTreeReferences(ref));
64
+ }
65
+ else {
66
+ this.setTreeRefs((0, FrontendTiles_1.createFallbackSpatialTileTreeReferences)(view));
67
+ }
68
+ }).catch(() => {
69
+ this.setTreeRefs((0, FrontendTiles_1.createFallbackSpatialTileTreeReferences)(view));
70
+ });
71
+ }
72
+ setTreeRefs(refs) {
73
+ this._impl = refs;
74
+ if (this._attachArgs) {
75
+ this._impl.attachToViewport(this._attachArgs);
76
+ this._attachArgs.invalidateSymbologyOverrides();
77
+ this._attachArgs = undefined;
78
+ }
79
+ }
80
+ update() {
81
+ var _a;
82
+ (_a = this._impl) === null || _a === void 0 ? void 0 : _a.update();
83
+ }
84
+ attachToViewport(args) {
85
+ if (this._impl)
86
+ this._impl.attachToViewport(args);
87
+ else
88
+ this._attachArgs = args;
89
+ }
90
+ detachFromViewport() {
91
+ if (this._impl)
92
+ this._impl.detachFromViewport();
93
+ else
94
+ this._attachArgs = undefined;
95
+ }
96
+ setDeactivated() { }
97
+ *[Symbol.iterator]() {
98
+ if (this._impl)
99
+ return this._impl[Symbol.iterator]();
100
+ yield this._proxyRef;
101
+ }
102
+ }
103
+ const iModelToBaseUrl = new Map();
29
104
  /** @internal */
30
105
  function createBatchedSpatialTileTreeReferences(view, computeBaseUrl) {
31
- const treeRef = BatchedTileTreeReference_1.BatchedTileTreeReference.create(view, computeBaseUrl(view.iModel));
32
- return new TreeRefs(treeRef);
106
+ const iModel = view.iModel;
107
+ let entry = iModelToBaseUrl.get(iModel);
108
+ if (undefined === entry) {
109
+ const promise = computeBaseUrl(iModel);
110
+ iModelToBaseUrl.set(iModel, entry = promise);
111
+ iModel.onClose.addOnce(() => iModelToBaseUrl.delete(iModel));
112
+ promise.then((url) => {
113
+ if (iModelToBaseUrl.has(iModel))
114
+ iModelToBaseUrl.set(iModel, url !== null && url !== void 0 ? url : null);
115
+ }).catch(() => {
116
+ if (iModelToBaseUrl.has(iModel))
117
+ iModelToBaseUrl.set(iModel, null);
118
+ });
119
+ }
120
+ if (null === entry) {
121
+ // No tileset exists for this iModel - use default tile generation instead.
122
+ return (0, FrontendTiles_1.createFallbackSpatialTileTreeReferences)(view);
123
+ }
124
+ if (entry instanceof Promise)
125
+ return new ProxySpatialTileTreeReferences(view, entry);
126
+ const ref = BatchedTileTreeReference_1.BatchedTileTreeReference.create(view, entry);
127
+ return new BatchedSpatialTileTreeReferences(ref);
33
128
  }
34
129
  exports.createBatchedSpatialTileTreeReferences = createBatchedSpatialTileTreeReferences;
35
130
  //# sourceMappingURL=BatchedSpatialTileTreeRefs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BatchedSpatialTileTreeRefs.js","sourceRoot":"","sources":["../../src/BatchedSpatialTileTreeRefs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAK/F,yEAAsE;AAEtE,MAAM,QAAQ;IAGZ,YAAmB,OAAiC;QAClD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAEM,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvB,MAAM,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAEM,MAAM;QACX,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IACrC,CAAC;IAEM,gBAAgB,CAAC,IAA0B;QAChD,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAEM,kBAAkB;QACvB,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IACrC,CAAC;IAEM,cAAc;QACnB,yDAAyD;IAC3D,CAAC;CACF;AAED,gBAAgB;AAChB,SAAgB,sCAAsC,CAAC,IAAsB,EAAE,cAAiD;IAC9H,MAAM,OAAO,GAAG,mDAAwB,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACnF,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAHD,wFAGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport {\r\n AttachToViewportArgs, IModelConnection, SpatialTileTreeReferences, SpatialViewState, TileTreeReference,\r\n} from \"@itwin/core-frontend\";\r\nimport { BatchedTileTreeReference } from \"./BatchedTileTreeReference\";\r\n\r\nclass TreeRefs implements SpatialTileTreeReferences {\r\n private readonly _treeRef: BatchedTileTreeReference;\r\n\r\n public constructor(treeRef: BatchedTileTreeReference) {\r\n this._treeRef = treeRef;\r\n }\r\n\r\n public *[Symbol.iterator](): Iterator<TileTreeReference> {\r\n yield this._treeRef;\r\n }\r\n\r\n public update(): void {\r\n this._treeRef.updateViewedModels();\r\n }\r\n\r\n public attachToViewport(args: AttachToViewportArgs): void {\r\n this._treeRef.attachToViewport(args);\r\n }\r\n\r\n public detachFromViewport(): void {\r\n this._treeRef.detachFromViewport();\r\n }\r\n\r\n public setDeactivated(): void {\r\n // This exists chiefly for debugging. Unimplemented here.\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function createBatchedSpatialTileTreeReferences(view: SpatialViewState, computeBaseUrl: (iModel: IModelConnection) => URL): SpatialTileTreeReferences {\r\n const treeRef = BatchedTileTreeReference.create(view, computeBaseUrl(view.iModel));\r\n return new TreeRefs(treeRef);\r\n}\r\n"]}
1
+ {"version":3,"file":"BatchedSpatialTileTreeRefs.js","sourceRoot":"","sources":["../../src/BatchedSpatialTileTreeRefs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAE8B;AAC9B,yEAAsE;AACtE,mDAAwG;AAExG,sDAAsD;AACtD,MAAM,gCAAgC;IAGpC,YAAmB,OAA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GAAG,GAAG,mDAAwB,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzD,OAAO,IAAI,gCAAgC,CAAC,GAAG,CAAC,CAAC;AACnD,CAAC;AA1BD,wFA0BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport {\r\n AttachToViewportArgs, IModelConnection, SpatialTileTreeReferences, SpatialViewState, TileTreeLoadStatus, TileTreeOwner, TileTreeReference,\r\n} from \"@itwin/core-frontend\";\r\nimport { BatchedTileTreeReference } from \"./BatchedTileTreeReference\";\r\nimport { ComputeSpatialTilesetBaseUrl, createFallbackSpatialTileTreeReferences } from \"./FrontendTiles\";\r\n\r\n// Obtains tiles pre-published by mesh export service.\r\nclass BatchedSpatialTileTreeReferences implements SpatialTileTreeReferences {\r\n private readonly _treeRef: BatchedTileTreeReference;\r\n\r\n public constructor(treeRef: BatchedTileTreeReference) {\r\n this._treeRef = treeRef;\r\n }\r\n\r\n public *[Symbol.iterator](): Iterator<TileTreeReference> {\r\n yield this._treeRef;\r\n }\r\n\r\n public update(): void {\r\n this._treeRef.updateViewedModels();\r\n }\r\n\r\n public attachToViewport(args: AttachToViewportArgs): void {\r\n this._treeRef.attachToViewport(args);\r\n }\r\n\r\n public detachFromViewport(): void {\r\n this._treeRef.detachFromViewport();\r\n }\r\n\r\n public setDeactivated(): void {\r\n // This exists chiefly for debugging. Unimplemented here.\r\n }\r\n}\r\n\r\n// A placeholder used by [[ProxySpatialTileTreeReferences]] until asynchronous loading completes.\r\n// It provides a TileTreeOwner that never loads a tile tree.\r\n// This ensures that [ViewState.areAllTileTreesLoaded]($frontend) will not return `true` while we are loading.\r\nclass ProxyTileTreeReference extends TileTreeReference {\r\n private readonly _treeOwner: TileTreeOwner;\r\n\r\n public constructor(iModel: IModelConnection) {\r\n super();\r\n this._treeOwner = {\r\n iModel,\r\n tileTree: undefined,\r\n loadStatus: TileTreeLoadStatus.NotLoaded,\r\n load: () => undefined,\r\n dispose: () => { },\r\n loadTree: async () => Promise.resolve(undefined),\r\n };\r\n }\r\n\r\n public override get treeOwner() {\r\n return this._treeOwner;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public override get _isLoadingComplete() {\r\n return false;\r\n }\r\n}\r\n\r\n// Serves as a placeholder while we asynchronously obtain the base URL for a pre-published tileset (or asynchronously determine\r\n// that no such tileset exists).\r\nclass ProxySpatialTileTreeReferences implements SpatialTileTreeReferences {\r\n // Once async loading completes, all methods will be forwarded to this implementation.\r\n private _impl?: SpatialTileTreeReferences;\r\n private readonly _proxyRef: ProxyTileTreeReference;\r\n // Retained if attachToViewport is called while we are still loading; and reset if detachFromViewport is called while loading.\r\n private _attachArgs?: AttachToViewportArgs;\r\n\r\n public constructor(view: SpatialViewState, getBaseUrl: Promise<URL | undefined>) {\r\n this._proxyRef = new ProxyTileTreeReference(view.iModel);\r\n getBaseUrl.then((url: URL | undefined) => {\r\n if (url) {\r\n const ref = BatchedTileTreeReference.create(view, url);\r\n this.setTreeRefs(new BatchedSpatialTileTreeReferences(ref));\r\n } else {\r\n this.setTreeRefs(createFallbackSpatialTileTreeReferences(view));\r\n }\r\n }).catch(() => {\r\n this.setTreeRefs(createFallbackSpatialTileTreeReferences(view));\r\n });\r\n }\r\n\r\n private setTreeRefs(refs: SpatialTileTreeReferences): void {\r\n this._impl = refs;\r\n if (this._attachArgs) {\r\n this._impl.attachToViewport(this._attachArgs);\r\n this._attachArgs.invalidateSymbologyOverrides();\r\n this._attachArgs = undefined;\r\n }\r\n }\r\n\r\n public update(): void {\r\n this._impl?.update();\r\n }\r\n\r\n public attachToViewport(args: AttachToViewportArgs): void {\r\n if (this._impl)\r\n this._impl.attachToViewport(args);\r\n else\r\n this._attachArgs = args;\r\n }\r\n\r\n public detachFromViewport(): void {\r\n if (this._impl)\r\n this._impl.detachFromViewport();\r\n else\r\n this._attachArgs = undefined;\r\n }\r\n\r\n public setDeactivated(): void { }\r\n\r\n public *[Symbol.iterator](): Iterator<TileTreeReference> {\r\n if (this._impl)\r\n return this._impl[Symbol.iterator]();\r\n\r\n yield this._proxyRef;\r\n }\r\n}\r\n\r\nconst iModelToBaseUrl = new Map<IModelConnection, URL | null | Promise<URL | undefined>>();\r\n\r\n/** @internal */\r\nexport function createBatchedSpatialTileTreeReferences(view: SpatialViewState, computeBaseUrl: ComputeSpatialTilesetBaseUrl): SpatialTileTreeReferences {\r\n const iModel = view.iModel;\r\n let entry = iModelToBaseUrl.get(iModel);\r\n if (undefined === entry) {\r\n const promise = computeBaseUrl(iModel);\r\n iModelToBaseUrl.set(iModel, entry = promise);\r\n iModel.onClose.addOnce(() => iModelToBaseUrl.delete(iModel));\r\n promise.then((url: URL | undefined) => {\r\n if (iModelToBaseUrl.has(iModel))\r\n iModelToBaseUrl.set(iModel, url ?? null);\r\n }).catch(() => {\r\n if (iModelToBaseUrl.has(iModel))\r\n iModelToBaseUrl.set(iModel, null);\r\n });\r\n }\r\n\r\n if (null === entry) {\r\n // No tileset exists for this iModel - use default tile generation instead.\r\n return createFallbackSpatialTileTreeReferences(view);\r\n }\r\n\r\n if (entry instanceof Promise)\r\n return new ProxySpatialTileTreeReferences(view, entry);\r\n\r\n const ref = BatchedTileTreeReference.create(view, entry);\r\n return new BatchedSpatialTileTreeReferences(ref);\r\n}\r\n"]}
@@ -1,13 +1,20 @@
1
- import { IModelConnection } from "@itwin/core-frontend";
1
+ import { IModelConnection, SpatialTileTreeReferences } from "@itwin/core-frontend";
2
+ /** A function that can provide the base URL where a tileset representing all of the spatial models in a given iModel are stored.
3
+ * The tileset is expected to reside at "baseUrl/tileset.json" and to have been produced by the [mesh export service](https://developer.bentley.com/apis/mesh-export/).
4
+ * If no such tileset exists for the given iModel, return `undefined`.
5
+ * @see [[FrontendTilesOptions.computeSpatialTilesetBaseUrl]].
6
+ * @alpha
7
+ */
8
+ export declare type ComputeSpatialTilesetBaseUrl = (iModel: IModelConnection) => Promise<URL | undefined>;
2
9
  /** Options supplied to [[initializeFrontendTiles]].
3
10
  * @alpha
4
11
  */
5
12
  export interface FrontendTilesOptions {
6
- /** Given an iModel, provide the base URL where the tiles are stored representing all of the spatial models in the iModel.
7
- * It is expected that baseUrl/tileset.json exists and contains a 3d tileset in which all relative URLs are relative to baseUrl.
8
- */
9
- computeSpatialTilesetBaseUrl: (iModel: IModelConnection) => URL;
13
+ /** Provide the base URL for the pre-published tileset for a given iModel. */
14
+ computeSpatialTilesetBaseUrl: ComputeSpatialTilesetBaseUrl;
10
15
  }
16
+ /** @internal */
17
+ export declare const createFallbackSpatialTileTreeReferences: typeof SpatialTileTreeReferences.create;
11
18
  /** Initialize the frontend-tiles package to obtain tiles for spatial views.
12
19
  * @alpha
13
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"FrontendTiles.d.ts","sourceRoot":"","sources":["../../src/FrontendTiles.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAA+C,MAAM,sBAAsB,CAAC;AAGrG;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,4BAA4B,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,GAAG,CAAC;CACjE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAE3E"}
1
+ {"version":3,"file":"FrontendTiles.d.ts","sourceRoot":"","sources":["../../src/FrontendTiles.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAoB,MAAM,sBAAsB,CAAC;AAGrG;;;;;GAKG;AACH,oBAAY,4BAA4B,GAAG,CAAC,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;AAElG;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D;AAED,gBAAgB;AAChB,eAAO,MAAM,uCAAuC,yCAAmC,CAAC;AAExF;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAE3E"}
@@ -4,9 +4,11 @@
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.initializeFrontendTiles = void 0;
7
+ exports.initializeFrontendTiles = exports.createFallbackSpatialTileTreeReferences = void 0;
8
8
  const core_frontend_1 = require("@itwin/core-frontend");
9
9
  const BatchedSpatialTileTreeRefs_1 = require("./BatchedSpatialTileTreeRefs");
10
+ /** @internal */
11
+ exports.createFallbackSpatialTileTreeReferences = core_frontend_1.SpatialTileTreeReferences.create;
10
12
  /** Initialize the frontend-tiles package to obtain tiles for spatial views.
11
13
  * @alpha
12
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"FrontendTiles.js","sourceRoot":"","sources":["../../src/FrontendTiles.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAAqG;AACrG,6EAAsF;AAYtF;;GAEG;AACH,SAAgB,uBAAuB,CAAC,OAA6B;IACnE,yCAAyB,CAAC,MAAM,GAAG,CAAC,IAAsB,EAAE,EAAE,CAAC,IAAA,mEAAsC,EAAC,IAAI,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACpJ,CAAC;AAFD,0DAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { IModelConnection, SpatialTileTreeReferences, SpatialViewState } from \"@itwin/core-frontend\";\r\nimport { createBatchedSpatialTileTreeReferences } from \"./BatchedSpatialTileTreeRefs\";\r\n\r\n/** Options supplied to [[initializeFrontendTiles]].\r\n * @alpha\r\n */\r\nexport interface FrontendTilesOptions {\r\n /** Given an iModel, provide the base URL where the tiles are stored representing all of the spatial models in the iModel.\r\n * It is expected that baseUrl/tileset.json exists and contains a 3d tileset in which all relative URLs are relative to baseUrl.\r\n */\r\n computeSpatialTilesetBaseUrl: (iModel: IModelConnection) => URL;\r\n}\r\n\r\n/** Initialize the frontend-tiles package to obtain tiles for spatial views.\r\n * @alpha\r\n */\r\nexport function initializeFrontendTiles(options: FrontendTilesOptions): void {\r\n SpatialTileTreeReferences.create = (view: SpatialViewState) => createBatchedSpatialTileTreeReferences(view, options.computeSpatialTilesetBaseUrl);\r\n}\r\n"]}
1
+ {"version":3,"file":"FrontendTiles.js","sourceRoot":"","sources":["../../src/FrontendTiles.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAAqG;AACrG,6EAAsF;AAkBtF,gBAAgB;AACH,QAAA,uCAAuC,GAAG,yCAAyB,CAAC,MAAM,CAAC;AAExF;;GAEG;AACH,SAAgB,uBAAuB,CAAC,OAA6B;IACnE,yCAAyB,CAAC,MAAM,GAAG,CAAC,IAAsB,EAAE,EAAE,CAAC,IAAA,mEAAsC,EAAC,IAAI,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACpJ,CAAC;AAFD,0DAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { IModelConnection, SpatialTileTreeReferences, SpatialViewState } from \"@itwin/core-frontend\";\r\nimport { createBatchedSpatialTileTreeReferences } from \"./BatchedSpatialTileTreeRefs\";\r\n\r\n/** A function that can provide the base URL where a tileset representing all of the spatial models in a given iModel are stored.\r\n * The tileset is expected to reside at \"baseUrl/tileset.json\" and to have been produced by the [mesh export service](https://developer.bentley.com/apis/mesh-export/).\r\n * If no such tileset exists for the given iModel, return `undefined`.\r\n * @see [[FrontendTilesOptions.computeSpatialTilesetBaseUrl]].\r\n * @alpha\r\n */\r\nexport type ComputeSpatialTilesetBaseUrl = (iModel: IModelConnection) => Promise<URL | undefined>;\r\n\r\n/** Options supplied to [[initializeFrontendTiles]].\r\n * @alpha\r\n */\r\nexport interface FrontendTilesOptions {\r\n /** Provide the base URL for the pre-published tileset for a given iModel. */\r\n computeSpatialTilesetBaseUrl: ComputeSpatialTilesetBaseUrl;\r\n}\r\n\r\n/** @internal */\r\nexport const createFallbackSpatialTileTreeReferences = SpatialTileTreeReferences.create;\r\n\r\n/** Initialize the frontend-tiles package to obtain tiles for spatial views.\r\n * @alpha\r\n */\r\nexport function initializeFrontendTiles(options: FrontendTilesOptions): void {\r\n SpatialTileTreeReferences.create = (view: SpatialViewState) => createBatchedSpatialTileTreeReferences(view, options.computeSpatialTilesetBaseUrl);\r\n}\r\n"]}