@cesium/engine 12.0.1 → 13.1.0

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 (161) hide show
  1. package/Build/Workers/{chunk-7D6T2WYT.js → chunk-2ONAV62A.js} +14 -47
  2. package/Build/Workers/{chunk-MV7YO647.js → chunk-2SRHVCFD.js} +6 -6
  3. package/Build/Workers/{chunk-ZPTNVB3S.js → chunk-3SCCWLZS.js} +34 -8
  4. package/Build/Workers/{chunk-7CKQ7PVJ.js → chunk-54I6VSRP.js} +6 -6
  5. package/Build/Workers/{chunk-XDJ7V4NZ.js → chunk-5I3LPAS7.js} +5 -5
  6. package/Build/Workers/{chunk-GSJ6LWIS.js → chunk-5ICYLS6B.js} +35 -21
  7. package/Build/Workers/{chunk-BH5M522L.js → chunk-5JY4LYO3.js} +7 -7
  8. package/Build/Workers/{chunk-DR56WFYZ.js → chunk-APCS5YJI.js} +7 -7
  9. package/Build/Workers/{chunk-COHL4R3G.js → chunk-AXYZUG4N.js} +1 -1
  10. package/Build/Workers/{chunk-2IJZVFHY.js → chunk-B34JXFHF.js} +5 -5
  11. package/Build/Workers/{chunk-54NYY4U4.js → chunk-B6IJY6AN.js} +7 -7
  12. package/Build/Workers/{chunk-H3RMGG7L.js → chunk-BMFWWTD7.js} +5 -5
  13. package/Build/Workers/{chunk-PJHRB4YJ.js → chunk-CBE4HRBH.js} +7 -7
  14. package/Build/Workers/{chunk-U7SH6OK7.js → chunk-CNPP6TQ2.js} +4 -4
  15. package/Build/Workers/{chunk-2XOUWNPN.js → chunk-DWIKWWEE.js} +5 -5
  16. package/Build/Workers/{chunk-PNA47CR7.js → chunk-EHGQQA7C.js} +1 -1
  17. package/Build/Workers/{chunk-7EBHNJTG.js → chunk-EJ5DT5BP.js} +1 -1
  18. package/Build/Workers/{chunk-3Y4UGAYI.js → chunk-EYZFEJX3.js} +6 -6
  19. package/Build/Workers/{chunk-EMCXAVSG.js → chunk-FNCXBBCF.js} +2 -2
  20. package/Build/Workers/{chunk-NL73INJS.js → chunk-GIOZHX7U.js} +2 -2
  21. package/Build/Workers/{chunk-VHGI7D3P.js → chunk-GSLKQJM2.js} +10 -10
  22. package/Build/Workers/{chunk-647NL6VU.js → chunk-HI73PIPQ.js} +2 -2
  23. package/Build/Workers/{chunk-GRQQHWMD.js → chunk-IP7F2MVW.js} +7 -7
  24. package/Build/Workers/{chunk-LBNGHEJY.js → chunk-IXNXKVOB.js} +4 -4
  25. package/Build/Workers/{chunk-2F42VIW6.js → chunk-J7BMSSY7.js} +13 -13
  26. package/Build/Workers/{chunk-PH3T7LNP.js → chunk-K62EHZFT.js} +15 -15
  27. package/Build/Workers/{chunk-GBPW65E3.js → chunk-K6SQV4IS.js} +6 -6
  28. package/Build/Workers/{chunk-WMHJAREU.js → chunk-KO232FLP.js} +2 -2
  29. package/Build/Workers/{chunk-AER5CLXD.js → chunk-KRVALCCI.js} +5 -5
  30. package/Build/Workers/{chunk-22FZ334F.js → chunk-LFUFGHL3.js} +10 -10
  31. package/Build/Workers/{chunk-AGYO4ZSF.js → chunk-LQT2ZK7D.js} +17 -17
  32. package/Build/Workers/{chunk-KJ65M35B.js → chunk-M2AA2ARJ.js} +11 -11
  33. package/Build/Workers/{chunk-YT5PQMSP.js → chunk-MGABCOOH.js} +6 -6
  34. package/Build/Workers/{chunk-JPNFQRN7.js → chunk-NQDKNE7V.js} +13 -13
  35. package/Build/Workers/{chunk-IJWXYSFC.js → chunk-OARMSJUU.js} +2 -2
  36. package/Build/Workers/{chunk-K7QC3WDT.js → chunk-OGRXNUR2.js} +1 -1
  37. package/Build/Workers/{chunk-KKMH4BKN.js → chunk-OZTFRHA2.js} +6 -6
  38. package/Build/Workers/{chunk-DJ7K7EYK.js → chunk-PBJQFLKS.js} +11 -11
  39. package/Build/Workers/{chunk-ETXXXGMP.js → chunk-PM76TX2X.js} +6 -6
  40. package/Build/Workers/{chunk-PISTPJXS.js → chunk-PTFIVVLX.js} +12 -12
  41. package/Build/Workers/{chunk-VXVQITFC.js → chunk-R2KGFZBA.js} +13 -13
  42. package/Build/Workers/{chunk-VO4SXJXT.js → chunk-S3UM4OKP.js} +7 -7
  43. package/Build/Workers/{chunk-NELAPOO6.js → chunk-SAKQO5NX.js} +2 -2
  44. package/Build/Workers/{chunk-ENARO52I.js → chunk-T34EOLFR.js} +14 -14
  45. package/Build/Workers/{chunk-X6YBZOOA.js → chunk-THDHWSEJ.js} +4 -4
  46. package/Build/Workers/{chunk-LVHHB5T6.js → chunk-TOHDFUJM.js} +4 -4
  47. package/Build/Workers/{chunk-Q7IIOKAT.js → chunk-UBAHTE4Q.js} +1 -1
  48. package/Build/Workers/{chunk-IAX6MIST.js → chunk-WAJNX74N.js} +17 -17
  49. package/Build/Workers/{chunk-76KRKKEF.js → chunk-WE4KF4AM.js} +9 -9
  50. package/Build/Workers/{chunk-JAKTB6CE.js → chunk-WUIDEXAN.js} +7 -7
  51. package/Build/Workers/{chunk-IVCFTVYW.js → chunk-YVGU235V.js} +4 -4
  52. package/Build/Workers/{chunk-ZCCI55EY.js → chunk-ZWSWJYJP.js} +13 -13
  53. package/Build/Workers/combineGeometry.js +22 -22
  54. package/Build/Workers/createBoxGeometry.js +16 -16
  55. package/Build/Workers/createBoxOutlineGeometry.js +14 -14
  56. package/Build/Workers/createCircleGeometry.js +24 -24
  57. package/Build/Workers/createCircleOutlineGeometry.js +17 -17
  58. package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
  59. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
  60. package/Build/Workers/createCorridorGeometry.js +27 -27
  61. package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
  62. package/Build/Workers/createCylinderGeometry.js +18 -18
  63. package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
  64. package/Build/Workers/createEllipseGeometry.js +24 -24
  65. package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
  66. package/Build/Workers/createEllipsoidGeometry.js +17 -17
  67. package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
  68. package/Build/Workers/createFrustumGeometry.js +16 -16
  69. package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
  70. package/Build/Workers/createGeometry.js +22 -22
  71. package/Build/Workers/createGroundPolylineGeometry.js +20 -20
  72. package/Build/Workers/createPlaneGeometry.js +14 -14
  73. package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
  74. package/Build/Workers/createPolygonGeometry.js +30 -30
  75. package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
  76. package/Build/Workers/createPolylineGeometry.js +23 -23
  77. package/Build/Workers/createPolylineVolumeGeometry.js +31 -32
  78. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
  79. package/Build/Workers/createRectangleGeometry.js +25 -25
  80. package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
  81. package/Build/Workers/createSimplePolylineGeometry.js +21 -21
  82. package/Build/Workers/createSphereGeometry.js +17 -17
  83. package/Build/Workers/createSphereOutlineGeometry.js +16 -16
  84. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  85. package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
  86. package/Build/Workers/createVectorTileGeometries.js +22 -22
  87. package/Build/Workers/createVectorTilePoints.js +12 -12
  88. package/Build/Workers/createVectorTilePolygons.js +20 -20
  89. package/Build/Workers/createVectorTilePolylines.js +13 -13
  90. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
  91. package/Build/Workers/createVerticesFromHeightmap.js +20 -20
  92. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
  93. package/Build/Workers/createWallGeometry.js +22 -22
  94. package/Build/Workers/createWallOutlineGeometry.js +21 -21
  95. package/Build/Workers/decodeDraco.js +11 -11
  96. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  97. package/Build/Workers/decodeI3S.js +10 -10
  98. package/Build/Workers/transcodeKTX2.js +7 -7
  99. package/Build/Workers/transferTypedArrayTest.js +1 -1
  100. package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
  101. package/Source/Core/BingMapsGeocoderService.js +2 -0
  102. package/Source/Core/Check.d.ts +2 -1
  103. package/Source/Core/GoogleGeocoderService.js +110 -0
  104. package/Source/Core/ITwinPlatform.js +324 -0
  105. package/Source/Core/Ion.js +1 -1
  106. package/Source/Core/IonGeocodeProviderType.js +33 -0
  107. package/Source/Core/IonGeocoderService.js +72 -0
  108. package/Source/Core/JulianDate.js +14 -7
  109. package/Source/Core/Rectangle.js +0 -20
  110. package/Source/Core/TrackingReferenceFrame.js +45 -0
  111. package/Source/Core/defined.d.ts +11 -0
  112. package/Source/DataSources/Entity.js +15 -1
  113. package/Source/DataSources/EntityView.js +55 -4
  114. package/Source/DataSources/ModelGraphics.js +23 -1
  115. package/Source/DataSources/ModelVisualizer.js +22 -1
  116. package/Source/DataSources/SampledProperty.js +24 -0
  117. package/Source/Renderer/ContextLimits.js +1 -1
  118. package/Source/Renderer/Texture.js +104 -92
  119. package/Source/Scene/ArcGisMapService.js +1 -1
  120. package/Source/Scene/Cesium3DTileset.js +1 -1
  121. package/Source/Scene/Cesium3DTilesetStatistics.js +109 -42
  122. package/Source/Scene/DerivedCommand.js +109 -16
  123. package/Source/Scene/DynamicEnvironmentMapManager.js +202 -65
  124. package/Source/Scene/GltfTextureLoader.js +16 -1
  125. package/Source/Scene/ITwinData.js +208 -0
  126. package/Source/Scene/Label.js +17 -3
  127. package/Source/Scene/MetadataClassProperty.js +26 -0
  128. package/Source/Scene/MetadataPicking.js +108 -17
  129. package/Source/Scene/MetadataType.js +20 -0
  130. package/Source/Scene/Model/Extensions/Gpm/GltfMeshPrimitiveGpmLoader.js +6 -11
  131. package/Source/Scene/Model/Model.js +1 -1
  132. package/Source/Scene/Model/Model3DTileContent.js +23 -1
  133. package/Source/Scene/Model/ModelStatistics.js +33 -5
  134. package/Source/Scene/Model/PointCloudStylingPipelineStage.js +2 -1
  135. package/Source/Scene/PickedMetadataInfo.js +21 -3
  136. package/Source/Scene/Picking.js +7 -1
  137. package/Source/Scene/PostProcessStage.js +14 -17
  138. package/Source/Scene/PostProcessStageCollection.js +4 -16
  139. package/Source/Scene/PostProcessStageLibrary.js +13 -51
  140. package/Source/Scene/PropertyAttributeProperty.js +15 -3
  141. package/Source/Scene/PropertyTextureProperty.js +12 -0
  142. package/Source/Scene/Scene.js +17 -2
  143. package/Source/Scene/SkyBox.js +23 -4
  144. package/Source/Scene/UrlTemplateImageryProvider.js +5 -5
  145. package/Source/Scene/createGooglePhotorealistic3DTileset.js +55 -16
  146. package/Source/Scene/getMetadataProperty.js +48 -0
  147. package/Source/Shaders/Builtin/Functions/reverseLogDepth.glsl +1 -1
  148. package/Source/Shaders/Builtin/Functions/reverseLogDepth.js +1 -1
  149. package/Source/Shaders/ConvolveSpecularMapFS.glsl +1 -1
  150. package/Source/Shaders/ConvolveSpecularMapFS.js +1 -1
  151. package/Source/Shaders/DepthPlaneVS.glsl +1 -1
  152. package/Source/Shaders/DepthPlaneVS.js +1 -1
  153. package/Source/Shaders/Model/ModelFS.glsl +7 -0
  154. package/Source/Shaders/Model/ModelFS.js +7 -0
  155. package/Source/Shaders/Model/ModelVS.glsl +9 -1
  156. package/Source/Shaders/Model/ModelVS.js +9 -1
  157. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.glsl +66 -37
  158. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.js +66 -37
  159. package/index.d.ts +295 -42
  160. package/index.js +67 -61
  161. package/package.json +1 -1
@@ -0,0 +1,208 @@
1
+ import Cesium3DTileset from "./Cesium3DTileset.js";
2
+ import defined from "../Core/defined.js";
3
+ import Resource from "../Core/Resource.js";
4
+ import ITwinPlatform from "../Core/ITwinPlatform.js";
5
+ import RuntimeError from "../Core/RuntimeError.js";
6
+ import Check from "../Core/Check.js";
7
+ import KmlDataSource from "../DataSources/KmlDataSource.js";
8
+ import GeoJsonDataSource from "../DataSources/GeoJsonDataSource.js";
9
+
10
+ /**
11
+ * Methods for loading iTwin platform data into CesiumJS
12
+ *
13
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
14
+ *
15
+ * @see ITwinPlatform
16
+ * @namespace ITwinData
17
+ */
18
+ const ITwinData = {};
19
+
20
+ /**
21
+ * Create a {@link Cesium3DTileset} for the given iModel id using iTwin's Mesh Export API.
22
+ *
23
+ * If there is not a completed export available for the given iModel id, the returned promise will resolve to <code>undefined</code>.
24
+ * We recommend waiting 10-20 seconds and trying to load the tileset again.
25
+ * If all exports are Invalid this will throw an error.
26
+ *
27
+ * @example
28
+ * const tileset = await Cesium.ITwinData.createTilesetFromIModelId(iModelId);
29
+ * if (Cesium.defined(tileset)) {
30
+ * viewer.scene.primitives.add(tileset);
31
+ * }
32
+ *
33
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
34
+ *
35
+ * @param {string} iModelId The id of the iModel to load
36
+ * @param {Cesium3DTileset.ConstructorOptions} [options] Object containing options to pass to the internally created {@link Cesium3DTileset}.
37
+ * @returns {Promise<Cesium3DTileset | undefined>} A promise that will resolve to the created 3D tileset or <code>undefined</code> if there is no completed export for the given iModel id
38
+ *
39
+ * @throws {RuntimeError} If all exports for the given iModel are Invalid
40
+ * @throws {RuntimeError} If the iTwin API request is not successful
41
+ */
42
+ ITwinData.createTilesetFromIModelId = async function (iModelId, options) {
43
+ const { exports } = await ITwinPlatform.getExports(iModelId);
44
+
45
+ if (
46
+ exports.length > 0 &&
47
+ exports.every((exportObj) => {
48
+ return exportObj.status === ITwinPlatform.ExportStatus.Invalid;
49
+ })
50
+ ) {
51
+ throw new RuntimeError(
52
+ `All exports for this iModel are Invalid: ${iModelId}`,
53
+ );
54
+ }
55
+
56
+ const completeExport = exports.find((exportObj) => {
57
+ return exportObj.status === ITwinPlatform.ExportStatus.Complete;
58
+ });
59
+
60
+ if (!defined(completeExport)) {
61
+ return;
62
+ }
63
+
64
+ // Convert the link to the tileset url while preserving the search paramaters
65
+ // This link is only valid 1 hour
66
+ const baseUrl = new URL(completeExport._links.mesh.href);
67
+ baseUrl.pathname = `${baseUrl.pathname}/tileset.json`;
68
+ const tilesetUrl = baseUrl.toString();
69
+
70
+ const resource = new Resource({
71
+ url: tilesetUrl,
72
+ });
73
+
74
+ return Cesium3DTileset.fromUrl(resource, options);
75
+ };
76
+
77
+ /**
78
+ * Create a tileset for the specified reality data id. This function only works
79
+ * with 3D Tiles meshes and point clouds.
80
+ *
81
+ * If the <code>type</code> or <code>rootDocument</code> are not provided this function
82
+ * will first request the full metadata for the specified reality data to fill these values.
83
+ *
84
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
85
+ *
86
+ * @param {string} iTwinId The id of the iTwin to load data from
87
+ * @param {string} realityDataId The id of the reality data to load
88
+ * @param {ITwinPlatform.RealityDataType} [type] The type of this reality data
89
+ * @param {string} [rootDocument] The path of the root document for this reality data
90
+ * @returns {Promise<Cesium3DTileset>}
91
+ *
92
+ * @throws {RuntimeError} if the type of reality data is not supported by this function
93
+ */
94
+ ITwinData.createTilesetForRealityDataId = async function (
95
+ iTwinId,
96
+ realityDataId,
97
+ type,
98
+ rootDocument,
99
+ ) {
100
+ //>>includeStart('debug', pragmas.debug);
101
+ Check.typeOf.string("iTwinId", iTwinId);
102
+ Check.typeOf.string("realityDataId", realityDataId);
103
+ if (defined(type)) {
104
+ Check.typeOf.string("type", type);
105
+ }
106
+ if (defined(rootDocument)) {
107
+ Check.typeOf.string("rootDocument", rootDocument);
108
+ }
109
+ //>>includeEnd('debug')
110
+
111
+ if (!defined(type) || !defined(rootDocument)) {
112
+ const metadata = await ITwinPlatform.getRealityDataMetadata(
113
+ iTwinId,
114
+ realityDataId,
115
+ );
116
+ rootDocument = metadata.rootDocument;
117
+ type = metadata.type;
118
+ }
119
+
120
+ const supportedRealityDataTypes = [
121
+ ITwinPlatform.RealityDataType.Cesium3DTiles,
122
+ ITwinPlatform.RealityDataType.PNTS,
123
+ ITwinPlatform.RealityDataType.RealityMesh3DTiles,
124
+ ITwinPlatform.RealityDataType.Terrain3DTiles,
125
+ ];
126
+
127
+ if (!supportedRealityDataTypes.includes(type)) {
128
+ throw new RuntimeError(`Reality data type is not a mesh type: ${type}`);
129
+ }
130
+
131
+ const tilesetAccessUrl = await ITwinPlatform.getRealityDataURL(
132
+ iTwinId,
133
+ realityDataId,
134
+ rootDocument,
135
+ );
136
+
137
+ return Cesium3DTileset.fromUrl(tilesetAccessUrl, {
138
+ maximumScreenSpaceError: 4,
139
+ });
140
+ };
141
+
142
+ /**
143
+ * Create a data source of the correct type for the specified reality data id.
144
+ * This function only works for KML and GeoJSON type data.
145
+ *
146
+ * If the <code>type</code> or <code>rootDocument</code> are not provided this function
147
+ * will first request the full metadata for the specified reality data to fill these values.
148
+ *
149
+ * @param {string} iTwinId The id of the iTwin to load data from
150
+ * @param {string} realityDataId The id of the reality data to load
151
+ * @param {ITwinPlatform.RealityDataType} [type] The type of this reality data
152
+ * @param {string} [rootDocument] The path of the root document for this reality data
153
+ * @returns {Promise<GeoJsonDataSource | KmlDataSource>}
154
+ *
155
+ * @throws {RuntimeError} if the type of reality data is not supported by this function
156
+ */
157
+ ITwinData.createDataSourceForRealityDataId = async function loadRealityData(
158
+ iTwinId,
159
+ realityDataId,
160
+ type,
161
+ rootDocument,
162
+ ) {
163
+ //>>includeStart('debug', pragmas.debug);
164
+ Check.typeOf.string("iTwinId", iTwinId);
165
+ Check.typeOf.string("realityDataId", realityDataId);
166
+ if (defined(type)) {
167
+ Check.typeOf.string("type", type);
168
+ }
169
+ if (defined(rootDocument)) {
170
+ Check.typeOf.string("rootDocument", rootDocument);
171
+ }
172
+ //>>includeEnd('debug')
173
+
174
+ if (!defined(type) || !defined(rootDocument)) {
175
+ const metadata = await ITwinPlatform.getRealityDataMetadata(
176
+ iTwinId,
177
+ realityDataId,
178
+ );
179
+ rootDocument = metadata.rootDocument;
180
+ type = metadata.type;
181
+ }
182
+
183
+ const supportedRealityDataTypes = [
184
+ ITwinPlatform.RealityDataType.KML,
185
+ ITwinPlatform.RealityDataType.GeoJSON,
186
+ ];
187
+
188
+ if (!supportedRealityDataTypes.includes(type)) {
189
+ throw new RuntimeError(
190
+ `Reality data type is not a data source type: ${type}`,
191
+ );
192
+ }
193
+
194
+ const tilesetAccessUrl = await ITwinPlatform.getRealityDataURL(
195
+ iTwinId,
196
+ realityDataId,
197
+ rootDocument,
198
+ );
199
+
200
+ if (type === ITwinPlatform.RealityDataType.GeoJSON) {
201
+ return GeoJsonDataSource.load(tilesetAccessUrl);
202
+ }
203
+
204
+ // If we get here it's guaranteed to be a KML type
205
+ return KmlDataSource.load(tilesetAccessUrl);
206
+ };
207
+
208
+ export default ITwinData;
@@ -400,8 +400,7 @@ Object.defineProperties(Label.prototype, {
400
400
  if (this._text !== value) {
401
401
  this._text = value;
402
402
 
403
- // Strip soft-hyphen (auto-wrap) characters from input string
404
- const renderedValue = value.replace(/\u00ad/g, "");
403
+ const renderedValue = Label.filterUnsupportedCharacters(value);
405
404
  this._renderedText = Label.enableRightToLeftDetection
406
405
  ? reverseRtl(renderedValue)
407
406
  : renderedValue;
@@ -1346,6 +1345,21 @@ Label.getScreenSpaceBoundingBox = function (
1346
1345
  return result;
1347
1346
  };
1348
1347
 
1348
+ /**
1349
+ * Removes control characters and soft hyphon (auto-wrap) characters, which will cause an error when rendering a glyph. This does not remove tabs, carriage returns, or newlines.
1350
+ * @private
1351
+ * @param {string} text The original label text
1352
+ * @returns {string} The renderable filtered text
1353
+ */
1354
+ Label.filterUnsupportedCharacters = function (text) {
1355
+ const problematicCharactersRegex = new RegExp(
1356
+ // eslint-disable-next-line no-control-regex
1357
+ /[\u0000-\u0008\u000E-\u001F\u00ad\u202a-\u206f\u200b-\u200f]/,
1358
+ "g",
1359
+ );
1360
+ return text.replace(problematicCharactersRegex, "");
1361
+ };
1362
+
1349
1363
  /**
1350
1364
  * Determines if this label equals another label. Labels are equal if all their properties
1351
1365
  * are equal. Labels in different collections can be equal.
@@ -1502,7 +1516,7 @@ function reverseBrackets(bracket) {
1502
1516
  }
1503
1517
  }
1504
1518
 
1505
- //To add another language, simply add its Unicode block range(s) to the below regex.
1519
+ // To add another language, add its Unicode block range(s) to the below regex.
1506
1520
  const hebrew = "\u05D0-\u05EA";
1507
1521
  const arabic = "\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF";
1508
1522
  const rtlChars = new RegExp(`[${hebrew}${arabic}]`);
@@ -438,6 +438,10 @@ Object.defineProperties(MetadataClassProperty.prototype, {
438
438
  /**
439
439
  * The offset to be added to property values as part of the value transform.
440
440
  *
441
+ * This is always defined, even when `hasValueTransform` is `false`. If
442
+ * the class property JSON itself did not define it, then it will be
443
+ * initialized to the default value.
444
+ *
441
445
  * @memberof MetadataClassProperty.prototype
442
446
  * @type {number|number[]|number[][]}
443
447
  * @readonly
@@ -451,6 +455,10 @@ Object.defineProperties(MetadataClassProperty.prototype, {
451
455
  /**
452
456
  * The scale to be multiplied to property values as part of the value transform.
453
457
  *
458
+ * This is always defined, even when `hasValueTransform` is `false`. If
459
+ * the class property JSON itself did not define it, then it will be
460
+ * initialized to the default value.
461
+ *
454
462
  * @memberof MetadataClassProperty.prototype
455
463
  * @type {number|number[]|number[][]}
456
464
  * @readonly
@@ -1139,6 +1147,24 @@ function normalizeInPlace(values, valueType, normalizeFunction) {
1139
1147
  }
1140
1148
 
1141
1149
  /**
1150
+ * Applies the value transform that is defined with the given offsets
1151
+ * and scales to the given values.
1152
+ *
1153
+ * If the given values are not an array, then the given transformation
1154
+ * function will be applied directly.
1155
+ *
1156
+ * If the values are an array, then this function will be called recursively
1157
+ * with the array elements, boiling down to a component-wise application
1158
+ * of the transformation function to the innermost array elements.
1159
+ *
1160
+ * @param {number|number[]|number[][]} values The input values
1161
+ * @param {number|number[]|number[][]} offsets The offsets
1162
+ * @param {number|number[]|number[][]} scales The scales
1163
+ * @param {Function} transformationFunction The function with the signature
1164
+ * `(value:number, offset:number, scale:number) : number` that will be
1165
+ * applied to the innermost elements
1166
+ * @returns The input values (or the result of applying the transformation
1167
+ * function to a single value if the values have not been an array).
1142
1168
  * @private
1143
1169
  */
1144
1170
  MetadataClassProperty.valueTransformInPlace = function (
@@ -6,6 +6,7 @@ import Matrix2 from "../Core/Matrix2.js";
6
6
  import Matrix3 from "../Core/Matrix3.js";
7
7
  import Matrix4 from "../Core/Matrix4.js";
8
8
  import RuntimeError from "../Core/RuntimeError.js";
9
+ import MetadataClassProperty from "./MetadataClassProperty.js";
9
10
  import MetadataComponentType from "./MetadataComponentType.js";
10
11
  import MetadataType from "./MetadataType.js";
11
12
 
@@ -29,6 +30,10 @@ const MetadataPicking = {};
29
30
  * @param {DataView} dataView The data view
30
31
  * @param {number} index The index (byte offset)
31
32
  * @returns {number|bigint|undefined} The value
33
+ * @throws RuntimeError If the given component type is not a valid
34
+ * `MetadataComponentType`
35
+ * @throws RangeError If reading the data from the given data view would
36
+ * cause an out-of-bounds access
32
37
  *
33
38
  * @private
34
39
  */
@@ -43,21 +48,21 @@ MetadataPicking.decodeRawMetadataValue = function (
43
48
  case MetadataComponentType.UINT8:
44
49
  return dataView.getUint8(index);
45
50
  case MetadataComponentType.INT16:
46
- return dataView.getInt16(index);
51
+ return dataView.getInt16(index, true);
47
52
  case MetadataComponentType.UINT16:
48
- return dataView.getUint16(index);
53
+ return dataView.getUint16(index, true);
49
54
  case MetadataComponentType.INT32:
50
- return dataView.getInt32(index);
55
+ return dataView.getInt32(index, true);
51
56
  case MetadataComponentType.UINT32:
52
- return dataView.getUint32(index);
57
+ return dataView.getUint32(index, true);
53
58
  case MetadataComponentType.INT64:
54
- return dataView.getBigInt64(index);
59
+ return dataView.getBigInt64(index, true);
55
60
  case MetadataComponentType.UINT64:
56
- return dataView.getBigUint64(index);
61
+ return dataView.getBigUint64(index, true);
57
62
  case MetadataComponentType.FLOAT32:
58
- return dataView.getFloat32(index);
63
+ return dataView.getFloat32(index, true);
59
64
  case MetadataComponentType.FLOAT64:
60
- return dataView.getFloat64(index);
65
+ return dataView.getFloat64(index, true);
61
66
  }
62
67
  throw new RuntimeError(`Invalid component type: ${componentType}`);
63
68
  };
@@ -77,6 +82,10 @@ MetadataPicking.decodeRawMetadataValue = function (
77
82
  * @param {number} dataViewOffset The byte offset within the data view from
78
83
  * which the component should be read
79
84
  * @returns {number|bigint|undefined} The metadata value component
85
+ * @throws RuntimeError If the component of the given property is not
86
+ * a valid `MetadataComponentType`
87
+ * @throws RangeError If reading the data from the given data view would
88
+ * cause an out-of-bounds access
80
89
  */
81
90
  MetadataPicking.decodeRawMetadataValueComponent = function (
82
91
  classProperty,
@@ -114,6 +123,11 @@ MetadataPicking.decodeRawMetadataValueComponent = function (
114
123
  * @param {number} elementIndex The index of the element. This is the index
115
124
  * inside the array for array-typed properties, and 0 for non-array types.
116
125
  * @returns {number|number[]|bigint|bigint[]|undefined} The decoded metadata value element
126
+ * @throws RuntimeError If the component of the given property is not
127
+ * a valid `MetadataComponentType`
128
+ * @throws RangeError If reading the data from the given data view would
129
+ * cause an out-of-bounds access
130
+ *
117
131
  */
118
132
  MetadataPicking.decodeRawMetadataValueElement = function (
119
133
  classProperty,
@@ -183,6 +197,7 @@ MetadataPicking.decodeRawMetadataValueElement = function (
183
197
  * @param {MetadataClassProperty} classProperty The `MetadataClassProperty`
184
198
  * @param {Uint8Array} rawPixelValues The raw values
185
199
  * @returns {number|bigint|number[]|bigint[]|undefined} The value
200
+ * @throws RuntimeError If the class property has an invalid component type
186
201
  *
187
202
  * @private
188
203
  */
@@ -229,7 +244,8 @@ MetadataPicking.decodeRawMetadataValues = function (
229
244
  *
230
245
  * @param {string} type The `ClassProperty` type
231
246
  * @param {number|bigint|number[]|bigint[]|undefined} value The input value
232
- * @returns {any} The object representation
247
+ * @returns {undefined|number|bigint|string|boolean|Cartesian2|Cartesian3|Cartesian4|Matrix2|Matrix3|Matrix4} The object representation
248
+ * @throws RuntimeError If the type is not a valid `MetadataType`
233
249
  */
234
250
  MetadataPicking.convertToObjectType = function (type, value) {
235
251
  if (!defined(value)) {
@@ -250,7 +266,7 @@ MetadataPicking.convertToObjectType = function (type, value) {
250
266
  case MetadataType.VEC3:
251
267
  return Cartesian3.unpack(numbers, 0, new Cartesian3());
252
268
  case MetadataType.VEC4:
253
- return Cartesian4.unpack(numbers, 0, new Cartesian3());
269
+ return Cartesian4.unpack(numbers, 0, new Cartesian4());
254
270
  case MetadataType.MAT2:
255
271
  return Matrix2.unpack(numbers, 0, new Matrix2());
256
272
  case MetadataType.MAT3:
@@ -259,29 +275,104 @@ MetadataPicking.convertToObjectType = function (type, value) {
259
275
  return Matrix4.unpack(numbers, 0, new Matrix4());
260
276
  }
261
277
  // Should never happen:
262
- return value;
278
+ throw new RuntimeError(`Invalid metadata object type: ${type}`);
279
+ };
280
+
281
+ /**
282
+ * Converts the given type into a raw value or array representation.
283
+ *
284
+ * For `VECn/MATn` types, the given value is converted into an array.
285
+ * For other types, the value is returned directly
286
+ *
287
+ * @param {string} type The `ClassProperty` type
288
+ * @param {undefined|number|bigint|string|boolean|Cartesian2|Cartesian3|Cartesian4|Matrix2|Matrix3|Matrix4} value The input value
289
+ * @returns {undefined|number|bigint|string|boolean|number[]} The array representation
290
+ * @throws RuntimeError If the type is not a valid `MetadataType`
291
+ */
292
+ MetadataPicking.convertFromObjectType = function (type, value) {
293
+ if (!defined(value)) {
294
+ return value;
295
+ }
296
+ if (
297
+ type === MetadataType.SCALAR ||
298
+ type === MetadataType.STRING ||
299
+ type === MetadataType.BOOLEAN ||
300
+ type === MetadataType.ENUM
301
+ ) {
302
+ return value;
303
+ }
304
+ switch (type) {
305
+ case MetadataType.VEC2:
306
+ return Cartesian2.pack(value, Array(2));
307
+ case MetadataType.VEC3:
308
+ return Cartesian3.pack(value, Array(3));
309
+ case MetadataType.VEC4:
310
+ return Cartesian4.pack(value, Array(4));
311
+ case MetadataType.MAT2:
312
+ return Matrix2.pack(value, Array(4));
313
+ case MetadataType.MAT3:
314
+ return Matrix3.pack(value, Array(9));
315
+ case MetadataType.MAT4:
316
+ return Matrix4.pack(value, Array(16));
317
+ }
318
+ // Should never happen:
319
+ throw new RuntimeError(`Invalid metadata object type: ${type}`);
263
320
  };
264
321
 
265
322
  /**
266
323
  * Decode the given raw values into a metadata property value.
267
324
  *
268
- * This just converts the result of `decodeRawMetadataValues`
269
- * from array-based types into object types like `CartesianN`.
325
+ * This applies the value transform (offset/scale) to the result
326
+ * of `decodeRawMetadataValues`, and converts this from array-based
327
+ * types into object types like `CartesianN`.
270
328
  *
271
329
  * @param {MetadataClassProperty} classProperty The `MetadataClassProperty`
330
+ * @param {object} metadataProperty The
331
+ * `PropertyTextureProperty` or `PropertyAttributeProperty`
272
332
  * @param {Uint8Array} rawPixelValues The raw values
273
- * @returns {any} The value
333
+ * @returns {MetadataValue} The value
334
+ * @throws RuntimeError If the class property has an invalid type
335
+ * or component type
336
+ * @throws RangeError If the given pixel values do not have sufficient
337
+ * size to contain the expected value type
274
338
  *
275
339
  * @private
276
340
  */
277
341
  MetadataPicking.decodeMetadataValues = function (
278
342
  classProperty,
343
+ metadataProperty,
279
344
  rawPixelValues,
280
345
  ) {
281
- const arrayBasedResult = MetadataPicking.decodeRawMetadataValues(
346
+ let arrayBasedResult = MetadataPicking.decodeRawMetadataValues(
282
347
  classProperty,
283
348
  rawPixelValues,
284
349
  );
350
+
351
+ if (metadataProperty.hasValueTransform) {
352
+ // In the MetadataClassProperty, these offset/scale are always in
353
+ // their array-based form (e.g. a number[3] for `VEC3`). But for
354
+ // the PropertyTextureProperty and PropertyAttributeProperty,
355
+ // the type of the offset/scale is defined to be
356
+ // number|Cartesian2|Cartesian3|Cartesian4|Matrix2|Matrix3|Matrix4
357
+ // So these types are converted into their array-based form here, before
358
+ // applying them with `MetadataClassProperty.valueTransformInPlace`
359
+
360
+ const offset = MetadataPicking.convertFromObjectType(
361
+ classProperty.type,
362
+ metadataProperty.offset,
363
+ );
364
+ const scale = MetadataPicking.convertFromObjectType(
365
+ classProperty.type,
366
+ metadataProperty.scale,
367
+ );
368
+ arrayBasedResult = MetadataClassProperty.valueTransformInPlace(
369
+ arrayBasedResult,
370
+ offset,
371
+ scale,
372
+ MetadataComponentType.applyValueTransform,
373
+ );
374
+ }
375
+
285
376
  if (classProperty.isArray) {
286
377
  const arrayLength = classProperty.arrayLength;
287
378
  const result = Array(arrayLength);
@@ -295,11 +386,11 @@ MetadataPicking.decodeMetadataValues = function (
295
386
  }
296
387
  return result;
297
388
  }
298
- const result = MetadataPicking.convertToObjectType(
389
+ const objectResult = MetadataPicking.convertToObjectType(
299
390
  classProperty.type,
300
391
  arrayBasedResult,
301
392
  );
302
- return result;
393
+ return objectResult;
303
394
  };
304
395
 
305
396
  export default Object.freeze(MetadataPicking);
@@ -7,6 +7,26 @@ import Matrix2 from "../Core/Matrix2.js";
7
7
  import Matrix3 from "../Core/Matrix3.js";
8
8
  import Matrix4 from "../Core/Matrix4.js";
9
9
 
10
+ /**
11
+ * An instance of a metadata value.<br>
12
+ * <br>
13
+ * This can be one of the following types:
14
+ * <ul>
15
+ * <li><code>number</code> for type <code>SCALAR</code> and numeric component types except for <code>INT64</code> or <code>UINT64</code></li>
16
+ * <li><code>bigint</code> for type <code>SCALAR</code> and component type <code>INT64</code> or <code>UINT64</code></li>
17
+ * <li><code>string</code> for type <code>STRING</code> or <code>ENUM</code></li>
18
+ * <li><code>boolean</code> for type <code>BOOLEAN</code></li>
19
+ * <li><code>Cartesian2</code> for type <code>VEC2</code></li>
20
+ * <li><code>Cartesian3</code> for type <code>VEC3</code></li>
21
+ * <li><code>Cartesian4</code> for type <code>VEC4</code></li>
22
+ * <li><code>Matrix2</code> for type <code>MAT2</code></li>
23
+ * <li><code>Matrix3</code> for type <code>MAT3</code></li>
24
+ * <li><code>Matrix4</code> for type <code>MAT4</code></li>
25
+ * <li>Arrays of these types when the metadata value is an array</li>
26
+ * </ul>
27
+ * @typedef {(number|bigint|string|boolean|Cartesian2|Cartesian3|Cartesian4|Matrix2|Matrix3|Matrix4|number[]|bigint[]|string[]|boolean[]|Cartesian2[]|Cartesian3[]|Cartesian4[]|Matrix2[]|Matrix3[]|Matrix4[])} MetadataValue
28
+ */
29
+
10
30
  /**
11
31
  * An enum of metadata types. These metadata types are containers containing
12
32
  * one or more components of type {@link MetadataComponentType}
@@ -234,7 +234,7 @@ GltfMeshPrimitiveGpmLoader.ppeTexturesMetadataSchemaCache = new Map();
234
234
  * Create the JSON description of a metadata class that treats
235
235
  * the given PPE texture as a property texture property.
236
236
  *
237
- * @param {any} ppeTexture - The PPE texture
237
+ * @param {PpeTexture} ppeTexture - The PPE texture
238
238
  * @param {number} index - The index of the texture in the extension
239
239
  * @returns The class JSON
240
240
  */
@@ -268,9 +268,9 @@ GltfMeshPrimitiveGpmLoader._createPpeTextureClassJson = function (
268
268
  // property values when they are `normalized`, the values will be
269
269
  // declared as `normalized` here.
270
270
  // The normalization factor will later have to be cancelled out,
271
- // when integrating the `scale` into the actual property texture
272
- // property. In the property texture property, the `scale` has to
273
- // be multiplied by 255.
271
+ // with the `scale` being multiplied by 255.
272
+ const offset = ppeTexture.offset ?? 0.0;
273
+ const scale = (ppeTexture.scale ?? 1.0) * 255.0;
274
274
  const classJson = {
275
275
  name: `PPE texture class ${index}`,
276
276
  properties: {
@@ -279,6 +279,8 @@ GltfMeshPrimitiveGpmLoader._createPpeTextureClassJson = function (
279
279
  type: "SCALAR",
280
280
  componentType: "UINT8",
281
281
  normalized: true,
282
+ offset: offset,
283
+ scale: scale,
282
284
  min: traits.min,
283
285
  max: traits.max,
284
286
  },
@@ -406,19 +408,12 @@ GltfMeshPrimitiveGpmLoader._convertToStructuralMetadata = function (
406
408
  const ppePropertyName = traits.source;
407
409
  const metadataClass = ppeTexturesMetadataSchema.classes[classId];
408
410
 
409
- // The class property has been declared as `normalized`, so
410
- // that `offset` and `scale` can be applied. The normalization
411
- // factor has to be cancelled out here, by multiplying the
412
- // `scale` with 255.
413
- const scale = (ppeTexture.scale ?? 1.0) * 255.0;
414
411
  const ppeTextureAsPropertyTexture = {
415
412
  class: classId,
416
413
  properties: {
417
414
  [ppePropertyName]: {
418
415
  index: ppeTexture.index,
419
416
  texCoord: ppeTexture.texCoord,
420
- offset: ppeTexture.offset,
421
- scale: scale,
422
417
  },
423
418
  },
424
419
  };
@@ -1823,7 +1823,7 @@ Model.prototype.applyArticulations = function () {
1823
1823
  *
1824
1824
  * The given name may be the name of a glTF extension, like `"EXT_example_extension"`.
1825
1825
  * If the specified extension was present in the root of the underlying glTF asset,
1826
- * and a loder for the specified extension has processed the extension data, then
1826
+ * and a loader for the specified extension has processed the extension data, then
1827
1827
  * this will return the model representation of the extension.
1828
1828
  *
1829
1829
  * @param {string} extensionName The name of the extension
@@ -152,12 +152,34 @@ Object.defineProperties(Model3DTileContent.prototype, {
152
152
  },
153
153
  });
154
154
 
155
+ /**
156
+ * Returns an array containing the `texture.id` values for all textures
157
+ * that are part of this content.
158
+ *
159
+ * @returns {string[]} The texture IDs
160
+ */
161
+ Model3DTileContent.prototype.getTextureIds = function () {
162
+ return this._model.statistics.getTextureIds();
163
+ };
164
+
165
+ /**
166
+ * Returns the length, in bytes, of the texture data for the texture with
167
+ * the given ID that is part of this content, or `undefined` if this
168
+ * content does not contain the texture with the given ID.
169
+ *
170
+ * @param {string} textureId The texture ID
171
+ * @returns {number|undefined} The texture byte length
172
+ */
173
+ Model3DTileContent.prototype.getTextureByteLengthById = function (textureId) {
174
+ return this._model.statistics.getTextureByteLengthById(textureId);
175
+ };
176
+
155
177
  /**
156
178
  * Returns the object that was created for the given extension.
157
179
  *
158
180
  * The given name may be the name of a glTF extension, like `"EXT_example_extension"`.
159
181
  * If the specified extension was present in the root of the underlying glTF asset,
160
- * and a loder for the specified extension has processed the extension data, then
182
+ * and a loader for the specified extension has processed the extension data, then
161
183
  * this will return the model representation of the extension.
162
184
  *
163
185
  * @param {string} extensionName The name of the extension