@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
|
@@ -4,116 +4,73 @@
|
|
|
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.RealityDataSource =
|
|
7
|
+
exports.RealityDataSource = void 0;
|
|
8
|
+
const itwin_client_1 = require("@bentley/itwin-client");
|
|
8
9
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
10
|
const core_common_1 = require("@itwin/core-common");
|
|
10
11
|
const FrontendLoggerCategory_1 = require("./FrontendLoggerCategory");
|
|
11
12
|
const IModelApp_1 = require("./IModelApp");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.rdSourceKey = props.sourceKey;
|
|
29
|
-
this._isUrlResolved = false;
|
|
13
|
+
const internal_1 = require("./tile/internal");
|
|
14
|
+
/** @alpha */
|
|
15
|
+
var RealityDataSource;
|
|
16
|
+
(function (RealityDataSource) {
|
|
17
|
+
/** Utility function to convert a RealityDataSourceKey into its string representation
|
|
18
|
+
* @alpha
|
|
19
|
+
*/
|
|
20
|
+
function keyToString(rdSourceKey) {
|
|
21
|
+
return `${rdSourceKey.provider}:${rdSourceKey.format}:${rdSourceKey.id}:${rdSourceKey.iTwinId}`;
|
|
22
|
+
}
|
|
23
|
+
RealityDataSource.keyToString = keyToString;
|
|
24
|
+
function formatfromUrl(tilesetUrl) {
|
|
25
|
+
let format = core_common_1.RealityDataFormat.ThreeDTile;
|
|
26
|
+
if (tilesetUrl.includes(".opc"))
|
|
27
|
+
format = core_common_1.RealityDataFormat.OPC;
|
|
28
|
+
return format;
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
RealityDataSource.formatfromUrl = formatfromUrl;
|
|
31
|
+
function createKeyFromUrl(tilesetUrl, inputProvider, inputFormat) {
|
|
32
|
+
let format = inputFormat ? inputFormat : formatfromUrl(tilesetUrl);
|
|
33
|
+
if (internal_1.CesiumIonAssetProvider.isProviderUrl(tilesetUrl)) {
|
|
34
34
|
const provider = inputProvider ? inputProvider : core_common_1.RealityDataProvider.CesiumIonAsset;
|
|
35
35
|
const cesiumIonAssetKey = { provider, format, id: tilesetUrl };
|
|
36
36
|
return cesiumIonAssetKey;
|
|
37
37
|
}
|
|
38
38
|
// Try to extract realityDataId from URL and if not possible, use the url as the key
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const invalidUrlKey = { provider: core_common_1.RealityDataProvider.TilesetUrl, format, id: tilesetUrl };
|
|
46
|
-
return invalidUrlKey;
|
|
47
|
-
}
|
|
48
|
-
// detect if it is a RDS url
|
|
49
|
-
const formattedUrl1 = attUrl.pathname.replace(/~2F/g, "/").replace(/\\/g, "/");
|
|
50
|
-
if (formattedUrl1) {
|
|
51
|
-
const urlParts1 = formattedUrl1.split("/").map((entry) => entry.replace(/%2D/g, "-"));
|
|
52
|
-
let partOffset1 = 0;
|
|
53
|
-
urlParts1.find((value, index) => {
|
|
54
|
-
if (value === "Repositories") {
|
|
55
|
-
partOffset1 = index;
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
});
|
|
60
|
-
const isOPC = attUrl.pathname.match(".opc*") !== null;
|
|
61
|
-
const isRDSUrl = (urlParts1[partOffset1] === "Repositories") && (urlParts1[partOffset1 + 1].match("S3MXECPlugin--*") !== null) && (urlParts1[partOffset1 + 2] === "S3MX");
|
|
62
|
-
let projectId;
|
|
63
|
-
const projectIdSection = urlParts1.find((val) => val.includes("--"));
|
|
64
|
-
if (projectIdSection)
|
|
65
|
-
projectId = projectIdSection.split("--")[1];
|
|
66
|
-
// Make sure the url to compare are REALITYMESH3DTILES url, otherwise, compare the url directly
|
|
67
|
-
if (isRDSUrl || isOPC) {
|
|
68
|
-
// Make sure the reality data id are the same
|
|
69
|
-
const guid1 = urlParts1.find(core_bentley_1.Guid.isGuid);
|
|
70
|
-
if (guid1 !== undefined) {
|
|
71
|
-
const provider = inputProvider ? inputProvider : core_common_1.RealityDataProvider.ContextShare;
|
|
72
|
-
format = inputFormat ? inputFormat : isOPC ? core_common_1.RealityDataFormat.OPC : core_common_1.RealityDataFormat.ThreeDTile;
|
|
73
|
-
const contextShareKey = { provider, format, id: guid1, iTwinId: projectId };
|
|
74
|
-
return contextShareKey;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
39
|
+
if (internal_1.ContextShareProvider.isProviderUrl(tilesetUrl)) {
|
|
40
|
+
const info = internal_1.ContextShareProvider.getInfoFromUrl(tilesetUrl);
|
|
41
|
+
const provider = inputProvider ? inputProvider : info.provider;
|
|
42
|
+
format = inputFormat ? inputFormat : info.format;
|
|
43
|
+
const contextShareKey = { provider, format, id: info.id, iTwinId: info.iTwinId };
|
|
44
|
+
return contextShareKey;
|
|
77
45
|
}
|
|
78
46
|
// default to tileSetUrl
|
|
79
47
|
const provider2 = inputProvider ? inputProvider : core_common_1.RealityDataProvider.TilesetUrl;
|
|
80
48
|
const urlKey = { provider: provider2, format, id: tilesetUrl };
|
|
81
49
|
return urlKey;
|
|
82
50
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return { provider, format, id: blobUrl };
|
|
90
|
-
// const accountName = url.hostname.split(".")[0];
|
|
91
|
-
let containerName = "";
|
|
92
|
-
if (url.pathname) {
|
|
93
|
-
const pathSplit = url.pathname.split("/");
|
|
94
|
-
containerName = pathSplit[1];
|
|
95
|
-
}
|
|
96
|
-
// const blobFileName = `/${pathSplit[2]}`;
|
|
97
|
-
// const sasToken = url.search.substr(1);
|
|
98
|
-
const isOPC = url.pathname.match(".opc*") !== null;
|
|
99
|
-
provider = inputProvider ? inputProvider : core_common_1.RealityDataProvider.ContextShare;
|
|
100
|
-
format = inputFormat ? inputFormat : isOPC ? core_common_1.RealityDataFormat.OPC : core_common_1.RealityDataFormat.ThreeDTile;
|
|
101
|
-
const contextShareKey = { provider, format, id: containerName };
|
|
51
|
+
RealityDataSource.createKeyFromUrl = createKeyFromUrl;
|
|
52
|
+
function createKeyFromBlobUrl(blobUrl, inputProvider, inputFormat) {
|
|
53
|
+
const info = internal_1.ContextShareProvider.getInfoFromBlobUrl(blobUrl);
|
|
54
|
+
const format = inputFormat ? inputFormat : info.format;
|
|
55
|
+
const provider = inputProvider ? inputProvider : info.provider;
|
|
56
|
+
const contextShareKey = { provider, format, id: info.id };
|
|
102
57
|
return contextShareKey;
|
|
103
58
|
}
|
|
104
|
-
|
|
59
|
+
RealityDataSource.createKeyFromBlobUrl = createKeyFromBlobUrl;
|
|
60
|
+
function createKeyFromOrbitGtBlobProps(orbitGtBlob, inputProvider, inputFormat) {
|
|
105
61
|
const format = inputFormat ? inputFormat : core_common_1.RealityDataFormat.OPC;
|
|
106
62
|
if (orbitGtBlob.blobFileName && orbitGtBlob.blobFileName.toLowerCase().startsWith("http")) {
|
|
107
|
-
return RealityDataSource.
|
|
63
|
+
return RealityDataSource.createKeyFromBlobUrl(orbitGtBlob.blobFileName, inputProvider, format);
|
|
108
64
|
}
|
|
109
65
|
else if (orbitGtBlob.rdsUrl) {
|
|
110
|
-
return RealityDataSource.
|
|
66
|
+
return RealityDataSource.createKeyFromUrl(orbitGtBlob.rdsUrl, inputProvider, format);
|
|
111
67
|
}
|
|
112
68
|
const provider = inputProvider ? inputProvider : core_common_1.RealityDataProvider.OrbitGtBlob;
|
|
113
69
|
const id = `${orbitGtBlob.accountName}:${orbitGtBlob.containerName}:${orbitGtBlob.blobFileName}:?${orbitGtBlob.sasToken}`;
|
|
114
70
|
return { provider, format, id };
|
|
115
71
|
}
|
|
116
|
-
|
|
72
|
+
RealityDataSource.createKeyFromOrbitGtBlobProps = createKeyFromOrbitGtBlobProps;
|
|
73
|
+
function createOrbitGtBlobPropsFromKey(rdSourceKey) {
|
|
117
74
|
if (rdSourceKey.provider !== core_common_1.RealityDataProvider.OrbitGtBlob)
|
|
118
75
|
return undefined;
|
|
119
76
|
const splitIds = rdSourceKey.id.split(":");
|
|
@@ -127,21 +84,151 @@ class RealityDataSource {
|
|
|
127
84
|
};
|
|
128
85
|
return orbitGtBlob;
|
|
129
86
|
}
|
|
87
|
+
RealityDataSource.createOrbitGtBlobPropsFromKey = createOrbitGtBlobPropsFromKey;
|
|
88
|
+
/** Return an instance of a RealityDataSource from a source key.
|
|
89
|
+
* There will aways be only one reality data RealityDataSource for a corresponding reality data source key.
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
async function fromKey(rdSourceKey, iTwinId) {
|
|
93
|
+
return RealityDataSourceImpl.fromKey(rdSourceKey, iTwinId);
|
|
94
|
+
}
|
|
95
|
+
RealityDataSource.fromKey = fromKey;
|
|
96
|
+
})(RealityDataSource = exports.RealityDataSource || (exports.RealityDataSource = {}));
|
|
97
|
+
/** This class provides access to the reality data provider services.
|
|
98
|
+
* It encapsulates access to a reality data wether it be from local access, http or ProjectWise Context Share.
|
|
99
|
+
* The key provided at the creation determines if this is ProjectWise Context Share reference.
|
|
100
|
+
* If not then it is considered local (ex: C:\temp\TileRoot.json) or plain http access (http://someserver.com/data/TileRoot.json)
|
|
101
|
+
* There is a one to one relationship between a reality data and the instances of present class.
|
|
102
|
+
* @alpha
|
|
103
|
+
*/
|
|
104
|
+
class RealityDataSourceImpl {
|
|
105
|
+
/** Construct a new reality data source.
|
|
106
|
+
* @param props JSON representation of the reality data source
|
|
107
|
+
*/
|
|
108
|
+
constructor(props) {
|
|
109
|
+
this._isUrlResolved = false;
|
|
110
|
+
/** For use by all Reality Data. For RD stored on PW Context Share, represents the portion from the root of the Azure Blob Container*/
|
|
111
|
+
this._baseUrl = "";
|
|
112
|
+
this.key = props.sourceKey;
|
|
113
|
+
this._isUrlResolved = false;
|
|
114
|
+
}
|
|
130
115
|
/** Construct a new reality data source.
|
|
131
116
|
* @param props JSON representation of the reality data source
|
|
132
117
|
*/
|
|
133
118
|
static fromProps(props) {
|
|
134
|
-
return new
|
|
119
|
+
return new RealityDataSourceImpl(props);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Create an instance of this class from a source key and iTwin context/
|
|
123
|
+
* @alpha
|
|
124
|
+
*/
|
|
125
|
+
static async createFromKey(sourceKey, iTwinId) {
|
|
126
|
+
const rdSource = new RealityDataSourceImpl({ sourceKey });
|
|
127
|
+
let tilesetUrl;
|
|
128
|
+
try {
|
|
129
|
+
await rdSource.queryRealityData(iTwinId);
|
|
130
|
+
tilesetUrl = await rdSource.getServiceUrl(iTwinId);
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
}
|
|
134
|
+
return (tilesetUrl !== undefined) ? rdSource : undefined;
|
|
135
|
+
}
|
|
136
|
+
/** Return an instance of a RealityDataSource from a source key.
|
|
137
|
+
* There will aways be only one reality data connection for a corresponding reality data source key.
|
|
138
|
+
* @alpha
|
|
139
|
+
*/
|
|
140
|
+
static async fromKey(rdSourceKey, iTwinId) {
|
|
141
|
+
// search to see if it was already created
|
|
142
|
+
const rdSourceKeyString = RealityDataSource.keyToString(rdSourceKey);
|
|
143
|
+
let rdSource = RealityDataSourceImpl._realityDataSources.get(rdSourceKeyString);
|
|
144
|
+
if (rdSource)
|
|
145
|
+
return rdSource;
|
|
146
|
+
// If not already in our list, create and add it to our list before returing it.
|
|
147
|
+
rdSource = await RealityDataSourceImpl.createFromKey(rdSourceKey, iTwinId);
|
|
148
|
+
if (rdSource)
|
|
149
|
+
RealityDataSourceImpl._realityDataSources.set(rdSourceKeyString, rdSource);
|
|
150
|
+
return rdSource;
|
|
135
151
|
}
|
|
136
152
|
get isContextShare() {
|
|
137
|
-
return (this.
|
|
153
|
+
return (this.key.provider === core_common_1.RealityDataProvider.ContextShare);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Returns Reality Data if available
|
|
157
|
+
*/
|
|
158
|
+
get realityData() {
|
|
159
|
+
return this._rd;
|
|
138
160
|
}
|
|
139
161
|
get realityDataId() {
|
|
140
|
-
const realityDataId = this.isContextShare ? this.
|
|
162
|
+
const realityDataId = this.isContextShare ? this.key.id : undefined;
|
|
141
163
|
return realityDataId;
|
|
142
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns Reality Data type if available
|
|
167
|
+
*/
|
|
168
|
+
get realityDataType() {
|
|
169
|
+
var _a;
|
|
170
|
+
return (_a = this._rd) === null || _a === void 0 ? void 0 : _a.type;
|
|
171
|
+
}
|
|
143
172
|
get iTwinId() {
|
|
144
|
-
return this.
|
|
173
|
+
return this.key.iTwinId;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Query Reality Data from provider
|
|
177
|
+
*/
|
|
178
|
+
async queryRealityData(iTwinId) {
|
|
179
|
+
var _a;
|
|
180
|
+
if (this.isContextShare && !this._rd) {
|
|
181
|
+
const token = await IModelApp_1.IModelApp.getAccessToken();
|
|
182
|
+
if (token && this.realityDataId) {
|
|
183
|
+
if (undefined === IModelApp_1.IModelApp.realityDataAccess)
|
|
184
|
+
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.");
|
|
185
|
+
this._rd = await IModelApp_1.IModelApp.realityDataAccess.getRealityData(token, iTwinId, this.realityDataId);
|
|
186
|
+
// A reality data that has not root document set should not be considered.
|
|
187
|
+
const rootDocument = (_a = this._rd.rootDocument) !== null && _a !== void 0 ? _a : "";
|
|
188
|
+
this.setBaseUrl(rootDocument);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// This is to set the root url from the provided root document path.
|
|
193
|
+
// If the root document is stored on PW Context Share then the root document property of the Reality Data is provided,
|
|
194
|
+
// otherwise the full path to root document is given.
|
|
195
|
+
// The base URL contains the base URL from which tile relative path are constructed.
|
|
196
|
+
// The tile's path root will need to be reinserted for child tiles to return a 200
|
|
197
|
+
setBaseUrl(url) {
|
|
198
|
+
const urlParts = url.split("/");
|
|
199
|
+
urlParts.pop();
|
|
200
|
+
if (urlParts.length === 0)
|
|
201
|
+
this._baseUrl = "";
|
|
202
|
+
else
|
|
203
|
+
this._baseUrl = `${urlParts.join("/")}/`;
|
|
204
|
+
}
|
|
205
|
+
async _doRequest(url, responseType) {
|
|
206
|
+
let options = {
|
|
207
|
+
method: "GET",
|
|
208
|
+
responseType,
|
|
209
|
+
};
|
|
210
|
+
const authToken = this._requestAuthorization;
|
|
211
|
+
if (authToken) {
|
|
212
|
+
options = {
|
|
213
|
+
...options,
|
|
214
|
+
headers: {
|
|
215
|
+
authorization: authToken,
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
const data = await (0, itwin_client_1.request)(url, options);
|
|
220
|
+
return data.body;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Gets a tileset's app data json
|
|
224
|
+
* @param name name or path of tile
|
|
225
|
+
* @returns app data json object
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
async getRealityDataTileJson(accessToken, name, realityData) {
|
|
229
|
+
const url = await realityData.getBlobUrl(accessToken, name);
|
|
230
|
+
const data = await (0, itwin_client_1.getJson)(url.toString());
|
|
231
|
+
return data;
|
|
145
232
|
}
|
|
146
233
|
/**
|
|
147
234
|
* This method returns the URL to access the actual 3d tiles from the service provider.
|
|
@@ -150,7 +237,7 @@ class RealityDataSource {
|
|
|
150
237
|
async getServiceUrl(iTwinId) {
|
|
151
238
|
// If url was not resolved - resolve it
|
|
152
239
|
if (this.isContextShare && !this._isUrlResolved) {
|
|
153
|
-
const rdSourceKey = this.
|
|
240
|
+
const rdSourceKey = this.key;
|
|
154
241
|
// we need to resolve tilesetURl from realityDataId and iTwinId
|
|
155
242
|
if (undefined === IModelApp_1.IModelApp.realityDataAccess)
|
|
156
243
|
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.");
|
|
@@ -164,11 +251,78 @@ class RealityDataSource {
|
|
|
164
251
|
core_bentley_1.Logger.logError(FrontendLoggerCategory_1.FrontendLoggerCategory.RealityData, errMsg);
|
|
165
252
|
}
|
|
166
253
|
}
|
|
167
|
-
else if (this.
|
|
168
|
-
this._tilesetUrl = this.
|
|
254
|
+
else if (this.key.provider === core_common_1.RealityDataProvider.TilesetUrl || this.key.provider === core_common_1.RealityDataProvider.CesiumIonAsset) {
|
|
255
|
+
this._tilesetUrl = this.key.id;
|
|
169
256
|
}
|
|
170
257
|
return this._tilesetUrl;
|
|
171
258
|
}
|
|
259
|
+
/** TODO: This probably required three different realitydataSource implementations based on different provider -> locally hosted, RDS and cesium */
|
|
260
|
+
async getRootDocument(iTwinId) {
|
|
261
|
+
const token = await IModelApp_1.IModelApp.getAccessToken();
|
|
262
|
+
if (this.isContextShare && token) {
|
|
263
|
+
const realityData = this.realityData;
|
|
264
|
+
if (!realityData)
|
|
265
|
+
throw new Error(`Reality Data not defined`);
|
|
266
|
+
if (!realityData.rootDocument)
|
|
267
|
+
throw new Error(`Root document not defined for reality data: ${realityData.id}`);
|
|
268
|
+
return this.getRealityDataTileJson(token, realityData.rootDocument, realityData);
|
|
269
|
+
}
|
|
270
|
+
let url = await this.getServiceUrl(iTwinId);
|
|
271
|
+
if (!url)
|
|
272
|
+
throw new core_common_1.IModelError(core_bentley_1.BentleyStatus.ERROR, "Unable to get service url");
|
|
273
|
+
// The following is only if the reality data is not stored on PW Context Share.
|
|
274
|
+
const cesiumAsset = internal_1.CesiumIonAssetProvider.parseCesiumUrl(url);
|
|
275
|
+
if (cesiumAsset) {
|
|
276
|
+
const tokenAndUrl = await (0, internal_1.getCesiumAccessTokenAndEndpointUrl)(cesiumAsset.id, cesiumAsset.key);
|
|
277
|
+
if (tokenAndUrl.url && tokenAndUrl.token) {
|
|
278
|
+
url = tokenAndUrl.url;
|
|
279
|
+
this._requestAuthorization = `Bearer ${tokenAndUrl.token}`;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// The following is only if the reality data is not stored on PW Context Share.
|
|
283
|
+
this.setBaseUrl(url);
|
|
284
|
+
return this._doRequest(url, "json");
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Gets tile content
|
|
288
|
+
* @param name name or path of tile
|
|
289
|
+
* @returns array buffer of tile content
|
|
290
|
+
*/
|
|
291
|
+
async getRealityDataTileContent(accessToken, name, realityData) {
|
|
292
|
+
const url = await realityData.getBlobUrl(accessToken, name);
|
|
293
|
+
const options = {
|
|
294
|
+
method: "GET",
|
|
295
|
+
responseType: "arraybuffer",
|
|
296
|
+
};
|
|
297
|
+
const data = await (0, itwin_client_1.request)(url.toString(), options);
|
|
298
|
+
return data.body;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* TODO: This probably required different realitydataSource implementations based on different provider -> locally hosted, RDS and cesium
|
|
302
|
+
* Returns the tile content. The path to the tile is relative to the base url of present reality data whatever the type.
|
|
303
|
+
*/
|
|
304
|
+
async getTileContent(name) {
|
|
305
|
+
const token = await IModelApp_1.IModelApp.getAccessToken();
|
|
306
|
+
const useRds = this.isContextShare && token !== undefined;
|
|
307
|
+
const tileUrl = this._baseUrl + name;
|
|
308
|
+
if (useRds && this.realityData) {
|
|
309
|
+
return this.getRealityDataTileContent(token, tileUrl, this.realityData);
|
|
310
|
+
}
|
|
311
|
+
return this._doRequest(tileUrl, "arraybuffer");
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* TODO: This probably required different realitydataSource implementations based on different provider -> locally hosted, RDS and cesium
|
|
315
|
+
* 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.
|
|
316
|
+
*/
|
|
317
|
+
async getTileJson(name) {
|
|
318
|
+
const token = await IModelApp_1.IModelApp.getAccessToken();
|
|
319
|
+
const useRds = this.isContextShare && token !== undefined;
|
|
320
|
+
const tileUrl = this._baseUrl + name;
|
|
321
|
+
if (useRds && this.realityData) {
|
|
322
|
+
return this.getRealityDataTileJson(token, tileUrl, this.realityData);
|
|
323
|
+
}
|
|
324
|
+
return this._doRequest(tileUrl, "json");
|
|
325
|
+
}
|
|
172
326
|
}
|
|
173
|
-
|
|
327
|
+
RealityDataSourceImpl._realityDataSources = new Map();
|
|
174
328
|
//# sourceMappingURL=RealityDataSource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealityDataSource.js","sourceRoot":"","sources":["../../src/RealityDataSource.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA+D;AAC/D,oDAA4I;AAC5I,qEAAkE;AAClE,2CAAwC;AAExC;;EAEE;AACF,SAAgB,4BAA4B,CAAC,WAAiC;IAC5E,OAAO,GAAG,WAAW,CAAC,QAAQ,I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G;IACI,KAAK,CAAC,aAAa,CAAC,OAA+B;QACxD,uCAAuC;QACvC,IAAI,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;YACrC,+DAA+D;YAC/D,IAAI,SAAS,KAAK,qBAAS,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,qBAAS,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,qBAAM,CAAC,QAAQ,CAAC,+CAAsB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;aAC7D;SACF;aAAM,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,KAAK,iCAAmB,CAAC,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,KAAK,iCAAmB,CAAC,cAAc,EAAE;YAC3I,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;SACxC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AA9JD,8CA8JC","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":["../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E;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"}
|