@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.
Files changed (136) hide show
  1. package/CHANGELOG.md +156 -35
  2. package/lib/cjs/DrawingViewState.d.ts.map +1 -1
  3. package/lib/cjs/DrawingViewState.js +6 -5
  4. package/lib/cjs/DrawingViewState.js.map +1 -1
  5. package/lib/cjs/IModelApp.d.ts +1 -3
  6. package/lib/cjs/IModelApp.d.ts.map +1 -1
  7. package/lib/cjs/IModelApp.js +8 -6
  8. package/lib/cjs/IModelApp.js.map +1 -1
  9. package/lib/cjs/RealityDataSource.d.ts +50 -14
  10. package/lib/cjs/RealityDataSource.d.ts.map +1 -1
  11. package/lib/cjs/RealityDataSource.js +19 -241
  12. package/lib/cjs/RealityDataSource.js.map +1 -1
  13. package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.d.ts +67 -0
  14. package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.d.ts.map +1 -0
  15. package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.js +166 -0
  16. package/lib/cjs/RealityDataSourceCesiumIonAssetImpl.js.map +1 -0
  17. package/lib/cjs/RealityDataSourceContextShareImpl.d.ts +83 -0
  18. package/lib/cjs/RealityDataSourceContextShareImpl.d.ts.map +1 -0
  19. package/lib/cjs/RealityDataSourceContextShareImpl.js +234 -0
  20. package/lib/cjs/RealityDataSourceContextShareImpl.js.map +1 -0
  21. package/lib/cjs/RealityDataSourceTilesetUrlImpl.d.ts +65 -0
  22. package/lib/cjs/RealityDataSourceTilesetUrlImpl.d.ts.map +1 -0
  23. package/lib/cjs/RealityDataSourceTilesetUrlImpl.js +135 -0
  24. package/lib/cjs/RealityDataSourceTilesetUrlImpl.js.map +1 -0
  25. package/lib/cjs/SheetViewState.js +4 -0
  26. package/lib/cjs/SheetViewState.js.map +1 -1
  27. package/lib/cjs/ViewState.d.ts +8 -0
  28. package/lib/cjs/ViewState.d.ts.map +1 -1
  29. package/lib/cjs/ViewState.js.map +1 -1
  30. package/lib/cjs/Viewport.d.ts +19 -3
  31. package/lib/cjs/Viewport.d.ts.map +1 -1
  32. package/lib/cjs/Viewport.js +20 -0
  33. package/lib/cjs/Viewport.js.map +1 -1
  34. package/lib/cjs/core-frontend.d.ts +1 -0
  35. package/lib/cjs/core-frontend.d.ts.map +1 -1
  36. package/lib/cjs/core-frontend.js +1 -0
  37. package/lib/cjs/core-frontend.js.map +1 -1
  38. package/lib/cjs/quantity-formatting/BasicUnitsProvider.d.ts +2 -2
  39. package/lib/cjs/quantity-formatting/BasicUnitsProvider.d.ts.map +1 -1
  40. package/lib/cjs/quantity-formatting/BasicUnitsProvider.js +48 -44
  41. package/lib/cjs/quantity-formatting/BasicUnitsProvider.js.map +1 -1
  42. package/lib/cjs/quantity-formatting/QuantityFormatter.d.ts +90 -80
  43. package/lib/cjs/quantity-formatting/QuantityFormatter.d.ts.map +1 -1
  44. package/lib/cjs/quantity-formatting/QuantityFormatter.js +76 -45
  45. package/lib/cjs/quantity-formatting/QuantityFormatter.js.map +1 -1
  46. package/lib/cjs/quantity-formatting/QuantityTypesEditorSpecs.d.ts +54 -0
  47. package/lib/cjs/quantity-formatting/QuantityTypesEditorSpecs.d.ts.map +1 -0
  48. package/lib/cjs/quantity-formatting/QuantityTypesEditorSpecs.js +32 -0
  49. package/lib/cjs/quantity-formatting/QuantityTypesEditorSpecs.js.map +1 -0
  50. package/lib/cjs/quantity-formatting/UnitsData.d.ts +11 -0
  51. package/lib/cjs/quantity-formatting/UnitsData.d.ts.map +1 -0
  52. package/lib/cjs/quantity-formatting/UnitsData.js +59 -0
  53. package/lib/cjs/quantity-formatting/UnitsData.js.map +1 -0
  54. package/lib/cjs/tile/OPCFormatInterpreter.d.ts +21 -0
  55. package/lib/cjs/tile/OPCFormatInterpreter.d.ts.map +1 -0
  56. package/lib/cjs/tile/OPCFormatInterpreter.js +81 -0
  57. package/lib/cjs/tile/OPCFormatInterpreter.js.map +1 -0
  58. package/lib/cjs/tile/PntsReader.d.ts.map +1 -1
  59. package/lib/cjs/tile/PntsReader.js +79 -17
  60. package/lib/cjs/tile/PntsReader.js.map +1 -1
  61. package/lib/cjs/tile/ThreeDTileFormatInterpreter.d.ts +51 -0
  62. package/lib/cjs/tile/ThreeDTileFormatInterpreter.d.ts.map +1 -0
  63. package/lib/cjs/tile/ThreeDTileFormatInterpreter.js +160 -0
  64. package/lib/cjs/tile/ThreeDTileFormatInterpreter.js.map +1 -0
  65. package/lib/cjs/tile/internal.d.ts +2 -0
  66. package/lib/cjs/tile/internal.d.ts.map +1 -1
  67. package/lib/cjs/tile/internal.js +2 -0
  68. package/lib/cjs/tile/internal.js.map +1 -1
  69. package/lib/esm/DrawingViewState.d.ts.map +1 -1
  70. package/lib/esm/DrawingViewState.js +6 -5
  71. package/lib/esm/DrawingViewState.js.map +1 -1
  72. package/lib/esm/IModelApp.d.ts +1 -3
  73. package/lib/esm/IModelApp.d.ts.map +1 -1
  74. package/lib/esm/IModelApp.js +8 -6
  75. package/lib/esm/IModelApp.js.map +1 -1
  76. package/lib/esm/RealityDataSource.d.ts +50 -14
  77. package/lib/esm/RealityDataSource.d.ts.map +1 -1
  78. package/lib/esm/RealityDataSource.js +22 -244
  79. package/lib/esm/RealityDataSource.js.map +1 -1
  80. package/lib/esm/RealityDataSourceCesiumIonAssetImpl.d.ts +67 -0
  81. package/lib/esm/RealityDataSourceCesiumIonAssetImpl.d.ts.map +1 -0
  82. package/lib/esm/RealityDataSourceCesiumIonAssetImpl.js +162 -0
  83. package/lib/esm/RealityDataSourceCesiumIonAssetImpl.js.map +1 -0
  84. package/lib/esm/RealityDataSourceContextShareImpl.d.ts +83 -0
  85. package/lib/esm/RealityDataSourceContextShareImpl.d.ts.map +1 -0
  86. package/lib/esm/RealityDataSourceContextShareImpl.js +230 -0
  87. package/lib/esm/RealityDataSourceContextShareImpl.js.map +1 -0
  88. package/lib/esm/RealityDataSourceTilesetUrlImpl.d.ts +65 -0
  89. package/lib/esm/RealityDataSourceTilesetUrlImpl.d.ts.map +1 -0
  90. package/lib/esm/RealityDataSourceTilesetUrlImpl.js +131 -0
  91. package/lib/esm/RealityDataSourceTilesetUrlImpl.js.map +1 -0
  92. package/lib/esm/SheetViewState.js +4 -0
  93. package/lib/esm/SheetViewState.js.map +1 -1
  94. package/lib/esm/ViewState.d.ts +8 -0
  95. package/lib/esm/ViewState.d.ts.map +1 -1
  96. package/lib/esm/ViewState.js.map +1 -1
  97. package/lib/esm/Viewport.d.ts +19 -3
  98. package/lib/esm/Viewport.d.ts.map +1 -1
  99. package/lib/esm/Viewport.js +20 -0
  100. package/lib/esm/Viewport.js.map +1 -1
  101. package/lib/esm/core-frontend.d.ts +1 -0
  102. package/lib/esm/core-frontend.d.ts.map +1 -1
  103. package/lib/esm/core-frontend.js +1 -0
  104. package/lib/esm/core-frontend.js.map +1 -1
  105. package/lib/esm/quantity-formatting/BasicUnitsProvider.d.ts +2 -2
  106. package/lib/esm/quantity-formatting/BasicUnitsProvider.d.ts.map +1 -1
  107. package/lib/esm/quantity-formatting/BasicUnitsProvider.js +48 -44
  108. package/lib/esm/quantity-formatting/BasicUnitsProvider.js.map +1 -1
  109. package/lib/esm/quantity-formatting/QuantityFormatter.d.ts +90 -80
  110. package/lib/esm/quantity-formatting/QuantityFormatter.d.ts.map +1 -1
  111. package/lib/esm/quantity-formatting/QuantityFormatter.js +75 -41
  112. package/lib/esm/quantity-formatting/QuantityFormatter.js.map +1 -1
  113. package/lib/esm/quantity-formatting/QuantityTypesEditorSpecs.d.ts +54 -0
  114. package/lib/esm/quantity-formatting/QuantityTypesEditorSpecs.d.ts.map +1 -0
  115. package/lib/esm/quantity-formatting/QuantityTypesEditorSpecs.js +26 -0
  116. package/lib/esm/quantity-formatting/QuantityTypesEditorSpecs.js.map +1 -0
  117. package/lib/esm/quantity-formatting/UnitsData.d.ts +11 -0
  118. package/lib/esm/quantity-formatting/UnitsData.d.ts.map +1 -0
  119. package/lib/esm/quantity-formatting/UnitsData.js +56 -0
  120. package/lib/esm/quantity-formatting/UnitsData.js.map +1 -0
  121. package/lib/esm/tile/OPCFormatInterpreter.d.ts +21 -0
  122. package/lib/esm/tile/OPCFormatInterpreter.d.ts.map +1 -0
  123. package/lib/esm/tile/OPCFormatInterpreter.js +77 -0
  124. package/lib/esm/tile/OPCFormatInterpreter.js.map +1 -0
  125. package/lib/esm/tile/PntsReader.d.ts.map +1 -1
  126. package/lib/esm/tile/PntsReader.js +79 -17
  127. package/lib/esm/tile/PntsReader.js.map +1 -1
  128. package/lib/esm/tile/ThreeDTileFormatInterpreter.d.ts +51 -0
  129. package/lib/esm/tile/ThreeDTileFormatInterpreter.d.ts.map +1 -0
  130. package/lib/esm/tile/ThreeDTileFormatInterpreter.js +156 -0
  131. package/lib/esm/tile/ThreeDTileFormatInterpreter.js.map +1 -0
  132. package/lib/esm/tile/internal.d.ts +2 -0
  133. package/lib/esm/tile/internal.d.ts.map +1 -1
  134. package/lib/esm/tile/internal.js +2 -0
  135. package/lib/esm/tile/internal.js.map +1 -1
  136. 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;AACU,QAAA,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,EAA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AAgB,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,81 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.OPCFormatInterpreter = void 0;
8
+ const core_common_1 = require("@itwin/core-common");
9
+ const core_geometry_1 = require("@itwin/core-geometry");
10
+ const core_orbitgt_1 = require("@itwin/core-orbitgt");
11
+ const FrontendLoggerCategory_1 = require("../FrontendLoggerCategory");
12
+ const DownloaderNode_1 = require("@itwin/core-orbitgt/lib/cjs/system/runtime/DownloaderNode");
13
+ const core_bentley_1 = require("@itwin/core-bentley");
14
+ const loggerCategory = FrontendLoggerCategory_1.FrontendLoggerCategory.RealityData;
15
+ /**
16
+ * This class provide methods used to interpret Orbit Point Cloud (OPC) format
17
+ * @internal
18
+ */
19
+ class OPCFormatInterpreter {
20
+ /** Gets an OPC file reader from a blobFileUrl
21
+ * @param blobFileURL the name of the file.
22
+ * @returns return a file reader open to read provided blob file
23
+ * @internal
24
+ */
25
+ static async getFileReaderFromBlobFileURL(blobFileURL) {
26
+ if (core_orbitgt_1.Downloader.INSTANCE == null)
27
+ core_orbitgt_1.Downloader.INSTANCE = new DownloaderNode_1.DownloaderNode();
28
+ if (core_orbitgt_1.CRSManager.ENGINE == null)
29
+ core_orbitgt_1.CRSManager.ENGINE = await core_orbitgt_1.OnlineEngine.create();
30
+ // let blobFileURL: string = rdUrl;
31
+ // if (accountName.length > 0) blobFileURL = UrlFS.getAzureBlobSasUrl(opcConfig.accountName, opcConfig.containerName, opcConfig.blobFileName, opcConfig.sasToken);
32
+ const urlFS = new core_orbitgt_1.UrlFS();
33
+ // wrap a caching layer (16 MB) around the blob file
34
+ const blobFileSize = await urlFS.getFileLength(blobFileURL);
35
+ core_bentley_1.Logger.logTrace(loggerCategory, `OPC File Size is ${blobFileSize}`);
36
+ const blobFile = new core_orbitgt_1.PageCachedFile(urlFS, blobFileURL, blobFileSize, 128 * 1024 /* pageSize */, 128 /* maxPageCount */);
37
+ const fileReader = await core_orbitgt_1.OPCReader.openFile(blobFile, blobFileURL, true /* lazyLoading */);
38
+ return fileReader;
39
+ }
40
+ /** Gets reality data spatial location and extents
41
+ * @param fileReader a file reader instance obtains from call to getFileReaderFromBlobFileURL
42
+ * @returns spatial location and volume of interest, in meters, centered around `spatial location`
43
+ * @internal
44
+ */
45
+ static async getSpatialLocationAndExtents(fileReader) {
46
+ let worldRange = new core_geometry_1.Range3d();
47
+ let location;
48
+ let isGeolocated = true;
49
+ const bounds = fileReader.getFileBounds();
50
+ worldRange = core_geometry_1.Range3d.createXYZXYZ(bounds.getMinX(), bounds.getMinY(), bounds.getMinZ(), bounds.getMaxX(), bounds.getMaxY(), bounds.getMaxZ());
51
+ isGeolocated = false;
52
+ const fileCrs = fileReader.getFileCRS();
53
+ if (fileCrs) {
54
+ await core_orbitgt_1.CRSManager.ENGINE.prepareForArea(fileCrs, bounds);
55
+ const wgs84ECEFCrs = "4978";
56
+ await core_orbitgt_1.CRSManager.ENGINE.prepareForArea(wgs84ECEFCrs, new core_orbitgt_1.OrbitGtBounds());
57
+ const ecefBounds = core_orbitgt_1.CRSManager.transformBounds(bounds, fileCrs, wgs84ECEFCrs);
58
+ const ecefRange = core_geometry_1.Range3d.createXYZXYZ(ecefBounds.getMinX(), ecefBounds.getMinY(), ecefBounds.getMinZ(), ecefBounds.getMaxX(), ecefBounds.getMaxY(), ecefBounds.getMaxZ());
59
+ const ecefCenter = ecefRange.localXYZToWorld(.5, .5, .5);
60
+ const cartoCenter = core_common_1.Cartographic.fromEcef(ecefCenter);
61
+ cartoCenter.height = 0;
62
+ const ecefLocation = core_common_1.EcefLocation.createFromCartographicOrigin(cartoCenter);
63
+ location = ecefLocation;
64
+ // this.iModelDb.setEcefLocation(ecefLocation);
65
+ const ecefToWorld = ecefLocation.getTransform().inverse();
66
+ worldRange = ecefToWorld.multiplyRange(ecefRange);
67
+ isGeolocated = true;
68
+ }
69
+ else {
70
+ // NoGCS case
71
+ isGeolocated = false;
72
+ const centerOfEarth = new core_common_1.EcefLocation({ origin: { x: 0.0, y: 0.0, z: 0.0 }, orientation: { yaw: 0.0, pitch: 0.0, roll: 0.0 } });
73
+ location = centerOfEarth;
74
+ core_bentley_1.Logger.logTrace(loggerCategory, "OPC RealityData NOT Geolocated", () => ({ ...location }));
75
+ }
76
+ const spatialLocation = { location, worldRange, isGeolocated };
77
+ return spatialLocation;
78
+ }
79
+ }
80
+ exports.OPCFormatInterpreter = OPCFormatInterpreter;
81
+ //# 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,oDAAgE;AAChE,wDAA+C;AAC/C,sDAAqJ;AACrJ,sEAAmE;AACnE,8FAA2F;AAC3F,sDAA6C;AAG7C,MAAM,cAAc,GAAW,+CAAsB,CAAC,WAAW,CAAC;AAElE;;;GAGG;AACH,MAAa,oBAAoB;IAC/B;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,WAAmB;QAClE,IAAI,yBAAU,CAAC,QAAQ,IAAI,IAAI;YAC7B,yBAAU,CAAC,QAAQ,GAAG,IAAI,+BAAc,EAAE,CAAC;QAC7C,IAAI,yBAAU,CAAC,MAAM,IAAI,IAAI;YAC3B,yBAAU,CAAC,MAAM,GAAG,MAAM,2BAAY,CAAC,MAAM,EAAE,CAAC;QAElD,mCAAmC;QACnC,kKAAkK;QAClK,MAAM,KAAK,GAAU,IAAI,oBAAK,EAAE,CAAC;QACjC,oDAAoD;QACpD,MAAM,YAAY,GAAU,MAAM,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QACnE,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,oBAAoB,YAAY,EAAE,CAAC,CAAC;QACpE,MAAM,QAAQ,GAAmB,IAAI,6BAAc,CAAC,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACzI,MAAM,UAAU,GAAqB,MAAM,wBAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAA,iBAAiB,CAAC,CAAC;Q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,CAAC;YAC1D,MAAM,WAAW,GAAG,0BAAY,CAAC,QAAQ,CAAC,UAAU,CAAE,CAAC;YACvD,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;YACvB,MAAM,YAAY,GAAG,0BAAY,CAAC,4BAA4B,CAAC,WAAW,CAAC,CAAC;YAC5E,QAAQ,GAAG,YAAY,CAAC;YACxB,+CAA+C;YAC/C,MAAM,WAAW,GAAG,YAAY,CAAC,YAAY,EAAE,CAAC,OAAO,EAAG,CAAC;YAC3D,UAAU,GAAG,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YAClD,YAAY,GAAG,IAAI,CAAC;SACrB;aAAM;YACL,aAAa;YACb,YAAY,GAAG,KAAK,CAAC;YACrB,MAAM,aAAa,GAAG,IAAI,0BAAY,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YACjI,QAAQ,GAAG,aAAa,CAAC;YACzB,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,gCAAgC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,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;AA/DD,oDA+DC","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;AA0GtD;;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,CA+CvN"}
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"}
@@ -33,6 +33,70 @@ const core_common_1 = require("@itwin/core-common");
33
33
  const FrontendLoggerCategory_1 = require("../FrontendLoggerCategory");
34
34
  const MeshPrimitives_1 = require("../render/primitives/mesh/MeshPrimitives");
35
35
  const PointCloudPrimitive_1 = require("../render/primitives/PointCloudPrimitive");
36
+ function readPntsColors(stream, dataOffset, pnts) {
37
+ const nPts = pnts.POINTS_LENGTH;
38
+ const nComponents = 3 * nPts;
39
+ if (pnts.RGB)
40
+ return new Uint8Array(stream.arrayBuffer, dataOffset + pnts.RGB.byteOffset, nComponents);
41
+ if (pnts.RGBA) {
42
+ // ###TODO support point cloud transparency.
43
+ const rgb = new Uint8Array(nComponents);
44
+ const rgba = new Uint8Array(stream.arrayBuffer, dataOffset + pnts.RGBA.byteOffset, nComponents);
45
+ for (let i = 0; i < nComponents; i += 4) {
46
+ rgb[i + 0] = rgba[i + 0];
47
+ rgb[i + 1] = rgba[i + 1];
48
+ rgb[i + 2] = rgba[i + 2];
49
+ }
50
+ return rgb;
51
+ }
52
+ else if (pnts.RGB565) {
53
+ // Each color is 16 bits: 5 red, 6 green, 5 blue.
54
+ const crgb = new Uint16Array(stream.arrayBuffer, dataOffset + pnts.RGB565.byteOffset, nPts);
55
+ const rgb = new Uint8Array(nComponents);
56
+ for (let i = 0; i < nPts; i++) {
57
+ const c = crgb[i];
58
+ rgb[i + 0] = (c >> 11) & 0x1f;
59
+ rgb[i + 1] = (c >> 5) & 0x3f;
60
+ rgb[i + 2] = c & 0x1f;
61
+ }
62
+ return rgb;
63
+ }
64
+ return undefined;
65
+ }
66
+ function readPnts(stream, dataOffset, pnts) {
67
+ const nPts = pnts.POINTS_LENGTH;
68
+ let params;
69
+ let points;
70
+ if (pnts.POSITION_QUANTIZED) {
71
+ const qpos = pnts.POSITION_QUANTIZED;
72
+ const offset = pnts.QUANTIZED_VOLUME_OFFSET;
73
+ const scale = pnts.QUANTIZED_VOLUME_SCALE;
74
+ const qOrigin = new core_geometry_1.Point3d(offset[0], offset[1], offset[2]);
75
+ const qScale = new core_geometry_1.Point3d(core_common_1.Quantization.computeScale(scale[0]), core_common_1.Quantization.computeScale(scale[1]), core_common_1.Quantization.computeScale(scale[2]));
76
+ params = core_common_1.QParams3d.fromOriginAndScale(qOrigin, qScale);
77
+ points = new Uint16Array(stream.arrayBuffer, dataOffset + qpos.byteOffset, 3 * nPts);
78
+ }
79
+ else {
80
+ const nCoords = nPts * 3;
81
+ const fpts = new Float32Array(stream.arrayBuffer, dataOffset + pnts.POSITION.byteOffset, 3 * nPts);
82
+ const range = core_geometry_1.Range3d.createNull();
83
+ for (let i = 0; i < nCoords; i += 3)
84
+ range.extendXYZ(fpts[i], fpts[i + 1], fpts[i + 2]);
85
+ params = core_common_1.QParams3d.fromRange(range);
86
+ const qpt = new core_common_1.QPoint3d();
87
+ const fpt = new core_geometry_1.Point3d();
88
+ points = new Uint16Array(3 * nPts);
89
+ for (let i = 0; i < nCoords; i += 3) {
90
+ fpt.set(fpts[i], fpts[i + 1], fpts[i + 2]);
91
+ qpt.init(fpt, params);
92
+ points[i] = qpt.x;
93
+ points[i + 1] = qpt.y;
94
+ points[i + 2] = qpt.z;
95
+ }
96
+ }
97
+ const colors = readPntsColors(stream, dataOffset, pnts);
98
+ return { params, points, colors };
99
+ }
36
100
  async function decodeDracoPointCloud(buf) {
37
101
  var _a, _b, _c, _d, _e, _f;
38
102
  try {
@@ -45,6 +109,7 @@ async function decodeDracoPointCloud(buf) {
45
109
  return undefined;
46
110
  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;
47
111
  if (!colors) {
112
+ // ###TODO support point cloud transparency.
48
113
  const rgba = (_e = mesh.attributes.RGBA) === null || _e === void 0 ? void 0 : _e.value;
49
114
  if (rgba && (rgba.length % 4) === 0) {
50
115
  // We currently don't support alpha channel for point clouds - strip it.
@@ -86,21 +151,6 @@ async function decodeDracoPointCloud(buf) {
86
151
  return undefined;
87
152
  }
88
153
  }
89
- function readPnts(stream, dataOffset, pnts) {
90
- const offset = pnts.QUANTIZED_VOLUME_OFFSET;
91
- const scale = pnts.QUANTIZED_VOLUME_SCALE;
92
- const qpos = pnts.POSITION_QUANTIZED;
93
- const nPts = pnts.POINTS_LENGTH;
94
- if (!offset || !scale || !qpos || !nPts)
95
- return undefined;
96
- const qOrigin = new core_geometry_1.Point3d(offset[0], offset[1], offset[2]);
97
- const qScale = new core_geometry_1.Point3d(core_common_1.Quantization.computeScale(scale[0]), core_common_1.Quantization.computeScale(scale[1]), core_common_1.Quantization.computeScale(scale[2]));
98
- return {
99
- params: core_common_1.QParams3d.fromOriginAndScale(qOrigin, qScale),
100
- points: new Uint16Array(stream.arrayBuffer, dataOffset + qpos.byteOffset, 3 * nPts),
101
- colors: pnts.RGB ? new Uint8Array(stream.arrayBuffer, dataOffset + pnts.RGB.byteOffset, 3 * nPts) : undefined,
102
- };
103
- }
104
154
  /** Deserialize a point cloud tile and return it as a RenderGraphic.
105
155
  * @internal
106
156
  */
@@ -134,10 +184,22 @@ async function readPointCloudTileContent(stream, iModel, modelId, _is3d, range,
134
184
  if (featureValue.RTC_CENTER)
135
185
  props.params = core_common_1.QParams3d.fromOriginAndScale(props.params.origin.plus(core_geometry_1.Vector3d.fromJSON(featureValue.RTC_CENTER)), props.params.scale);
136
186
  if (!props.colors) {
187
+ // ###TODO we really should support uniform color instead of allocating an RGB value per point...
137
188
  props.colors = new Uint8Array(3 * featureValue.POINTS_LENGTH);
138
- props.colors.fill(0xff, 0, props.colors.length); // TBD... Default color?
189
+ const rgba = featureValue.CONSTANT_RGBA;
190
+ if (rgba) {
191
+ // ###TODO support point cloud transparency.
192
+ for (let i = 0; i < featureValue.POINTS_LENGTH * 3; i += 3) {
193
+ props.colors[i] = rgba[0];
194
+ props.colors[i + 1] = rgba[1];
195
+ props.colors[i + 2] = rgba[2];
196
+ }
197
+ }
198
+ else {
199
+ // Default to white.
200
+ props.colors.fill(0xff, 0, props.colors.length);
201
+ }
139
202
  }
140
- // ###TODO? Do we expect a batch table? not currently handled...
141
203
  const featureTable = new core_common_1.FeatureTable(1, modelId, core_common_1.BatchType.Primary);
142
204
  const features = new MeshPrimitives_1.Mesh.Features(featureTable);
143
205
  features.add(new core_common_1.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,sDAAmF;AACnF,wDAAkE;AAClE,oDAA8J;AAC9J,sEAAmE;AAEnE,6EAAgE;AAChE,kFAA0E;AA0B1E,KAAK,UAAU,qBAAqB,CAAC,GAAe;;IAClD,IAAI;QACF,MAAM,WAAW,GAAG,CAAC,wDAAa,mBAAmB,GAAC,CAAC,CAAC,WAAW,CAAC;QACpE,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,EAAG,CAAC,CAAC;QAC/C,IAAI,IAAI,CAAC,QAAQ,KAAK,YAAY;YAChC,OAAO,SAAS,CAAC;QAEnB,MAAM,GAAG,GAAG,MAAA,IAAI,CAAC,UAAU,CAAC,QAAQ,0CAAE,KAAK,CAAC;QAC5C,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC;YAChC,OAAO,SAAS,CAAC;QAEnB,IAAI,MAAM,GAAG,MAAA,MAAA,IAAI,CAAC,UAAU,CAAC,GAAG,0CAAE,KAAK,mCAAI,MAAA,IAAI,CAAC,UAAU,CAAC,OAAO,0CAAE,KAAK,CAAC;QAC1E,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,GAAG,MAAA,IAAI,CAAC,UAAU,CAAC,IAAI,0CAAE,KAAK,CAAC;YACzC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,C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,IAAI,CAAC,wBAAQ,CAAC,QAAQ,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,0BAAY,CAAC,CAAC,EAAE,OAAO,EAAE,uBAAS,CAAC,OAAO,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,IAAI,qBAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACjD,QAAQ,CAAC,GAAG,CAAC,IAAI,qBAAO,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,oCAAc,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,gCAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;IACjG,OAAO,aAAa,CAAC;AACvB,CAAC;AA/CD,8DA+CC","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,sDAAmF;AACnF,wDAAkE;AAClE,oDAA8J;AAC9J,sEAAmE;AAEnE,6EAAgE;AAChE,kFAA0E;AAsE1E,SAAS,cAAc,CAAC,MAAkB,EAAE,UAAkB,EAAE,IAAe;IAC7E,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC;IAChC,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,CAAC;IAC7B,IAAI,IAAI,CAAC,GAAG;QACV,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,WAAW,EAAE,UAA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jG,OAAO,aAAa,CAAC;AACvB,CAAC;AA1DD,8DA0DC","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,160 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ThreeDTileFormatInterpreter = void 0;
8
+ const core_bentley_1 = require("@itwin/core-bentley");
9
+ const core_common_1 = require("@itwin/core-common");
10
+ const core_geometry_1 = require("@itwin/core-geometry");
11
+ const FrontendLoggerCategory_1 = require("../FrontendLoggerCategory");
12
+ const loggerCategory = FrontendLoggerCategory_1.FrontendLoggerCategory.RealityData;
13
+ /**
14
+ * This class provide methods used to interpret Cesium 3dTile format
15
+ * @internal
16
+ */
17
+ class ThreeDTileFormatInterpreter {
18
+ /** Gets reality data spatial location and extents
19
+ * @param json root document file in json format
20
+ * @returns spatial location and volume of interest, in meters, centered around `spatial location`
21
+ * @internal
22
+ */
23
+ static getSpatialLocationAndExtents(json) {
24
+ const worldRange = new core_geometry_1.Range3d();
25
+ let isGeolocated = true;
26
+ let location;
27
+ core_bentley_1.Logger.logTrace(loggerCategory, "RealityData realityModelFromJson");
28
+ if (undefined !== json.root.boundingVolume.region) {
29
+ const region = core_bentley_1.JsonUtils.asArray(json.root.boundingVolume.region);
30
+ core_bentley_1.Logger.logTrace(loggerCategory, "RealityData json.root.boundingVolume.region", () => ({ ...region }));
31
+ if (undefined === region) {
32
+ core_bentley_1.Logger.logError(loggerCategory, `Error realityModelFromJson - region undefined`);
33
+ throw new TypeError("Unable to determine GeoLocation - no root Transform or Region on root.");
34
+ }
35
+ const ecefLow = (core_common_1.Cartographic.fromRadians({ longitude: region[0], latitude: region[1], height: region[4] })).toEcef();
36
+ const ecefHigh = (core_common_1.Cartographic.fromRadians({ longitude: region[2], latitude: region[3], height: region[5] })).toEcef();
37
+ const ecefRange = core_geometry_1.Range3d.create(ecefLow, ecefHigh);
38
+ const cartoCenter = core_common_1.Cartographic.fromRadians({ longitude: (region[0] + region[2]) / 2.0, latitude: (region[1] + region[3]) / 2.0, height: (region[4] + region[5]) / 2.0 });
39
+ location = cartoCenter;
40
+ const ecefLocation = core_common_1.EcefLocation.createFromCartographicOrigin(cartoCenter);
41
+ // iModelDb.setEcefLocation(ecefLocation);
42
+ const ecefToWorld = ecefLocation.getTransform().inverse();
43
+ worldRange.extendRange(core_geometry_1.Range3d.fromJSON(ecefToWorld.multiplyRange(ecefRange)));
44
+ }
45
+ else {
46
+ let worldToEcefTransform = ThreeDTileFormatInterpreter.transformFromJson(json.root.transform);
47
+ core_bentley_1.Logger.logTrace(loggerCategory, "RealityData json.root.transform", () => ({ ...worldToEcefTransform }));
48
+ const range = ThreeDTileFormatInterpreter.rangeFromBoundingVolume(json.root.boundingVolume);
49
+ if (undefined === worldToEcefTransform)
50
+ worldToEcefTransform = core_geometry_1.Transform.createIdentity();
51
+ const ecefRange = worldToEcefTransform.multiplyRange(range); // range in model -> range in ecef
52
+ const ecefCenter = worldToEcefTransform.multiplyPoint3d(range.center); // range center in model -> range center in ecef
53
+ const cartoCenter = core_common_1.Cartographic.fromEcef(ecefCenter); // ecef center to cartographic center
54
+ const isNotNearEarthSurface = cartoCenter && (cartoCenter.height < -5000); // 5 km under ground!
55
+ const earthCenterToRangeCenterRayLenght = range.center.magnitude();
56
+ if (worldToEcefTransform.matrix.isIdentity && (earthCenterToRangeCenterRayLenght < 1.0E5 || isNotNearEarthSurface)) {
57
+ isGeolocated = false;
58
+ worldRange.extendRange(core_geometry_1.Range3d.fromJSON(ecefRange));
59
+ const centerOfEarth = new core_common_1.EcefLocation({ origin: { x: 0.0, y: 0.0, z: 0.0 }, orientation: { yaw: 0.0, pitch: 0.0, roll: 0.0 } });
60
+ location = centerOfEarth;
61
+ core_bentley_1.Logger.logTrace(loggerCategory, "RealityData NOT Geolocated", () => ({ ...location }));
62
+ }
63
+ else {
64
+ let ecefLocation;
65
+ const locationOrientation = core_geometry_1.YawPitchRollAngles.tryFromTransform(worldToEcefTransform);
66
+ // Fix Bug 445630: [RDV][Regression] Orientation of georeferenced Reality Mesh is wrong.
67
+ // Use json.root.transform only if defined and not identity -> otherwise will use a transform computed from cartographic center.
68
+ if (!worldToEcefTransform.matrix.isIdentity && locationOrientation !== undefined && locationOrientation.angles !== undefined)
69
+ ecefLocation = new core_common_1.EcefLocation({ origin: locationOrientation.origin, orientation: locationOrientation.angles.toJSON() });
70
+ else
71
+ ecefLocation = core_common_1.EcefLocation.createFromCartographicOrigin(cartoCenter);
72
+ location = ecefLocation;
73
+ core_bentley_1.Logger.logTrace(loggerCategory, "RealityData is worldToEcefTransform.matrix.isIdentity", () => ({ isIdentity: worldToEcefTransform.matrix.isIdentity }));
74
+ // iModelDb.setEcefLocation(ecefLocation);
75
+ const ecefToWorld = ecefLocation.getTransform().inverse();
76
+ worldRange.extendRange(core_geometry_1.Range3d.fromJSON(ecefToWorld.multiplyRange(ecefRange)));
77
+ core_bentley_1.Logger.logTrace(loggerCategory, "RealityData ecefToWorld", () => ({ ...ecefToWorld }));
78
+ }
79
+ }
80
+ const spatialLocation = { location, worldRange, isGeolocated };
81
+ return spatialLocation;
82
+ }
83
+ /** Gets information to identify the product and engine that create this reality data
84
+ * Will return undefined if cannot be resolved
85
+ * @param rootDocjson root document file in json format
86
+ * @returns information to identify the product and engine that create this reality data
87
+ * @alpha
88
+ */
89
+ static getPublisherProductInfo(rootDocjson) {
90
+ const info = { product: "", engine: "", version: "" };
91
+ if (rootDocjson && rootDocjson.root) {
92
+ if (rootDocjson.root.SMPublisherInfo) {
93
+ info.product = rootDocjson.root.SMPublisherInfo.Product ? rootDocjson.root.SMPublisherInfo.Product : "";
94
+ info.engine = rootDocjson.root.SMPublisherInfo.Publisher ? rootDocjson.root.SMPublisherInfo.Publisher : "";
95
+ info.version = rootDocjson.root.SMPublisherInfo["Publisher Version"] ? rootDocjson.root.SMPublisherInfo["Publisher Version"] : "";
96
+ }
97
+ }
98
+ return info;
99
+ }
100
+ /** Gets information about 3dTile file for this reality data
101
+ * Will return undefined if cannot be resolved
102
+ * @param rootDocjson root document file in json format
103
+ * @returns information about 3dTile file for this reality data
104
+ * @internal
105
+ */
106
+ static getFileInfo(rootDocjson) {
107
+ var _a, _b, _c;
108
+ const info = {
109
+ 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,
110
+ };
111
+ return info;
112
+ }
113
+ /** Convert a boundingVolume into a range
114
+ * @param boundingVolume the bounding volume to convert
115
+ * @returns the range or undefined if cannot convert
116
+ * @internal
117
+ */
118
+ static rangeFromBoundingVolume(boundingVolume) {
119
+ if (undefined === boundingVolume)
120
+ return undefined;
121
+ if (Array.isArray(boundingVolume.box)) {
122
+ const box = boundingVolume.box;
123
+ const center = core_geometry_1.Point3d.create(box[0], box[1], box[2]);
124
+ const ux = core_geometry_1.Vector3d.create(box[3], box[4], box[5]);
125
+ const uy = core_geometry_1.Vector3d.create(box[6], box[7], box[8]);
126
+ const uz = core_geometry_1.Vector3d.create(box[9], box[10], box[11]);
127
+ const corners = [];
128
+ for (let j = 0; j < 2; j++) {
129
+ for (let k = 0; k < 2; k++) {
130
+ for (let l = 0; l < 2; l++) {
131
+ corners.push(center.plus3Scaled(ux, (j ? -1.0 : 1.0), uy, (k ? -1.0 : 1.0), uz, (l ? -1.0 : 1.0)));
132
+ }
133
+ }
134
+ }
135
+ return core_geometry_1.Range3d.createArray(corners);
136
+ }
137
+ else if (Array.isArray(boundingVolume.sphere)) {
138
+ const sphere = boundingVolume.sphere;
139
+ const center = core_geometry_1.Point3d.create(sphere[0], sphere[1], sphere[2]);
140
+ const radius = sphere[3];
141
+ return core_geometry_1.Range3d.createXYZXYZ(center.x - radius, center.y - radius, center.z - radius, center.x + radius, center.y + radius, center.z + radius);
142
+ }
143
+ return undefined;
144
+ }
145
+ /** Convert a boundingVolume into a range
146
+ * @internal
147
+ */
148
+ static maximumSizeFromGeometricTolerance(range, geometricError) {
149
+ 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.
150
+ return minToleranceRatio * range.diagonal().magnitude() / geometricError;
151
+ }
152
+ /** Convert a boundingVolume into a range
153
+ * @internal
154
+ */
155
+ static transformFromJson(jTrans) {
156
+ return (jTrans === undefined) ? undefined : core_geometry_1.Transform.createOriginAndMatrix(core_geometry_1.Point3d.create(jTrans[12], jTrans[13], jTrans[14]), core_geometry_1.Matrix3d.createRowValues(jTrans[0], jTrans[4], jTrans[8], jTrans[1], jTrans[5], jTrans[9], jTrans[2], jTrans[6], jTrans[10]));
157
+ }
158
+ }
159
+ exports.ThreeDTileFormatInterpreter = ThreeDTileFormatInterpreter;
160
+ //# sourceMappingURL=ThreeDTileFormatInterpreter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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AC,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;AA9ID,kEA8IC","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"]}