@cesium/engine 22.3.0 → 23.0.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 (193) hide show
  1. package/Build/Workers/{chunk-EAAH543Q.js → chunk-2GL2EUEE.js} +11 -11
  2. package/Build/Workers/{chunk-EUDHHS7K.js → chunk-2WI4HGJU.js} +6 -6
  3. package/Build/Workers/{chunk-LWZHJWYK.js → chunk-36LBFITA.js} +665 -366
  4. package/Build/Workers/{chunk-7U5YNLF3.js → chunk-3B65YFXC.js} +1 -1
  5. package/Build/Workers/{chunk-D63Z7KKL.js → chunk-4LGFX2P5.js} +11 -11
  6. package/Build/Workers/{chunk-D6OKR3BQ.js → chunk-4UNQX2MP.js} +2 -2
  7. package/Build/Workers/{chunk-BO22JHBX.js → chunk-52K3GJKG.js} +3 -3
  8. package/Build/Workers/{chunk-XLIJV3YZ.js → chunk-56OHFSLH.js} +10 -10
  9. package/Build/Workers/{chunk-AWELU5C6.js → chunk-5A7YSAXT.js} +14 -14
  10. package/Build/Workers/{chunk-T5MJDW43.js → chunk-5JP5FG7U.js} +7 -7
  11. package/Build/Workers/{chunk-NVL7JXAQ.js → chunk-5R7SBUTW.js} +10 -10
  12. package/Build/Workers/chunk-5VKZVPO5.js +1829 -0
  13. package/Build/Workers/{chunk-YHPBT4I5.js → chunk-6FVFM2KB.js} +5 -5
  14. package/Build/Workers/{chunk-WHLGBMBC.js → chunk-6SLGTBB2.js} +5 -5
  15. package/Build/Workers/{chunk-VIQIKMTZ.js → chunk-7KRN6JPQ.js} +14 -14
  16. package/Build/Workers/{chunk-TCOUGKXF.js → chunk-AA33B6PU.js} +4 -4
  17. package/Build/Workers/{chunk-S2KVL7OJ.js → chunk-AP6XWET5.js} +8 -8
  18. package/Build/Workers/{chunk-5PJB7ASO.js → chunk-APDKMX7W.js} +6 -6
  19. package/Build/Workers/{chunk-IXL46IYV.js → chunk-ARCFIOKA.js} +12 -12
  20. package/Build/Workers/{chunk-KIJR26N3.js → chunk-BNBD2YZK.js} +16 -16
  21. package/Build/Workers/{chunk-4R6FGUFP.js → chunk-DT5SJBKA.js} +29 -15
  22. package/Build/Workers/{chunk-FUDC3KOT.js → chunk-ESD4IEOU.js} +5 -5
  23. package/Build/Workers/{chunk-K2PLKJJG.js → chunk-FSDVXW7M.js} +5 -5
  24. package/Build/Workers/{chunk-4BBANFU6.js → chunk-G3YT7M7A.js} +1 -1
  25. package/Build/Workers/{chunk-K4PGSAR5.js → chunk-GN5NEUDT.js} +8 -8
  26. package/Build/Workers/{chunk-OOYICVOK.js → chunk-HYLEKKO5.js} +1 -1
  27. package/Build/Workers/{chunk-FDOLXORR.js → chunk-HYTFXWMY.js} +7 -7
  28. package/Build/Workers/{chunk-7SLNBIZS.js → chunk-IFA7VHHP.js} +560 -277
  29. package/Build/Workers/{chunk-N66PIK46.js → chunk-IYVDOB5V.js} +4 -4
  30. package/Build/Workers/{chunk-ZWWN2CQH.js → chunk-JUGY5AZN.js} +4 -4
  31. package/Build/Workers/{chunk-4O2ARYS7.js → chunk-KPYU6YZG.js} +1 -1
  32. package/Build/Workers/{chunk-TY5JXMVO.js → chunk-L7RDJ4V7.js} +1 -1
  33. package/Build/Workers/{chunk-L4OFWHNI.js → chunk-LDQWNMEC.js} +1 -1
  34. package/Build/Workers/{chunk-N6XBJBI7.js → chunk-MQJG522T.js} +6 -6
  35. package/Build/Workers/{chunk-FS42VX2H.js → chunk-MT5M7RLZ.js} +2 -2
  36. package/Build/Workers/{chunk-7ATKQRBM.js → chunk-N4AWE7TZ.js} +10 -10
  37. package/Build/Workers/{chunk-EOSX23OS.js → chunk-NAYRNPEP.js} +4 -4
  38. package/Build/Workers/{chunk-NO3LMU7T.js → chunk-NNHU33JK.js} +7 -7
  39. package/Build/Workers/{chunk-HWGP4GVC.js → chunk-NQCAZU7S.js} +13 -13
  40. package/Build/Workers/{chunk-6GBGEUWR.js → chunk-NUYLNQKV.js} +2 -2
  41. package/Build/Workers/{chunk-E4YDCSQK.js → chunk-OC6X22PG.js} +9 -9
  42. package/Build/Workers/{chunk-ZGGVEGTA.js → chunk-OHBM4YG4.js} +12 -12
  43. package/Build/Workers/{chunk-6WDMPXQ7.js → chunk-OMXN7YF4.js} +12 -12
  44. package/Build/Workers/{chunk-LK7GEFGB.js → chunk-OQ3EAJNW.js} +2 -2
  45. package/Build/Workers/{chunk-M5DVYXJJ.js → chunk-OQBPOKPZ.js} +6 -6
  46. package/Build/Workers/{chunk-WUWPKBOZ.js → chunk-PQVNT5CJ.js} +6 -6
  47. package/Build/Workers/{chunk-W5NV72VR.js → chunk-QA24Q62E.js} +17 -17
  48. package/Build/Workers/{chunk-PJLRXIMS.js → chunk-QQX7S5QT.js} +17 -17
  49. package/Build/Workers/{chunk-D2PEV362.js → chunk-QTOHIXGF.js} +10 -10
  50. package/Build/Workers/{chunk-MASEF4OV.js → chunk-R7M4XNPP.js} +8 -8
  51. package/Build/Workers/{chunk-2MLJ46ZZ.js → chunk-SGKTBHFQ.js} +13 -13
  52. package/Build/Workers/{chunk-EY5HOJFQ.js → chunk-SQTRWKO2.js} +5 -5
  53. package/Build/Workers/{chunk-AFGP5BXS.js → chunk-T43FXHNC.js} +7 -7
  54. package/Build/Workers/{chunk-IHFAFGR2.js → chunk-UEEGWJJP.js} +2 -2
  55. package/Build/Workers/{chunk-TMGLPEZW.js → chunk-WKXDCVBO.js} +4 -4
  56. package/Build/Workers/{chunk-VRAAQ3FS.js → chunk-Y5AJSEEN.js} +2 -2
  57. package/Build/Workers/{chunk-Y5MRBKQN.js → chunk-ZIW5FCIW.js} +18 -18
  58. package/Build/Workers/combineGeometry.js +24 -24
  59. package/Build/Workers/createBoxGeometry.js +18 -18
  60. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCircleGeometry.js +26 -26
  62. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  63. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  64. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  65. package/Build/Workers/createCorridorGeometry.js +29 -29
  66. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  67. package/Build/Workers/createCylinderGeometry.js +20 -20
  68. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  69. package/Build/Workers/createEllipseGeometry.js +26 -26
  70. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  71. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  73. package/Build/Workers/createFrustumGeometry.js +18 -18
  74. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  75. package/Build/Workers/createGeometry.js +24 -24
  76. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPlaneGeometry.js +16 -16
  78. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  79. package/Build/Workers/createPolygonGeometry.js +32 -32
  80. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  81. package/Build/Workers/createPolylineGeometry.js +25 -25
  82. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  83. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  84. package/Build/Workers/createRectangleGeometry.js +27 -27
  85. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  86. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  87. package/Build/Workers/createSphereGeometry.js +19 -19
  88. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  89. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  90. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  91. package/Build/Workers/createVectorTileGeometries.js +24 -24
  92. package/Build/Workers/createVectorTilePoints.js +13 -13
  93. package/Build/Workers/createVectorTilePolygons.js +22 -22
  94. package/Build/Workers/createVectorTilePolylines.js +14 -14
  95. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  96. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  97. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  98. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  99. package/Build/Workers/createWallGeometry.js +24 -24
  100. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  101. package/Build/Workers/decodeDraco.js +10 -10
  102. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  103. package/Build/Workers/decodeI3S.js +10 -10
  104. package/Build/Workers/gaussianSplatSorter.js +4 -4
  105. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  106. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  107. package/Build/Workers/transcodeKTX2.js +6 -6
  108. package/Build/Workers/transferTypedArrayTest.js +1 -1
  109. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  110. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  111. package/Source/Core/AttributeCompression.js +53 -6
  112. package/Source/Core/Cartesian2.js +689 -684
  113. package/Source/Core/Cartesian3.js +1044 -1043
  114. package/Source/Core/Cartesian4.js +816 -813
  115. package/Source/Core/GoogleMaps.js +23 -2
  116. package/Source/Core/Ion.js +1 -1
  117. package/Source/Core/OpenCageGeocoderService.js +2 -3
  118. package/Source/Core/globalTypes.js +16 -0
  119. package/Source/Renderer/ShaderDestination.js +54 -13
  120. package/Source/Scene/ArcGisMapService.js +1 -1
  121. package/Source/Scene/Billboard.js +7 -4
  122. package/Source/Scene/BillboardCollection.js +64 -25
  123. package/Source/Scene/BufferLoader.js +65 -74
  124. package/Source/Scene/CubeMapPanorama.js +351 -0
  125. package/Source/Scene/DerivedCommand.js +8 -31
  126. package/Source/Scene/DracoLoader.js +79 -78
  127. package/Source/Scene/EquirectangularPanorama.js +264 -0
  128. package/Source/Scene/FrameState.js +7 -0
  129. package/Source/Scene/GaussianSplatPrimitive.js +906 -167
  130. package/Source/Scene/GlobeSurfaceShaderSet.js +36 -32
  131. package/Source/Scene/GltfBufferViewLoader.js +109 -118
  132. package/Source/Scene/GltfDracoLoader.js +167 -176
  133. package/Source/Scene/GltfImageLoader.js +91 -101
  134. package/Source/Scene/GltfIndexBufferLoader.js +228 -241
  135. package/Source/Scene/GltfJsonLoader.js +90 -99
  136. package/Source/Scene/GltfLoader.js +313 -324
  137. package/Source/Scene/GltfSpzLoader.js +127 -134
  138. package/Source/Scene/GltfStructuralMetadataLoader.js +181 -186
  139. package/Source/Scene/GltfTextureLoader.js +217 -231
  140. package/Source/Scene/GltfVertexBufferLoader.js +267 -276
  141. package/Source/Scene/GoogleStreetViewCubeMapPanoramaProvider.js +341 -0
  142. package/Source/Scene/Label.js +6 -4
  143. package/Source/Scene/LabelCollection.js +59 -1
  144. package/Source/Scene/MetadataClassProperty.js +212 -7
  145. package/Source/Scene/MetadataComponentType.js +162 -127
  146. package/Source/Scene/MetadataSchemaLoader.js +60 -67
  147. package/Source/Scene/MetadataTable.js +14 -0
  148. package/Source/Scene/MetadataTableProperty.js +14 -0
  149. package/Source/Scene/Model/B3dmLoader.js +216 -224
  150. package/Source/Scene/Model/CustomShader.js +6 -1
  151. package/Source/Scene/Model/CustomShaderPipelineStage.js +122 -7
  152. package/Source/Scene/Model/GeoJsonLoader.js +53 -61
  153. package/Source/Scene/Model/GeometryPipelineStage.js +17 -3
  154. package/Source/Scene/Model/I3dmLoader.js +232 -240
  155. package/Source/Scene/Model/MaterialPipelineStage.js +1 -1
  156. package/Source/Scene/Model/MetadataPipelineStage.js +438 -22
  157. package/Source/Scene/Model/PntsLoader.js +78 -89
  158. package/Source/Scene/Panorama.js +53 -0
  159. package/Source/Scene/PanoramaProvider.js +43 -0
  160. package/Source/Scene/PointPrimitiveCollection.js +14 -22
  161. package/Source/Scene/PropertyTable.js +43 -0
  162. package/Source/Scene/PropertyTexture.js +1 -1
  163. package/Source/Scene/PropertyTextureProperty.js +0 -97
  164. package/Source/Scene/ResourceLoader.js +84 -92
  165. package/Source/Scene/Scene.js +12 -0
  166. package/Source/Scene/SkyBox.js +29 -164
  167. package/Source/Scene/StructuralMetadata.js +18 -3
  168. package/Source/Scene/parseStructuralMetadata.js +244 -0
  169. package/Source/Shaders/BillboardCollectionFS.glsl +66 -40
  170. package/Source/Shaders/BillboardCollectionFS.js +67 -40
  171. package/Source/Shaders/BillboardCollectionVS.glsl +22 -31
  172. package/Source/Shaders/BillboardCollectionVS.js +22 -31
  173. package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
  174. package/Source/Shaders/Builtin/Functions/decodeRGB8.glsl +22 -0
  175. package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
  176. package/Source/Shaders/Builtin/Functions/unpackTexture.glsl +35 -0
  177. package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
  178. package/Source/Shaders/CubeMapPanoramaVS.glsl +11 -0
  179. package/Source/Shaders/CubeMapPanoramaVS.js +13 -0
  180. package/Source/Shaders/Model/MetadataStageFS.glsl +2 -1
  181. package/Source/Shaders/Model/MetadataStageFS.js +2 -1
  182. package/Source/Shaders/Model/MetadataStageVS.glsl +2 -1
  183. package/Source/Shaders/Model/MetadataStageVS.js +2 -1
  184. package/Source/Shaders/Model/ModelFS.glsl +2 -2
  185. package/Source/Shaders/Model/ModelFS.js +2 -2
  186. package/Source/Shaders/Model/ModelVS.glsl +2 -2
  187. package/Source/Shaders/Model/ModelVS.js +2 -2
  188. package/Source/Shaders/PointPrimitiveCollectionVS.glsl +8 -39
  189. package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
  190. package/index.d.ts +564 -189
  191. package/index.js +127 -119
  192. package/package.json +1 -1
  193. package/Build/Workers/chunk-LYBNPUEI.js +0 -1443
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.138.0
4
+ * Version 1.139.0
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -25,17 +25,17 @@
25
25
 
26
26
  import {
27
27
  Cartesian3_default
28
- } from "./chunk-LYBNPUEI.js";
28
+ } from "./chunk-5VKZVPO5.js";
29
29
  import {
30
30
  Math_default
31
- } from "./chunk-BO22JHBX.js";
31
+ } from "./chunk-52K3GJKG.js";
32
32
  import {
33
33
  Check_default,
34
34
  DeveloperError_default
35
- } from "./chunk-FS42VX2H.js";
35
+ } from "./chunk-MT5M7RLZ.js";
36
36
  import {
37
37
  defined_default
38
- } from "./chunk-7U5YNLF3.js";
38
+ } from "./chunk-3B65YFXC.js";
39
39
 
40
40
  // packages/engine/Source/Core/scaleToGeodeticSurface.js
41
41
  var scaleToGeodeticSurfaceIntersection = new Cartesian3_default();
@@ -242,299 +242,582 @@ Cartographic.prototype.toString = function() {
242
242
  var Cartographic_default = Cartographic;
243
243
 
244
244
  // packages/engine/Source/Core/Cartesian2.js
245
- function Cartesian2(x, y) {
246
- this.x = x ?? 0;
247
- this.y = y ?? 0;
248
- }
249
- Cartesian2.fromElements = function(x, y, result) {
250
- if (!defined_default(result)) {
251
- return new Cartesian2(x, y);
245
+ var Cartesian2 = class _Cartesian2 {
246
+ /**
247
+ * @param {number} [x=0.0] The X component.
248
+ * @param {number} [y=0.0] The Y component.
249
+ */
250
+ constructor(x, y) {
251
+ this.x = x ?? 0;
252
+ this.y = y ?? 0;
252
253
  }
253
- result.x = x;
254
- result.y = y;
255
- return result;
256
- };
257
- Cartesian2.clone = function(cartesian, result) {
258
- if (!defined_default(cartesian)) {
259
- return void 0;
254
+ /**
255
+ * Creates a Cartesian2 instance from x and y coordinates.
256
+ *
257
+ * @param {number} x The x coordinate.
258
+ * @param {number} y The y coordinate.
259
+ * @param {Cartesian2} [result] The object onto which to store the result.
260
+ * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
261
+ */
262
+ static fromElements(x, y, result) {
263
+ if (!defined_default(result)) {
264
+ return new _Cartesian2(x, y);
265
+ }
266
+ result.x = x;
267
+ result.y = y;
268
+ return result;
260
269
  }
261
- if (!defined_default(result)) {
262
- return new Cartesian2(cartesian.x, cartesian.y);
270
+ /**
271
+ * Duplicates a Cartesian2 instance.
272
+ *
273
+ * @param {Cartesian2} cartesian The Cartesian to duplicate.
274
+ * @param {Cartesian2} [result] The object onto which to store the result.
275
+ * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided. (Returns undefined if cartesian is undefined)
276
+ */
277
+ static clone(cartesian, result) {
278
+ if (!defined_default(cartesian)) {
279
+ return void 0;
280
+ }
281
+ if (!defined_default(result)) {
282
+ return new _Cartesian2(cartesian.x, cartesian.y);
283
+ }
284
+ result.x = cartesian.x;
285
+ result.y = cartesian.y;
286
+ return result;
263
287
  }
264
- result.x = cartesian.x;
265
- result.y = cartesian.y;
266
- return result;
267
- };
268
- Cartesian2.fromCartesian3 = Cartesian2.clone;
269
- Cartesian2.fromCartesian4 = Cartesian2.clone;
270
- Cartesian2.packedLength = 2;
271
- Cartesian2.pack = function(value, array, startingIndex) {
272
- Check_default.typeOf.object("value", value);
273
- Check_default.defined("array", array);
274
- startingIndex = startingIndex ?? 0;
275
- array[startingIndex++] = value.x;
276
- array[startingIndex] = value.y;
277
- return array;
278
- };
279
- Cartesian2.unpack = function(array, startingIndex, result) {
280
- Check_default.defined("array", array);
281
- startingIndex = startingIndex ?? 0;
282
- if (!defined_default(result)) {
283
- result = new Cartesian2();
288
+ /**
289
+ * Stores the provided instance into the provided array.
290
+ *
291
+ * @param {Cartesian2} value The value to pack.
292
+ * @param {number[]|TypedArray} array The array to pack into.
293
+ * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
294
+ *
295
+ * @returns {number[]|TypedArray} The array that was packed into
296
+ */
297
+ static pack(value, array, startingIndex) {
298
+ Check_default.typeOf.object("value", value);
299
+ Check_default.defined("array", array);
300
+ startingIndex = startingIndex ?? 0;
301
+ array[startingIndex++] = value.x;
302
+ array[startingIndex] = value.y;
303
+ return array;
284
304
  }
285
- result.x = array[startingIndex++];
286
- result.y = array[startingIndex];
287
- return result;
288
- };
289
- Cartesian2.packArray = function(array, result) {
290
- Check_default.defined("array", array);
291
- const length = array.length;
292
- const resultLength = length * 2;
293
- if (!defined_default(result)) {
294
- result = new Array(resultLength);
295
- } else if (!Array.isArray(result) && result.length !== resultLength) {
296
- throw new DeveloperError_default(
297
- "If result is a typed array, it must have exactly array.length * 2 elements"
305
+ /**
306
+ * Retrieves an instance from a packed array.
307
+ *
308
+ * @param {number[]|TypedArray} array The packed array.
309
+ * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
310
+ * @param {Cartesian2} [result] The object into which to store the result.
311
+ * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
312
+ */
313
+ static unpack(array, startingIndex, result) {
314
+ Check_default.defined("array", array);
315
+ startingIndex = startingIndex ?? 0;
316
+ if (!defined_default(result)) {
317
+ result = new _Cartesian2();
318
+ }
319
+ result.x = array[startingIndex++];
320
+ result.y = array[startingIndex];
321
+ return result;
322
+ }
323
+ /**
324
+ * Flattens an array of Cartesian2s into an array of components.
325
+ *
326
+ * @param {Cartesian2[]} array The array of cartesians to pack.
327
+ * @param {number[]|TypedArray} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 2 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 2) elements.
328
+ * @returns {number[]|TypedArray} The packed array.
329
+ */
330
+ static packArray(array, result) {
331
+ Check_default.defined("array", array);
332
+ const length = array.length;
333
+ const resultLength = length * 2;
334
+ if (!defined_default(result)) {
335
+ result = new Array(resultLength);
336
+ } else if (!Array.isArray(result) && result.length !== resultLength) {
337
+ throw new DeveloperError_default(
338
+ "If result is a typed array, it must have exactly array.length * 2 elements"
339
+ );
340
+ } else if (result.length !== resultLength) {
341
+ result.length = resultLength;
342
+ }
343
+ for (let i = 0; i < length; ++i) {
344
+ _Cartesian2.pack(array[i], result, i * 2);
345
+ }
346
+ return result;
347
+ }
348
+ /**
349
+ * Unpacks an array of cartesian components into an array of Cartesian2s.
350
+ *
351
+ * @param {number[]} array The array of components to unpack.
352
+ * @param {Cartesian2[]} [result] The array onto which to store the result.
353
+ * @returns {Cartesian2[]} The unpacked array.
354
+ */
355
+ static unpackArray(array, result) {
356
+ Check_default.defined("array", array);
357
+ Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 2);
358
+ if (array.length % 2 !== 0) {
359
+ throw new DeveloperError_default("array length must be a multiple of 2.");
360
+ }
361
+ const length = array.length;
362
+ if (!defined_default(result)) {
363
+ result = new Array(length / 2);
364
+ } else {
365
+ result.length = length / 2;
366
+ }
367
+ for (let i = 0; i < length; i += 2) {
368
+ const index = i / 2;
369
+ result[index] = _Cartesian2.unpack(array, i, result[index]);
370
+ }
371
+ return result;
372
+ }
373
+ /**
374
+ * Computes the value of the maximum component for the supplied Cartesian.
375
+ *
376
+ * @param {Cartesian2} cartesian The cartesian to use.
377
+ * @returns {number} The value of the maximum component.
378
+ */
379
+ static maximumComponent(cartesian) {
380
+ Check_default.typeOf.object("cartesian", cartesian);
381
+ return Math.max(cartesian.x, cartesian.y);
382
+ }
383
+ /**
384
+ * Computes the value of the minimum component for the supplied Cartesian.
385
+ *
386
+ * @param {Cartesian2} cartesian The cartesian to use.
387
+ * @returns {number} The value of the minimum component.
388
+ */
389
+ static minimumComponent(cartesian) {
390
+ Check_default.typeOf.object("cartesian", cartesian);
391
+ return Math.min(cartesian.x, cartesian.y);
392
+ }
393
+ /**
394
+ * Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
395
+ *
396
+ * @param {Cartesian2} first A cartesian to compare.
397
+ * @param {Cartesian2} second A cartesian to compare.
398
+ * @param {Cartesian2} result The object into which to store the result.
399
+ * @returns {Cartesian2} A cartesian with the minimum components.
400
+ */
401
+ static minimumByComponent(first, second, result) {
402
+ Check_default.typeOf.object("first", first);
403
+ Check_default.typeOf.object("second", second);
404
+ Check_default.typeOf.object("result", result);
405
+ result.x = Math.min(first.x, second.x);
406
+ result.y = Math.min(first.y, second.y);
407
+ return result;
408
+ }
409
+ /**
410
+ * Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
411
+ *
412
+ * @param {Cartesian2} first A cartesian to compare.
413
+ * @param {Cartesian2} second A cartesian to compare.
414
+ * @param {Cartesian2} result The object into which to store the result.
415
+ * @returns {Cartesian2} A cartesian with the maximum components.
416
+ */
417
+ static maximumByComponent(first, second, result) {
418
+ Check_default.typeOf.object("first", first);
419
+ Check_default.typeOf.object("second", second);
420
+ Check_default.typeOf.object("result", result);
421
+ result.x = Math.max(first.x, second.x);
422
+ result.y = Math.max(first.y, second.y);
423
+ return result;
424
+ }
425
+ /**
426
+ * Constrain a value to lie between two values.
427
+ *
428
+ * @param {Cartesian2} value The value to clamp.
429
+ * @param {Cartesian2} min The minimum bound.
430
+ * @param {Cartesian2} max The maximum bound.
431
+ * @param {Cartesian2} result The object into which to store the result.
432
+ * @returns {Cartesian2} The clamped value such that min <= result <= max.
433
+ */
434
+ static clamp(value, min, max, result) {
435
+ Check_default.typeOf.object("value", value);
436
+ Check_default.typeOf.object("min", min);
437
+ Check_default.typeOf.object("max", max);
438
+ Check_default.typeOf.object("result", result);
439
+ const x = Math_default.clamp(value.x, min.x, max.x);
440
+ const y = Math_default.clamp(value.y, min.y, max.y);
441
+ result.x = x;
442
+ result.y = y;
443
+ return result;
444
+ }
445
+ /**
446
+ * Computes the provided Cartesian's squared magnitude.
447
+ *
448
+ * @param {Cartesian2} cartesian The Cartesian instance whose squared magnitude is to be computed.
449
+ * @returns {number} The squared magnitude.
450
+ */
451
+ static magnitudeSquared(cartesian) {
452
+ Check_default.typeOf.object("cartesian", cartesian);
453
+ return cartesian.x * cartesian.x + cartesian.y * cartesian.y;
454
+ }
455
+ /**
456
+ * Computes the Cartesian's magnitude (length).
457
+ *
458
+ * @param {Cartesian2} cartesian The Cartesian instance whose magnitude is to be computed.
459
+ * @returns {number} The magnitude.
460
+ */
461
+ static magnitude(cartesian) {
462
+ return Math.sqrt(_Cartesian2.magnitudeSquared(cartesian));
463
+ }
464
+ /**
465
+ * Computes the distance between two points.
466
+ *
467
+ * @param {Cartesian2} left The first point to compute the distance from.
468
+ * @param {Cartesian2} right The second point to compute the distance to.
469
+ * @returns {number} The distance between two points.
470
+ *
471
+ * @example
472
+ * // Returns 1.0
473
+ * const d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(2.0, 0.0));
474
+ */
475
+ static distance(left, right) {
476
+ Check_default.typeOf.object("left", left);
477
+ Check_default.typeOf.object("right", right);
478
+ _Cartesian2.subtract(left, right, distanceScratch);
479
+ return _Cartesian2.magnitude(distanceScratch);
480
+ }
481
+ /**
482
+ * Computes the squared distance between two points. Comparing squared distances
483
+ * using this function is more efficient than comparing distances using {@link Cartesian2#distance}.
484
+ *
485
+ * @param {Cartesian2} left The first point to compute the distance from.
486
+ * @param {Cartesian2} right The second point to compute the distance to.
487
+ * @returns {number} The distance between two points.
488
+ *
489
+ * @example
490
+ * // Returns 4.0, not 2.0
491
+ * const d = Cesium.Cartesian2.distance(new Cesium.Cartesian2(1.0, 0.0), new Cesium.Cartesian2(3.0, 0.0));
492
+ */
493
+ static distanceSquared(left, right) {
494
+ Check_default.typeOf.object("left", left);
495
+ Check_default.typeOf.object("right", right);
496
+ _Cartesian2.subtract(left, right, distanceScratch);
497
+ return _Cartesian2.magnitudeSquared(distanceScratch);
498
+ }
499
+ /**
500
+ * Computes the normalized form of the supplied Cartesian.
501
+ *
502
+ * @param {Cartesian2} cartesian The Cartesian to be normalized.
503
+ * @param {Cartesian2} result The object onto which to store the result.
504
+ * @returns {Cartesian2} The modified result parameter.
505
+ */
506
+ static normalize(cartesian, result) {
507
+ Check_default.typeOf.object("cartesian", cartesian);
508
+ Check_default.typeOf.object("result", result);
509
+ const magnitude = _Cartesian2.magnitude(cartesian);
510
+ result.x = cartesian.x / magnitude;
511
+ result.y = cartesian.y / magnitude;
512
+ if (isNaN(result.x) || isNaN(result.y)) {
513
+ throw new DeveloperError_default("normalized result is not a number");
514
+ }
515
+ return result;
516
+ }
517
+ /**
518
+ * Computes the dot (scalar) product of two Cartesians.
519
+ *
520
+ * @param {Cartesian2} left The first Cartesian.
521
+ * @param {Cartesian2} right The second Cartesian.
522
+ * @returns {number} The dot product.
523
+ */
524
+ static dot(left, right) {
525
+ Check_default.typeOf.object("left", left);
526
+ Check_default.typeOf.object("right", right);
527
+ return left.x * right.x + left.y * right.y;
528
+ }
529
+ /**
530
+ * Computes the magnitude of the cross product that would result from implicitly setting the Z coordinate of the input vectors to 0
531
+ *
532
+ * @param {Cartesian2} left The first Cartesian.
533
+ * @param {Cartesian2} right The second Cartesian.
534
+ * @returns {number} The cross product.
535
+ */
536
+ static cross(left, right) {
537
+ Check_default.typeOf.object("left", left);
538
+ Check_default.typeOf.object("right", right);
539
+ return left.x * right.y - left.y * right.x;
540
+ }
541
+ /**
542
+ * Computes the componentwise product of two Cartesians.
543
+ *
544
+ * @param {Cartesian2} left The first Cartesian.
545
+ * @param {Cartesian2} right The second Cartesian.
546
+ * @param {Cartesian2} result The object onto which to store the result.
547
+ * @returns {Cartesian2} The modified result parameter.
548
+ */
549
+ static multiplyComponents(left, right, result) {
550
+ Check_default.typeOf.object("left", left);
551
+ Check_default.typeOf.object("right", right);
552
+ Check_default.typeOf.object("result", result);
553
+ result.x = left.x * right.x;
554
+ result.y = left.y * right.y;
555
+ return result;
556
+ }
557
+ /**
558
+ * Computes the componentwise quotient of two Cartesians.
559
+ *
560
+ * @param {Cartesian2} left The first Cartesian.
561
+ * @param {Cartesian2} right The second Cartesian.
562
+ * @param {Cartesian2} result The object onto which to store the result.
563
+ * @returns {Cartesian2} The modified result parameter.
564
+ */
565
+ static divideComponents(left, right, result) {
566
+ Check_default.typeOf.object("left", left);
567
+ Check_default.typeOf.object("right", right);
568
+ Check_default.typeOf.object("result", result);
569
+ result.x = left.x / right.x;
570
+ result.y = left.y / right.y;
571
+ return result;
572
+ }
573
+ /**
574
+ * Computes the componentwise sum of two Cartesians.
575
+ *
576
+ * @param {Cartesian2} left The first Cartesian.
577
+ * @param {Cartesian2} right The second Cartesian.
578
+ * @param {Cartesian2} result The object onto which to store the result.
579
+ * @returns {Cartesian2} The modified result parameter.
580
+ */
581
+ static add(left, right, result) {
582
+ Check_default.typeOf.object("left", left);
583
+ Check_default.typeOf.object("right", right);
584
+ Check_default.typeOf.object("result", result);
585
+ result.x = left.x + right.x;
586
+ result.y = left.y + right.y;
587
+ return result;
588
+ }
589
+ /**
590
+ * Computes the componentwise difference of two Cartesians.
591
+ *
592
+ * @param {Cartesian2} left The first Cartesian.
593
+ * @param {Cartesian2} right The second Cartesian.
594
+ * @param {Cartesian2} result The object onto which to store the result.
595
+ * @returns {Cartesian2} The modified result parameter.
596
+ */
597
+ static subtract(left, right, result) {
598
+ Check_default.typeOf.object("left", left);
599
+ Check_default.typeOf.object("right", right);
600
+ Check_default.typeOf.object("result", result);
601
+ result.x = left.x - right.x;
602
+ result.y = left.y - right.y;
603
+ return result;
604
+ }
605
+ /**
606
+ * Multiplies the provided Cartesian componentwise by the provided scalar.
607
+ *
608
+ * @param {Cartesian2} cartesian The Cartesian to be scaled.
609
+ * @param {number} scalar The scalar to multiply with.
610
+ * @param {Cartesian2} result The object onto which to store the result.
611
+ * @returns {Cartesian2} The modified result parameter.
612
+ */
613
+ static multiplyByScalar(cartesian, scalar, result) {
614
+ Check_default.typeOf.object("cartesian", cartesian);
615
+ Check_default.typeOf.number("scalar", scalar);
616
+ Check_default.typeOf.object("result", result);
617
+ result.x = cartesian.x * scalar;
618
+ result.y = cartesian.y * scalar;
619
+ return result;
620
+ }
621
+ /**
622
+ * Divides the provided Cartesian componentwise by the provided scalar.
623
+ *
624
+ * @param {Cartesian2} cartesian The Cartesian to be divided.
625
+ * @param {number} scalar The scalar to divide by.
626
+ * @param {Cartesian2} result The object onto which to store the result.
627
+ * @returns {Cartesian2} The modified result parameter.
628
+ */
629
+ static divideByScalar(cartesian, scalar, result) {
630
+ Check_default.typeOf.object("cartesian", cartesian);
631
+ Check_default.typeOf.number("scalar", scalar);
632
+ Check_default.typeOf.object("result", result);
633
+ result.x = cartesian.x / scalar;
634
+ result.y = cartesian.y / scalar;
635
+ return result;
636
+ }
637
+ /**
638
+ * Negates the provided Cartesian.
639
+ *
640
+ * @param {Cartesian2} cartesian The Cartesian to be negated.
641
+ * @param {Cartesian2} result The object onto which to store the result.
642
+ * @returns {Cartesian2} The modified result parameter.
643
+ */
644
+ static negate(cartesian, result) {
645
+ Check_default.typeOf.object("cartesian", cartesian);
646
+ Check_default.typeOf.object("result", result);
647
+ result.x = -cartesian.x;
648
+ result.y = -cartesian.y;
649
+ return result;
650
+ }
651
+ /**
652
+ * Computes the absolute value of the provided Cartesian.
653
+ *
654
+ * @param {Cartesian2} cartesian The Cartesian whose absolute value is to be computed.
655
+ * @param {Cartesian2} result The object onto which to store the result.
656
+ * @returns {Cartesian2} The modified result parameter.
657
+ */
658
+ static abs(cartesian, result) {
659
+ Check_default.typeOf.object("cartesian", cartesian);
660
+ Check_default.typeOf.object("result", result);
661
+ result.x = Math.abs(cartesian.x);
662
+ result.y = Math.abs(cartesian.y);
663
+ return result;
664
+ }
665
+ /**
666
+ * Computes the linear interpolation or extrapolation at t using the provided cartesians.
667
+ *
668
+ * @param {Cartesian2} start The value corresponding to t at 0.0.
669
+ * @param {Cartesian2} end The value corresponding to t at 1.0.
670
+ * @param {number} t The point along t at which to interpolate.
671
+ * @param {Cartesian2} result The object onto which to store the result.
672
+ * @returns {Cartesian2} The modified result parameter.
673
+ */
674
+ static lerp(start, end, t, result) {
675
+ Check_default.typeOf.object("start", start);
676
+ Check_default.typeOf.object("end", end);
677
+ Check_default.typeOf.number("t", t);
678
+ Check_default.typeOf.object("result", result);
679
+ _Cartesian2.multiplyByScalar(end, t, lerpScratch);
680
+ result = _Cartesian2.multiplyByScalar(start, 1 - t, result);
681
+ return _Cartesian2.add(lerpScratch, result, result);
682
+ }
683
+ /**
684
+ * Returns the angle, in radians, between the provided Cartesians.
685
+ *
686
+ * @param {Cartesian2} left The first Cartesian.
687
+ * @param {Cartesian2} right The second Cartesian.
688
+ * @returns {number} The angle between the Cartesians.
689
+ */
690
+ static angleBetween(left, right) {
691
+ Check_default.typeOf.object("left", left);
692
+ Check_default.typeOf.object("right", right);
693
+ _Cartesian2.normalize(left, angleBetweenScratch);
694
+ _Cartesian2.normalize(right, angleBetweenScratch2);
695
+ return Math_default.acosClamped(
696
+ _Cartesian2.dot(angleBetweenScratch, angleBetweenScratch2)
298
697
  );
299
- } else if (result.length !== resultLength) {
300
- result.length = resultLength;
301
698
  }
302
- for (let i = 0; i < length; ++i) {
303
- Cartesian2.pack(array[i], result, i * 2);
699
+ /**
700
+ * Returns the axis that is most orthogonal to the provided Cartesian.
701
+ *
702
+ * @param {Cartesian2} cartesian The Cartesian on which to find the most orthogonal axis.
703
+ * @param {Cartesian2} result The object onto which to store the result.
704
+ * @returns {Cartesian2} The most orthogonal axis.
705
+ */
706
+ static mostOrthogonalAxis(cartesian, result) {
707
+ Check_default.typeOf.object("cartesian", cartesian);
708
+ Check_default.typeOf.object("result", result);
709
+ const f = _Cartesian2.normalize(cartesian, mostOrthogonalAxisScratch);
710
+ _Cartesian2.abs(f, f);
711
+ if (f.x <= f.y) {
712
+ result = _Cartesian2.clone(_Cartesian2.UNIT_X, result);
713
+ } else {
714
+ result = _Cartesian2.clone(_Cartesian2.UNIT_Y, result);
715
+ }
716
+ return result;
304
717
  }
305
- return result;
306
- };
307
- Cartesian2.unpackArray = function(array, result) {
308
- Check_default.defined("array", array);
309
- Check_default.typeOf.number.greaterThanOrEquals("array.length", array.length, 2);
310
- if (array.length % 2 !== 0) {
311
- throw new DeveloperError_default("array length must be a multiple of 2.");
718
+ /**
719
+ * Compares the provided Cartesians componentwise and returns
720
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
721
+ *
722
+ * @param {Cartesian2} [left] The first Cartesian.
723
+ * @param {Cartesian2} [right] The second Cartesian.
724
+ * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
725
+ */
726
+ static equals(left, right) {
727
+ return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y;
312
728
  }
313
- const length = array.length;
314
- if (!defined_default(result)) {
315
- result = new Array(length / 2);
316
- } else {
317
- result.length = length / 2;
729
+ /**
730
+ * @param {Cartesian2} cartesian
731
+ * @param {number[]} array
732
+ * @param {number} offset
733
+ * @private
734
+ */
735
+ static equalsArray(cartesian, array, offset) {
736
+ return cartesian.x === array[offset] && cartesian.y === array[offset + 1];
737
+ }
738
+ /**
739
+ * Compares the provided Cartesians componentwise and returns
740
+ * <code>true</code> if they pass an absolute or relative tolerance test,
741
+ * <code>false</code> otherwise.
742
+ *
743
+ * @param {Cartesian2} [left] The first Cartesian.
744
+ * @param {Cartesian2} [right] The second Cartesian.
745
+ * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
746
+ * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
747
+ * @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
748
+ */
749
+ static equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon) {
750
+ return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
751
+ left.x,
752
+ right.x,
753
+ relativeEpsilon,
754
+ absoluteEpsilon
755
+ ) && Math_default.equalsEpsilon(
756
+ left.y,
757
+ right.y,
758
+ relativeEpsilon,
759
+ absoluteEpsilon
760
+ );
318
761
  }
319
- for (let i = 0; i < length; i += 2) {
320
- const index = i / 2;
321
- result[index] = Cartesian2.unpack(array, i, result[index]);
762
+ /**
763
+ * Duplicates this Cartesian2 instance.
764
+ *
765
+ * @param {Cartesian2} [result] The object onto which to store the result.
766
+ * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided.
767
+ */
768
+ clone(result) {
769
+ return _Cartesian2.clone(this, result);
770
+ }
771
+ /**
772
+ * Compares this Cartesian against the provided Cartesian componentwise and returns
773
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
774
+ *
775
+ * @param {Cartesian2} [right] The right hand side Cartesian.
776
+ * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
777
+ */
778
+ equals(right) {
779
+ return _Cartesian2.equals(this, right);
780
+ }
781
+ /**
782
+ * Compares this Cartesian against the provided Cartesian componentwise and returns
783
+ * <code>true</code> if they pass an absolute or relative tolerance test,
784
+ * <code>false</code> otherwise.
785
+ *
786
+ * @param {Cartesian2} [right] The right hand side Cartesian.
787
+ * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
788
+ * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
789
+ * @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
790
+ */
791
+ equalsEpsilon(right, relativeEpsilon, absoluteEpsilon) {
792
+ return _Cartesian2.equalsEpsilon(
793
+ this,
794
+ right,
795
+ relativeEpsilon,
796
+ absoluteEpsilon
797
+ );
798
+ }
799
+ /**
800
+ * Creates a string representing this Cartesian in the format '(x, y)'.
801
+ *
802
+ * @returns {string} A string representing the provided Cartesian in the format '(x, y)'.
803
+ */
804
+ toString() {
805
+ return `(${this.x}, ${this.y})`;
322
806
  }
323
- return result;
324
807
  };
808
+ Cartesian2.fromCartesian3 = Cartesian2.clone;
809
+ Cartesian2.fromCartesian4 = Cartesian2.clone;
810
+ Cartesian2.packedLength = 2;
325
811
  Cartesian2.fromArray = Cartesian2.unpack;
326
- Cartesian2.maximumComponent = function(cartesian) {
327
- Check_default.typeOf.object("cartesian", cartesian);
328
- return Math.max(cartesian.x, cartesian.y);
329
- };
330
- Cartesian2.minimumComponent = function(cartesian) {
331
- Check_default.typeOf.object("cartesian", cartesian);
332
- return Math.min(cartesian.x, cartesian.y);
333
- };
334
- Cartesian2.minimumByComponent = function(first, second, result) {
335
- Check_default.typeOf.object("first", first);
336
- Check_default.typeOf.object("second", second);
337
- Check_default.typeOf.object("result", result);
338
- result.x = Math.min(first.x, second.x);
339
- result.y = Math.min(first.y, second.y);
340
- return result;
341
- };
342
- Cartesian2.maximumByComponent = function(first, second, result) {
343
- Check_default.typeOf.object("first", first);
344
- Check_default.typeOf.object("second", second);
345
- Check_default.typeOf.object("result", result);
346
- result.x = Math.max(first.x, second.x);
347
- result.y = Math.max(first.y, second.y);
348
- return result;
349
- };
350
- Cartesian2.clamp = function(value, min, max, result) {
351
- Check_default.typeOf.object("value", value);
352
- Check_default.typeOf.object("min", min);
353
- Check_default.typeOf.object("max", max);
354
- Check_default.typeOf.object("result", result);
355
- const x = Math_default.clamp(value.x, min.x, max.x);
356
- const y = Math_default.clamp(value.y, min.y, max.y);
357
- result.x = x;
358
- result.y = y;
359
- return result;
360
- };
361
- Cartesian2.magnitudeSquared = function(cartesian) {
362
- Check_default.typeOf.object("cartesian", cartesian);
363
- return cartesian.x * cartesian.x + cartesian.y * cartesian.y;
364
- };
365
- Cartesian2.magnitude = function(cartesian) {
366
- return Math.sqrt(Cartesian2.magnitudeSquared(cartesian));
367
- };
368
812
  var distanceScratch = new Cartesian2();
369
- Cartesian2.distance = function(left, right) {
370
- Check_default.typeOf.object("left", left);
371
- Check_default.typeOf.object("right", right);
372
- Cartesian2.subtract(left, right, distanceScratch);
373
- return Cartesian2.magnitude(distanceScratch);
374
- };
375
- Cartesian2.distanceSquared = function(left, right) {
376
- Check_default.typeOf.object("left", left);
377
- Check_default.typeOf.object("right", right);
378
- Cartesian2.subtract(left, right, distanceScratch);
379
- return Cartesian2.magnitudeSquared(distanceScratch);
380
- };
381
- Cartesian2.normalize = function(cartesian, result) {
382
- Check_default.typeOf.object("cartesian", cartesian);
383
- Check_default.typeOf.object("result", result);
384
- const magnitude = Cartesian2.magnitude(cartesian);
385
- result.x = cartesian.x / magnitude;
386
- result.y = cartesian.y / magnitude;
387
- if (isNaN(result.x) || isNaN(result.y)) {
388
- throw new DeveloperError_default("normalized result is not a number");
389
- }
390
- return result;
391
- };
392
- Cartesian2.dot = function(left, right) {
393
- Check_default.typeOf.object("left", left);
394
- Check_default.typeOf.object("right", right);
395
- return left.x * right.x + left.y * right.y;
396
- };
397
- Cartesian2.cross = function(left, right) {
398
- Check_default.typeOf.object("left", left);
399
- Check_default.typeOf.object("right", right);
400
- return left.x * right.y - left.y * right.x;
401
- };
402
- Cartesian2.multiplyComponents = function(left, right, result) {
403
- Check_default.typeOf.object("left", left);
404
- Check_default.typeOf.object("right", right);
405
- Check_default.typeOf.object("result", result);
406
- result.x = left.x * right.x;
407
- result.y = left.y * right.y;
408
- return result;
409
- };
410
- Cartesian2.divideComponents = function(left, right, result) {
411
- Check_default.typeOf.object("left", left);
412
- Check_default.typeOf.object("right", right);
413
- Check_default.typeOf.object("result", result);
414
- result.x = left.x / right.x;
415
- result.y = left.y / right.y;
416
- return result;
417
- };
418
- Cartesian2.add = function(left, right, result) {
419
- Check_default.typeOf.object("left", left);
420
- Check_default.typeOf.object("right", right);
421
- Check_default.typeOf.object("result", result);
422
- result.x = left.x + right.x;
423
- result.y = left.y + right.y;
424
- return result;
425
- };
426
- Cartesian2.subtract = function(left, right, result) {
427
- Check_default.typeOf.object("left", left);
428
- Check_default.typeOf.object("right", right);
429
- Check_default.typeOf.object("result", result);
430
- result.x = left.x - right.x;
431
- result.y = left.y - right.y;
432
- return result;
433
- };
434
- Cartesian2.multiplyByScalar = function(cartesian, scalar, result) {
435
- Check_default.typeOf.object("cartesian", cartesian);
436
- Check_default.typeOf.number("scalar", scalar);
437
- Check_default.typeOf.object("result", result);
438
- result.x = cartesian.x * scalar;
439
- result.y = cartesian.y * scalar;
440
- return result;
441
- };
442
- Cartesian2.divideByScalar = function(cartesian, scalar, result) {
443
- Check_default.typeOf.object("cartesian", cartesian);
444
- Check_default.typeOf.number("scalar", scalar);
445
- Check_default.typeOf.object("result", result);
446
- result.x = cartesian.x / scalar;
447
- result.y = cartesian.y / scalar;
448
- return result;
449
- };
450
- Cartesian2.negate = function(cartesian, result) {
451
- Check_default.typeOf.object("cartesian", cartesian);
452
- Check_default.typeOf.object("result", result);
453
- result.x = -cartesian.x;
454
- result.y = -cartesian.y;
455
- return result;
456
- };
457
- Cartesian2.abs = function(cartesian, result) {
458
- Check_default.typeOf.object("cartesian", cartesian);
459
- Check_default.typeOf.object("result", result);
460
- result.x = Math.abs(cartesian.x);
461
- result.y = Math.abs(cartesian.y);
462
- return result;
463
- };
464
813
  var lerpScratch = new Cartesian2();
465
- Cartesian2.lerp = function(start, end, t, result) {
466
- Check_default.typeOf.object("start", start);
467
- Check_default.typeOf.object("end", end);
468
- Check_default.typeOf.number("t", t);
469
- Check_default.typeOf.object("result", result);
470
- Cartesian2.multiplyByScalar(end, t, lerpScratch);
471
- result = Cartesian2.multiplyByScalar(start, 1 - t, result);
472
- return Cartesian2.add(lerpScratch, result, result);
473
- };
474
814
  var angleBetweenScratch = new Cartesian2();
475
815
  var angleBetweenScratch2 = new Cartesian2();
476
- Cartesian2.angleBetween = function(left, right) {
477
- Check_default.typeOf.object("left", left);
478
- Check_default.typeOf.object("right", right);
479
- Cartesian2.normalize(left, angleBetweenScratch);
480
- Cartesian2.normalize(right, angleBetweenScratch2);
481
- return Math_default.acosClamped(
482
- Cartesian2.dot(angleBetweenScratch, angleBetweenScratch2)
483
- );
484
- };
485
816
  var mostOrthogonalAxisScratch = new Cartesian2();
486
- Cartesian2.mostOrthogonalAxis = function(cartesian, result) {
487
- Check_default.typeOf.object("cartesian", cartesian);
488
- Check_default.typeOf.object("result", result);
489
- const f = Cartesian2.normalize(cartesian, mostOrthogonalAxisScratch);
490
- Cartesian2.abs(f, f);
491
- if (f.x <= f.y) {
492
- result = Cartesian2.clone(Cartesian2.UNIT_X, result);
493
- } else {
494
- result = Cartesian2.clone(Cartesian2.UNIT_Y, result);
495
- }
496
- return result;
497
- };
498
- Cartesian2.equals = function(left, right) {
499
- return left === right || defined_default(left) && defined_default(right) && left.x === right.x && left.y === right.y;
500
- };
501
- Cartesian2.equalsArray = function(cartesian, array, offset) {
502
- return cartesian.x === array[offset] && cartesian.y === array[offset + 1];
503
- };
504
- Cartesian2.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
505
- return left === right || defined_default(left) && defined_default(right) && Math_default.equalsEpsilon(
506
- left.x,
507
- right.x,
508
- relativeEpsilon,
509
- absoluteEpsilon
510
- ) && Math_default.equalsEpsilon(
511
- left.y,
512
- right.y,
513
- relativeEpsilon,
514
- absoluteEpsilon
515
- );
516
- };
517
817
  Cartesian2.ZERO = Object.freeze(new Cartesian2(0, 0));
518
818
  Cartesian2.ONE = Object.freeze(new Cartesian2(1, 1));
519
819
  Cartesian2.UNIT_X = Object.freeze(new Cartesian2(1, 0));
520
820
  Cartesian2.UNIT_Y = Object.freeze(new Cartesian2(0, 1));
521
- Cartesian2.prototype.clone = function(result) {
522
- return Cartesian2.clone(this, result);
523
- };
524
- Cartesian2.prototype.equals = function(right) {
525
- return Cartesian2.equals(this, right);
526
- };
527
- Cartesian2.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) {
528
- return Cartesian2.equalsEpsilon(
529
- this,
530
- right,
531
- relativeEpsilon,
532
- absoluteEpsilon
533
- );
534
- };
535
- Cartesian2.prototype.toString = function() {
536
- return `(${this.x}, ${this.y})`;
537
- };
538
821
  var Cartesian2_default = Cartesian2;
539
822
 
540
823
  // packages/engine/Source/Core/Ellipsoid.js