@itwin/core-frontend 3.1.0-dev.24 → 3.1.0-dev.28
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/CHANGELOG.md +156 -35
- package/lib/cjs/DrawingViewState.d.ts.map +1 -1
- package/lib/cjs/DrawingViewState.js +6 -5
- package/lib/cjs/DrawingViewState.js.map +1 -1
- package/lib/cjs/IModelApp.d.ts +1 -3
- package/lib/cjs/IModelApp.d.ts.map +1 -1
- package/lib/cjs/IModelApp.js +8 -6
- package/lib/cjs/IModelApp.js.map +1 -1
- package/lib/cjs/RealityDataSource.d.ts +50 -14
- package/lib/cjs/RealityDataSource.d.ts.map +1 -1
- package/lib/cjs/RealityDataSource.js +19 -241
- package/lib/cjs/RealityDataSource.js.map +1 -1
- package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.d.ts +67 -0
- package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.d.ts.map +1 -0
- package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.js +166 -0
- package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.js.map +1 -0
- package/lib/cjs/RealityDataSourceContextShareImpl.d.ts +83 -0
- package/lib/cjs/RealityDataSourceContextShareImpl.d.ts.map +1 -0
- package/lib/cjs/RealityDataSourceContextShareImpl.js +234 -0
- package/lib/cjs/RealityDataSourceContextShareImpl.js.map +1 -0
- package/lib/cjs/RealityDataSourceTilesetUrlImpl.d.ts +65 -0
- package/lib/cjs/RealityDataSourceTilesetUrlImpl.d.ts.map +1 -0
- package/lib/cjs/RealityDataSourceTilesetUrlImpl.js +135 -0
- package/lib/cjs/RealityDataSourceTilesetUrlImpl.js.map +1 -0
- package/lib/cjs/SheetViewState.js +4 -0
- package/lib/cjs/SheetViewState.js.map +1 -1
- package/lib/cjs/ViewState.d.ts +8 -0
- package/lib/cjs/ViewState.d.ts.map +1 -1
- package/lib/cjs/ViewState.js.map +1 -1
- package/lib/cjs/Viewport.d.ts +19 -3
- package/lib/cjs/Viewport.d.ts.map +1 -1
- package/lib/cjs/Viewport.js +20 -0
- package/lib/cjs/Viewport.js.map +1 -1
- package/lib/cjs/core-frontend.d.ts +1 -0
- package/lib/cjs/core-frontend.d.ts.map +1 -1
- package/lib/cjs/core-frontend.js +1 -0
- package/lib/cjs/core-frontend.js.map +1 -1
- package/lib/cjs/quantity-formatting/BasicUnitsProvider.d.ts +2 -2
- package/lib/cjs/quantity-formatting/BasicUnitsProvider.d.ts.map +1 -1
- package/lib/cjs/quantity-formatting/BasicUnitsProvider.js +48 -44
- package/lib/cjs/quantity-formatting/BasicUnitsProvider.js.map +1 -1
- package/lib/cjs/quantity-formatting/QuantityFormatter.d.ts +90 -80
- package/lib/cjs/quantity-formatting/QuantityFormatter.d.ts.map +1 -1
- package/lib/cjs/quantity-formatting/QuantityFormatter.js +76 -45
- package/lib/cjs/quantity-formatting/QuantityFormatter.js.map +1 -1
- package/lib/cjs/quantity-formatting/QuantityTypesEditorSpecs.d.ts +54 -0
- package/lib/cjs/quantity-formatting/QuantityTypesEditorSpecs.d.ts.map +1 -0
- package/lib/cjs/quantity-formatting/QuantityTypesEditorSpecs.js +32 -0
- package/lib/cjs/quantity-formatting/QuantityTypesEditorSpecs.js.map +1 -0
- package/lib/cjs/quantity-formatting/UnitsData.d.ts +11 -0
- package/lib/cjs/quantity-formatting/UnitsData.d.ts.map +1 -0
- package/lib/cjs/quantity-formatting/UnitsData.js +59 -0
- package/lib/cjs/quantity-formatting/UnitsData.js.map +1 -0
- package/lib/cjs/tile/OPCFormatInterpreter.d.ts +21 -0
- package/lib/cjs/tile/OPCFormatInterpreter.d.ts.map +1 -0
- package/lib/cjs/tile/OPCFormatInterpreter.js +81 -0
- package/lib/cjs/tile/OPCFormatInterpreter.js.map +1 -0
- package/lib/cjs/tile/PntsReader.d.ts.map +1 -1
- package/lib/cjs/tile/PntsReader.js +79 -17
- package/lib/cjs/tile/PntsReader.js.map +1 -1
- package/lib/cjs/tile/ThreeDTileFormatInterpreter.d.ts +51 -0
- package/lib/cjs/tile/ThreeDTileFormatInterpreter.d.ts.map +1 -0
- package/lib/cjs/tile/ThreeDTileFormatInterpreter.js +160 -0
- package/lib/cjs/tile/ThreeDTileFormatInterpreter.js.map +1 -0
- package/lib/cjs/tile/internal.d.ts +2 -0
- package/lib/cjs/tile/internal.d.ts.map +1 -1
- package/lib/cjs/tile/internal.js +2 -0
- package/lib/cjs/tile/internal.js.map +1 -1
- package/lib/esm/DrawingViewState.d.ts.map +1 -1
- package/lib/esm/DrawingViewState.js +6 -5
- package/lib/esm/DrawingViewState.js.map +1 -1
- package/lib/esm/IModelApp.d.ts +1 -3
- package/lib/esm/IModelApp.d.ts.map +1 -1
- package/lib/esm/IModelApp.js +8 -6
- package/lib/esm/IModelApp.js.map +1 -1
- package/lib/esm/RealityDataSource.d.ts +50 -14
- package/lib/esm/RealityDataSource.d.ts.map +1 -1
- package/lib/esm/RealityDataSource.js +22 -244
- package/lib/esm/RealityDataSource.js.map +1 -1
- package/lib/esm/RealityDataSourceCesiumIonAssetImpl.d.ts +67 -0
- package/lib/esm/RealityDataSourceCesiumIonAssetImpl.d.ts.map +1 -0
- package/lib/esm/RealityDataSourceCesiumIonAssetImpl.js +162 -0
- package/lib/esm/RealityDataSourceCesiumIonAssetImpl.js.map +1 -0
- package/lib/esm/RealityDataSourceContextShareImpl.d.ts +83 -0
- package/lib/esm/RealityDataSourceContextShareImpl.d.ts.map +1 -0
- package/lib/esm/RealityDataSourceContextShareImpl.js +230 -0
- package/lib/esm/RealityDataSourceContextShareImpl.js.map +1 -0
- package/lib/esm/RealityDataSourceTilesetUrlImpl.d.ts +65 -0
- package/lib/esm/RealityDataSourceTilesetUrlImpl.d.ts.map +1 -0
- package/lib/esm/RealityDataSourceTilesetUrlImpl.js +131 -0
- package/lib/esm/RealityDataSourceTilesetUrlImpl.js.map +1 -0
- package/lib/esm/SheetViewState.js +4 -0
- package/lib/esm/SheetViewState.js.map +1 -1
- package/lib/esm/ViewState.d.ts +8 -0
- package/lib/esm/ViewState.d.ts.map +1 -1
- package/lib/esm/ViewState.js.map +1 -1
- package/lib/esm/Viewport.d.ts +19 -3
- package/lib/esm/Viewport.d.ts.map +1 -1
- package/lib/esm/Viewport.js +20 -0
- package/lib/esm/Viewport.js.map +1 -1
- package/lib/esm/core-frontend.d.ts +1 -0
- package/lib/esm/core-frontend.d.ts.map +1 -1
- package/lib/esm/core-frontend.js +1 -0
- package/lib/esm/core-frontend.js.map +1 -1
- package/lib/esm/quantity-formatting/BasicUnitsProvider.d.ts +2 -2
- package/lib/esm/quantity-formatting/BasicUnitsProvider.d.ts.map +1 -1
- package/lib/esm/quantity-formatting/BasicUnitsProvider.js +48 -44
- package/lib/esm/quantity-formatting/BasicUnitsProvider.js.map +1 -1
- package/lib/esm/quantity-formatting/QuantityFormatter.d.ts +90 -80
- package/lib/esm/quantity-formatting/QuantityFormatter.d.ts.map +1 -1
- package/lib/esm/quantity-formatting/QuantityFormatter.js +75 -41
- package/lib/esm/quantity-formatting/QuantityFormatter.js.map +1 -1
- package/lib/esm/quantity-formatting/QuantityTypesEditorSpecs.d.ts +54 -0
- package/lib/esm/quantity-formatting/QuantityTypesEditorSpecs.d.ts.map +1 -0
- package/lib/esm/quantity-formatting/QuantityTypesEditorSpecs.js +26 -0
- package/lib/esm/quantity-formatting/QuantityTypesEditorSpecs.js.map +1 -0
- package/lib/esm/quantity-formatting/UnitsData.d.ts +11 -0
- package/lib/esm/quantity-formatting/UnitsData.d.ts.map +1 -0
- package/lib/esm/quantity-formatting/UnitsData.js +56 -0
- package/lib/esm/quantity-formatting/UnitsData.js.map +1 -0
- package/lib/esm/tile/OPCFormatInterpreter.d.ts +21 -0
- package/lib/esm/tile/OPCFormatInterpreter.d.ts.map +1 -0
- package/lib/esm/tile/OPCFormatInterpreter.js +77 -0
- package/lib/esm/tile/OPCFormatInterpreter.js.map +1 -0
- package/lib/esm/tile/PntsReader.d.ts.map +1 -1
- package/lib/esm/tile/PntsReader.js +79 -17
- package/lib/esm/tile/PntsReader.js.map +1 -1
- package/lib/esm/tile/ThreeDTileFormatInterpreter.d.ts +51 -0
- package/lib/esm/tile/ThreeDTileFormatInterpreter.d.ts.map +1 -0
- package/lib/esm/tile/ThreeDTileFormatInterpreter.js +156 -0
- package/lib/esm/tile/ThreeDTileFormatInterpreter.js.map +1 -0
- package/lib/esm/tile/internal.d.ts +2 -0
- package/lib/esm/tile/internal.d.ts.map +1 -1
- package/lib/esm/tile/internal.js +2 -0
- package/lib/esm/tile/internal.js.map +1 -1
- package/package.json +20 -20
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnitsData.js","sourceRoot":"","sources":["../../../src/quantity-formatting/UnitsData.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,8BAA8B;IAC9B,EAAE,IAAI,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC,QAAQ,CAAC,EAAE;IACnD,qBAAqB;IACrB,EAAE,IAAI,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;IACzD,EAAE,IAAI,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC,KAAK,CAAC,EAAE;IACvD,EAAE,IAAI,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC,KAAK,CAAC,EAAE;IACvD,EAAE,IAAI,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE;IAChD,4BAA4B;IAC5B,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC,KAAK,CAAC,EAAE;IAC9C,EAAE,IAAI,EAAE,WAAW,EAAE,gBAAgB,EAAE,EAAE,EAAE;IAC3C,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE;IAC9C,EAAE,IAAI,EAAE,WAAW,EAAE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AAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE;IACnE,EAAE,IAAI,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAAC,EAAE;IACvF,EAAE,IAAI,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,EAAE;IAC/E,EAAE,IAAI,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,EAAE;IAC/E,EAAE,IAAI,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,KAAK,CAAC,EAAE;IACpG,EAAE,IAAI,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,CAAC,oBAAoB,CAAC,EAAE;IAC3E,kDAAkD;IAClD,EAAE,IAAI,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE;IACjD,EAAE,IAAI,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,CAAC,OAAO,CAAC,EAAE;IAC9D,EAAE,IAAI,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE;IAChD,+CAA+C;IAC/C,EAAE,IAAI,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE;IAClD,EAAE,IAAI,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE;IAC5D,EAAE,IAAI,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE;IACnD,EAAE,IAAI,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE;CAClD,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/** @packageDocumentation\r\n * @module QuantityFormatting\r\n */\r\n\r\n/**\r\n * Additional unit data such alternate display label not found in the Units Schema\r\n */\r\nexport const UNIT_EXTRA_DATA = [\r\n // Angles ( base unit radian )\r\n { name: \"Units.RAD\", altDisplayLabels: [\"radian\"] },\r\n // 1 rad = 180.0/PI °\r\n { name: \"Units.ARC_DEG\", altDisplayLabels: [\"deg\", \"^\"] },\r\n { name: \"Units.ARC_MINUTE\", altDisplayLabels: [\"min\"] },\r\n { name: \"Units.ARC_SECOND\", altDisplayLabels: [\"sec\"] },\r\n { name: \"Units.GRAD\", altDisplayLabels: [\"gd\"] },\r\n // Time ( base unit second )\r\n { name: \"Units.S\", altDisplayLabels: [\"sec\"] },\r\n { name: \"Units.MIN\", altDisplayLabels: [] },\r\n { name: \"Units.HR\", altDisplayLabels: [\"hr\"] },\r\n { name: \"Units.DAY\", altDisplayLabels: [\"day\"] },\r\n { name: \"Units.WEEK\", altDisplayLabels: [\"week\"] },\r\n { name: \"Units.YR\", altDisplayLabels: [\"year\"] },\r\n // conversion => specified unit to base unit of m\r\n { name: \"Units.M\", altDisplayLabels: [\"meter\"] },\r\n { name: \"Units.MM\", altDisplayLabels: [\"MM\"] },\r\n { name: \"Units.CM\", altDisplayLabels: [\"CM\"] },\r\n { name: \"Units.DM\", altDisplayLabels: [\"DM\"] },\r\n { name: \"Units.KM\", altDisplayLabels: [\"KM\"] },\r\n { name: \"Units.UM\", altDisplayLabels: [] },\r\n { name: \"Units.MILLIINCH\", altDisplayLabels: [] },\r\n { name: \"Units.MICROINCH\", altDisplayLabels: [] },\r\n { name: \"Units.MILLIFOOT\", altDisplayLabels: [] },\r\n { name: \"Units.IN\", altDisplayLabels: [\"IN\", \"\\\"\"] },\r\n { name: \"Units.FT\", altDisplayLabels: [\"F\", \"FT\", \"'\"] },\r\n { name: \"Units.CHAIN\", altDisplayLabels: [\"CHAIN\"] },\r\n { name: \"Units.YRD\", altDisplayLabels: [\"YRD\", \"yrd\"] },\r\n { name: \"Units.MILE\", altDisplayLabels: [\"mile\", \"Miles\", \"Mile\"] },\r\n { name: \"Units.US_SURVEY_FT\", altDisplayLabels: [\"ft\", \"SF\", \"USF\", \"ft (US Survey)\"] },\r\n { name: \"Units.US_SURVEY_YRD\", altDisplayLabels: [\"USY\", \"yards (US Survey)\"] },\r\n { name: \"Units.US_SURVEY_IN\", altDisplayLabels: [\"USI\", \"inches (US Survey)\"] },\r\n { name: \"Units.US_SURVEY_MILE\", altDisplayLabels: [\"miles (US Survey)\", \"mile (US Survey)\", \"USM\"] },\r\n { name: \"Units.US_SURVEY_CHAIN\", altDisplayLabels: [\"chains (US Survey)\"] },\r\n // conversion => specified unit to base unit of m²\r\n { name: \"Units.SQ_FT\", altDisplayLabels: [\"sf\"] },\r\n { name: \"Units.SQ_US_SURVEY_FT\", altDisplayLabels: [\"sussf\"] },\r\n { name: \"Units.SQ_M\", altDisplayLabels: [\"sm\"] },\r\n // conversion => specified unit to base unit m³\r\n { name: \"Units.CUB_FT\", altDisplayLabels: [\"cf\"] },\r\n { name: \"Units.CUB_US_SURVEY_FT\", altDisplayLabels: [\"cf\"] },\r\n { name: \"Units.CUB_YRD\", altDisplayLabels: [\"cy\"] },\r\n { name: \"Units.CUB_M\", altDisplayLabels: [\"cm\"] },\r\n];\r\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PointCloudReader } from "@itwin/core-orbitgt";
|
|
2
|
+
import { SpatialLocationAndExtents } from "../RealityDataSource";
|
|
3
|
+
/**
|
|
4
|
+
* This class provide methods used to interpret Orbit Point Cloud (OPC) format
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare class OPCFormatInterpreter {
|
|
8
|
+
/** Gets an OPC file reader from a blobFileUrl
|
|
9
|
+
* @param blobFileURL the name of the file.
|
|
10
|
+
* @returns return a file reader open to read provided blob file
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
static getFileReaderFromBlobFileURL(blobFileURL: string): Promise<PointCloudReader>;
|
|
14
|
+
/** Gets reality data spatial location and extents
|
|
15
|
+
* @param fileReader a file reader instance obtains from call to getFileReaderFromBlobFileURL
|
|
16
|
+
* @returns spatial location and volume of interest, in meters, centered around `spatial location`
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
static getSpatialLocationAndExtents(fileReader: PointCloudReader): Promise<SpatialLocationAndExtents>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=OPCFormatInterpreter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OPCFormatInterpreter.d.ts","sourceRoot":"","sources":["../../../src/tile/OPCFormatInterpreter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAyF,gBAAgB,EAAS,MAAM,qBAAqB,CAAC;AAIrJ,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAIjE;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B;;;;OAIG;WACiB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAiBhG;;;;OAIG;WACiB,4BAA4B,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAmCnH"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Cartographic, EcefLocation } from "@itwin/core-common";
|
|
6
|
+
import { Range3d } from "@itwin/core-geometry";
|
|
7
|
+
import { CRSManager, Downloader, OnlineEngine, OPCReader, OrbitGtBounds, PageCachedFile, UrlFS } from "@itwin/core-orbitgt";
|
|
8
|
+
import { FrontendLoggerCategory } from "../FrontendLoggerCategory";
|
|
9
|
+
import { DownloaderNode } from "@itwin/core-orbitgt/lib/cjs/system/runtime/DownloaderNode";
|
|
10
|
+
import { Logger } from "@itwin/core-bentley";
|
|
11
|
+
const loggerCategory = FrontendLoggerCategory.RealityData;
|
|
12
|
+
/**
|
|
13
|
+
* This class provide methods used to interpret Orbit Point Cloud (OPC) format
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export class OPCFormatInterpreter {
|
|
17
|
+
/** Gets an OPC file reader from a blobFileUrl
|
|
18
|
+
* @param blobFileURL the name of the file.
|
|
19
|
+
* @returns return a file reader open to read provided blob file
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
static async getFileReaderFromBlobFileURL(blobFileURL) {
|
|
23
|
+
if (Downloader.INSTANCE == null)
|
|
24
|
+
Downloader.INSTANCE = new DownloaderNode();
|
|
25
|
+
if (CRSManager.ENGINE == null)
|
|
26
|
+
CRSManager.ENGINE = await OnlineEngine.create();
|
|
27
|
+
// let blobFileURL: string = rdUrl;
|
|
28
|
+
// if (accountName.length > 0) blobFileURL = UrlFS.getAzureBlobSasUrl(opcConfig.accountName, opcConfig.containerName, opcConfig.blobFileName, opcConfig.sasToken);
|
|
29
|
+
const urlFS = new UrlFS();
|
|
30
|
+
// wrap a caching layer (16 MB) around the blob file
|
|
31
|
+
const blobFileSize = await urlFS.getFileLength(blobFileURL);
|
|
32
|
+
Logger.logTrace(loggerCategory, `OPC File Size is ${blobFileSize}`);
|
|
33
|
+
const blobFile = new PageCachedFile(urlFS, blobFileURL, blobFileSize, 128 * 1024 /* pageSize */, 128 /* maxPageCount */);
|
|
34
|
+
const fileReader = await OPCReader.openFile(blobFile, blobFileURL, true /* lazyLoading */);
|
|
35
|
+
return fileReader;
|
|
36
|
+
}
|
|
37
|
+
/** Gets reality data spatial location and extents
|
|
38
|
+
* @param fileReader a file reader instance obtains from call to getFileReaderFromBlobFileURL
|
|
39
|
+
* @returns spatial location and volume of interest, in meters, centered around `spatial location`
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
static async getSpatialLocationAndExtents(fileReader) {
|
|
43
|
+
let worldRange = new Range3d();
|
|
44
|
+
let location;
|
|
45
|
+
let isGeolocated = true;
|
|
46
|
+
const bounds = fileReader.getFileBounds();
|
|
47
|
+
worldRange = Range3d.createXYZXYZ(bounds.getMinX(), bounds.getMinY(), bounds.getMinZ(), bounds.getMaxX(), bounds.getMaxY(), bounds.getMaxZ());
|
|
48
|
+
isGeolocated = false;
|
|
49
|
+
const fileCrs = fileReader.getFileCRS();
|
|
50
|
+
if (fileCrs) {
|
|
51
|
+
await CRSManager.ENGINE.prepareForArea(fileCrs, bounds);
|
|
52
|
+
const wgs84ECEFCrs = "4978";
|
|
53
|
+
await CRSManager.ENGINE.prepareForArea(wgs84ECEFCrs, new OrbitGtBounds());
|
|
54
|
+
const ecefBounds = CRSManager.transformBounds(bounds, fileCrs, wgs84ECEFCrs);
|
|
55
|
+
const ecefRange = Range3d.createXYZXYZ(ecefBounds.getMinX(), ecefBounds.getMinY(), ecefBounds.getMinZ(), ecefBounds.getMaxX(), ecefBounds.getMaxY(), ecefBounds.getMaxZ());
|
|
56
|
+
const ecefCenter = ecefRange.localXYZToWorld(.5, .5, .5);
|
|
57
|
+
const cartoCenter = Cartographic.fromEcef(ecefCenter);
|
|
58
|
+
cartoCenter.height = 0;
|
|
59
|
+
const ecefLocation = EcefLocation.createFromCartographicOrigin(cartoCenter);
|
|
60
|
+
location = ecefLocation;
|
|
61
|
+
// this.iModelDb.setEcefLocation(ecefLocation);
|
|
62
|
+
const ecefToWorld = ecefLocation.getTransform().inverse();
|
|
63
|
+
worldRange = ecefToWorld.multiplyRange(ecefRange);
|
|
64
|
+
isGeolocated = true;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// NoGCS case
|
|
68
|
+
isGeolocated = false;
|
|
69
|
+
const centerOfEarth = new EcefLocation({ origin: { x: 0.0, y: 0.0, z: 0.0 }, orientation: { yaw: 0.0, pitch: 0.0, roll: 0.0 } });
|
|
70
|
+
location = centerOfEarth;
|
|
71
|
+
Logger.logTrace(loggerCategory, "OPC RealityData NOT Geolocated", () => ({ ...location }));
|
|
72
|
+
}
|
|
73
|
+
const spatialLocation = { location, worldRange, isGeolocated };
|
|
74
|
+
return spatialLocation;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=OPCFormatInterpreter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OPCFormatInterpreter.js","sourceRoot":"","sources":["../../../src/tile/OPCFormatInterpreter.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAS,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAoB,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACrJ,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,2DAA2D,CAAC;AAC3F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,MAAM,cAAc,GAAW,sBAAsB,CAAC,WAAW,CAAC;AAElE;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAC/B;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,WAAmB;QAClE,IAAI,UAAU,CAAC,QAAQ,IAAI,IAAI;YAC7B,UAAU,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QAC7C,IAAI,UAAU,CAAC,MAAM,IAAI,IAAI;YAC3B,UAAU,CAAC,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC;QAElD,mCAAmC;QACnC,kKAAkK;QAClK,MAAM,KAAK,GAAU,IAAI,KAAK,EAAE,CAAC;QACjC,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E,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC;SAC5F;QACD,MAAM,eAAe,GAA8B,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;QAC1F,OAAO,eAAe,CAAC;IACzB,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 { Cartographic, EcefLocation } from \"@itwin/core-common\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { ALong, CRSManager, Downloader, OnlineEngine, OPCReader, OrbitGtBounds, PageCachedFile, PointCloudReader, UrlFS } from \"@itwin/core-orbitgt\";\r\nimport { FrontendLoggerCategory } from \"../FrontendLoggerCategory\";\r\nimport { DownloaderNode } from \"@itwin/core-orbitgt/lib/cjs/system/runtime/DownloaderNode\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { SpatialLocationAndExtents } from \"../RealityDataSource\";\r\n\r\nconst loggerCategory: string = FrontendLoggerCategory.RealityData;\r\n\r\n/**\r\n * This class provide methods used to interpret Orbit Point Cloud (OPC) format\r\n * @internal\r\n */\r\nexport class OPCFormatInterpreter {\r\n /** Gets an OPC file reader from a blobFileUrl\r\n * @param blobFileURL the name of the file.\r\n * @returns return a file reader open to read provided blob file\r\n * @internal\r\n */\r\n public static async getFileReaderFromBlobFileURL(blobFileURL: string): Promise<PointCloudReader> {\r\n if (Downloader.INSTANCE == null)\r\n Downloader.INSTANCE = new DownloaderNode();\r\n if (CRSManager.ENGINE == null)\r\n CRSManager.ENGINE = await OnlineEngine.create();\r\n\r\n // let blobFileURL: string = rdUrl;\r\n // if (accountName.length > 0) blobFileURL = UrlFS.getAzureBlobSasUrl(opcConfig.accountName, opcConfig.containerName, opcConfig.blobFileName, opcConfig.sasToken);\r\n const urlFS: UrlFS = new UrlFS();\r\n // wrap a caching layer (16 MB) around the blob file\r\n const blobFileSize: ALong = await urlFS.getFileLength(blobFileURL);\r\n Logger.logTrace(loggerCategory, `OPC File Size is ${blobFileSize}`);\r\n const blobFile: PageCachedFile = new PageCachedFile(urlFS, blobFileURL, blobFileSize, 128 * 1024 /* pageSize */, 128 /* maxPageCount */);\r\n const fileReader: PointCloudReader = await OPCReader.openFile(blobFile, blobFileURL, true/* lazyLoading */);\r\n return fileReader;\r\n }\r\n\r\n /** Gets reality data spatial location and extents\r\n * @param fileReader a file reader instance obtains from call to getFileReaderFromBlobFileURL\r\n * @returns spatial location and volume of interest, in meters, centered around `spatial location`\r\n * @internal\r\n */\r\n public static async getSpatialLocationAndExtents(fileReader: PointCloudReader): Promise<SpatialLocationAndExtents> {\r\n let worldRange = new Range3d();\r\n let location: Cartographic | EcefLocation;\r\n let isGeolocated = true;\r\n\r\n const bounds = fileReader.getFileBounds();\r\n worldRange = Range3d.createXYZXYZ(bounds.getMinX(), bounds.getMinY(), bounds.getMinZ(), bounds.getMaxX(), bounds.getMaxY(), bounds.getMaxZ());\r\n isGeolocated = false;\r\n const fileCrs = fileReader.getFileCRS();\r\n if (fileCrs) {\r\n await CRSManager.ENGINE.prepareForArea(fileCrs, bounds);\r\n const wgs84ECEFCrs = \"4978\";\r\n await CRSManager.ENGINE.prepareForArea(wgs84ECEFCrs, new OrbitGtBounds());\r\n\r\n const ecefBounds = CRSManager.transformBounds(bounds, fileCrs, wgs84ECEFCrs);\r\n const ecefRange = Range3d.createXYZXYZ(ecefBounds.getMinX(), ecefBounds.getMinY(), ecefBounds.getMinZ(), ecefBounds.getMaxX(), ecefBounds.getMaxY(), ecefBounds.getMaxZ());\r\n const ecefCenter = ecefRange.localXYZToWorld(.5, .5, .5)!;\r\n const cartoCenter = Cartographic.fromEcef(ecefCenter)!;\r\n cartoCenter.height = 0;\r\n const ecefLocation = EcefLocation.createFromCartographicOrigin(cartoCenter);\r\n location = ecefLocation;\r\n // this.iModelDb.setEcefLocation(ecefLocation);\r\n const ecefToWorld = ecefLocation.getTransform().inverse()!;\r\n worldRange = ecefToWorld.multiplyRange(ecefRange);\r\n isGeolocated = true;\r\n } else {\r\n // NoGCS case\r\n isGeolocated = false;\r\n const centerOfEarth = new EcefLocation({ origin: { x: 0.0, y: 0.0, z: 0.0 }, orientation: { yaw: 0.0, pitch: 0.0, roll: 0.0 } });\r\n location = centerOfEarth;\r\n Logger.logTrace(loggerCategory, \"OPC RealityData NOT Geolocated\", () => ({ ...location }));\r\n }\r\n const spatialLocation: SpatialLocationAndExtents = { location, worldRange, isGeolocated };\r\n return spatialLocation;\r\n }\r\n}\r\n\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PntsReader.d.ts","sourceRoot":"","sources":["../../../src/tile/PntsReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAwB,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAa,mBAAmB,EAA4F,MAAM,oBAAoB,CAAC;AAE9J,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"PntsReader.d.ts","sourceRoot":"","sources":["../../../src/tile/PntsReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAwB,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAa,mBAAmB,EAA4F,MAAM,oBAAoB,CAAC;AAE9J,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAsMtD;;GAEG;AACH,wBAAsB,yBAAyB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA0DvN"}
|
|
@@ -11,6 +11,70 @@ import { BatchType, Feature, FeatureTable, PackedFeatureTable, PntsHeader, QPara
|
|
|
11
11
|
import { FrontendLoggerCategory } from "../FrontendLoggerCategory";
|
|
12
12
|
import { Mesh } from "../render/primitives/mesh/MeshPrimitives";
|
|
13
13
|
import { PointCloudArgs } from "../render/primitives/PointCloudPrimitive";
|
|
14
|
+
function readPntsColors(stream, dataOffset, pnts) {
|
|
15
|
+
const nPts = pnts.POINTS_LENGTH;
|
|
16
|
+
const nComponents = 3 * nPts;
|
|
17
|
+
if (pnts.RGB)
|
|
18
|
+
return new Uint8Array(stream.arrayBuffer, dataOffset + pnts.RGB.byteOffset, nComponents);
|
|
19
|
+
if (pnts.RGBA) {
|
|
20
|
+
// ###TODO support point cloud transparency.
|
|
21
|
+
const rgb = new Uint8Array(nComponents);
|
|
22
|
+
const rgba = new Uint8Array(stream.arrayBuffer, dataOffset + pnts.RGBA.byteOffset, nComponents);
|
|
23
|
+
for (let i = 0; i < nComponents; i += 4) {
|
|
24
|
+
rgb[i + 0] = rgba[i + 0];
|
|
25
|
+
rgb[i + 1] = rgba[i + 1];
|
|
26
|
+
rgb[i + 2] = rgba[i + 2];
|
|
27
|
+
}
|
|
28
|
+
return rgb;
|
|
29
|
+
}
|
|
30
|
+
else if (pnts.RGB565) {
|
|
31
|
+
// Each color is 16 bits: 5 red, 6 green, 5 blue.
|
|
32
|
+
const crgb = new Uint16Array(stream.arrayBuffer, dataOffset + pnts.RGB565.byteOffset, nPts);
|
|
33
|
+
const rgb = new Uint8Array(nComponents);
|
|
34
|
+
for (let i = 0; i < nPts; i++) {
|
|
35
|
+
const c = crgb[i];
|
|
36
|
+
rgb[i + 0] = (c >> 11) & 0x1f;
|
|
37
|
+
rgb[i + 1] = (c >> 5) & 0x3f;
|
|
38
|
+
rgb[i + 2] = c & 0x1f;
|
|
39
|
+
}
|
|
40
|
+
return rgb;
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
function readPnts(stream, dataOffset, pnts) {
|
|
45
|
+
const nPts = pnts.POINTS_LENGTH;
|
|
46
|
+
let params;
|
|
47
|
+
let points;
|
|
48
|
+
if (pnts.POSITION_QUANTIZED) {
|
|
49
|
+
const qpos = pnts.POSITION_QUANTIZED;
|
|
50
|
+
const offset = pnts.QUANTIZED_VOLUME_OFFSET;
|
|
51
|
+
const scale = pnts.QUANTIZED_VOLUME_SCALE;
|
|
52
|
+
const qOrigin = new Point3d(offset[0], offset[1], offset[2]);
|
|
53
|
+
const qScale = new Point3d(Quantization.computeScale(scale[0]), Quantization.computeScale(scale[1]), Quantization.computeScale(scale[2]));
|
|
54
|
+
params = QParams3d.fromOriginAndScale(qOrigin, qScale);
|
|
55
|
+
points = new Uint16Array(stream.arrayBuffer, dataOffset + qpos.byteOffset, 3 * nPts);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const nCoords = nPts * 3;
|
|
59
|
+
const fpts = new Float32Array(stream.arrayBuffer, dataOffset + pnts.POSITION.byteOffset, 3 * nPts);
|
|
60
|
+
const range = Range3d.createNull();
|
|
61
|
+
for (let i = 0; i < nCoords; i += 3)
|
|
62
|
+
range.extendXYZ(fpts[i], fpts[i + 1], fpts[i + 2]);
|
|
63
|
+
params = QParams3d.fromRange(range);
|
|
64
|
+
const qpt = new QPoint3d();
|
|
65
|
+
const fpt = new Point3d();
|
|
66
|
+
points = new Uint16Array(3 * nPts);
|
|
67
|
+
for (let i = 0; i < nCoords; i += 3) {
|
|
68
|
+
fpt.set(fpts[i], fpts[i + 1], fpts[i + 2]);
|
|
69
|
+
qpt.init(fpt, params);
|
|
70
|
+
points[i] = qpt.x;
|
|
71
|
+
points[i + 1] = qpt.y;
|
|
72
|
+
points[i + 2] = qpt.z;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const colors = readPntsColors(stream, dataOffset, pnts);
|
|
76
|
+
return { params, points, colors };
|
|
77
|
+
}
|
|
14
78
|
async function decodeDracoPointCloud(buf) {
|
|
15
79
|
var _a, _b, _c, _d, _e, _f;
|
|
16
80
|
try {
|
|
@@ -23,6 +87,7 @@ async function decodeDracoPointCloud(buf) {
|
|
|
23
87
|
return undefined;
|
|
24
88
|
let colors = (_c = (_b = mesh.attributes.RGB) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : (_d = mesh.attributes.COLOR_0) === null || _d === void 0 ? void 0 : _d.value;
|
|
25
89
|
if (!colors) {
|
|
90
|
+
// ###TODO support point cloud transparency.
|
|
26
91
|
const rgba = (_e = mesh.attributes.RGBA) === null || _e === void 0 ? void 0 : _e.value;
|
|
27
92
|
if (rgba && (rgba.length % 4) === 0) {
|
|
28
93
|
// We currently don't support alpha channel for point clouds - strip it.
|
|
@@ -64,21 +129,6 @@ async function decodeDracoPointCloud(buf) {
|
|
|
64
129
|
return undefined;
|
|
65
130
|
}
|
|
66
131
|
}
|
|
67
|
-
function readPnts(stream, dataOffset, pnts) {
|
|
68
|
-
const offset = pnts.QUANTIZED_VOLUME_OFFSET;
|
|
69
|
-
const scale = pnts.QUANTIZED_VOLUME_SCALE;
|
|
70
|
-
const qpos = pnts.POSITION_QUANTIZED;
|
|
71
|
-
const nPts = pnts.POINTS_LENGTH;
|
|
72
|
-
if (!offset || !scale || !qpos || !nPts)
|
|
73
|
-
return undefined;
|
|
74
|
-
const qOrigin = new Point3d(offset[0], offset[1], offset[2]);
|
|
75
|
-
const qScale = new Point3d(Quantization.computeScale(scale[0]), Quantization.computeScale(scale[1]), Quantization.computeScale(scale[2]));
|
|
76
|
-
return {
|
|
77
|
-
params: QParams3d.fromOriginAndScale(qOrigin, qScale),
|
|
78
|
-
points: new Uint16Array(stream.arrayBuffer, dataOffset + qpos.byteOffset, 3 * nPts),
|
|
79
|
-
colors: pnts.RGB ? new Uint8Array(stream.arrayBuffer, dataOffset + pnts.RGB.byteOffset, 3 * nPts) : undefined,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
132
|
/** Deserialize a point cloud tile and return it as a RenderGraphic.
|
|
83
133
|
* @internal
|
|
84
134
|
*/
|
|
@@ -112,10 +162,22 @@ export async function readPointCloudTileContent(stream, iModel, modelId, _is3d,
|
|
|
112
162
|
if (featureValue.RTC_CENTER)
|
|
113
163
|
props.params = QParams3d.fromOriginAndScale(props.params.origin.plus(Vector3d.fromJSON(featureValue.RTC_CENTER)), props.params.scale);
|
|
114
164
|
if (!props.colors) {
|
|
165
|
+
// ###TODO we really should support uniform color instead of allocating an RGB value per point...
|
|
115
166
|
props.colors = new Uint8Array(3 * featureValue.POINTS_LENGTH);
|
|
116
|
-
|
|
167
|
+
const rgba = featureValue.CONSTANT_RGBA;
|
|
168
|
+
if (rgba) {
|
|
169
|
+
// ###TODO support point cloud transparency.
|
|
170
|
+
for (let i = 0; i < featureValue.POINTS_LENGTH * 3; i += 3) {
|
|
171
|
+
props.colors[i] = rgba[0];
|
|
172
|
+
props.colors[i + 1] = rgba[1];
|
|
173
|
+
props.colors[i + 2] = rgba[2];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
// Default to white.
|
|
178
|
+
props.colors.fill(0xff, 0, props.colors.length);
|
|
179
|
+
}
|
|
117
180
|
}
|
|
118
|
-
// ###TODO? Do we expect a batch table? not currently handled...
|
|
119
181
|
const featureTable = new FeatureTable(1, modelId, BatchType.Primary);
|
|
120
182
|
const features = new Mesh.Features(featureTable);
|
|
121
183
|
features.add(new Feature(modelId), 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PntsReader.js","sourceRoot":"","sources":["../../../src/tile/PntsReader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA0B,MA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CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAExI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QACjB,KAAK,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;QAC9D,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAI,wBAAwB;KAC7E;IAED,gEAAgE;IAChE,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACjD,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;IAE5D,IAAI,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;IACvI,aAAa,GAAG,MAAM,CAAC,WAAW,CAAC,aAAc,EAAE,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;IACjG,OAAO,aAAa,CAAC;AACvB,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/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { ByteStream, Id64String, Logger, utf8ToString } from \"@itwin/core-bentley\";\r\nimport { Point3d, Range3d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { BatchType, ElementAlignedBox3d, Feature, FeatureTable, PackedFeatureTable, PntsHeader, QParams3d, QPoint3d, Quantization } from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"../FrontendLoggerCategory\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { Mesh } from \"../render/primitives/mesh/MeshPrimitives\";\r\nimport { PointCloudArgs } from \"../render/primitives/PointCloudPrimitive\";\r\nimport { RenderGraphic } from \"../render/RenderGraphic\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\n\r\n/** Schema for the [3DTILES_draco_point_compression](https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_draco_point_compression) extension. */\r\ninterface DracoPointCloud {\r\n byteLength: number;\r\n byteOffset: number;\r\n /** Each specifies the Id of a compressed attribute. */\r\n properties: {\r\n POSITION?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n RGB?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n RGBA?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n NORMAL?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n BATCH_ID?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n /** This is not in the spec but is present in sample data in Cesium's git repository. */\r\n COLOR_0?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n };\r\n}\r\n\r\ninterface PointCloudProps {\r\n params: QParams3d;\r\n points: Uint16Array;\r\n colors?: Uint8Array;\r\n}\r\n\r\nasync function decodeDracoPointCloud(buf: Uint8Array): Promise<PointCloudProps | undefined> {\r\n try {\r\n const dracoLoader = (await import(\"@loaders.gl/draco\")).DracoLoader;\r\n const mesh = await dracoLoader.parse(buf, { });\r\n if (mesh.topology !== \"point-list\")\r\n return undefined;\r\n\r\n const pos = mesh.attributes.POSITION?.value;\r\n if (!pos || (pos.length % 3) !== 0)\r\n return undefined;\r\n\r\n let colors = mesh.attributes.RGB?.value ?? mesh.attributes.COLOR_0?.value;\r\n if (!colors) {\r\n const rgba = mesh.attributes.RGBA?.value;\r\n if (rgba && (rgba.length % 4) === 0) {\r\n // We currently don't support alpha channel for point clouds - strip it.\r\n colors = new Uint8Array(3 * rgba.length / 4);\r\n let j = 0;\r\n for (let i = 0; i < rgba.length; i += 4) {\r\n colors[j++] = rgba[i];\r\n colors[j++] = rgba[i + 1];\r\n colors[j++] = rgba[i + 2];\r\n }\r\n }\r\n }\r\n\r\n let posRange: Range3d;\r\n const bbox = mesh.header?.boundingBox;\r\n if (bbox) {\r\n posRange = Range3d.createXYZXYZ(bbox[0][0], bbox[0][1], bbox[0][2], bbox[1][0], bbox[1][1], bbox[1][2]);\r\n } else {\r\n posRange = Range3d.createNull();\r\n for (let i = 0; i < pos.length; i += 3)\r\n posRange.extendXYZ(pos[i], pos[i + 1], pos[i + 2]);\r\n }\r\n\r\n const params = QParams3d.fromRange(posRange);\r\n const pt = Point3d.createZero();\r\n const qpt = QPoint3d.create(pt, params);\r\n const points = new Uint16Array(pos.length);\r\n for (let i = 0; i < pos.length; i += 3) {\r\n pt.set(pos[i], pos[i + 1], pos[i + 2]);\r\n qpt.init(pt, params);\r\n points[i] = qpt.x;\r\n points[i + 1] = qpt.y;\r\n points[i + 2] = qpt.z;\r\n }\r\n\r\n return { points, params, colors: colors instanceof Uint8Array ? colors : undefined };\r\n } catch (err) {\r\n Logger.logWarning(FrontendLoggerCategory.Render, \"Failed to decode draco-encoded point cloud\");\r\n Logger.logException(FrontendLoggerCategory.Render, err);\r\n return undefined;\r\n }\r\n}\r\n\r\ninterface PntsProps {\r\n POSITION_QUANTIZED?: { byteOffset: number }; // eslint-disable-line @typescript-eslint/naming-convention\r\n QUANTIZED_VOLUME_OFFSET?: number[]; // eslint-disable-line @typescript-eslint/naming-convention\r\n QUANTIZED_VOLUME_SCALE?: number[]; // eslint-disable-line @typescript-eslint/naming-convention\r\n POINTS_LENGTH?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n RGB?: { byteOffset: number }; // eslint-disable-line @typescript-eslint/naming-convention\r\n}\r\n\r\nfunction readPnts(stream: ByteStream, dataOffset: number, pnts: PntsProps): PointCloudProps | undefined {\r\n const offset = pnts.QUANTIZED_VOLUME_OFFSET;\r\n const scale = pnts.QUANTIZED_VOLUME_SCALE;\r\n const qpos = pnts.POSITION_QUANTIZED;\r\n const nPts = pnts.POINTS_LENGTH;\r\n if (!offset || !scale || !qpos || !nPts)\r\n return undefined;\r\n\r\n const qOrigin = new Point3d(offset[0], offset[1], offset[2]);\r\n const qScale = new Point3d(Quantization.computeScale(scale[0]), Quantization.computeScale(scale[1]), Quantization.computeScale(scale[2]));\r\n\r\n return {\r\n params: QParams3d.fromOriginAndScale(qOrigin, qScale),\r\n points: new Uint16Array(stream.arrayBuffer, dataOffset + qpos.byteOffset, 3 * nPts),\r\n colors: pnts.RGB ? new Uint8Array(stream.arrayBuffer, dataOffset + pnts.RGB.byteOffset, 3 * nPts) : undefined,\r\n };\r\n}\r\n\r\n/** Deserialize a point cloud tile and return it as a RenderGraphic.\r\n * @internal\r\n */\r\nexport async function readPointCloudTileContent(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, _is3d: boolean, range: ElementAlignedBox3d, system: RenderSystem): Promise<RenderGraphic | undefined> {\r\n const header = new PntsHeader(stream);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n const featureTableJsonOffset = stream.curPos;\r\n const featureStrData = stream.nextBytes(header.featureTableJsonLength);\r\n const featureStr = utf8ToString(featureStrData);\r\n const featureValue = JSON.parse(featureStr as string);\r\n\r\n if (undefined === featureValue)\r\n return undefined;\r\n\r\n let props: PointCloudProps | undefined;\r\n const dataOffset = featureTableJsonOffset + header.featureTableJsonLength;\r\n const draco: DracoPointCloud | undefined = featureValue.extensions ? featureValue.extensions[\"3DTILES_draco_point_compression\"] : undefined;\r\n if (draco) {\r\n try {\r\n const buf = new Uint8Array(stream.arrayBuffer, dataOffset + draco.byteOffset, draco.byteLength);\r\n props = await decodeDracoPointCloud(buf);\r\n } catch (_) {\r\n //\r\n }\r\n } else {\r\n props = readPnts(stream, dataOffset, featureValue);\r\n }\r\n\r\n if (!props)\r\n return undefined;\r\n\r\n if (featureValue.RTC_CENTER)\r\n props.params = QParams3d.fromOriginAndScale(props.params.origin.plus(Vector3d.fromJSON(featureValue.RTC_CENTER)), props.params.scale);\r\n\r\n if (!props.colors) {\r\n props.colors = new Uint8Array(3 * featureValue.POINTS_LENGTH);\r\n props.colors.fill(0xff, 0, props.colors.length); // TBD... Default color?\r\n }\r\n\r\n // ###TODO? Do we expect a batch table? not currently handled...\r\n const featureTable = new FeatureTable(1, modelId, BatchType.Primary);\r\n const features = new Mesh.Features(featureTable);\r\n features.add(new Feature(modelId), 1);\r\n const voxelSize = props.params.rangeDiagonal.maxAbs() / 256;\r\n\r\n let renderGraphic = system.createPointCloud(new PointCloudArgs(props.points, props.params, props.colors, features, voxelSize), iModel);\r\n renderGraphic = system.createBatch(renderGraphic!, PackedFeatureTable.pack(featureTable), range);\r\n return renderGraphic;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"PntsReader.js","sourceRoot":"","sources":["../../../src/tile/PntsReader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAA0B,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAuB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9J,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAChE,OAAO,EAAE,cAAc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AAI,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;IACvI,aAAa,GAAG,MAAM,CAAC,WAAW,CAAC,aAAc,EAAE,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;IACjG,OAAO,aAAa,CAAC;AACvB,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/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { ByteStream, Id64String, Logger, utf8ToString } from \"@itwin/core-bentley\";\r\nimport { Point3d, Range3d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { BatchType, ElementAlignedBox3d, Feature, FeatureTable, PackedFeatureTable, PntsHeader, QParams3d, QPoint3d, Quantization } from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"../FrontendLoggerCategory\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { Mesh } from \"../render/primitives/mesh/MeshPrimitives\";\r\nimport { PointCloudArgs } from \"../render/primitives/PointCloudPrimitive\";\r\nimport { RenderGraphic } from \"../render/RenderGraphic\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\n\r\n/** Schema for the [3DTILES_draco_point_compression](https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_draco_point_compression) extension. */\r\ninterface DracoPointCloud {\r\n byteLength: number;\r\n byteOffset: number;\r\n /** Each specifies the Id of a compressed attribute. */\r\n properties: {\r\n POSITION?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n RGB?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n RGBA?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n NORMAL?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n BATCH_ID?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n /** This is not in the spec but is present in sample data in Cesium's git repository. */\r\n COLOR_0?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n };\r\n}\r\n\r\ninterface PointCloudProps {\r\n params: QParams3d;\r\n points: Uint16Array;\r\n colors?: Uint8Array;\r\n}\r\n\r\ninterface BinaryBodyReference {\r\n byteOffset: number;\r\n}\r\n\r\n/** [3D tiles specification section 10.3](https://docs.opengeospatial.org/cs/18-053r2/18-053r2.html#199).\r\n * [JSON schema](https://github.com/CesiumGS/3d-tiles/blob/main/specification/schema/pnts.featureTable.schema.json).\r\n */\r\ninterface CommonPntsProps {\r\n POINTS_LENGTH: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n RTC_CENTER?: number[]; // eslint-disable-line @typescript-eslint/naming-convention\r\n CONSTANT_RGBA?: number[]; // eslint-disable-line @typescript-eslint/naming-convention\r\n RGB?: BinaryBodyReference; // eslint-disable-line @typescript-eslint/naming-convention\r\n RGBA?: BinaryBodyReference; // eslint-disable-line @typescript-eslint/naming-convention\r\n RGB565?: BinaryBodyReference; // eslint-disable-line @typescript-eslint/naming-convention\r\n\r\n extensions?: {\r\n \"3DTILES_draco_point_compression\"?: DracoPointCloud; // eslint-disable-line @typescript-eslint/naming-convention\r\n };\r\n\r\n // The following are currently ignored.\r\n NORMAL?: BinaryBodyReference; // eslint-disable-line @typescript-eslint/naming-convention\r\n NORMAL_OCT16P?: BinaryBodyReference; // eslint-disable-line @typescript-eslint/naming-convention\r\n BATCH_ID?: BinaryBodyReference; // eslint-disable-line @typescript-eslint/naming-convention\r\n BATCH_LENGTH?: number; // eslint-disable-line @typescript-eslint/naming-convention\r\n}\r\n\r\ntype QuantizedPntsProps = CommonPntsProps & {\r\n POSITION_QUANTIZED: BinaryBodyReference; // eslint-disable-line @typescript-eslint/naming-convention\r\n QUANTIZED_VOLUME_OFFSET: number[]; // eslint-disable-line @typescript-eslint/naming-convention\r\n QUANTIZED_VOLUME_SCALE: number[]; // eslint-disable-line @typescript-eslint/naming-convention\r\n\r\n POSITION?: never; // eslint-disable-line @typescript-eslint/naming-convention\r\n};\r\n\r\ntype UnquantizedPntsProps = CommonPntsProps & {\r\n POSITION: BinaryBodyReference; // eslint-disable-line @typescript-eslint/naming-convention\r\n\r\n POSITION_QUANTIZED?: never; // eslint-disable-line @typescript-eslint/naming-convention\r\n QUANTIZED_VOLUME_OFFSET?: never; // eslint-disable-line @typescript-eslint/naming-convention\r\n QUANTIZED_VOLUME_SCALE?: never; // eslint-disable-line @typescript-eslint/naming-convention\r\n};\r\n\r\ntype PntsProps = QuantizedPntsProps | UnquantizedPntsProps;\r\n\r\nfunction readPntsColors(stream: ByteStream, dataOffset: number, pnts: PntsProps): Uint8Array | undefined {\r\n const nPts = pnts.POINTS_LENGTH;\r\n const nComponents = 3 * nPts;\r\n if (pnts.RGB)\r\n return new Uint8Array(stream.arrayBuffer, dataOffset + pnts.RGB.byteOffset, nComponents);\r\n\r\n if (pnts.RGBA) {\r\n // ###TODO support point cloud transparency.\r\n const rgb = new Uint8Array(nComponents);\r\n const rgba = new Uint8Array(stream.arrayBuffer, dataOffset + pnts.RGBA.byteOffset, nComponents);\r\n for (let i = 0; i < nComponents; i += 4) {\r\n rgb[i + 0] = rgba[i + 0];\r\n rgb[i + 1] = rgba[i + 1];\r\n rgb[i + 2] = rgba[i + 2];\r\n }\r\n\r\n return rgb;\r\n } else if (pnts.RGB565) {\r\n // Each color is 16 bits: 5 red, 6 green, 5 blue.\r\n const crgb = new Uint16Array(stream.arrayBuffer, dataOffset + pnts.RGB565.byteOffset, nPts);\r\n const rgb = new Uint8Array(nComponents);\r\n for (let i = 0; i < nPts; i++) {\r\n const c = crgb[i];\r\n rgb[i + 0] = (c >> 11) & 0x1f;\r\n rgb[i + 1] = (c >> 5) & 0x3f;\r\n rgb[i + 2] = c & 0x1f;\r\n }\r\n\r\n return rgb;\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\nfunction readPnts(stream: ByteStream, dataOffset: number, pnts: PntsProps): PointCloudProps | undefined {\r\n const nPts = pnts.POINTS_LENGTH;\r\n let params: QParams3d;\r\n let points: Uint16Array;\r\n\r\n if (pnts.POSITION_QUANTIZED) {\r\n const qpos = pnts.POSITION_QUANTIZED;\r\n const offset = pnts.QUANTIZED_VOLUME_OFFSET;\r\n const scale = pnts.QUANTIZED_VOLUME_SCALE;\r\n\r\n const qOrigin = new Point3d(offset[0], offset[1], offset[2]);\r\n const qScale = new Point3d(Quantization.computeScale(scale[0]), Quantization.computeScale(scale[1]), Quantization.computeScale(scale[2]));\r\n\r\n params = QParams3d.fromOriginAndScale(qOrigin, qScale);\r\n points = new Uint16Array(stream.arrayBuffer, dataOffset + qpos.byteOffset, 3 * nPts);\r\n } else {\r\n const nCoords = nPts * 3;\r\n const fpts = new Float32Array(stream.arrayBuffer, dataOffset + pnts.POSITION.byteOffset, 3 * nPts);\r\n const range = Range3d.createNull();\r\n for (let i = 0; i < nCoords; i += 3)\r\n range.extendXYZ(fpts[i], fpts[i + 1], fpts[i + 2]);\r\n\r\n params = QParams3d.fromRange(range);\r\n const qpt = new QPoint3d();\r\n const fpt = new Point3d();\r\n points = new Uint16Array(3 * nPts);\r\n for (let i = 0; i < nCoords; i += 3) {\r\n fpt.set(fpts[i], fpts[i + 1], fpts[i + 2]);\r\n qpt.init(fpt, params);\r\n points[i] = qpt.x;\r\n points[i + 1] = qpt.y;\r\n points[i + 2] = qpt.z;\r\n }\r\n }\r\n\r\n const colors = readPntsColors(stream, dataOffset, pnts);\r\n return { params, points, colors };\r\n}\r\n\r\nasync function decodeDracoPointCloud(buf: Uint8Array): Promise<PointCloudProps | undefined> {\r\n try {\r\n const dracoLoader = (await import(\"@loaders.gl/draco\")).DracoLoader;\r\n const mesh = await dracoLoader.parse(buf, { });\r\n if (mesh.topology !== \"point-list\")\r\n return undefined;\r\n\r\n const pos = mesh.attributes.POSITION?.value;\r\n if (!pos || (pos.length % 3) !== 0)\r\n return undefined;\r\n\r\n let colors = mesh.attributes.RGB?.value ?? mesh.attributes.COLOR_0?.value;\r\n if (!colors) {\r\n // ###TODO support point cloud transparency.\r\n const rgba = mesh.attributes.RGBA?.value;\r\n if (rgba && (rgba.length % 4) === 0) {\r\n // We currently don't support alpha channel for point clouds - strip it.\r\n colors = new Uint8Array(3 * rgba.length / 4);\r\n let j = 0;\r\n for (let i = 0; i < rgba.length; i += 4) {\r\n colors[j++] = rgba[i];\r\n colors[j++] = rgba[i + 1];\r\n colors[j++] = rgba[i + 2];\r\n }\r\n }\r\n }\r\n\r\n let posRange: Range3d;\r\n const bbox = mesh.header?.boundingBox;\r\n if (bbox) {\r\n posRange = Range3d.createXYZXYZ(bbox[0][0], bbox[0][1], bbox[0][2], bbox[1][0], bbox[1][1], bbox[1][2]);\r\n } else {\r\n posRange = Range3d.createNull();\r\n for (let i = 0; i < pos.length; i += 3)\r\n posRange.extendXYZ(pos[i], pos[i + 1], pos[i + 2]);\r\n }\r\n\r\n const params = QParams3d.fromRange(posRange);\r\n const pt = Point3d.createZero();\r\n const qpt = QPoint3d.create(pt, params);\r\n const points = new Uint16Array(pos.length);\r\n for (let i = 0; i < pos.length; i += 3) {\r\n pt.set(pos[i], pos[i + 1], pos[i + 2]);\r\n qpt.init(pt, params);\r\n points[i] = qpt.x;\r\n points[i + 1] = qpt.y;\r\n points[i + 2] = qpt.z;\r\n }\r\n\r\n return { points, params, colors: colors instanceof Uint8Array ? colors : undefined };\r\n } catch (err) {\r\n Logger.logWarning(FrontendLoggerCategory.Render, \"Failed to decode draco-encoded point cloud\");\r\n Logger.logException(FrontendLoggerCategory.Render, err);\r\n return undefined;\r\n }\r\n}\r\n\r\n/** Deserialize a point cloud tile and return it as a RenderGraphic.\r\n * @internal\r\n */\r\nexport async function readPointCloudTileContent(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, _is3d: boolean, range: ElementAlignedBox3d, system: RenderSystem): Promise<RenderGraphic | undefined> {\r\n const header = new PntsHeader(stream);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n const featureTableJsonOffset = stream.curPos;\r\n const featureStrData = stream.nextBytes(header.featureTableJsonLength);\r\n const featureStr = utf8ToString(featureStrData);\r\n const featureValue = JSON.parse(featureStr as string) as PntsProps;\r\n\r\n if (undefined === featureValue)\r\n return undefined;\r\n\r\n let props: PointCloudProps | undefined;\r\n const dataOffset = featureTableJsonOffset + header.featureTableJsonLength;\r\n const draco = featureValue.extensions ? featureValue.extensions[\"3DTILES_draco_point_compression\"] : undefined;\r\n if (draco) {\r\n try {\r\n const buf = new Uint8Array(stream.arrayBuffer, dataOffset + draco.byteOffset, draco.byteLength);\r\n props = await decodeDracoPointCloud(buf);\r\n } catch (_) {\r\n //\r\n }\r\n } else {\r\n props = readPnts(stream, dataOffset, featureValue);\r\n }\r\n\r\n if (!props)\r\n return undefined;\r\n\r\n if (featureValue.RTC_CENTER)\r\n props.params = QParams3d.fromOriginAndScale(props.params.origin.plus(Vector3d.fromJSON(featureValue.RTC_CENTER)), props.params.scale);\r\n\r\n if (!props.colors) {\r\n // ###TODO we really should support uniform color instead of allocating an RGB value per point...\r\n props.colors = new Uint8Array(3 * featureValue.POINTS_LENGTH);\r\n const rgba = featureValue.CONSTANT_RGBA;\r\n if (rgba) {\r\n // ###TODO support point cloud transparency.\r\n for (let i = 0; i < featureValue.POINTS_LENGTH * 3; i += 3) {\r\n props.colors[i] = rgba[0];\r\n props.colors[i + 1] = rgba[1];\r\n props.colors[i + 2] = rgba[2];\r\n }\r\n } else {\r\n // Default to white.\r\n props.colors.fill(0xff, 0, props.colors.length);\r\n }\r\n }\r\n\r\n const featureTable = new FeatureTable(1, modelId, BatchType.Primary);\r\n const features = new Mesh.Features(featureTable);\r\n features.add(new Feature(modelId), 1);\r\n const voxelSize = props.params.rangeDiagonal.maxAbs() / 256;\r\n\r\n let renderGraphic = system.createPointCloud(new PointCloudArgs(props.points, props.params, props.colors, features, voxelSize), iModel);\r\n renderGraphic = system.createBatch(renderGraphic!, PackedFeatureTable.pack(featureTable), range);\r\n return renderGraphic;\r\n}\r\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Range3d, Transform } from "@itwin/core-geometry";
|
|
2
|
+
import { PublisherProductInfo, SpatialLocationAndExtents } from "../RealityDataSource";
|
|
3
|
+
/** This interface provides information about 3dTile files for this reality data
|
|
4
|
+
* Currently only used for debbugging
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export interface ThreeDTileFileInfo {
|
|
8
|
+
/** the number of children at the root of this reality data */
|
|
9
|
+
rootChildren?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* This class provide methods used to interpret Cesium 3dTile format
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare class ThreeDTileFormatInterpreter {
|
|
16
|
+
/** Gets reality data spatial location and extents
|
|
17
|
+
* @param json root document file in json format
|
|
18
|
+
* @returns spatial location and volume of interest, in meters, centered around `spatial location`
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
static getSpatialLocationAndExtents(json: any): SpatialLocationAndExtents;
|
|
22
|
+
/** Gets information to identify the product and engine that create this reality data
|
|
23
|
+
* Will return undefined if cannot be resolved
|
|
24
|
+
* @param rootDocjson root document file in json format
|
|
25
|
+
* @returns information to identify the product and engine that create this reality data
|
|
26
|
+
* @alpha
|
|
27
|
+
*/
|
|
28
|
+
static getPublisherProductInfo(rootDocjson: any): PublisherProductInfo;
|
|
29
|
+
/** Gets information about 3dTile file for this reality data
|
|
30
|
+
* Will return undefined if cannot be resolved
|
|
31
|
+
* @param rootDocjson root document file in json format
|
|
32
|
+
* @returns information about 3dTile file for this reality data
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
static getFileInfo(rootDocjson: any): ThreeDTileFileInfo;
|
|
36
|
+
/** Convert a boundingVolume into a range
|
|
37
|
+
* @param boundingVolume the bounding volume to convert
|
|
38
|
+
* @returns the range or undefined if cannot convert
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
static rangeFromBoundingVolume(boundingVolume: any): Range3d | undefined;
|
|
42
|
+
/** Convert a boundingVolume into a range
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
static maximumSizeFromGeometricTolerance(range: Range3d, geometricError: number): number;
|
|
46
|
+
/** Convert a boundingVolume into a range
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
static transformFromJson(jTrans: number[] | undefined): Transform | undefined;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=ThreeDTileFormatInterpreter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThreeDTileFormatInterpreter.d.ts","sourceRoot":"","sources":["../../../src/tile/ThreeDTileFormatInterpreter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAqB,OAAO,EAAE,SAAS,EAAgC,MAAM,sBAAsB,CAAC;AAE3G,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAGvF;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AACD;;;GAGG;AACH,qBAAa,2BAA2B;IACtC;;;;OAIG;WACW,4BAA4B,CAAC,IAAI,EAAE,GAAG,GAAG,yBAAyB;IA+DhF;;;;;OAKG;WACW,uBAAuB,CAAC,WAAW,EAAE,GAAG,GAAG,oBAAoB;IAW7E;;;;;OAKG;WACW,WAAW,CAAC,WAAW,EAAE,GAAG,GAAG,kBAAkB;IAM/D;;;;OAIG;WACW,uBAAuB,CAAC,cAAc,EAAE,GAAG,GAAG,OAAO,GAAG,SAAS;IA0B/E;;OAEG;WACW,iCAAiC,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;IAI/F;;OAEG;WACW,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS;CAGrF"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { JsonUtils, Logger } from "@itwin/core-bentley";
|
|
6
|
+
import { Cartographic, EcefLocation } from "@itwin/core-common";
|
|
7
|
+
import { Matrix3d, Point3d, Range3d, Transform, Vector3d, YawPitchRollAngles } from "@itwin/core-geometry";
|
|
8
|
+
import { FrontendLoggerCategory } from "../FrontendLoggerCategory";
|
|
9
|
+
const loggerCategory = FrontendLoggerCategory.RealityData;
|
|
10
|
+
/**
|
|
11
|
+
* This class provide methods used to interpret Cesium 3dTile format
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export class ThreeDTileFormatInterpreter {
|
|
15
|
+
/** Gets reality data spatial location and extents
|
|
16
|
+
* @param json root document file in json format
|
|
17
|
+
* @returns spatial location and volume of interest, in meters, centered around `spatial location`
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
static getSpatialLocationAndExtents(json) {
|
|
21
|
+
const worldRange = new Range3d();
|
|
22
|
+
let isGeolocated = true;
|
|
23
|
+
let location;
|
|
24
|
+
Logger.logTrace(loggerCategory, "RealityData realityModelFromJson");
|
|
25
|
+
if (undefined !== json.root.boundingVolume.region) {
|
|
26
|
+
const region = JsonUtils.asArray(json.root.boundingVolume.region);
|
|
27
|
+
Logger.logTrace(loggerCategory, "RealityData json.root.boundingVolume.region", () => ({ ...region }));
|
|
28
|
+
if (undefined === region) {
|
|
29
|
+
Logger.logError(loggerCategory, `Error realityModelFromJson - region undefined`);
|
|
30
|
+
throw new TypeError("Unable to determine GeoLocation - no root Transform or Region on root.");
|
|
31
|
+
}
|
|
32
|
+
const ecefLow = (Cartographic.fromRadians({ longitude: region[0], latitude: region[1], height: region[4] })).toEcef();
|
|
33
|
+
const ecefHigh = (Cartographic.fromRadians({ longitude: region[2], latitude: region[3], height: region[5] })).toEcef();
|
|
34
|
+
const ecefRange = Range3d.create(ecefLow, ecefHigh);
|
|
35
|
+
const cartoCenter = Cartographic.fromRadians({ longitude: (region[0] + region[2]) / 2.0, latitude: (region[1] + region[3]) / 2.0, height: (region[4] + region[5]) / 2.0 });
|
|
36
|
+
location = cartoCenter;
|
|
37
|
+
const ecefLocation = EcefLocation.createFromCartographicOrigin(cartoCenter);
|
|
38
|
+
// iModelDb.setEcefLocation(ecefLocation);
|
|
39
|
+
const ecefToWorld = ecefLocation.getTransform().inverse();
|
|
40
|
+
worldRange.extendRange(Range3d.fromJSON(ecefToWorld.multiplyRange(ecefRange)));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
let worldToEcefTransform = ThreeDTileFormatInterpreter.transformFromJson(json.root.transform);
|
|
44
|
+
Logger.logTrace(loggerCategory, "RealityData json.root.transform", () => ({ ...worldToEcefTransform }));
|
|
45
|
+
const range = ThreeDTileFormatInterpreter.rangeFromBoundingVolume(json.root.boundingVolume);
|
|
46
|
+
if (undefined === worldToEcefTransform)
|
|
47
|
+
worldToEcefTransform = Transform.createIdentity();
|
|
48
|
+
const ecefRange = worldToEcefTransform.multiplyRange(range); // range in model -> range in ecef
|
|
49
|
+
const ecefCenter = worldToEcefTransform.multiplyPoint3d(range.center); // range center in model -> range center in ecef
|
|
50
|
+
const cartoCenter = Cartographic.fromEcef(ecefCenter); // ecef center to cartographic center
|
|
51
|
+
const isNotNearEarthSurface = cartoCenter && (cartoCenter.height < -5000); // 5 km under ground!
|
|
52
|
+
const earthCenterToRangeCenterRayLenght = range.center.magnitude();
|
|
53
|
+
if (worldToEcefTransform.matrix.isIdentity && (earthCenterToRangeCenterRayLenght < 1.0E5 || isNotNearEarthSurface)) {
|
|
54
|
+
isGeolocated = false;
|
|
55
|
+
worldRange.extendRange(Range3d.fromJSON(ecefRange));
|
|
56
|
+
const centerOfEarth = new EcefLocation({ origin: { x: 0.0, y: 0.0, z: 0.0 }, orientation: { yaw: 0.0, pitch: 0.0, roll: 0.0 } });
|
|
57
|
+
location = centerOfEarth;
|
|
58
|
+
Logger.logTrace(loggerCategory, "RealityData NOT Geolocated", () => ({ ...location }));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
let ecefLocation;
|
|
62
|
+
const locationOrientation = YawPitchRollAngles.tryFromTransform(worldToEcefTransform);
|
|
63
|
+
// Fix Bug 445630: [RDV][Regression] Orientation of georeferenced Reality Mesh is wrong.
|
|
64
|
+
// Use json.root.transform only if defined and not identity -> otherwise will use a transform computed from cartographic center.
|
|
65
|
+
if (!worldToEcefTransform.matrix.isIdentity && locationOrientation !== undefined && locationOrientation.angles !== undefined)
|
|
66
|
+
ecefLocation = new EcefLocation({ origin: locationOrientation.origin, orientation: locationOrientation.angles.toJSON() });
|
|
67
|
+
else
|
|
68
|
+
ecefLocation = EcefLocation.createFromCartographicOrigin(cartoCenter);
|
|
69
|
+
location = ecefLocation;
|
|
70
|
+
Logger.logTrace(loggerCategory, "RealityData is worldToEcefTransform.matrix.isIdentity", () => ({ isIdentity: worldToEcefTransform.matrix.isIdentity }));
|
|
71
|
+
// iModelDb.setEcefLocation(ecefLocation);
|
|
72
|
+
const ecefToWorld = ecefLocation.getTransform().inverse();
|
|
73
|
+
worldRange.extendRange(Range3d.fromJSON(ecefToWorld.multiplyRange(ecefRange)));
|
|
74
|
+
Logger.logTrace(loggerCategory, "RealityData ecefToWorld", () => ({ ...ecefToWorld }));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const spatialLocation = { location, worldRange, isGeolocated };
|
|
78
|
+
return spatialLocation;
|
|
79
|
+
}
|
|
80
|
+
/** Gets information to identify the product and engine that create this reality data
|
|
81
|
+
* Will return undefined if cannot be resolved
|
|
82
|
+
* @param rootDocjson root document file in json format
|
|
83
|
+
* @returns information to identify the product and engine that create this reality data
|
|
84
|
+
* @alpha
|
|
85
|
+
*/
|
|
86
|
+
static getPublisherProductInfo(rootDocjson) {
|
|
87
|
+
const info = { product: "", engine: "", version: "" };
|
|
88
|
+
if (rootDocjson && rootDocjson.root) {
|
|
89
|
+
if (rootDocjson.root.SMPublisherInfo) {
|
|
90
|
+
info.product = rootDocjson.root.SMPublisherInfo.Product ? rootDocjson.root.SMPublisherInfo.Product : "";
|
|
91
|
+
info.engine = rootDocjson.root.SMPublisherInfo.Publisher ? rootDocjson.root.SMPublisherInfo.Publisher : "";
|
|
92
|
+
info.version = rootDocjson.root.SMPublisherInfo["Publisher Version"] ? rootDocjson.root.SMPublisherInfo["Publisher Version"] : "";
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return info;
|
|
96
|
+
}
|
|
97
|
+
/** Gets information about 3dTile file for this reality data
|
|
98
|
+
* Will return undefined if cannot be resolved
|
|
99
|
+
* @param rootDocjson root document file in json format
|
|
100
|
+
* @returns information about 3dTile file for this reality data
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
static getFileInfo(rootDocjson) {
|
|
104
|
+
var _a, _b, _c;
|
|
105
|
+
const info = {
|
|
106
|
+
rootChildren: (_c = (_b = (_a = rootDocjson === null || rootDocjson === void 0 ? void 0 : rootDocjson.root) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0,
|
|
107
|
+
};
|
|
108
|
+
return info;
|
|
109
|
+
}
|
|
110
|
+
/** Convert a boundingVolume into a range
|
|
111
|
+
* @param boundingVolume the bounding volume to convert
|
|
112
|
+
* @returns the range or undefined if cannot convert
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
115
|
+
static rangeFromBoundingVolume(boundingVolume) {
|
|
116
|
+
if (undefined === boundingVolume)
|
|
117
|
+
return undefined;
|
|
118
|
+
if (Array.isArray(boundingVolume.box)) {
|
|
119
|
+
const box = boundingVolume.box;
|
|
120
|
+
const center = Point3d.create(box[0], box[1], box[2]);
|
|
121
|
+
const ux = Vector3d.create(box[3], box[4], box[5]);
|
|
122
|
+
const uy = Vector3d.create(box[6], box[7], box[8]);
|
|
123
|
+
const uz = Vector3d.create(box[9], box[10], box[11]);
|
|
124
|
+
const corners = [];
|
|
125
|
+
for (let j = 0; j < 2; j++) {
|
|
126
|
+
for (let k = 0; k < 2; k++) {
|
|
127
|
+
for (let l = 0; l < 2; l++) {
|
|
128
|
+
corners.push(center.plus3Scaled(ux, (j ? -1.0 : 1.0), uy, (k ? -1.0 : 1.0), uz, (l ? -1.0 : 1.0)));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return Range3d.createArray(corners);
|
|
133
|
+
}
|
|
134
|
+
else if (Array.isArray(boundingVolume.sphere)) {
|
|
135
|
+
const sphere = boundingVolume.sphere;
|
|
136
|
+
const center = Point3d.create(sphere[0], sphere[1], sphere[2]);
|
|
137
|
+
const radius = sphere[3];
|
|
138
|
+
return Range3d.createXYZXYZ(center.x - radius, center.y - radius, center.z - radius, center.x + radius, center.y + radius, center.z + radius);
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
/** Convert a boundingVolume into a range
|
|
143
|
+
* @internal
|
|
144
|
+
*/
|
|
145
|
+
static maximumSizeFromGeometricTolerance(range, geometricError) {
|
|
146
|
+
const minToleranceRatio = .5; // Nominally the error on screen size of a tile. Increasing generally increases performance (fewer draw calls) at expense of higher load times.
|
|
147
|
+
return minToleranceRatio * range.diagonal().magnitude() / geometricError;
|
|
148
|
+
}
|
|
149
|
+
/** Convert a boundingVolume into a range
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
static transformFromJson(jTrans) {
|
|
153
|
+
return (jTrans === undefined) ? undefined : Transform.createOriginAndMatrix(Point3d.create(jTrans[12], jTrans[13], jTrans[14]), Matrix3d.createRowValues(jTrans[0], jTrans[4], jTrans[8], jTrans[1], jTrans[5], jTrans[9], jTrans[2], jTrans[6], jTrans[10]));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=ThreeDTileFormatInterpreter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThreeDTileFormatInterpreter.js","sourceRoot":"","sources":["../../../src/tile/ThreeDTileFormatInterpreter.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,MAAM,cAAc,GAAW,sBAAsB,CAAC,WAAW,CAAC;AASlE;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IACtC;;;;OAIG;IACI,MAAM,CAAC,4BAA4B,CAAC,IAAS;QAClD,MAAM,UAAU,GAAG,IAAI,OAAO,EAAE,CAAC;QACjC,IAAI,YAAY,GAAG,IAAI,CAAC;QACxB,IAAI,QAAqC,CAAC;QAC1C,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,kCAAkC,CAAC,CAAC;QAEpE,IAAI,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE;YACjD,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YAElE,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,6CAA6C,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;YACtG,IAAI,SAAS,KAAK,MAAM,EAAE;gBACxB,MAAM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AK,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,qBAAqB,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAChQ,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 { JsonUtils, Logger } from \"@itwin/core-bentley\";\r\nimport { Cartographic, EcefLocation } from \"@itwin/core-common\";\r\nimport { Matrix3d, Point3d, Range3d, Transform, Vector3d, YawPitchRollAngles } from \"@itwin/core-geometry\";\r\nimport { FrontendLoggerCategory } from \"../FrontendLoggerCategory\";\r\nimport { PublisherProductInfo, SpatialLocationAndExtents } from \"../RealityDataSource\";\r\n\r\nconst loggerCategory: string = FrontendLoggerCategory.RealityData;\r\n/** This interface provides information about 3dTile files for this reality data\r\n * Currently only used for debbugging\r\n * @internal\r\n */\r\nexport interface ThreeDTileFileInfo {\r\n /** the number of children at the root of this reality data */\r\n rootChildren?: number;\r\n}\r\n/**\r\n * This class provide methods used to interpret Cesium 3dTile format\r\n * @internal\r\n */\r\nexport class ThreeDTileFormatInterpreter {\r\n /** Gets reality data spatial location and extents\r\n * @param json root document file in json format\r\n * @returns spatial location and volume of interest, in meters, centered around `spatial location`\r\n * @internal\r\n */\r\n public static getSpatialLocationAndExtents(json: any): SpatialLocationAndExtents {\r\n const worldRange = new Range3d();\r\n let isGeolocated = true;\r\n let location: Cartographic | EcefLocation;\r\n Logger.logTrace(loggerCategory, \"RealityData realityModelFromJson\");\r\n\r\n if (undefined !== json.root.boundingVolume.region) {\r\n const region = JsonUtils.asArray(json.root.boundingVolume.region);\r\n\r\n Logger.logTrace(loggerCategory, \"RealityData json.root.boundingVolume.region\", () => ({ ...region }));\r\n if (undefined === region) {\r\n Logger.logError(loggerCategory, `Error realityModelFromJson - region undefined`);\r\n throw new TypeError(\"Unable to determine GeoLocation - no root Transform or Region on root.\");\r\n }\r\n const ecefLow = (Cartographic.fromRadians({ longitude: region[0], latitude: region[1], height: region[4] })).toEcef();\r\n const ecefHigh = (Cartographic.fromRadians({ longitude: region[2], latitude: region[3], height: region[5] })).toEcef();\r\n const ecefRange = Range3d.create(ecefLow, ecefHigh);\r\n const cartoCenter = Cartographic.fromRadians({ longitude: (region[0] + region[2]) / 2.0, latitude: (region[1] + region[3]) / 2.0, height: (region[4] + region[5]) / 2.0 });\r\n location = cartoCenter;\r\n const ecefLocation = EcefLocation.createFromCartographicOrigin(cartoCenter);\r\n // iModelDb.setEcefLocation(ecefLocation);\r\n const ecefToWorld = ecefLocation.getTransform().inverse()!;\r\n worldRange.extendRange(Range3d.fromJSON(ecefToWorld.multiplyRange(ecefRange)));\r\n } else {\r\n let worldToEcefTransform = ThreeDTileFormatInterpreter.transformFromJson(json.root.transform);\r\n\r\n Logger.logTrace(loggerCategory, \"RealityData json.root.transform\", () => ({ ...worldToEcefTransform }));\r\n const range = ThreeDTileFormatInterpreter.rangeFromBoundingVolume(json.root.boundingVolume)!;\r\n if (undefined === worldToEcefTransform)\r\n worldToEcefTransform = Transform.createIdentity();\r\n\r\n const ecefRange = worldToEcefTransform.multiplyRange(range); // range in model -> range in ecef\r\n const ecefCenter = worldToEcefTransform.multiplyPoint3d(range.center); // range center in model -> range center in ecef\r\n const cartoCenter = Cartographic.fromEcef(ecefCenter); // ecef center to cartographic center\r\n const isNotNearEarthSurface = cartoCenter && (cartoCenter.height < -5000); // 5 km under ground!\r\n const earthCenterToRangeCenterRayLenght = range.center.magnitude();\r\n\r\n if (worldToEcefTransform.matrix.isIdentity && (earthCenterToRangeCenterRayLenght < 1.0E5 || isNotNearEarthSurface)) {\r\n isGeolocated = false;\r\n worldRange.extendRange(Range3d.fromJSON(ecefRange));\r\n const centerOfEarth = new EcefLocation({ origin: { x: 0.0, y: 0.0, z: 0.0 }, orientation: { yaw: 0.0, pitch: 0.0, roll: 0.0 } });\r\n location = centerOfEarth;\r\n Logger.logTrace(loggerCategory, \"RealityData NOT Geolocated\", () => ({ ...location }));\r\n } else {\r\n let ecefLocation: EcefLocation;\r\n const locationOrientation = YawPitchRollAngles.tryFromTransform(worldToEcefTransform);\r\n // Fix Bug 445630: [RDV][Regression] Orientation of georeferenced Reality Mesh is wrong.\r\n // Use json.root.transform only if defined and not identity -> otherwise will use a transform computed from cartographic center.\r\n if (!worldToEcefTransform.matrix.isIdentity && locationOrientation !== undefined && locationOrientation.angles !== undefined)\r\n ecefLocation = new EcefLocation({ origin: locationOrientation.origin, orientation: locationOrientation.angles.toJSON() });\r\n else\r\n ecefLocation = EcefLocation.createFromCartographicOrigin(cartoCenter!);\r\n location = ecefLocation;\r\n Logger.logTrace(loggerCategory, \"RealityData is worldToEcefTransform.matrix.isIdentity\", () => ({ isIdentity: worldToEcefTransform!.matrix.isIdentity }));\r\n // iModelDb.setEcefLocation(ecefLocation);\r\n const ecefToWorld = ecefLocation.getTransform().inverse()!;\r\n worldRange.extendRange(Range3d.fromJSON(ecefToWorld.multiplyRange(ecefRange)));\r\n Logger.logTrace(loggerCategory, \"RealityData ecefToWorld\", () => ({ ...ecefToWorld }));\r\n }\r\n }\r\n const spatialLocation: SpatialLocationAndExtents = { location, worldRange, isGeolocated };\r\n return spatialLocation;\r\n }\r\n /** Gets information to identify the product and engine that create this reality data\r\n * Will return undefined if cannot be resolved\r\n * @param rootDocjson root document file in json format\r\n * @returns information to identify the product and engine that create this reality data\r\n * @alpha\r\n */\r\n public static getPublisherProductInfo(rootDocjson: any): PublisherProductInfo {\r\n const info: PublisherProductInfo = {product: \"\", engine: \"\", version: \"\"};\r\n if (rootDocjson && rootDocjson.root) {\r\n if (rootDocjson.root.SMPublisherInfo) {\r\n info.product = rootDocjson.root.SMPublisherInfo.Product ? rootDocjson.root.SMPublisherInfo.Product : \"\";\r\n info.engine = rootDocjson.root.SMPublisherInfo.Publisher ? rootDocjson.root.SMPublisherInfo.Publisher : \"\";\r\n info.version = rootDocjson.root.SMPublisherInfo[\"Publisher Version\"] ? rootDocjson.root.SMPublisherInfo[\"Publisher Version\"] : \"\" ;\r\n }\r\n }\r\n return info;\r\n }\r\n /** Gets information about 3dTile file for this reality data\r\n * Will return undefined if cannot be resolved\r\n * @param rootDocjson root document file in json format\r\n * @returns information about 3dTile file for this reality data\r\n * @internal\r\n */\r\n public static getFileInfo(rootDocjson: any): ThreeDTileFileInfo {\r\n const info: ThreeDTileFileInfo = {\r\n rootChildren: rootDocjson?.root?.children?.length ?? 0,\r\n };\r\n return info;\r\n }\r\n /** Convert a boundingVolume into a range\r\n * @param boundingVolume the bounding volume to convert\r\n * @returns the range or undefined if cannot convert\r\n * @internal\r\n */\r\n public static rangeFromBoundingVolume(boundingVolume: any): Range3d | undefined {\r\n if (undefined === boundingVolume)\r\n return undefined;\r\n if (Array.isArray(boundingVolume.box)) {\r\n const box: number[] = boundingVolume.box;\r\n const center = Point3d.create(box[0], box[1], box[2]);\r\n const ux = Vector3d.create(box[3], box[4], box[5]);\r\n const uy = Vector3d.create(box[6], box[7], box[8]);\r\n const uz = Vector3d.create(box[9], box[10], box[11]);\r\n const corners: Point3d[] = [];\r\n for (let j = 0; j < 2; j++) {\r\n for (let k = 0; k < 2; k++) {\r\n for (let l = 0; l < 2; l++) {\r\n corners.push(center.plus3Scaled(ux, (j ? -1.0 : 1.0), uy, (k ? -1.0 : 1.0), uz, (l ? -1.0 : 1.0)));\r\n }\r\n }\r\n }\r\n return Range3d.createArray(corners);\r\n } else if (Array.isArray(boundingVolume.sphere)) {\r\n const sphere: number[] = boundingVolume.sphere;\r\n const center = Point3d.create(sphere[0], sphere[1], sphere[2]);\r\n const radius = sphere[3];\r\n return Range3d.createXYZXYZ(center.x - radius, center.y - radius, center.z - radius, center.x + radius, center.y + radius, center.z + radius);\r\n }\r\n return undefined;\r\n }\r\n /** Convert a boundingVolume into a range\r\n * @internal\r\n */\r\n public static maximumSizeFromGeometricTolerance(range: Range3d, geometricError: number): number {\r\n const minToleranceRatio = .5; // Nominally the error on screen size of a tile. Increasing generally increases performance (fewer draw calls) at expense of higher load times.\r\n return minToleranceRatio * range.diagonal().magnitude() / geometricError;\r\n }\r\n /** Convert a boundingVolume into a range\r\n * @internal\r\n */\r\n public static transformFromJson(jTrans: number[] | undefined): Transform | undefined {\r\n return (jTrans === undefined) ? undefined : Transform.createOriginAndMatrix(Point3d.create(jTrans[12], jTrans[13], jTrans[14]), Matrix3d.createRowValues(jTrans[0], jTrans[4], jTrans[8], jTrans[1], jTrans[5], jTrans[9], jTrans[2], jTrans[6], jTrans[10]));\r\n }\r\n}\r\n"]}
|
|
@@ -76,4 +76,6 @@ export * from "./map/MapLayerSources";
|
|
|
76
76
|
export * from "./map/MapTiledGraphicsProvider";
|
|
77
77
|
export * from "./CesiumAssetProvider";
|
|
78
78
|
export * from "./ContextShareProvider";
|
|
79
|
+
export * from "./ThreeDTileFormatInterpreter";
|
|
80
|
+
export * from "./OPCFormatInterpreter";
|
|
79
81
|
//# sourceMappingURL=internal.d.ts.map
|