@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,324 @@
1
+ import Check from "./Check.js";
2
+ import defined from "./defined.js";
3
+ import DeveloperError from "./DeveloperError.js";
4
+ import Resource from "./Resource.js";
5
+ import RuntimeError from "./RuntimeError.js";
6
+
7
+ /**
8
+ * Default settings for accessing the iTwin platform.
9
+ *
10
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
11
+ *
12
+ * @see ITwinData
13
+ * @namespace ITwinPlatform
14
+ */
15
+ const ITwinPlatform = {};
16
+
17
+ /**
18
+ * Status states for a mesh-export export.
19
+ * Valid values are: <code>NotStarted</code>, <code>InProgress</code>, <code>Complete</code>, <code>Invalid</code>
20
+ * @enum {string}
21
+ */
22
+ ITwinPlatform.ExportStatus = Object.freeze({
23
+ NotStarted: "NotStarted",
24
+ InProgress: "InProgress",
25
+ Complete: "Complete",
26
+ Invalid: "Invalid",
27
+ });
28
+
29
+ /**
30
+ * Types of mesh-export exports. CesiumJS only supports loading <code>3DTILES</code> type exports.
31
+ * Valid values are: <code>IMODEL</code>, <code>CESIUM</code>, <code>3DTILES</code>
32
+ * @enum {string}
33
+ */
34
+ ITwinPlatform.ExportType = Object.freeze({
35
+ IMODEL: "IMODEL",
36
+ CESIUM: "CESIUM",
37
+ "3DTILES": "3DTILES",
38
+ });
39
+
40
+ /**
41
+ * Types of Reality data. This is a partial list of types we know we can support
42
+ *
43
+ * @see https://developer.bentley.com/apis/reality-management/rm-rd-details/#types
44
+ * @enum {string}
45
+ */
46
+ ITwinPlatform.RealityDataType = Object.freeze({
47
+ Cesium3DTiles: "Cesium3DTiles",
48
+ PNTS: "PNTS",
49
+ RealityMesh3DTiles: "RealityMesh3DTiles",
50
+ Terrain3DTiles: "Terrain3DTiles",
51
+ KML: "KML",
52
+ GeoJSON: "GeoJSON",
53
+ Unstructured: "Unstructured",
54
+ });
55
+
56
+ /**
57
+ * Gets or sets the default iTwin access token. This token should have the <code>itwin-platform</code> scope.
58
+ *
59
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
60
+ *
61
+ * @type {string|undefined}
62
+ */
63
+ ITwinPlatform.defaultAccessToken = undefined;
64
+
65
+ /**
66
+ * Gets or sets the default iTwin API endpoint.
67
+ *
68
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
69
+ *
70
+ * @type {string|Resource}
71
+ * @default "https://api.bentley.com"
72
+ */
73
+ ITwinPlatform.apiEndpoint = new Resource({
74
+ url: "https://api.bentley.com",
75
+ });
76
+
77
+ /**
78
+ * @typedef {Object} ExportRequest
79
+ * @private
80
+ * @property {string} iModelId
81
+ * @property {string} changesetId
82
+ * @property {ITwinPlatform.ExportType} exportType Type of the export. CesiumJS only supports the 3DTILES type
83
+ */
84
+
85
+ /**
86
+ * @typedef {Object} Link
87
+ * @private
88
+ * @property {string} href
89
+ */
90
+
91
+ /**
92
+ * @typedef {Object} ExportRepresentation
93
+ * The export objects from get-exports when using return=representation
94
+ * @private
95
+ * @property {string} id Export id
96
+ * @property {string} displayName Name of the iModel
97
+ * @property {ITwinPlatform.ExportStatus} status Status of this export
98
+ * @property {string} lastModified
99
+ * @property {ExportRequest} request Object containing info about the export itself
100
+ * @property {{mesh: Link}} _links Object containing relevant links. For Exports this includes the access url for the mesh itself
101
+ */
102
+
103
+ /**
104
+ * @typedef {Object} GetExportsResponse
105
+ * @private
106
+ * @property {ExportRepresentation[]} exports The list of exports for the current page
107
+ * @property {{self: Link, next: Link | undefined, prev: Link | undefined}} _links Pagination links
108
+ */
109
+
110
+ /**
111
+ * Get the list of exports for the specified iModel at it's most current version.
112
+ * This will only return the top 5 exports with {@link ITwinPlatform.ExportType} of <code>3DTILES</code>.
113
+ *
114
+ * @private
115
+ *
116
+ * @param {string} iModelId iModel id
117
+ * @returns {Promise<GetExportsResponse>}
118
+ *
119
+ * @throws {RuntimeError} If the iTwin API request is not successful
120
+ */
121
+ ITwinPlatform.getExports = async function (iModelId) {
122
+ //>>includeStart('debug', pragmas.debug);
123
+ Check.typeOf.string("iModelId", iModelId);
124
+ if (!defined(ITwinPlatform.defaultAccessToken)) {
125
+ throw new DeveloperError("Must set ITwinPlatform.defaultAccessToken first");
126
+ }
127
+ //>>includeEnd('debug')
128
+
129
+ const resource = new Resource({
130
+ url: `${ITwinPlatform.apiEndpoint}mesh-export`,
131
+ headers: {
132
+ Authorization: `Bearer ${ITwinPlatform.defaultAccessToken}`,
133
+ Accept: "application/vnd.bentley.itwin-platform.v1+json",
134
+ Prefer: "return=representation",
135
+ },
136
+ queryParameters: {
137
+ iModelId: iModelId,
138
+ exportType: ITwinPlatform.ExportType["3DTILES"],
139
+ // With the export auto-generation it will auto-delete the 6th export so
140
+ // there should never be more than 5 results. Just request them all and parse
141
+ // for ones that are COMPLETE
142
+ $top: "5",
143
+ client: "CesiumJS",
144
+ },
145
+ });
146
+ /* global CESIUM_VERSION */
147
+ if (typeof CESIUM_VERSION !== "undefined") {
148
+ resource.appendQueryParameters({ clientVersion: CESIUM_VERSION });
149
+ }
150
+
151
+ try {
152
+ const response = await resource.fetchJson();
153
+ return response;
154
+ } catch (error) {
155
+ const result = JSON.parse(error.response);
156
+ if (error.statusCode === 401) {
157
+ throw new RuntimeError(
158
+ `Unauthorized, bad token, wrong scopes or headers bad. ${result.error.details[0].code}`,
159
+ );
160
+ } else if (error.statusCode === 403) {
161
+ console.error(result.error.code, result.error.message);
162
+ throw new RuntimeError("Not allowed, forbidden");
163
+ } else if (error.statusCode === 422) {
164
+ throw new RuntimeError(
165
+ `Unprocessable Entity:${result.error.code} ${result.error.message}`,
166
+ );
167
+ } else if (error.statusCode === 429) {
168
+ throw new RuntimeError("Too many requests");
169
+ }
170
+ throw new RuntimeError(`Unknown request failure ${error.statusCode}`);
171
+ }
172
+ };
173
+
174
+ /**
175
+ * @typedef {Object} RealityDataExtent
176
+ * @private
177
+ * @property {{latitude: number, longitude: number}} southWest
178
+ * @property {{latitude: number, longitude: number}} northEast
179
+ */
180
+
181
+ /**
182
+ * @typedef {Object} RealityDataRepresentation
183
+ * @private
184
+ * @property {string} id "95d8dccd-d89e-4287-bb5f-3219acbc71ae",
185
+ * @property {string} displayName "Name of reality data",
186
+ * @property {string} dataset "Dataset",
187
+ * @property {string} group "73d09423-28c3-4fdb-ab4a-03a47a5b04f8",
188
+ * @property {string} description "Description of reality data",
189
+ * @property {string} rootDocument "Directory/SubDirectory/realityData.3mx",
190
+ * @property {number} size 6521212,
191
+ * @property {string} classification "Model",
192
+ * @property {ITwinPlatform.RealityDataType} type "3MX",
193
+ * @property {{startDateTime: string, endDateTime: string, acquirer: string}} acquisition
194
+ * @property {RealityDataExtent} extent
195
+ * @property {boolean} authoring false,
196
+ * @property {string} dataCenterLocation "North Europe",
197
+ * @property {string} modifiedDateTime "2021-04-09T19:03:12Z",
198
+ * @property {string} lastAccessedDateTime "2021-04-09T00:00:00Z",
199
+ * @property {string} createdDateTime "2021-02-22T20:03:40Z",
200
+ * @property {string} ownerId "f1d49cc7-f9b3-494f-9c67-563ea5597063",
201
+ */
202
+
203
+ /**
204
+ * Load the full metadata for the given iTwin id and reality data id.
205
+ *
206
+ * @private
207
+ *
208
+ * @param {string} iTwinId The id of the iTwin to load data from
209
+ * @param {string} realityDataId The id of the reality data to load
210
+ * @returns {Promise<RealityDataRepresentation>}
211
+ */
212
+ ITwinPlatform.getRealityDataMetadata = async function (iTwinId, realityDataId) {
213
+ //>>includeStart('debug', pragmas.debug);
214
+ Check.typeOf.string("iTwinId", iTwinId);
215
+ Check.typeOf.string("realityDataId", realityDataId);
216
+ if (!defined(ITwinPlatform.defaultAccessToken)) {
217
+ throw new DeveloperError("Must set ITwinPlatform.defaultAccessToken first");
218
+ }
219
+ //>>includeEnd('debug')
220
+
221
+ const resource = new Resource({
222
+ url: `${ITwinPlatform.apiEndpoint}reality-management/reality-data/${realityDataId}`,
223
+ headers: {
224
+ Authorization: `Bearer ${ITwinPlatform.defaultAccessToken}`,
225
+ Accept: "application/vnd.bentley.itwin-platform.v1+json",
226
+ },
227
+ queryParameters: { iTwinId: iTwinId },
228
+ });
229
+
230
+ try {
231
+ const response = await resource.fetchJson();
232
+ return response.realityData;
233
+ } catch (error) {
234
+ const result = JSON.parse(error.response);
235
+ if (error.statusCode === 401) {
236
+ throw new RuntimeError(
237
+ `Unauthorized, bad token, wrong scopes or headers bad. ${result.error.details[0].code}`,
238
+ );
239
+ } else if (error.statusCode === 403) {
240
+ console.error(result.error.code, result.error.message);
241
+ throw new RuntimeError("Not allowed, forbidden");
242
+ } else if (error.statusCode === 404) {
243
+ throw new RuntimeError(
244
+ `Reality data not found: ${iTwinId}, ${realityDataId}`,
245
+ );
246
+ } else if (error.statusCode === 422) {
247
+ throw new RuntimeError(
248
+ `Unprocessable Entity:${result.error.code} ${result.error.message}`,
249
+ );
250
+ } else if (error.statusCode === 429) {
251
+ throw new RuntimeError("Too many requests");
252
+ }
253
+ throw new RuntimeError(`Unknown request failure ${error.statusCode}`);
254
+ }
255
+ };
256
+
257
+ /**
258
+ * Request the access url for the given iTwin id, reality data id and root document.
259
+ * The root document can be requested from the list using <code>return=representation</code>
260
+ * or the metadata route from {@link ITwinPlatform.getRealityDataMetadata}
261
+ *
262
+ * @private
263
+ *
264
+ * @param {string} iTwinId The id of the iTwin to load data from
265
+ * @param {string} realityDataId The id of the reality data to load
266
+ * @param {string} rootDocument The path of the root document for this reality data
267
+ * @returns {Promise<string>}
268
+ */
269
+ ITwinPlatform.getRealityDataURL = async function (
270
+ iTwinId,
271
+ realityDataId,
272
+ rootDocument,
273
+ ) {
274
+ //>>includeStart('debug', pragmas.debug);
275
+ Check.typeOf.string("iTwinId", iTwinId);
276
+ Check.typeOf.string("realityDataId", realityDataId);
277
+ Check.typeOf.string("rootDocument", rootDocument);
278
+ if (!defined(ITwinPlatform.defaultAccessToken)) {
279
+ throw new DeveloperError("Must set ITwinPlatform.defaultAccessToken first");
280
+ }
281
+ //>>includeEnd('debug')
282
+
283
+ const resource = new Resource({
284
+ url: `${ITwinPlatform.apiEndpoint}reality-management/reality-data/${realityDataId}/readaccess`,
285
+ headers: {
286
+ Authorization: `Bearer ${ITwinPlatform.defaultAccessToken}`,
287
+ Accept: "application/vnd.bentley.itwin-platform.v1+json",
288
+ },
289
+ queryParameters: { iTwinId: iTwinId },
290
+ });
291
+
292
+ try {
293
+ const result = await resource.fetchJson();
294
+
295
+ const containerUrl = result._links.containerUrl.href;
296
+ const tilesetUrl = new URL(containerUrl);
297
+ tilesetUrl.pathname = `${tilesetUrl.pathname}/${rootDocument}`;
298
+
299
+ return tilesetUrl.toString();
300
+ } catch (error) {
301
+ const result = JSON.parse(error.response);
302
+ if (error.statusCode === 401) {
303
+ throw new RuntimeError(
304
+ `Unauthorized, bad token, wrong scopes or headers bad. ${result.error.details[0].code}`,
305
+ );
306
+ } else if (error.statusCode === 403) {
307
+ console.error(result.error.code, result.error.message);
308
+ throw new RuntimeError("Not allowed, forbidden");
309
+ } else if (error.statusCode === 404) {
310
+ throw new RuntimeError(
311
+ `Reality data not found: ${iTwinId}, ${realityDataId}`,
312
+ );
313
+ } else if (error.statusCode === 422) {
314
+ throw new RuntimeError(
315
+ `Unprocessable Entity:${result.error.code} ${result.error.message}`,
316
+ );
317
+ } else if (error.statusCode === 429) {
318
+ throw new RuntimeError("Too many requests");
319
+ }
320
+ throw new RuntimeError(`Unknown request failure ${error.statusCode}`);
321
+ }
322
+ };
323
+
324
+ export default ITwinPlatform;
@@ -4,7 +4,7 @@ import Resource from "./Resource.js";
4
4
 
5
5
  let defaultTokenCredit;
6
6
  const defaultAccessToken =
7
- "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiZjBmMDE4Ny05M2JlLTRlMzgtYjIxYi05YmJjM2QwMzJkYWMiLCJpZCI6MjU5LCJpYXQiOjE3MzA0NjY3MDl9.t-7gCGPUe-oGCyCoeXPtYmlMVdgqUQD9mn-Da23yUoI";
7
+ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzYTBjYzY2NC0yMGEyLTQxZDYtYmI2MC1hMWE4ZTBlMGNlNjciLCJpZCI6MjU5LCJpYXQiOjE3MzU4NTEwMzF9.nshpaoC5qpRD4F5diwcjwJ3tddp1OjCSXoMrv37Ales";
8
8
  /**
9
9
  * Default settings for accessing the Cesium ion API.
10
10
  *
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Underlying geocoding services that can be used via Cesium ion.
3
+ *
4
+ * @enum {string}
5
+ */
6
+ const IonGeocodeProviderType = {
7
+ /**
8
+ * Google geocoder, for use with Google data.
9
+ *
10
+ * @type {string}
11
+ * @constant
12
+ */
13
+ GOOGLE: "GOOGLE",
14
+
15
+ /**
16
+ * Bing geocoder, for use with Bing data.
17
+ *
18
+ * @type {string}
19
+ * @constant
20
+ */
21
+ BING: "BING",
22
+
23
+ /**
24
+ * Use the default geocoder as set on the server. Used when neither Bing or
25
+ * Google data is used.
26
+ *
27
+ * @type {string}
28
+ * @constant
29
+ */
30
+ DEFAULT: "DEFAULT",
31
+ };
32
+
33
+ export default Object.freeze(IonGeocodeProviderType);
@@ -2,10 +2,45 @@ import Check from "./Check.js";
2
2
  import Credit from "./Credit.js";
3
3
  import defaultValue from "./defaultValue.js";
4
4
  import defined from "./defined.js";
5
+ import DeveloperError from "./DeveloperError.js";
5
6
  import Ion from "./Ion.js";
7
+ import IonGeocodeProviderType from "./IonGeocodeProviderType.js";
6
8
  import PeliasGeocoderService from "./PeliasGeocoderService.js";
7
9
  import Resource from "./Resource.js";
8
10
 
11
+ /**
12
+ * @param {*} geocodeProviderType
13
+ * @throws {DeveloperError}
14
+ * @private
15
+ */
16
+ function validateIonGeocodeProviderType(geocodeProviderType) {
17
+ if (
18
+ !Object.values(IonGeocodeProviderType).some(
19
+ (value) => value === geocodeProviderType,
20
+ )
21
+ ) {
22
+ throw new DeveloperError(
23
+ `Invalid geocodeProviderType: "${geocodeProviderType}"`,
24
+ );
25
+ }
26
+ }
27
+
28
+ const providerToParameterMap = Object.freeze({
29
+ [IonGeocodeProviderType.GOOGLE]: "google",
30
+ [IonGeocodeProviderType.BING]: "bing",
31
+ [IonGeocodeProviderType.DEFAULT]: undefined,
32
+ });
33
+
34
+ function providerToQueryParameter(provider) {
35
+ return providerToParameterMap[provider];
36
+ }
37
+
38
+ function queryParameterToProvider(parameter) {
39
+ return Object.entries(providerToParameterMap).find(
40
+ (entry) => entry[1] === parameter,
41
+ )[0];
42
+ }
43
+
9
44
  /**
10
45
  * Provides geocoding through Cesium ion.
11
46
  * @alias IonGeocoderService
@@ -15,6 +50,7 @@ import Resource from "./Resource.js";
15
50
  * @param {Scene} options.scene The scene
16
51
  * @param {string} [options.accessToken=Ion.defaultAccessToken] The access token to use.
17
52
  * @param {string|Resource} [options.server=Ion.defaultServer] The resource to the Cesium ion API server.
53
+ * @param {IonGeocodeProviderType} [options.geocodeProviderType=IonGeocodeProviderType.DEFAULT] The geocoder the Cesium ion API server should use to fulfill this request.
18
54
  *
19
55
  * @see Ion
20
56
  */
@@ -25,6 +61,14 @@ function IonGeocoderService(options) {
25
61
  Check.typeOf.object("options.scene", options.scene);
26
62
  //>>includeEnd('debug');
27
63
 
64
+ const geocodeProviderType = defaultValue(
65
+ options.geocodeProviderType,
66
+ IonGeocodeProviderType.DEFAULT,
67
+ );
68
+ //>>includeStart('debug', pragmas.debug);
69
+ validateIonGeocodeProviderType(geocodeProviderType);
70
+ //>>includeEnd('debug');
71
+
28
72
  const accessToken = defaultValue(options.accessToken, Ion.defaultAccessToken);
29
73
  const server = Resource.createIfNeeded(
30
74
  defaultValue(options.server, Ion.defaultServer),
@@ -49,6 +93,9 @@ function IonGeocoderService(options) {
49
93
  this._accessToken = accessToken;
50
94
  this._server = server;
51
95
  this._pelias = new PeliasGeocoderService(searchEndpoint);
96
+ // geocoderProviderType isn't stored here directly but instead relies on the
97
+ // query parameters of this._pelias.url. Use the setter logic to update value.
98
+ this.geocodeProviderType = geocodeProviderType;
52
99
  }
53
100
 
54
101
  Object.defineProperties(IonGeocoderService.prototype, {
@@ -64,6 +111,31 @@ Object.defineProperties(IonGeocoderService.prototype, {
64
111
  return undefined;
65
112
  },
66
113
  },
114
+ /**
115
+ * The geocoding service that Cesium ion API server should use to fulfill geocding requests.
116
+ * @memberof IonGeocoderService.prototype
117
+ * @type {IonGeocodeProviderType}
118
+ * @default IonGeocodeProviderType.DEFAULT
119
+ */
120
+ geocodeProviderType: {
121
+ get: function () {
122
+ return queryParameterToProvider(
123
+ this._pelias.url.queryParameters["geocoder"],
124
+ );
125
+ },
126
+ set: function (geocodeProviderType) {
127
+ validateIonGeocodeProviderType(geocodeProviderType);
128
+ const query = {
129
+ ...this._pelias.url.queryParameters,
130
+ geocoder: providerToQueryParameter(geocodeProviderType),
131
+ };
132
+ // Delete the geocoder parameter to prevent sending &geocoder=undefined in the query
133
+ if (!defined(query.geocoder)) {
134
+ delete query.geocoder;
135
+ }
136
+ this._pelias.url.setQueryParameters(query);
137
+ },
138
+ },
67
139
  });
68
140
 
69
141
  /**
@@ -10,7 +10,7 @@ import TimeStandard from "./TimeStandard.js";
10
10
 
11
11
  const gregorianDateScratch = new GregorianDate();
12
12
  const daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
13
- const daysInLeapFeburary = 29;
13
+ const daysInLeapFebruary = 29;
14
14
 
15
15
  function compareLeapSecondDates(leapSecond, dateToFind) {
16
16
  return JulianDate.compare(leapSecond.julianDate, dateToFind.julianDate);
@@ -430,7 +430,7 @@ JulianDate.fromIso8601 = function (iso8601String, result) {
430
430
  month > 12 ||
431
431
  day < 1 ||
432
432
  ((month !== 2 || !inLeapYear) && day > daysInMonth[month - 1]) ||
433
- (inLeapYear && month === 2 && day > daysInLeapFeburary)
433
+ (inLeapYear && month === 2 && day > daysInLeapFebruary)
434
434
  ) {
435
435
  throw new DeveloperError(iso8601ErrorMessage);
436
436
  }
@@ -542,7 +542,7 @@ JulianDate.fromIso8601 = function (iso8601String, result) {
542
542
  day++;
543
543
  }
544
544
 
545
- tmp = inLeapYear && month === 2 ? daysInLeapFeburary : daysInMonth[month - 1];
545
+ tmp = inLeapYear && month === 2 ? daysInLeapFebruary : daysInMonth[month - 1];
546
546
  while (day > tmp) {
547
547
  day -= tmp;
548
548
  month++;
@@ -553,7 +553,7 @@ JulianDate.fromIso8601 = function (iso8601String, result) {
553
553
  }
554
554
 
555
555
  tmp =
556
- inLeapYear && month === 2 ? daysInLeapFeburary : daysInMonth[month - 1];
556
+ inLeapYear && month === 2 ? daysInLeapFebruary : daysInMonth[month - 1];
557
557
  }
558
558
 
559
559
  //If UTC offset is at the beginning/end of the day, minutes can be negative.
@@ -575,7 +575,7 @@ JulianDate.fromIso8601 = function (iso8601String, result) {
575
575
  }
576
576
 
577
577
  tmp =
578
- inLeapYear && month === 2 ? daysInLeapFeburary : daysInMonth[month - 1];
578
+ inLeapYear && month === 2 ? daysInLeapFebruary : daysInMonth[month - 1];
579
579
  day += tmp;
580
580
  }
581
581
 
@@ -784,8 +784,15 @@ JulianDate.toIso8601 = function (julianDate, precision) {
784
784
  let millisecondStr;
785
785
 
786
786
  if (!defined(precision) && millisecond !== 0) {
787
- //Forces milliseconds into a number with at least 3 digits to whatever the default toString() precision is.
788
- millisecondStr = (millisecond * 0.01).toString().replace(".", "");
787
+ // Forces milliseconds into a number with at least 3 digits.
788
+ const millisecondHundreds = millisecond * 0.01;
789
+ // Below 1e-6, toString returns scientific notation, so it should be replaced by toFixed with appropriate number of digits.
790
+ // 20 digits is a trade-off choice guided by JavaScript's Number representation accuracy (15-17 decimal digits for most numbers).
791
+ // Using toFixed(20) ensures capturing enough precision while avoiding inaccuracies due to floating-point limitations.
792
+ millisecondStr =
793
+ millisecondHundreds < 1e-6
794
+ ? millisecondHundreds.toFixed(20).replace(".", "").replace(/0+$/, "")
795
+ : millisecondHundreds.toString().replace(".", "");
789
796
  return `${year.toString().padStart(4, "0")}-${month
790
797
  .toString()
791
798
  .padStart(2, "0")}-${day.toString().padStart(2, "0")}T${hour
@@ -7,7 +7,6 @@ import Ellipsoid from "./Ellipsoid.js";
7
7
  import CesiumMath from "./Math.js";
8
8
  import Transforms from "./Transforms.js";
9
9
  import Matrix4 from "./Matrix4.js";
10
- import deprecationWarning from "./deprecationWarning.js";
11
10
 
12
11
  /**
13
12
  * A two dimensional region specified as longitude and latitude coordinates.
@@ -533,25 +532,6 @@ Rectangle.prototype.equalsEpsilon = function (other, epsilon) {
533
532
  return Rectangle.equalsEpsilon(this, other, epsilon);
534
533
  };
535
534
 
536
- /**
537
- * Checks a Rectangle's properties and throws if they are not in valid ranges.
538
- *
539
- * @param {Rectangle} rectangle The rectangle to validate
540
- *
541
- * @exception {DeveloperError} <code>north</code> must be in the interval [<code>-Pi/2</code>, <code>Pi/2</code>].
542
- * @exception {DeveloperError} <code>south</code> must be in the interval [<code>-Pi/2</code>, <code>Pi/2</code>].
543
- * @exception {DeveloperError} <code>east</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>].
544
- * @exception {DeveloperError} <code>west</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>].
545
- * @deprecated This function is deprecated and will be removed in Cesium 1.124. See <a href="https://github.com/CesiumGS/cesium/issues/4921">Issue 4921</a>
546
- */
547
- Rectangle.validate = function (rectangle) {
548
- deprecationWarning(
549
- "Rectangle.validate",
550
- "Rectangle.validate is a no-op and has been deprecated. It will be removed in Cesium 1.124.",
551
- );
552
- return Rectangle._validate(rectangle);
553
- };
554
-
555
535
  /**
556
536
  * Checks a Rectangle's properties and throws if they are not in valid ranges.
557
537
  *
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Constants for identifying well-known tracking reference frames.
3
+ *
4
+ * @enum {number}
5
+ */
6
+ const TrackingReferenceFrame = {
7
+ /**
8
+ * Auto-detect algorithm. The reference frame used to track the Entity will
9
+ * be automatically selected based on its trajectory: near-surface slow moving
10
+ * objects will be tracked in the entity's local east-north-up reference
11
+ * frame, while faster objects like satellites will use VVLH (Vehicle Velocity,
12
+ * Local Horizontal).
13
+ *
14
+ * @type {number}
15
+ * @constant
16
+ */
17
+ AUTODETECT: 0,
18
+
19
+ /**
20
+ * The entity's local East-North-Up reference frame.
21
+ *
22
+ * @type {number}
23
+ * @constant
24
+ */
25
+ ENU: 1,
26
+
27
+ /**
28
+ * The entity's inertial reference frame. If entity has no defined orientation
29
+ * property, it falls back to auto-detect algorithm.
30
+ *
31
+ * @type {number}
32
+ * @constant
33
+ */
34
+ INERTIAL: 2,
35
+
36
+ /**
37
+ * The entity's inertial reference frame with orientation fixed to its
38
+ * {@link VelocityOrientationProperty}, ignoring its own orientation.
39
+ *
40
+ * @type {number}
41
+ * @constant
42
+ */
43
+ VELOCITY: 3,
44
+ };
45
+ export default Object.freeze(TrackingReferenceFrame);
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @example
3
+ * if (Cesium.defined(positions)) {
4
+ * doSomething();
5
+ * } else {
6
+ * doSomethingElse();
7
+ * }
8
+ * @param value - The object.
9
+ * @returns Returns true if the object is defined, returns false otherwise.
10
+ */
11
+ export default function defined<Type>(value: Type): value is NonNullable<Type>;
@@ -10,6 +10,7 @@ import CesiumMath from "../Core/Math.js";
10
10
  import Matrix3 from "../Core/Matrix3.js";
11
11
  import Matrix4 from "../Core/Matrix4.js";
12
12
  import Quaternion from "../Core/Quaternion.js";
13
+ import TrackingReferenceFrame from "../Core/TrackingReferenceFrame.js";
13
14
  import Transforms from "../Core/Transforms.js";
14
15
  import GroundPolylinePrimitive from "../Scene/GroundPolylinePrimitive.js";
15
16
  import GroundPrimitive from "../Scene/GroundPrimitive.js";
@@ -73,8 +74,9 @@ function createPropertyTypeDescriptor(name, Type) {
73
74
  * @property {string} [name] A human readable name to display to users. It does not have to be unique.
74
75
  * @property {TimeIntervalCollection} [availability] The availability, if any, associated with this object.
75
76
  * @property {boolean} [show] A boolean value indicating if the entity and its children are displayed.
77
+ * @property {TrackingReferenceFrame} [trackingReferenceFrame=TrackingReferenceFrame.AUTODETECT] The reference frame used when this entity is being tracked. <br/> If <code>undefined</code>, reference frame is determined based on entity velocity: near-surface slow moving entities are tracked using the local east-north-up reference frame, whereas fast moving entities such as satellites are tracked using VVLH (Vehicle Velocity, Local Horizontal).
76
78
  * @property {Property | string} [description] A string Property specifying an HTML description for this entity.
77
- * @property {PositionProperty | Cartesian3 | CallbackProperty} [position] A Property specifying the entity position.
79
+ * @property {PositionProperty | Cartesian3 | CallbackPositionProperty} [position] A Property specifying the entity position.
78
80
  * @property {Property | Quaternion} [orientation=Transforms.eastNorthUpToFixedFrame(position)] A Property specifying the entity orientation in respect to Earth-fixed-Earth-centered (ECEF). If undefined, east-north-up at entity position is used.
79
81
  * @property {Property | Cartesian3} [viewFrom] A suggested initial offset for viewing this object.
80
82
  * @property {Entity} [parent] A parent entity to associate with this entity.
@@ -122,6 +124,10 @@ function Entity(options) {
122
124
  this._definitionChanged = new Event();
123
125
  this._name = options.name;
124
126
  this._show = defaultValue(options.show, true);
127
+ this._trackingReferenceFrame = defaultValue(
128
+ options.trackingReferenceFrame,
129
+ TrackingReferenceFrame.AUTODETECT,
130
+ );
125
131
  this._parent = undefined;
126
132
  this._propertyNames = [
127
133
  "billboard",
@@ -296,6 +302,14 @@ Object.defineProperties(Entity.prototype, {
296
302
  this._definitionChanged.raiseEvent(this, "show", value, !value);
297
303
  },
298
304
  },
305
+ /**
306
+ * Gets or sets the entity's tracking reference frame.
307
+ * @demo {@link https://sandcastle.cesium.com/index.html?src=Entity tracking.html|Cesium Sandcastle Entity tracking Demo}
308
+ *
309
+ * @memberof Entity.prototype
310
+ * @type {TrackingReferenceFrame}
311
+ */
312
+ trackingReferenceFrame: createRawPropertyDescriptor("trackingReferenceFrame"),
299
313
  /**
300
314
  * Gets whether this entity is being displayed, taking into account
301
315
  * the visibility of any ancestor entities.