@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.
- package/lib/cjs/ApproximateTerrainHeights.js +3 -3
- package/lib/cjs/ApproximateTerrainHeights.js.map +1 -1
- package/lib/cjs/ContextRealityModelState.js +1 -1
- package/lib/cjs/ContextRealityModelState.js.map +1 -1
- package/lib/cjs/ElementLocateManager.d.ts +5 -0
- package/lib/cjs/ElementLocateManager.d.ts.map +1 -1
- package/lib/cjs/ElementLocateManager.js +12 -2
- package/lib/cjs/ElementLocateManager.js.map +1 -1
- package/lib/cjs/ModelState.js +1 -1
- package/lib/cjs/ModelState.js.map +1 -1
- package/lib/cjs/RealityDataSource.d.ts +53 -29
- package/lib/cjs/RealityDataSource.d.ts.map +1 -1
- package/lib/cjs/RealityDataSource.js +245 -91
- package/lib/cjs/RealityDataSource.js.map +1 -1
- package/lib/cjs/TwoWayViewportSync.d.ts +35 -6
- package/lib/cjs/TwoWayViewportSync.d.ts.map +1 -1
- package/lib/cjs/TwoWayViewportSync.js +51 -11
- package/lib/cjs/TwoWayViewportSync.js.map +1 -1
- package/lib/cjs/Viewport.d.ts +23 -5
- package/lib/cjs/Viewport.d.ts.map +1 -1
- package/lib/cjs/Viewport.js +13 -9
- package/lib/cjs/Viewport.js.map +1 -1
- package/lib/cjs/core-frontend.d.ts +0 -1
- package/lib/cjs/core-frontend.d.ts.map +1 -1
- package/lib/cjs/core-frontend.js +0 -1
- package/lib/cjs/core-frontend.js.map +1 -1
- package/lib/cjs/render/webgl/PlanarClassifier.d.ts.map +1 -1
- package/lib/cjs/render/webgl/PlanarClassifier.js +4 -2
- package/lib/cjs/render/webgl/PlanarClassifier.js.map +1 -1
- package/lib/cjs/render/webgl/glsl/PlanarClassification.d.ts.map +1 -1
- package/lib/cjs/render/webgl/glsl/PlanarClassification.js +10 -1
- package/lib/cjs/render/webgl/glsl/PlanarClassification.js.map +1 -1
- package/lib/cjs/tile/CesiumAssetProvider.d.ts +13 -0
- package/lib/cjs/tile/CesiumAssetProvider.d.ts.map +1 -0
- package/lib/cjs/tile/CesiumAssetProvider.js +34 -0
- package/lib/cjs/tile/CesiumAssetProvider.js.map +1 -0
- package/lib/cjs/tile/ContextShareProvider.d.ts +22 -0
- package/lib/cjs/tile/ContextShareProvider.d.ts.map +1 -0
- package/lib/cjs/tile/ContextShareProvider.js +110 -0
- package/lib/cjs/tile/ContextShareProvider.js.map +1 -0
- package/lib/cjs/tile/OrbitGtTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/OrbitGtTileTree.js +8 -5
- package/lib/cjs/tile/OrbitGtTileTree.js.map +1 -1
- package/lib/cjs/tile/RealityModelTileTree.d.ts +1 -54
- package/lib/cjs/tile/RealityModelTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/RealityModelTileTree.js +24 -217
- package/lib/cjs/tile/RealityModelTileTree.js.map +1 -1
- package/lib/cjs/tile/internal.d.ts +3 -0
- package/lib/cjs/tile/internal.d.ts.map +1 -1
- package/lib/cjs/tile/internal.js +3 -0
- package/lib/cjs/tile/internal.js.map +1 -1
- package/lib/cjs/tile/map/ArcGISTileMap.d.ts +22 -0
- package/lib/cjs/tile/map/ArcGISTileMap.d.ts.map +1 -0
- package/lib/cjs/tile/map/ArcGISTileMap.js +173 -0
- package/lib/cjs/tile/map/ArcGISTileMap.js.map +1 -0
- package/lib/cjs/tile/map/CesiumTerrainProvider.js +5 -4
- package/lib/cjs/tile/map/CesiumTerrainProvider.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts +2 -2
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +18 -40
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts +6 -1
- package/lib/cjs/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js +63 -21
- package/lib/cjs/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/ImageryTileTree.d.ts +4 -4
- package/lib/cjs/tile/map/ImageryTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/map/ImageryTileTree.js +20 -24
- package/lib/cjs/tile/map/ImageryTileTree.js.map +1 -1
- package/lib/cjs/tile/map/MapCartoRectangle.js +1 -1
- package/lib/cjs/tile/map/MapCartoRectangle.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryFormats.js +17 -6
- package/lib/cjs/tile/map/MapLayerImageryFormats.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts +9 -4
- package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryProvider.js +22 -4
- package/lib/cjs/tile/map/MapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/MapTile.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapTile.js +4 -3
- package/lib/cjs/tile/map/MapTile.js.map +1 -1
- package/lib/cjs/tile/map/MapTileTree.js +1 -1
- package/lib/cjs/tile/map/MapTileTree.js.map +1 -1
- package/lib/cjs/tile/map/MapTilingScheme.d.ts +7 -2
- package/lib/cjs/tile/map/MapTilingScheme.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapTilingScheme.js +21 -8
- package/lib/cjs/tile/map/MapTilingScheme.js.map +1 -1
- package/lib/cjs/tile/map/QuadId.d.ts +1 -0
- package/lib/cjs/tile/map/QuadId.d.ts.map +1 -1
- package/lib/cjs/tile/map/QuadId.js +2 -1
- package/lib/cjs/tile/map/QuadId.js.map +1 -1
- package/lib/cjs/tile/map/WmtsCapabilities.d.ts +7 -0
- package/lib/cjs/tile/map/WmtsCapabilities.d.ts.map +1 -1
- package/lib/cjs/tile/map/WmtsCapabilities.js +16 -2
- package/lib/cjs/tile/map/WmtsCapabilities.js.map +1 -1
- package/lib/cjs/tools/ViewTool.d.ts.map +1 -1
- package/lib/cjs/tools/ViewTool.js +2 -10
- package/lib/cjs/tools/ViewTool.js.map +1 -1
- package/lib/esm/ApproximateTerrainHeights.js +3 -3
- package/lib/esm/ApproximateTerrainHeights.js.map +1 -1
- package/lib/esm/ContextRealityModelState.js +1 -1
- package/lib/esm/ContextRealityModelState.js.map +1 -1
- package/lib/esm/ElementLocateManager.d.ts +5 -0
- package/lib/esm/ElementLocateManager.d.ts.map +1 -1
- package/lib/esm/ElementLocateManager.js +12 -2
- package/lib/esm/ElementLocateManager.js.map +1 -1
- package/lib/esm/ModelState.js +1 -1
- package/lib/esm/ModelState.js.map +1 -1
- package/lib/esm/RealityDataSource.d.ts +53 -29
- package/lib/esm/RealityDataSource.d.ts.map +1 -1
- package/lib/esm/RealityDataSource.js +246 -90
- package/lib/esm/RealityDataSource.js.map +1 -1
- package/lib/esm/TwoWayViewportSync.d.ts +35 -6
- package/lib/esm/TwoWayViewportSync.d.ts.map +1 -1
- package/lib/esm/TwoWayViewportSync.js +49 -10
- package/lib/esm/TwoWayViewportSync.js.map +1 -1
- package/lib/esm/Viewport.d.ts +23 -5
- package/lib/esm/Viewport.d.ts.map +1 -1
- package/lib/esm/Viewport.js +13 -9
- package/lib/esm/Viewport.js.map +1 -1
- package/lib/esm/core-frontend.d.ts +0 -1
- package/lib/esm/core-frontend.d.ts.map +1 -1
- package/lib/esm/core-frontend.js +0 -1
- package/lib/esm/core-frontend.js.map +1 -1
- package/lib/esm/render/webgl/PlanarClassifier.d.ts.map +1 -1
- package/lib/esm/render/webgl/PlanarClassifier.js +4 -2
- package/lib/esm/render/webgl/PlanarClassifier.js.map +1 -1
- package/lib/esm/render/webgl/glsl/PlanarClassification.d.ts.map +1 -1
- package/lib/esm/render/webgl/glsl/PlanarClassification.js +10 -1
- package/lib/esm/render/webgl/glsl/PlanarClassification.js.map +1 -1
- package/lib/esm/tile/CesiumAssetProvider.d.ts +13 -0
- package/lib/esm/tile/CesiumAssetProvider.d.ts.map +1 -0
- package/lib/esm/tile/CesiumAssetProvider.js +30 -0
- package/lib/esm/tile/CesiumAssetProvider.js.map +1 -0
- package/lib/esm/tile/ContextShareProvider.d.ts +22 -0
- package/lib/esm/tile/ContextShareProvider.d.ts.map +1 -0
- package/lib/esm/tile/ContextShareProvider.js +106 -0
- package/lib/esm/tile/ContextShareProvider.js.map +1 -0
- package/lib/esm/tile/OrbitGtTileTree.d.ts.map +1 -1
- package/lib/esm/tile/OrbitGtTileTree.js +8 -5
- package/lib/esm/tile/OrbitGtTileTree.js.map +1 -1
- package/lib/esm/tile/RealityModelTileTree.d.ts +1 -54
- package/lib/esm/tile/RealityModelTileTree.d.ts.map +1 -1
- package/lib/esm/tile/RealityModelTileTree.js +26 -218
- package/lib/esm/tile/RealityModelTileTree.js.map +1 -1
- package/lib/esm/tile/internal.d.ts +3 -0
- package/lib/esm/tile/internal.d.ts.map +1 -1
- package/lib/esm/tile/internal.js +3 -0
- package/lib/esm/tile/internal.js.map +1 -1
- package/lib/esm/tile/map/ArcGISTileMap.d.ts +22 -0
- package/lib/esm/tile/map/ArcGISTileMap.d.ts.map +1 -0
- package/lib/esm/tile/map/ArcGISTileMap.js +169 -0
- package/lib/esm/tile/map/ArcGISTileMap.js.map +1 -0
- package/lib/esm/tile/map/CesiumTerrainProvider.js +5 -4
- package/lib/esm/tile/map/CesiumTerrainProvider.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts +2 -2
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +19 -41
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts +6 -1
- package/lib/esm/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js +63 -21
- package/lib/esm/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/ImageryTileTree.d.ts +4 -4
- package/lib/esm/tile/map/ImageryTileTree.d.ts.map +1 -1
- package/lib/esm/tile/map/ImageryTileTree.js +21 -25
- package/lib/esm/tile/map/ImageryTileTree.js.map +1 -1
- package/lib/esm/tile/map/MapCartoRectangle.js +1 -1
- package/lib/esm/tile/map/MapCartoRectangle.js.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryFormats.js +17 -6
- package/lib/esm/tile/map/MapLayerImageryFormats.js.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryProvider.d.ts +9 -4
- package/lib/esm/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryProvider.js +22 -4
- package/lib/esm/tile/map/MapLayerImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/MapTile.d.ts.map +1 -1
- package/lib/esm/tile/map/MapTile.js +4 -3
- package/lib/esm/tile/map/MapTile.js.map +1 -1
- package/lib/esm/tile/map/MapTileTree.js +1 -1
- package/lib/esm/tile/map/MapTileTree.js.map +1 -1
- package/lib/esm/tile/map/MapTilingScheme.d.ts +7 -2
- package/lib/esm/tile/map/MapTilingScheme.d.ts.map +1 -1
- package/lib/esm/tile/map/MapTilingScheme.js +22 -9
- package/lib/esm/tile/map/MapTilingScheme.js.map +1 -1
- package/lib/esm/tile/map/QuadId.d.ts +1 -0
- package/lib/esm/tile/map/QuadId.d.ts.map +1 -1
- package/lib/esm/tile/map/QuadId.js +2 -1
- package/lib/esm/tile/map/QuadId.js.map +1 -1
- package/lib/esm/tile/map/WmtsCapabilities.d.ts +7 -0
- package/lib/esm/tile/map/WmtsCapabilities.d.ts.map +1 -1
- package/lib/esm/tile/map/WmtsCapabilities.js +16 -2
- package/lib/esm/tile/map/WmtsCapabilities.js.map +1 -1
- package/lib/esm/tools/ViewTool.d.ts.map +1 -1
- package/lib/esm/tools/ViewTool.js +2 -10
- package/lib/esm/tools/ViewTool.js.map +1 -1
- package/package.json +24 -24
- package/lib/cjs/RealityDataConnection.d.ts +0 -31
- package/lib/cjs/RealityDataConnection.d.ts.map +0 -1
- package/lib/cjs/RealityDataConnection.js +0 -101
- package/lib/cjs/RealityDataConnection.js.map +0 -1
- package/lib/esm/RealityDataConnection.d.ts +0 -31
- package/lib/esm/RealityDataConnection.d.ts.map +0 -1
- package/lib/esm/RealityDataConnection.js +0 -98
- package/lib/esm/RealityDataConnection.js.map +0 -1
|
@@ -2,114 +2,72 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { getJson, request } from "@bentley/itwin-client";
|
|
6
|
+
import { BentleyStatus, Logger } from "@itwin/core-bentley";
|
|
7
|
+
import { IModelError, RealityDataFormat, RealityDataProvider } from "@itwin/core-common";
|
|
7
8
|
import { FrontendLoggerCategory } from "./FrontendLoggerCategory";
|
|
8
9
|
import { IModelApp } from "./IModelApp";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this._isUrlResolved = false;
|
|
10
|
+
import { CesiumIonAssetProvider, ContextShareProvider, getCesiumAccessTokenAndEndpointUrl } from "./tile/internal";
|
|
11
|
+
/** @alpha */
|
|
12
|
+
export var RealityDataSource;
|
|
13
|
+
(function (RealityDataSource) {
|
|
14
|
+
/** Utility function to convert a RealityDataSourceKey into its string representation
|
|
15
|
+
* @alpha
|
|
16
|
+
*/
|
|
17
|
+
function keyToString(rdSourceKey) {
|
|
18
|
+
return `${rdSourceKey.provider}:${rdSourceKey.format}:${rdSourceKey.id}:${rdSourceKey.iTwinId}`;
|
|
19
|
+
}
|
|
20
|
+
RealityDataSource.keyToString = keyToString;
|
|
21
|
+
function formatfromUrl(tilesetUrl) {
|
|
22
|
+
let format = RealityDataFormat.ThreeDTile;
|
|
23
|
+
if (tilesetUrl.includes(".opc"))
|
|
24
|
+
format = RealityDataFormat.OPC;
|
|
25
|
+
return format;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
RealityDataSource.formatfromUrl = formatfromUrl;
|
|
28
|
+
function createKeyFromUrl(tilesetUrl, inputProvider, inputFormat) {
|
|
29
|
+
let format = inputFormat ? inputFormat : formatfromUrl(tilesetUrl);
|
|
30
|
+
if (CesiumIonAssetProvider.isProviderUrl(tilesetUrl)) {
|
|
30
31
|
const provider = inputProvider ? inputProvider : RealityDataProvider.CesiumIonAsset;
|
|
31
32
|
const cesiumIonAssetKey = { provider, format, id: tilesetUrl };
|
|
32
33
|
return cesiumIonAssetKey;
|
|
33
34
|
}
|
|
34
35
|
// Try to extract realityDataId from URL and if not possible, use the url as the key
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const invalidUrlKey = { provider: RealityDataProvider.TilesetUrl, format, id: tilesetUrl };
|
|
42
|
-
return invalidUrlKey;
|
|
43
|
-
}
|
|
44
|
-
// detect if it is a RDS url
|
|
45
|
-
const formattedUrl1 = attUrl.pathname.replace(/~2F/g, "/").replace(/\\/g, "/");
|
|
46
|
-
if (formattedUrl1) {
|
|
47
|
-
const urlParts1 = formattedUrl1.split("/").map((entry) => entry.replace(/%2D/g, "-"));
|
|
48
|
-
let partOffset1 = 0;
|
|
49
|
-
urlParts1.find((value, index) => {
|
|
50
|
-
if (value === "Repositories") {
|
|
51
|
-
partOffset1 = index;
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
});
|
|
56
|
-
const isOPC = attUrl.pathname.match(".opc*") !== null;
|
|
57
|
-
const isRDSUrl = (urlParts1[partOffset1] === "Repositories") && (urlParts1[partOffset1 + 1].match("S3MXECPlugin--*") !== null) && (urlParts1[partOffset1 + 2] === "S3MX");
|
|
58
|
-
let projectId;
|
|
59
|
-
const projectIdSection = urlParts1.find((val) => val.includes("--"));
|
|
60
|
-
if (projectIdSection)
|
|
61
|
-
projectId = projectIdSection.split("--")[1];
|
|
62
|
-
// Make sure the url to compare are REALITYMESH3DTILES url, otherwise, compare the url directly
|
|
63
|
-
if (isRDSUrl || isOPC) {
|
|
64
|
-
// Make sure the reality data id are the same
|
|
65
|
-
const guid1 = urlParts1.find(Guid.isGuid);
|
|
66
|
-
if (guid1 !== undefined) {
|
|
67
|
-
const provider = inputProvider ? inputProvider : RealityDataProvider.ContextShare;
|
|
68
|
-
format = inputFormat ? inputFormat : isOPC ? RealityDataFormat.OPC : RealityDataFormat.ThreeDTile;
|
|
69
|
-
const contextShareKey = { provider, format, id: guid1, iTwinId: projectId };
|
|
70
|
-
return contextShareKey;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
36
|
+
if (ContextShareProvider.isProviderUrl(tilesetUrl)) {
|
|
37
|
+
const info = ContextShareProvider.getInfoFromUrl(tilesetUrl);
|
|
38
|
+
const provider = inputProvider ? inputProvider : info.provider;
|
|
39
|
+
format = inputFormat ? inputFormat : info.format;
|
|
40
|
+
const contextShareKey = { provider, format, id: info.id, iTwinId: info.iTwinId };
|
|
41
|
+
return contextShareKey;
|
|
73
42
|
}
|
|
74
43
|
// default to tileSetUrl
|
|
75
44
|
const provider2 = inputProvider ? inputProvider : RealityDataProvider.TilesetUrl;
|
|
76
45
|
const urlKey = { provider: provider2, format, id: tilesetUrl };
|
|
77
46
|
return urlKey;
|
|
78
47
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return { provider, format, id: blobUrl };
|
|
86
|
-
// const accountName = url.hostname.split(".")[0];
|
|
87
|
-
let containerName = "";
|
|
88
|
-
if (url.pathname) {
|
|
89
|
-
const pathSplit = url.pathname.split("/");
|
|
90
|
-
containerName = pathSplit[1];
|
|
91
|
-
}
|
|
92
|
-
// const blobFileName = `/${pathSplit[2]}`;
|
|
93
|
-
// const sasToken = url.search.substr(1);
|
|
94
|
-
const isOPC = url.pathname.match(".opc*") !== null;
|
|
95
|
-
provider = inputProvider ? inputProvider : RealityDataProvider.ContextShare;
|
|
96
|
-
format = inputFormat ? inputFormat : isOPC ? RealityDataFormat.OPC : RealityDataFormat.ThreeDTile;
|
|
97
|
-
const contextShareKey = { provider, format, id: containerName };
|
|
48
|
+
RealityDataSource.createKeyFromUrl = createKeyFromUrl;
|
|
49
|
+
function createKeyFromBlobUrl(blobUrl, inputProvider, inputFormat) {
|
|
50
|
+
const info = ContextShareProvider.getInfoFromBlobUrl(blobUrl);
|
|
51
|
+
const format = inputFormat ? inputFormat : info.format;
|
|
52
|
+
const provider = inputProvider ? inputProvider : info.provider;
|
|
53
|
+
const contextShareKey = { provider, format, id: info.id };
|
|
98
54
|
return contextShareKey;
|
|
99
55
|
}
|
|
100
|
-
|
|
56
|
+
RealityDataSource.createKeyFromBlobUrl = createKeyFromBlobUrl;
|
|
57
|
+
function createKeyFromOrbitGtBlobProps(orbitGtBlob, inputProvider, inputFormat) {
|
|
101
58
|
const format = inputFormat ? inputFormat : RealityDataFormat.OPC;
|
|
102
59
|
if (orbitGtBlob.blobFileName && orbitGtBlob.blobFileName.toLowerCase().startsWith("http")) {
|
|
103
|
-
return RealityDataSource.
|
|
60
|
+
return RealityDataSource.createKeyFromBlobUrl(orbitGtBlob.blobFileName, inputProvider, format);
|
|
104
61
|
}
|
|
105
62
|
else if (orbitGtBlob.rdsUrl) {
|
|
106
|
-
return RealityDataSource.
|
|
63
|
+
return RealityDataSource.createKeyFromUrl(orbitGtBlob.rdsUrl, inputProvider, format);
|
|
107
64
|
}
|
|
108
65
|
const provider = inputProvider ? inputProvider : RealityDataProvider.OrbitGtBlob;
|
|
109
66
|
const id = `${orbitGtBlob.accountName}:${orbitGtBlob.containerName}:${orbitGtBlob.blobFileName}:?${orbitGtBlob.sasToken}`;
|
|
110
67
|
return { provider, format, id };
|
|
111
68
|
}
|
|
112
|
-
|
|
69
|
+
RealityDataSource.createKeyFromOrbitGtBlobProps = createKeyFromOrbitGtBlobProps;
|
|
70
|
+
function createOrbitGtBlobPropsFromKey(rdSourceKey) {
|
|
113
71
|
if (rdSourceKey.provider !== RealityDataProvider.OrbitGtBlob)
|
|
114
72
|
return undefined;
|
|
115
73
|
const splitIds = rdSourceKey.id.split(":");
|
|
@@ -123,21 +81,151 @@ export class RealityDataSource {
|
|
|
123
81
|
};
|
|
124
82
|
return orbitGtBlob;
|
|
125
83
|
}
|
|
84
|
+
RealityDataSource.createOrbitGtBlobPropsFromKey = createOrbitGtBlobPropsFromKey;
|
|
85
|
+
/** Return an instance of a RealityDataSource from a source key.
|
|
86
|
+
* There will aways be only one reality data RealityDataSource for a corresponding reality data source key.
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
async function fromKey(rdSourceKey, iTwinId) {
|
|
90
|
+
return RealityDataSourceImpl.fromKey(rdSourceKey, iTwinId);
|
|
91
|
+
}
|
|
92
|
+
RealityDataSource.fromKey = fromKey;
|
|
93
|
+
})(RealityDataSource || (RealityDataSource = {}));
|
|
94
|
+
/** This class provides access to the reality data provider services.
|
|
95
|
+
* It encapsulates access to a reality data wether it be from local access, http or ProjectWise Context Share.
|
|
96
|
+
* The key provided at the creation determines if this is ProjectWise Context Share reference.
|
|
97
|
+
* If not then it is considered local (ex: C:\temp\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)
|
|
98
|
+
* There is a one to one relationship between a reality data and the instances of present class.
|
|
99
|
+
* @alpha
|
|
100
|
+
*/
|
|
101
|
+
class RealityDataSourceImpl {
|
|
102
|
+
/** Construct a new reality data source.
|
|
103
|
+
* @param props JSON representation of the reality data source
|
|
104
|
+
*/
|
|
105
|
+
constructor(props) {
|
|
106
|
+
this._isUrlResolved = false;
|
|
107
|
+
/** For use by all Reality Data. For RD stored on PW Context Share, represents the portion from the root of the Azure Blob Container*/
|
|
108
|
+
this._baseUrl = "";
|
|
109
|
+
this.key = props.sourceKey;
|
|
110
|
+
this._isUrlResolved = false;
|
|
111
|
+
}
|
|
126
112
|
/** Construct a new reality data source.
|
|
127
113
|
* @param props JSON representation of the reality data source
|
|
128
114
|
*/
|
|
129
115
|
static fromProps(props) {
|
|
130
|
-
return new
|
|
116
|
+
return new RealityDataSourceImpl(props);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create an instance of this class from a source key and iTwin context/
|
|
120
|
+
* @alpha
|
|
121
|
+
*/
|
|
122
|
+
static async createFromKey(sourceKey, iTwinId) {
|
|
123
|
+
const rdSource = new RealityDataSourceImpl({ sourceKey });
|
|
124
|
+
let tilesetUrl;
|
|
125
|
+
try {
|
|
126
|
+
await rdSource.queryRealityData(iTwinId);
|
|
127
|
+
tilesetUrl = await rdSource.getServiceUrl(iTwinId);
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
}
|
|
131
|
+
return (tilesetUrl !== undefined) ? rdSource : undefined;
|
|
132
|
+
}
|
|
133
|
+
/** Return an instance of a RealityDataSource from a source key.
|
|
134
|
+
* There will aways be only one reality data connection for a corresponding reality data source key.
|
|
135
|
+
* @alpha
|
|
136
|
+
*/
|
|
137
|
+
static async fromKey(rdSourceKey, iTwinId) {
|
|
138
|
+
// search to see if it was already created
|
|
139
|
+
const rdSourceKeyString = RealityDataSource.keyToString(rdSourceKey);
|
|
140
|
+
let rdSource = RealityDataSourceImpl._realityDataSources.get(rdSourceKeyString);
|
|
141
|
+
if (rdSource)
|
|
142
|
+
return rdSource;
|
|
143
|
+
// If not already in our list, create and add it to our list before returing it.
|
|
144
|
+
rdSource = await RealityDataSourceImpl.createFromKey(rdSourceKey, iTwinId);
|
|
145
|
+
if (rdSource)
|
|
146
|
+
RealityDataSourceImpl._realityDataSources.set(rdSourceKeyString, rdSource);
|
|
147
|
+
return rdSource;
|
|
131
148
|
}
|
|
132
149
|
get isContextShare() {
|
|
133
|
-
return (this.
|
|
150
|
+
return (this.key.provider === RealityDataProvider.ContextShare);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Returns Reality Data if available
|
|
154
|
+
*/
|
|
155
|
+
get realityData() {
|
|
156
|
+
return this._rd;
|
|
134
157
|
}
|
|
135
158
|
get realityDataId() {
|
|
136
|
-
const realityDataId = this.isContextShare ? this.
|
|
159
|
+
const realityDataId = this.isContextShare ? this.key.id : undefined;
|
|
137
160
|
return realityDataId;
|
|
138
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Returns Reality Data type if available
|
|
164
|
+
*/
|
|
165
|
+
get realityDataType() {
|
|
166
|
+
var _a;
|
|
167
|
+
return (_a = this._rd) === null || _a === void 0 ? void 0 : _a.type;
|
|
168
|
+
}
|
|
139
169
|
get iTwinId() {
|
|
140
|
-
return this.
|
|
170
|
+
return this.key.iTwinId;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Query Reality Data from provider
|
|
174
|
+
*/
|
|
175
|
+
async queryRealityData(iTwinId) {
|
|
176
|
+
var _a;
|
|
177
|
+
if (this.isContextShare && !this._rd) {
|
|
178
|
+
const token = await IModelApp.getAccessToken();
|
|
179
|
+
if (token && this.realityDataId) {
|
|
180
|
+
if (undefined === IModelApp.realityDataAccess)
|
|
181
|
+
throw new Error("Missing an implementation of RealityDataAccess on IModelApp, it is required to access reality data. Please provide an implementation to the IModelApp.startup using IModelAppOptions.realityDataAccess.");
|
|
182
|
+
this._rd = await IModelApp.realityDataAccess.getRealityData(token, iTwinId, this.realityDataId);
|
|
183
|
+
// A reality data that has not root document set should not be considered.
|
|
184
|
+
const rootDocument = (_a = this._rd.rootDocument) !== null && _a !== void 0 ? _a : "";
|
|
185
|
+
this.setBaseUrl(rootDocument);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// This is to set the root url from the provided root document path.
|
|
190
|
+
// If the root document is stored on PW Context Share then the root document property of the Reality Data is provided,
|
|
191
|
+
// otherwise the full path to root document is given.
|
|
192
|
+
// The base URL contains the base URL from which tile relative path are constructed.
|
|
193
|
+
// The tile's path root will need to be reinserted for child tiles to return a 200
|
|
194
|
+
setBaseUrl(url) {
|
|
195
|
+
const urlParts = url.split("/");
|
|
196
|
+
urlParts.pop();
|
|
197
|
+
if (urlParts.length === 0)
|
|
198
|
+
this._baseUrl = "";
|
|
199
|
+
else
|
|
200
|
+
this._baseUrl = `${urlParts.join("/")}/`;
|
|
201
|
+
}
|
|
202
|
+
async _doRequest(url, responseType) {
|
|
203
|
+
let options = {
|
|
204
|
+
method: "GET",
|
|
205
|
+
responseType,
|
|
206
|
+
};
|
|
207
|
+
const authToken = this._requestAuthorization;
|
|
208
|
+
if (authToken) {
|
|
209
|
+
options = {
|
|
210
|
+
...options,
|
|
211
|
+
headers: {
|
|
212
|
+
authorization: authToken,
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const data = await request(url, options);
|
|
217
|
+
return data.body;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Gets a tileset's app data json
|
|
221
|
+
* @param name name or path of tile
|
|
222
|
+
* @returns app data json object
|
|
223
|
+
* @internal
|
|
224
|
+
*/
|
|
225
|
+
async getRealityDataTileJson(accessToken, name, realityData) {
|
|
226
|
+
const url = await realityData.getBlobUrl(accessToken, name);
|
|
227
|
+
const data = await getJson(url.toString());
|
|
228
|
+
return data;
|
|
141
229
|
}
|
|
142
230
|
/**
|
|
143
231
|
* This method returns the URL to access the actual 3d tiles from the service provider.
|
|
@@ -146,7 +234,7 @@ export class RealityDataSource {
|
|
|
146
234
|
async getServiceUrl(iTwinId) {
|
|
147
235
|
// If url was not resolved - resolve it
|
|
148
236
|
if (this.isContextShare && !this._isUrlResolved) {
|
|
149
|
-
const rdSourceKey = this.
|
|
237
|
+
const rdSourceKey = this.key;
|
|
150
238
|
// we need to resolve tilesetURl from realityDataId and iTwinId
|
|
151
239
|
if (undefined === IModelApp.realityDataAccess)
|
|
152
240
|
throw new Error("Missing an implementation of RealityDataAccess on IModelApp, it is required to access reality data. Please provide an implementation to the IModelApp.startup using IModelAppOptions.realityDataAccess.");
|
|
@@ -160,10 +248,78 @@ export class RealityDataSource {
|
|
|
160
248
|
Logger.logError(FrontendLoggerCategory.RealityData, errMsg);
|
|
161
249
|
}
|
|
162
250
|
}
|
|
163
|
-
else if (this.
|
|
164
|
-
this._tilesetUrl = this.
|
|
251
|
+
else if (this.key.provider === RealityDataProvider.TilesetUrl || this.key.provider === RealityDataProvider.CesiumIonAsset) {
|
|
252
|
+
this._tilesetUrl = this.key.id;
|
|
165
253
|
}
|
|
166
254
|
return this._tilesetUrl;
|
|
167
255
|
}
|
|
256
|
+
/** TODO: This probably required three different realitydataSource implementations based on different provider -> locally hosted, RDS and cesium */
|
|
257
|
+
async getRootDocument(iTwinId) {
|
|
258
|
+
const token = await IModelApp.getAccessToken();
|
|
259
|
+
if (this.isContextShare && token) {
|
|
260
|
+
const realityData = this.realityData;
|
|
261
|
+
if (!realityData)
|
|
262
|
+
throw new Error(`Reality Data not defined`);
|
|
263
|
+
if (!realityData.rootDocument)
|
|
264
|
+
throw new Error(`Root document not defined for reality data: ${realityData.id}`);
|
|
265
|
+
return this.getRealityDataTileJson(token, realityData.rootDocument, realityData);
|
|
266
|
+
}
|
|
267
|
+
let url = await this.getServiceUrl(iTwinId);
|
|
268
|
+
if (!url)
|
|
269
|
+
throw new IModelError(BentleyStatus.ERROR, "Unable to get service url");
|
|
270
|
+
// The following is only if the reality data is not stored on PW Context Share.
|
|
271
|
+
const cesiumAsset = CesiumIonAssetProvider.parseCesiumUrl(url);
|
|
272
|
+
if (cesiumAsset) {
|
|
273
|
+
const tokenAndUrl = await getCesiumAccessTokenAndEndpointUrl(cesiumAsset.id, cesiumAsset.key);
|
|
274
|
+
if (tokenAndUrl.url && tokenAndUrl.token) {
|
|
275
|
+
url = tokenAndUrl.url;
|
|
276
|
+
this._requestAuthorization = `Bearer ${tokenAndUrl.token}`;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// The following is only if the reality data is not stored on PW Context Share.
|
|
280
|
+
this.setBaseUrl(url);
|
|
281
|
+
return this._doRequest(url, "json");
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Gets tile content
|
|
285
|
+
* @param name name or path of tile
|
|
286
|
+
* @returns array buffer of tile content
|
|
287
|
+
*/
|
|
288
|
+
async getRealityDataTileContent(accessToken, name, realityData) {
|
|
289
|
+
const url = await realityData.getBlobUrl(accessToken, name);
|
|
290
|
+
const options = {
|
|
291
|
+
method: "GET",
|
|
292
|
+
responseType: "arraybuffer",
|
|
293
|
+
};
|
|
294
|
+
const data = await request(url.toString(), options);
|
|
295
|
+
return data.body;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* TODO: This probably required different realitydataSource implementations based on different provider -> locally hosted, RDS and cesium
|
|
299
|
+
* Returns the tile content. The path to the tile is relative to the base url of present reality data whatever the type.
|
|
300
|
+
*/
|
|
301
|
+
async getTileContent(name) {
|
|
302
|
+
const token = await IModelApp.getAccessToken();
|
|
303
|
+
const useRds = this.isContextShare && token !== undefined;
|
|
304
|
+
const tileUrl = this._baseUrl + name;
|
|
305
|
+
if (useRds && this.realityData) {
|
|
306
|
+
return this.getRealityDataTileContent(token, tileUrl, this.realityData);
|
|
307
|
+
}
|
|
308
|
+
return this._doRequest(tileUrl, "arraybuffer");
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* TODO: This probably required different realitydataSource implementations based on different provider -> locally hosted, RDS and cesium
|
|
312
|
+
* 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.
|
|
313
|
+
*/
|
|
314
|
+
async getTileJson(name) {
|
|
315
|
+
const token = await IModelApp.getAccessToken();
|
|
316
|
+
const useRds = this.isContextShare && token !== undefined;
|
|
317
|
+
const tileUrl = this._baseUrl + name;
|
|
318
|
+
if (useRds && this.realityData) {
|
|
319
|
+
return this.getRealityDataTileJson(token, tileUrl, this.realityData);
|
|
320
|
+
}
|
|
321
|
+
return this._doRequest(tileUrl, "json");
|
|
322
|
+
}
|
|
168
323
|
}
|
|
324
|
+
RealityDataSourceImpl._realityDataSources = new Map();
|
|
169
325
|
//# sourceMappingURL=RealityDataSource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealityDataSource.js","sourceRoot":"","sources":["../../src/RealityDataSource.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,IAAI,EAAc,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAoB,iBAAiB,EAAE,mBAAmB,EAAgD,MAAM,oBAAoB,CAAC;AAC5I,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;EAEE;AACF,MAAM,UAAU,4BAA4B,CAAC,WAAiC;IAC5E,OAAO,GAAG,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,EAAE,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;AAClG,CAAC;AAED;;EAEE;AACF,MAAM,OAAO,iBAAiB;IAM5B;;OAEG;IACH,YAAsB,KAA6B;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+DAA+D;YAC/D,IAAI,SAAS,KAAK,SAAS,CAAC,iBAAiB;gBAC3C,MAAM,IAAI,KAAK,CAAC,yMAAyM,CAAC,CAAC;YAC7N,IAAI;gBACF,MAAM,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC;gBAEhE,IAAI,CAAC,WAAW,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,eAAe,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;gBACxG,IAAI,CAAC,cAAc,GAAC,IAAI,CAAC;aAC1B;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,MAAM,GAAG,2DAA2D,WAAW,CAAC,EAAE,gBAAgB,OAAO,EAAE,CAAC;gBAClH,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;aAC7D;SACF;aAAM,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,KAAK,mBAAmB,CAAC,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,KAAK,mBAAmB,CAAC,cAAc,EAAE;YAC3I,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;SACxC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF","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 { Guid, GuidString, Logger } from \"@itwin/core-bentley\";\r\nimport { OrbitGtBlobProps, RealityDataFormat, RealityDataProvider, RealityDataSourceKey, RealityDataSourceProps } from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"./FrontendLoggerCategory\";\r\nimport { IModelApp } from \"./IModelApp\";\r\n\r\n/** Utility function to convert a RealityDataSourceKey into its string representation\r\n* @alpha\r\n*/\r\nexport function realityDataSourceKeyToString(rdSourceKey: RealityDataSourceKey): string {\r\n return `${rdSourceKey.provider}:${rdSourceKey.format}:${rdSourceKey.id}:${rdSourceKey.iTwinId}`;\r\n}\r\n\r\n/** This class provides access to the reality data provider services.\r\n* @alpha\r\n*/\r\nexport class RealityDataSource {\r\n public readonly rdSourceKey: RealityDataSourceKey;\r\n /** The URL that supplies the 3d tiles for displaying the reality model. */\r\n private _tilesetUrl: string | undefined;\r\n private _isUrlResolved: boolean = false;\r\n\r\n /** Construct a new reality data source.\r\n * @param props JSON representation of the reality data source\r\n */\r\n protected constructor(props: RealityDataSourceProps) {\r\n this.rdSourceKey = props.sourceKey;\r\n this._isUrlResolved=false;\r\n }\r\n public static createRealityDataSourceKeyFromUrl(tilesetUrl: string, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n let format = inputFormat ? inputFormat : RealityDataFormat.ThreeDTile;\r\n if (tilesetUrl.includes(\"$CesiumIonAsset=\")) {\r\n const provider = inputProvider ? inputProvider : RealityDataProvider.CesiumIonAsset;\r\n const cesiumIonAssetKey: RealityDataSourceKey = { provider, format, id: tilesetUrl };\r\n return cesiumIonAssetKey;\r\n }\r\n\r\n // Try to extract realityDataId from URL and if not possible, use the url as the key\r\n let attUrl: URL;\r\n try {\r\n attUrl = new URL(tilesetUrl);\r\n } catch (e) {\r\n // Not a valid URL and not equal, probably $cesiumAsset\r\n const invalidUrlKey: RealityDataSourceKey = { provider: RealityDataProvider.TilesetUrl, format, id: tilesetUrl };\r\n return invalidUrlKey;\r\n }\r\n // detect if it is a RDS url\r\n const formattedUrl1 = attUrl.pathname.replace(/~2F/g, \"/\").replace(/\\\\/g, \"/\");\r\n if (formattedUrl1) {\r\n const urlParts1 = formattedUrl1.split(\"/\").map((entry: string) => entry.replace(/%2D/g, \"-\"));\r\n let partOffset1: number = 0;\r\n urlParts1.find((value, index) => {\r\n if (value === \"Repositories\") {\r\n partOffset1 = index;\r\n return true;\r\n }\r\n return false;\r\n });\r\n const isOPC = attUrl.pathname.match(\".opc*\") !== null;\r\n const isRDSUrl = (urlParts1[partOffset1] === \"Repositories\") && (urlParts1[partOffset1 + 1].match(\"S3MXECPlugin--*\") !== null) && (urlParts1[partOffset1 + 2] === \"S3MX\");\r\n let projectId: string | undefined;\r\n const projectIdSection = urlParts1.find((val: string) => val.includes(\"--\"));\r\n if (projectIdSection)\r\n projectId = projectIdSection.split(\"--\")[1];\r\n // Make sure the url to compare are REALITYMESH3DTILES url, otherwise, compare the url directly\r\n if (isRDSUrl || isOPC) {\r\n // Make sure the reality data id are the same\r\n const guid1 = urlParts1.find(Guid.isGuid);\r\n if (guid1 !== undefined) {\r\n const provider = inputProvider ? inputProvider : RealityDataProvider.ContextShare;\r\n format = inputFormat ? inputFormat : isOPC ? RealityDataFormat.OPC : RealityDataFormat.ThreeDTile;\r\n const contextShareKey: RealityDataSourceKey = { provider, format, id: guid1, iTwinId: projectId };\r\n return contextShareKey;\r\n }\r\n }\r\n }\r\n\r\n // default to tileSetUrl\r\n const provider2 = inputProvider ? inputProvider : RealityDataProvider.TilesetUrl;\r\n const urlKey: RealityDataSourceKey = { provider: provider2, format, id: tilesetUrl };\r\n return urlKey;\r\n }\r\n public static createFromBlobUrl(blobUrl: string, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n let format = inputFormat ? inputFormat : RealityDataFormat.ThreeDTile;\r\n let provider = inputProvider ? inputProvider : RealityDataProvider.TilesetUrl;\r\n const url = new URL(blobUrl);\r\n\r\n // If we cannot interpret that url pass in parameter we just fallback to old implementation\r\n if(!url.pathname)\r\n return { provider, format, id: blobUrl };\r\n\r\n // const accountName = url.hostname.split(\".\")[0];\r\n let containerName= \"\";\r\n if (url.pathname) {\r\n const pathSplit = url.pathname.split(\"/\");\r\n containerName = pathSplit[1];\r\n }\r\n\r\n // const blobFileName = `/${pathSplit[2]}`;\r\n // const sasToken = url.search.substr(1);\r\n const isOPC = url.pathname.match(\".opc*\") !== null;\r\n provider = inputProvider ? inputProvider : RealityDataProvider.ContextShare;\r\n format = inputFormat ? inputFormat : isOPC ? RealityDataFormat.OPC : RealityDataFormat.ThreeDTile;\r\n const contextShareKey: RealityDataSourceKey = { provider, format, id: containerName };\r\n return contextShareKey;\r\n }\r\n public static createKeyFromOrbitGtBlobProps(orbitGtBlob: OrbitGtBlobProps, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n const format = inputFormat ? inputFormat : RealityDataFormat.OPC;\r\n if(orbitGtBlob.blobFileName && orbitGtBlob.blobFileName.toLowerCase().startsWith(\"http\")) {\r\n return RealityDataSource.createFromBlobUrl(orbitGtBlob.blobFileName,inputProvider,format);\r\n } else if (orbitGtBlob.rdsUrl) {\r\n return RealityDataSource.createRealityDataSourceKeyFromUrl(orbitGtBlob.rdsUrl,inputProvider,format);\r\n }\r\n const provider = inputProvider ? inputProvider : RealityDataProvider.OrbitGtBlob;\r\n const id = `${orbitGtBlob.accountName}:${orbitGtBlob.containerName}:${orbitGtBlob.blobFileName}:?${orbitGtBlob.sasToken}`;\r\n return { provider, format, id };\r\n }\r\n public static createOrbitGtBlobPropsFromKey(rdSourceKey: RealityDataSourceKey): OrbitGtBlobProps | undefined {\r\n if (rdSourceKey.provider !== RealityDataProvider.OrbitGtBlob)\r\n return undefined;\r\n const splitIds = rdSourceKey.id.split(\":\");\r\n const sasTokenIndex = rdSourceKey.id.indexOf(\":?\");\r\n const sasToken = rdSourceKey.id.substr(sasTokenIndex+2);\r\n const orbitGtBlob: OrbitGtBlobProps = {\r\n accountName: splitIds[0],\r\n containerName: splitIds[1],\r\n blobFileName: splitIds[2],\r\n sasToken,\r\n };\r\n\r\n return orbitGtBlob;\r\n }\r\n /** Construct a new reality data source.\r\n * @param props JSON representation of the reality data source\r\n */\r\n public static fromProps(props: RealityDataSourceProps): RealityDataSource {\r\n return new RealityDataSource(props);\r\n }\r\n public get isContextShare() {\r\n return (this.rdSourceKey.provider === RealityDataProvider.ContextShare);\r\n }\r\n public get realityDataId(): string | undefined {\r\n const realityDataId = this.isContextShare ? this.rdSourceKey.id : undefined;\r\n return realityDataId;\r\n }\r\n public get iTwinId(): string | undefined {\r\n return this.rdSourceKey.iTwinId;\r\n }\r\n\r\n /**\r\n * This method returns the URL to access the actual 3d tiles from the service provider.\r\n * @returns string containing the URL to reality data.\r\n */\r\n public async getServiceUrl(iTwinId: GuidString | undefined): Promise<string | undefined> {\r\n // If url was not resolved - resolve it\r\n if (this.isContextShare && !this._isUrlResolved) {\r\n const rdSourceKey = this.rdSourceKey;\r\n // we need to resolve tilesetURl from realityDataId and iTwinId\r\n if (undefined === IModelApp.realityDataAccess)\r\n throw new Error(\"Missing an implementation of RealityDataAccess on IModelApp, it is required to access reality data. Please provide an implementation to the IModelApp.startup using IModelAppOptions.realityDataAccess.\");\r\n try {\r\n const resolvedITwinId = iTwinId ? iTwinId : rdSourceKey.iTwinId;\r\n\r\n this._tilesetUrl = await IModelApp.realityDataAccess.getRealityDataUrl(resolvedITwinId, rdSourceKey.id);\r\n this._isUrlResolved=true;\r\n } catch (e) {\r\n const errMsg = `Error getting URL from ContextShare using realityDataId=${rdSourceKey.id} and iTwinId=${iTwinId}`;\r\n Logger.logError(FrontendLoggerCategory.RealityData, errMsg);\r\n }\r\n } else if (this.rdSourceKey.provider === RealityDataProvider.TilesetUrl || this.rdSourceKey.provider === RealityDataProvider.CesiumIonAsset) {\r\n this._tilesetUrl = this.rdSourceKey.id;\r\n }\r\n return this._tilesetUrl;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RealityDataSource.js","sourceRoot":"","sources":["../../src/RealityDataSource.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,OAAO,EAAE,OAAO,EAAkB,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAe,aAAa,EAAc,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,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AI,CAAC;QAErC,IAAI,MAAM,IAAI,IAAI,CAAC,WAAW,EAAE;YAC9B,OAAO,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;SACtE;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;;AAlPc,yCAAmB,GAAG,IAAI,GAAG,EAA6B,CAAC","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 { getJson, request, RequestOptions } from \"@bentley/itwin-client\";\r\nimport { AccessToken, BentleyStatus, GuidString, Logger } from \"@itwin/core-bentley\";\r\nimport { IModelError, OrbitGtBlobProps, RealityDataFormat, RealityDataProvider, RealityDataSourceKey, RealityDataSourceProps } from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"./FrontendLoggerCategory\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { RealityData } from \"./RealityDataAccessProps\";\r\nimport { CesiumIonAssetProvider, ContextShareProvider, getCesiumAccessTokenAndEndpointUrl } from \"./tile/internal\";\r\n\r\n/**\r\n * This interface provide methods used to access a reality data from a reality data provider\r\n * @alpha\r\n */\r\nexport interface RealityDataSource {\r\n readonly key: RealityDataSourceKey;\r\n readonly isContextShare: boolean;\r\n readonly realityDataId: string | undefined;\r\n /** Metatdata on the reality data source */\r\n readonly realityData: RealityData | undefined;\r\n /** The reality data type (e.g.: \"RealityMesh3DTiles\", OPC, Terrain3DTiles, Cesium3DTiles, ... )*/\r\n readonly realityDataType: string | undefined;\r\n /**\r\n * This method returns the URL to obtain the Reality Data properties.\r\n * @param iTwinId id of associated iTwin project\r\n * @returns string containing the URL to reality data.\r\n */\r\n getServiceUrl(iTwinId: GuidString | undefined): Promise<string | undefined>;\r\n\r\n /**\r\n * Gets a reality data root document json\r\n * @returns tile data json\r\n * @internal\r\n */\r\n getRootDocument(iTwinId: GuidString | undefined): Promise<any>;\r\n /**\r\n * Gets tile content\r\n * @param name name or path of tile\r\n * @returns array buffer of tile content\r\n * @internal\r\n */\r\n getTileContent(name: string): Promise<any>;\r\n /**\r\n * Gets a tileset's app data json\r\n * @param name name or path of tile\r\n * @returns app data json object\r\n * @internal\r\n */\r\n getTileJson(name: string): Promise<any>;\r\n}\r\n/** @alpha */\r\nexport namespace RealityDataSource {\r\n /** Utility function to convert a RealityDataSourceKey into its string representation\r\n * @alpha\r\n */\r\n export function keyToString(rdSourceKey: RealityDataSourceKey): string {\r\n return `${rdSourceKey.provider}:${rdSourceKey.format}:${rdSourceKey.id}:${rdSourceKey.iTwinId}`;\r\n }\r\n export function formatfromUrl(tilesetUrl: string): RealityDataFormat {\r\n let format = RealityDataFormat.ThreeDTile;\r\n if (tilesetUrl.includes(\".opc\"))\r\n format = RealityDataFormat.OPC;\r\n return format;\r\n }\r\n export function createKeyFromUrl(tilesetUrl: string, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n let format = inputFormat ? inputFormat : formatfromUrl(tilesetUrl);\r\n if (CesiumIonAssetProvider.isProviderUrl(tilesetUrl)) {\r\n const provider = inputProvider ? inputProvider : RealityDataProvider.CesiumIonAsset;\r\n const cesiumIonAssetKey: RealityDataSourceKey = { provider, format, id: tilesetUrl };\r\n return cesiumIonAssetKey;\r\n }\r\n\r\n // Try to extract realityDataId from URL and if not possible, use the url as the key\r\n if (ContextShareProvider.isProviderUrl(tilesetUrl)) {\r\n const info = ContextShareProvider.getInfoFromUrl(tilesetUrl);\r\n const provider = inputProvider ? inputProvider : info.provider;\r\n format = inputFormat ? inputFormat : info.format;\r\n const contextShareKey: RealityDataSourceKey = { provider, format, id: info.id, iTwinId: info.iTwinId };\r\n return contextShareKey;\r\n }\r\n\r\n // default to tileSetUrl\r\n const provider2 = inputProvider ? inputProvider : RealityDataProvider.TilesetUrl;\r\n const urlKey: RealityDataSourceKey = { provider: provider2, format, id: tilesetUrl };\r\n return urlKey;\r\n }\r\n export function createKeyFromBlobUrl(blobUrl: string, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n const info = ContextShareProvider.getInfoFromBlobUrl(blobUrl);\r\n const format = inputFormat ? inputFormat : info.format;\r\n const provider = inputProvider ? inputProvider : info.provider;\r\n const contextShareKey: RealityDataSourceKey = { provider, format, id: info.id };\r\n return contextShareKey;\r\n }\r\n export function createKeyFromOrbitGtBlobProps(orbitGtBlob: OrbitGtBlobProps, inputProvider?: RealityDataProvider, inputFormat?: RealityDataFormat): RealityDataSourceKey {\r\n const format = inputFormat ? inputFormat : RealityDataFormat.OPC;\r\n if(orbitGtBlob.blobFileName && orbitGtBlob.blobFileName.toLowerCase().startsWith(\"http\")) {\r\n return RealityDataSource.createKeyFromBlobUrl(orbitGtBlob.blobFileName,inputProvider,format);\r\n } else if (orbitGtBlob.rdsUrl) {\r\n return RealityDataSource.createKeyFromUrl(orbitGtBlob.rdsUrl,inputProvider,format);\r\n }\r\n const provider = inputProvider ? inputProvider : RealityDataProvider.OrbitGtBlob;\r\n const id = `${orbitGtBlob.accountName}:${orbitGtBlob.containerName}:${orbitGtBlob.blobFileName}:?${orbitGtBlob.sasToken}`;\r\n return { provider, format, id };\r\n }\r\n export function createOrbitGtBlobPropsFromKey(rdSourceKey: RealityDataSourceKey): OrbitGtBlobProps | undefined {\r\n if (rdSourceKey.provider !== RealityDataProvider.OrbitGtBlob)\r\n return undefined;\r\n const splitIds = rdSourceKey.id.split(\":\");\r\n const sasTokenIndex = rdSourceKey.id.indexOf(\":?\");\r\n const sasToken = rdSourceKey.id.substr(sasTokenIndex+2);\r\n const orbitGtBlob: OrbitGtBlobProps = {\r\n accountName: splitIds[0],\r\n containerName: splitIds[1],\r\n blobFileName: splitIds[2],\r\n sasToken,\r\n };\r\n return orbitGtBlob;\r\n }\r\n /** Return an instance of a RealityDataSource from a source key.\r\n * There will aways be only one reality data RealityDataSource for a corresponding reality data source key.\r\n * @internal\r\n */\r\n export async function fromKey(rdSourceKey: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined> {\r\n return RealityDataSourceImpl.fromKey(rdSourceKey, iTwinId);\r\n }\r\n}\r\n\r\n/** This class provides access to the reality data provider services.\r\n * It encapsulates access to a reality data wether it be from local access, http or ProjectWise Context Share.\r\n * The key provided at the creation determines if this is ProjectWise Context Share reference.\r\n * If not then it is considered local (ex: C:\\temp\\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)\r\n * There is a one to one relationship between a reality data and the instances of present class.\r\n* @alpha\r\n*/\r\nclass RealityDataSourceImpl implements RealityDataSource {\r\n private static _realityDataSources = new Map<string, RealityDataSource>();\r\n public readonly key: RealityDataSourceKey;\r\n /** The URL that supplies the 3d tiles for displaying the reality model. */\r\n private _tilesetUrl: string | undefined;\r\n private _isUrlResolved: boolean = false;\r\n private _rd: RealityData | undefined;\r\n /** For use by all Reality Data. For RD stored on PW Context Share, represents the portion from the root of the Azure Blob Container*/\r\n private _baseUrl: string = \"\";\r\n /** Request authorization for non PW ContextShare requests.*/\r\n private _requestAuthorization?: string;\r\n\r\n /** Construct a new reality data source.\r\n * @param props JSON representation of the reality data source\r\n */\r\n protected constructor(props: RealityDataSourceProps) {\r\n this.key = props.sourceKey;\r\n this._isUrlResolved=false;\r\n }\r\n\r\n /** Construct a new reality data source.\r\n * @param props JSON representation of the reality data source\r\n */\r\n public static fromProps(props: RealityDataSourceProps): RealityDataSource {\r\n return new RealityDataSourceImpl(props);\r\n }\r\n /**\r\n * Create an instance of this class from a source key and iTwin context/\r\n * @alpha\r\n */\r\n public static async createFromKey(sourceKey: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined> {\r\n const rdSource = new RealityDataSourceImpl({sourceKey});\r\n let tilesetUrl: string | undefined;\r\n try {\r\n await rdSource.queryRealityData(iTwinId);\r\n tilesetUrl = await rdSource.getServiceUrl(iTwinId);\r\n } catch (e) {\r\n }\r\n\r\n return (tilesetUrl !== undefined) ? rdSource: undefined;\r\n }\r\n /** Return an instance of a RealityDataSource from a source key.\r\n * There will aways be only one reality data connection for a corresponding reality data source key.\r\n * @alpha\r\n */\r\n public static async fromKey(rdSourceKey: RealityDataSourceKey, iTwinId: GuidString | undefined): Promise<RealityDataSource | undefined> {\r\n // search to see if it was already created\r\n const rdSourceKeyString = RealityDataSource.keyToString(rdSourceKey);\r\n let rdSource = RealityDataSourceImpl._realityDataSources.get(rdSourceKeyString);\r\n if (rdSource)\r\n return rdSource;\r\n // If not already in our list, create and add it to our list before returing it.\r\n rdSource = await RealityDataSourceImpl.createFromKey(rdSourceKey, iTwinId);\r\n if (rdSource)\r\n RealityDataSourceImpl._realityDataSources.set(rdSourceKeyString,rdSource);\r\n return rdSource;\r\n }\r\n public get isContextShare(): boolean {\r\n return (this.key.provider === RealityDataProvider.ContextShare);\r\n }\r\n /**\r\n * Returns Reality Data if available\r\n */\r\n public get realityData(): RealityData | undefined {\r\n return this._rd;\r\n }\r\n public get realityDataId(): string | undefined {\r\n const realityDataId = this.isContextShare ? this.key.id : undefined;\r\n return realityDataId;\r\n }\r\n /**\r\n * Returns Reality Data type if available\r\n */\r\n public get realityDataType(): string | undefined {\r\n return this._rd?.type;\r\n }\r\n public get iTwinId(): string | undefined {\r\n return this.key.iTwinId;\r\n }\r\n /**\r\n * Query Reality Data from provider\r\n */\r\n private async queryRealityData(iTwinId: GuidString | undefined) {\r\n if (this.isContextShare && !this._rd) {\r\n const token = await IModelApp.getAccessToken();\r\n if (token && this.realityDataId) {\r\n if (undefined === IModelApp.realityDataAccess)\r\n throw new Error(\"Missing an implementation of RealityDataAccess on IModelApp, it is required to access reality data. Please provide an implementation to the IModelApp.startup using IModelAppOptions.realityDataAccess.\");\r\n this._rd = await IModelApp.realityDataAccess.getRealityData(token, iTwinId, this.realityDataId);\r\n // A reality data that has not root document set should not be considered.\r\n const rootDocument: string = this._rd.rootDocument ?? \"\";\r\n this.setBaseUrl(rootDocument);\r\n }\r\n }\r\n }\r\n // This is to set the root url from the provided root document path.\r\n // If the root document is stored on PW Context Share then the root document property of the Reality Data is provided,\r\n // otherwise the full path to root document is given.\r\n // The base URL contains the base URL from which tile relative path are constructed.\r\n // The tile's path root will need to be reinserted for child tiles to return a 200\r\n private setBaseUrl(url: string): void {\r\n const urlParts = url.split(\"/\");\r\n urlParts.pop();\r\n if (urlParts.length === 0)\r\n this._baseUrl = \"\";\r\n else\r\n this._baseUrl = `${urlParts.join(\"/\")}/`;\r\n }\r\n private async _doRequest(url: string, responseType: string): Promise<any> {\r\n let options: RequestOptions = {\r\n method: \"GET\",\r\n responseType,\r\n };\r\n\r\n const authToken = this._requestAuthorization;\r\n if (authToken) {\r\n options = {\r\n ...options,\r\n headers: {\r\n authorization: authToken,\r\n },\r\n };\r\n }\r\n\r\n const data = await request(url, options);\r\n return data.body;\r\n }\r\n /**\r\n * Gets a tileset's app data json\r\n * @param name name or path of tile\r\n * @returns app data json object\r\n * @internal\r\n */\r\n public async getRealityDataTileJson(accessToken: AccessToken, name: string, realityData: RealityData): Promise<any> {\r\n const url = await realityData.getBlobUrl(accessToken, name);\r\n\r\n const data = await getJson(url.toString());\r\n return data;\r\n }\r\n /**\r\n * This method returns the URL to access the actual 3d tiles from the service provider.\r\n * @returns string containing the URL to reality data.\r\n */\r\n public async getServiceUrl(iTwinId: GuidString | undefined): Promise<string | undefined> {\r\n // If url was not resolved - resolve it\r\n if (this.isContextShare && !this._isUrlResolved) {\r\n const rdSourceKey = this.key;\r\n // we need to resolve tilesetURl from realityDataId and iTwinId\r\n if (undefined === IModelApp.realityDataAccess)\r\n throw new Error(\"Missing an implementation of RealityDataAccess on IModelApp, it is required to access reality data. Please provide an implementation to the IModelApp.startup using IModelAppOptions.realityDataAccess.\");\r\n try {\r\n const resolvedITwinId = iTwinId ? iTwinId : rdSourceKey.iTwinId;\r\n\r\n this._tilesetUrl = await IModelApp.realityDataAccess.getRealityDataUrl(resolvedITwinId, rdSourceKey.id);\r\n this._isUrlResolved=true;\r\n } catch (e) {\r\n const errMsg = `Error getting URL from ContextShare using realityDataId=${rdSourceKey.id} and iTwinId=${iTwinId}`;\r\n Logger.logError(FrontendLoggerCategory.RealityData, errMsg);\r\n }\r\n } else if (this.key.provider === RealityDataProvider.TilesetUrl || this.key.provider === RealityDataProvider.CesiumIonAsset) {\r\n this._tilesetUrl = this.key.id;\r\n }\r\n return this._tilesetUrl;\r\n }\r\n /** TODO: This probably required three different realitydataSource implementations based on different provider -> locally hosted, RDS and cesium */\r\n public async getRootDocument(iTwinId: GuidString | undefined): Promise<any> {\r\n const token = await IModelApp.getAccessToken();\r\n if (this.isContextShare && token) {\r\n const realityData = this.realityData;\r\n\r\n if (!realityData)\r\n throw new Error(`Reality Data not defined`);\r\n\r\n if (!realityData.rootDocument)\r\n throw new Error(`Root document not defined for reality data: ${realityData.id}`);\r\n\r\n return this.getRealityDataTileJson(token, realityData.rootDocument, realityData);\r\n }\r\n\r\n let url = await this.getServiceUrl(iTwinId);\r\n if (!url)\r\n throw new IModelError(BentleyStatus.ERROR, \"Unable to get service url\");\r\n\r\n // The following is only if the reality data is not stored on PW Context Share.\r\n const cesiumAsset = CesiumIonAssetProvider.parseCesiumUrl(url);\r\n if (cesiumAsset) {\r\n const tokenAndUrl = await getCesiumAccessTokenAndEndpointUrl(cesiumAsset.id, cesiumAsset.key);\r\n if (tokenAndUrl.url && tokenAndUrl.token) {\r\n url = tokenAndUrl.url;\r\n this._requestAuthorization = `Bearer ${tokenAndUrl.token}`;\r\n }\r\n }\r\n\r\n // The following is only if the reality data is not stored on PW Context Share.\r\n this.setBaseUrl(url);\r\n return this._doRequest(url, \"json\");\r\n }\r\n\r\n /**\r\n * Gets tile content\r\n * @param name name or path of tile\r\n * @returns array buffer of tile content\r\n */\r\n public async getRealityDataTileContent(accessToken: AccessToken, name: string, realityData: RealityData): Promise<any> {\r\n const url = await realityData.getBlobUrl(accessToken, name);\r\n const options: RequestOptions = {\r\n method: \"GET\",\r\n responseType: \"arraybuffer\",\r\n };\r\n const data = await request(url.toString(), options);\r\n return data.body;\r\n }\r\n\r\n /**\r\n * TODO: This probably required different realitydataSource implementations based on different provider -> locally hosted, RDS and cesium\r\n * Returns the tile content. The path to the tile is relative to the base url of present reality data whatever the type.\r\n */\r\n public async getTileContent(name: string): Promise<any> {\r\n const token = await IModelApp.getAccessToken();\r\n const useRds = this.isContextShare && token !== undefined;\r\n const tileUrl = this._baseUrl + name;\r\n\r\n if (useRds && this.realityData) {\r\n return this.getRealityDataTileContent(token, tileUrl, this.realityData);\r\n }\r\n\r\n return this._doRequest(tileUrl, \"arraybuffer\");\r\n }\r\n\r\n /**\r\n * TODO: This probably required different realitydataSource implementations based on different provider -> locally hosted, RDS and cesium\r\n * 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.\r\n */\r\n public async getTileJson(name: string): Promise<any> {\r\n const token = await IModelApp.getAccessToken();\r\n const useRds = this.isContextShare && token !== undefined;\r\n const tileUrl = this._baseUrl + name;\r\n\r\n if (useRds && this.realityData) {\r\n return this.getRealityDataTileJson(token, tileUrl, this.realityData);\r\n }\r\n\r\n return this._doRequest(tileUrl, \"json\");\r\n }\r\n}\r\n\r\n"]}
|
|
@@ -2,21 +2,50 @@
|
|
|
2
2
|
* @module Views
|
|
3
3
|
*/
|
|
4
4
|
import { Viewport } from "./Viewport";
|
|
5
|
-
/** Forms a bidirectional connection between two [[Viewport]]s such that the [
|
|
6
|
-
* For example, panning in one viewport will cause the other viewport to pan by the same distance
|
|
5
|
+
/** Forms a bidirectional connection between two [[Viewport]]s such that the [[ViewState]]s of each are synchronized with one another.
|
|
6
|
+
* For example, panning in one viewport will cause the other viewport to pan by the same distance, and changing the [RenderMode]($common) of one viewport
|
|
7
|
+
* will change it in the other viewport.
|
|
8
|
+
* By default, all aspects of the views - display style, category and model selectors, frustum, etc - are synchronized, but this can be customized by
|
|
9
|
+
* subclassing and overriding the [[syncViewports]] and [[connectViewports]] methods.
|
|
7
10
|
* @see [Multiple Viewport Sample](https://www.itwinjs.org/sample-showcase/?group=Viewer+Features&sample=multi-viewport-sample&imodel=Metrostation+Sample)
|
|
8
11
|
* for an interactive demonstration.
|
|
12
|
+
* @see [[TwoWayViewportFrustumSync]] to synchronize only the frusta of the viewports.
|
|
9
13
|
* @public
|
|
10
14
|
*/
|
|
11
15
|
export declare class TwoWayViewportSync {
|
|
12
|
-
|
|
16
|
+
protected readonly _disconnect: VoidFunction[];
|
|
13
17
|
private _isEcho;
|
|
14
18
|
private syncView;
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
19
|
+
/** Invoked from [[connect]] to set up the initial synchronization between the two viewports.
|
|
20
|
+
* `target` should be modified to match `source`.
|
|
21
|
+
* The default implementation applies a clone of `source`'s [[ViewState]] to `target`.
|
|
22
|
+
* @see [[syncViewports]] to customize subsequent synchronization.
|
|
17
23
|
*/
|
|
18
|
-
|
|
24
|
+
protected connectViewports(source: Viewport, target: Viewport): void;
|
|
25
|
+
/** Invoked each time `source` changes to update `target` to match.
|
|
26
|
+
* The default implementation applies a clone of `source`'s [[ViewState]] to `target`.
|
|
27
|
+
* @param source The viewport that changed
|
|
28
|
+
* @param target The viewport that should be updated to match `source`
|
|
29
|
+
* @see [[connectViewports]] to set up the initial synchronization between the two viewports.
|
|
30
|
+
*/
|
|
31
|
+
protected syncViewports(source: Viewport, target: Viewport): void;
|
|
32
|
+
/** Establish the connection between two Viewports. When this method is called, `viewport2` is initialized with the state of `viewport1` via [[connectViewports]].
|
|
33
|
+
* Thereafter, any change to the frustum of either viewport will be reflected in the frustum of the other viewport via [[syncViewports]].
|
|
34
|
+
*/
|
|
35
|
+
connect(viewport1: Viewport, viewport2: Viewport): void;
|
|
19
36
|
/** Remove the connection between the two views. */
|
|
20
37
|
disconnect(): void;
|
|
21
38
|
}
|
|
39
|
+
/** Forms a bidirectional connection between two [[Viewport]]s such that the [Frustum]($common)s of each are synchronized with one another.
|
|
40
|
+
* For example, zooming out in one viewport will zoom out by the same distance in the other viewport.
|
|
41
|
+
* No other aspects of the viewports are synchronized - they may have entirely different display styles, category/model selectors, etc.
|
|
42
|
+
* @see [[TwoWayViewportSync]] to synchronize all aspects of the viewports.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export declare class TwoWayViewportFrustumSync extends TwoWayViewportSync {
|
|
46
|
+
/** @internal override */
|
|
47
|
+
protected syncViewports(source: Viewport, target: Viewport): void;
|
|
48
|
+
/** @internal override */
|
|
49
|
+
protected connectViewports(source: Viewport, target: Viewport): void;
|
|
50
|
+
}
|
|
22
51
|
//# sourceMappingURL=TwoWayViewportSync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TwoWayViewportSync.d.ts","sourceRoot":"","sources":["../../src/TwoWayViewportSync.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC
|
|
1
|
+
{"version":3,"file":"TwoWayViewportSync.d.ts","sourceRoot":"","sources":["../../src/TwoWayViewportSync.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;GASG;AACH,qBAAa,kBAAkB;IAC7B,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,EAAE,CAAM;IACpD,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,QAAQ;IAShB;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAKpE;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAIjE;;OAEG;IACI,OAAO,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ;IAUvD,mDAAmD;IAC5C,UAAU;CAIlB;AAED;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,kBAAkB;IAC/D,yBAAyB;cACN,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAM1E,yBAAyB;cACN,gBAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;CAG9E"}
|