@cesium/engine 22.2.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 (282) hide show
  1. package/Build/Workers/{chunk-YFEZPDAY.js → chunk-2GL2EUEE.js} +11 -11
  2. package/Build/Workers/{chunk-A3NUMZBG.js → chunk-2WI4HGJU.js} +6 -6
  3. package/Build/Workers/{chunk-3JB2X2PR.js → chunk-36LBFITA.js} +665 -366
  4. package/Build/Workers/{chunk-VSZ5DB2W.js → chunk-3B65YFXC.js} +1 -1
  5. package/Build/Workers/{chunk-PSHZAHFE.js → chunk-4LGFX2P5.js} +11 -11
  6. package/Build/Workers/{chunk-AMWXJ5A7.js → chunk-4UNQX2MP.js} +2 -2
  7. package/Build/Workers/{chunk-LDSQMLRC.js → chunk-52K3GJKG.js} +3 -3
  8. package/Build/Workers/{chunk-MSTAVM2N.js → chunk-56OHFSLH.js} +10 -10
  9. package/Build/Workers/{chunk-IWOSJVFQ.js → chunk-5A7YSAXT.js} +14 -14
  10. package/Build/Workers/{chunk-PMDPP22G.js → chunk-5JP5FG7U.js} +7 -7
  11. package/Build/Workers/{chunk-DIJ7IG5D.js → chunk-5R7SBUTW.js} +10 -10
  12. package/Build/Workers/chunk-5VKZVPO5.js +1829 -0
  13. package/Build/Workers/{chunk-L2FSBEW2.js → chunk-6FVFM2KB.js} +5 -5
  14. package/Build/Workers/{chunk-G6WQA27G.js → chunk-6SLGTBB2.js} +5 -5
  15. package/Build/Workers/{chunk-3HUEBDFC.js → chunk-7KRN6JPQ.js} +14 -14
  16. package/Build/Workers/{chunk-GMHDOQPH.js → chunk-AA33B6PU.js} +4 -4
  17. package/Build/Workers/{chunk-7CDQUIP5.js → chunk-AP6XWET5.js} +8 -8
  18. package/Build/Workers/{chunk-IVN5HSOI.js → chunk-APDKMX7W.js} +6 -6
  19. package/Build/Workers/{chunk-72LZ3FN6.js → chunk-ARCFIOKA.js} +12 -12
  20. package/Build/Workers/{chunk-UBJYWGMV.js → chunk-BNBD2YZK.js} +16 -16
  21. package/Build/Workers/{chunk-VGH2CSC7.js → chunk-DT5SJBKA.js} +29 -15
  22. package/Build/Workers/{chunk-ED4UXMYY.js → chunk-ESD4IEOU.js} +5 -5
  23. package/Build/Workers/{chunk-JFN2DQHY.js → chunk-FSDVXW7M.js} +5 -5
  24. package/Build/Workers/{chunk-JERDRSEI.js → chunk-G3YT7M7A.js} +1 -1
  25. package/Build/Workers/{chunk-NY3CWLIZ.js → chunk-GN5NEUDT.js} +8 -8
  26. package/Build/Workers/{chunk-O3GWUTWM.js → chunk-HYLEKKO5.js} +1 -1
  27. package/Build/Workers/{chunk-64PJ4MTB.js → chunk-HYTFXWMY.js} +7 -7
  28. package/Build/Workers/{chunk-FPRM6PCE.js → chunk-IFA7VHHP.js} +560 -306
  29. package/Build/Workers/{chunk-FM5XPC2E.js → chunk-IYVDOB5V.js} +4 -4
  30. package/Build/Workers/{chunk-P7ISUYLW.js → chunk-JUGY5AZN.js} +4 -4
  31. package/Build/Workers/{chunk-JONWM4IO.js → chunk-KPYU6YZG.js} +1 -1
  32. package/Build/Workers/{chunk-JUOSYFXT.js → chunk-L7RDJ4V7.js} +1 -1
  33. package/Build/Workers/{chunk-MWGB6DLR.js → chunk-LDQWNMEC.js} +1 -1
  34. package/Build/Workers/{chunk-C6FTHSJA.js → chunk-MQJG522T.js} +6 -6
  35. package/Build/Workers/{chunk-WH4HDRGN.js → chunk-MT5M7RLZ.js} +2 -2
  36. package/Build/Workers/{chunk-4ZQN7M7E.js → chunk-N4AWE7TZ.js} +10 -10
  37. package/Build/Workers/{chunk-SDUH3N6G.js → chunk-NAYRNPEP.js} +4 -4
  38. package/Build/Workers/{chunk-7OPRTZBT.js → chunk-NNHU33JK.js} +7 -7
  39. package/Build/Workers/{chunk-CQCEPC6N.js → chunk-NQCAZU7S.js} +13 -13
  40. package/Build/Workers/{chunk-35J4D6PX.js → chunk-NUYLNQKV.js} +2 -2
  41. package/Build/Workers/{chunk-I45CATZK.js → chunk-OC6X22PG.js} +9 -9
  42. package/Build/Workers/{chunk-7MGTX4WP.js → chunk-OHBM4YG4.js} +12 -12
  43. package/Build/Workers/{chunk-DCR62BCO.js → chunk-OMXN7YF4.js} +12 -12
  44. package/Build/Workers/{chunk-XPNY2VY3.js → chunk-OQ3EAJNW.js} +2 -2
  45. package/Build/Workers/{chunk-4I7BCCNU.js → chunk-OQBPOKPZ.js} +6 -6
  46. package/Build/Workers/{chunk-2JNPWPLE.js → chunk-PQVNT5CJ.js} +6 -6
  47. package/Build/Workers/{chunk-K64RQCRK.js → chunk-QA24Q62E.js} +17 -17
  48. package/Build/Workers/{chunk-K6BXEBAF.js → chunk-QQX7S5QT.js} +17 -17
  49. package/Build/Workers/{chunk-2YVTOY5Z.js → chunk-QTOHIXGF.js} +10 -10
  50. package/Build/Workers/{chunk-4MCPC4TE.js → chunk-R7M4XNPP.js} +8 -8
  51. package/Build/Workers/{chunk-C35SJ4QP.js → chunk-SGKTBHFQ.js} +13 -13
  52. package/Build/Workers/{chunk-BKYJBTHW.js → chunk-SQTRWKO2.js} +5 -5
  53. package/Build/Workers/{chunk-I4D5IP46.js → chunk-T43FXHNC.js} +7 -7
  54. package/Build/Workers/{chunk-QO6Z5UJE.js → chunk-UEEGWJJP.js} +2 -2
  55. package/Build/Workers/{chunk-ZUWF63QU.js → chunk-WKXDCVBO.js} +4 -4
  56. package/Build/Workers/{chunk-N5MNKWED.js → chunk-Y5AJSEEN.js} +2 -2
  57. package/Build/Workers/{chunk-V26Y7ZQL.js → chunk-ZIW5FCIW.js} +37 -27
  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 +20 -12
  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/BoxGeometry.js +1 -1
  113. package/Source/Core/Cartesian2.js +689 -684
  114. package/Source/Core/Cartesian3.js +1044 -1043
  115. package/Source/Core/Cartesian4.js +816 -813
  116. package/Source/Core/CornerType.js +1 -1
  117. package/Source/Core/CorridorGeometry.js +1 -1
  118. package/Source/Core/FeatureDetection.js +1 -32
  119. package/Source/Core/Geometry.js +1 -1
  120. package/Source/Core/GoogleMaps.js +23 -2
  121. package/Source/Core/IntersectionTests.js +2 -2
  122. package/Source/Core/Ion.js +1 -1
  123. package/Source/Core/OpenCageGeocoderService.js +2 -3
  124. package/Source/Core/PinBuilder.js +1 -1
  125. package/Source/Core/PolygonGeometry.js +1 -1
  126. package/Source/Core/PolylineGeometry.js +1 -1
  127. package/Source/Core/PolylineVolumeGeometry.js +1 -1
  128. package/Source/Core/RectangleGeometry.js +1 -1
  129. package/Source/Core/ScreenSpaceEventHandler.js +4 -8
  130. package/Source/Core/TerrainMesh.js +11 -8
  131. package/Source/Core/TerrainPicker.js +24 -7
  132. package/Source/Core/VideoSynchronizer.js +1 -1
  133. package/Source/Core/WallGeometry.js +1 -1
  134. package/Source/Core/globalTypes.js +16 -0
  135. package/Source/Core/writeTextToCanvas.js +40 -86
  136. package/Source/DataSources/BillboardGraphics.js +1 -1
  137. package/Source/DataSources/BoxGraphics.js +1 -1
  138. package/Source/DataSources/CallbackPositionProperty.js +1 -1
  139. package/Source/DataSources/CorridorGraphics.js +1 -1
  140. package/Source/DataSources/CzmlDataSource.js +1 -1
  141. package/Source/DataSources/EllipseGraphics.js +1 -1
  142. package/Source/DataSources/EllipsoidGraphics.js +1 -1
  143. package/Source/DataSources/Entity.js +1 -1
  144. package/Source/DataSources/EntityCluster.js +2 -2
  145. package/Source/DataSources/GeoJsonDataSource.js +2 -2
  146. package/Source/DataSources/GpxDataSource.js +1 -1
  147. package/Source/DataSources/KmlDataSource.js +1 -1
  148. package/Source/DataSources/KmlTour.js +1 -1
  149. package/Source/DataSources/LabelGraphics.js +1 -1
  150. package/Source/DataSources/ModelGraphics.js +1 -1
  151. package/Source/DataSources/PlaneGraphics.js +1 -1
  152. package/Source/DataSources/PolygonGraphics.js +1 -1
  153. package/Source/DataSources/PolylineGraphics.js +1 -1
  154. package/Source/DataSources/PolylineVolumeGraphics.js +1 -1
  155. package/Source/DataSources/RectangleGraphics.js +1 -1
  156. package/Source/DataSources/WallGraphics.js +1 -1
  157. package/Source/DataSources/exportKml.js +1 -1
  158. package/Source/Renderer/Context.js +11 -10
  159. package/Source/Renderer/ContextLimits.js +66 -33
  160. package/Source/Renderer/ShaderDestination.js +54 -13
  161. package/Source/Renderer/ShaderSource.js +19 -18
  162. package/Source/Renderer/Texture.js +1 -1
  163. package/Source/Renderer/Texture3D.js +166 -7
  164. package/Source/Renderer/TextureAtlas.js +2 -2
  165. package/Source/Scene/Appearance.js +1 -1
  166. package/Source/Scene/ArcGisMapService.js +1 -1
  167. package/Source/Scene/Billboard.js +8 -5
  168. package/Source/Scene/BillboardCollection.js +65 -26
  169. package/Source/Scene/BillboardTexture.js +4 -1
  170. package/Source/Scene/BufferLoader.js +65 -74
  171. package/Source/Scene/Camera.js +13 -2
  172. package/Source/Scene/ClippingPlaneCollection.js +2 -2
  173. package/Source/Scene/CloudCollection.js +2 -2
  174. package/Source/Scene/CubeMapPanorama.js +351 -0
  175. package/Source/Scene/CumulusCloud.js +1 -1
  176. package/Source/Scene/DerivedCommand.js +8 -31
  177. package/Source/Scene/DracoLoader.js +79 -78
  178. package/Source/Scene/DynamicEnvironmentMapManager.js +41 -26
  179. package/Source/Scene/EquirectangularPanorama.js +264 -0
  180. package/Source/Scene/Fog.js +1 -1
  181. package/Source/Scene/FrameState.js +7 -0
  182. package/Source/Scene/GaussianSplatPrimitive.js +907 -168
  183. package/Source/Scene/Globe.js +3 -10
  184. package/Source/Scene/GlobeSurfaceShaderSet.js +36 -32
  185. package/Source/Scene/GltfBufferViewLoader.js +109 -118
  186. package/Source/Scene/GltfDracoLoader.js +167 -176
  187. package/Source/Scene/GltfImageLoader.js +91 -101
  188. package/Source/Scene/GltfIndexBufferLoader.js +228 -241
  189. package/Source/Scene/GltfJsonLoader.js +90 -99
  190. package/Source/Scene/GltfLoader.js +323 -324
  191. package/Source/Scene/GltfSpzLoader.js +127 -134
  192. package/Source/Scene/GltfStructuralMetadataLoader.js +181 -186
  193. package/Source/Scene/GltfTextureLoader.js +217 -231
  194. package/Source/Scene/GltfVertexBufferLoader.js +267 -276
  195. package/Source/Scene/GoogleStreetViewCubeMapPanoramaProvider.js +341 -0
  196. package/Source/Scene/ImageBasedLighting.js +2 -2
  197. package/Source/Scene/ImageryLayerCollection.js +2 -2
  198. package/Source/Scene/ImageryProvider.js +2 -2
  199. package/Source/Scene/Label.js +7 -5
  200. package/Source/Scene/LabelCollection.js +60 -2
  201. package/Source/Scene/Material.js +1 -1
  202. package/Source/Scene/MaterialAppearance.js +1 -1
  203. package/Source/Scene/Megatexture.js +174 -242
  204. package/Source/Scene/MetadataClassProperty.js +212 -7
  205. package/Source/Scene/MetadataComponentType.js +162 -127
  206. package/Source/Scene/MetadataSchemaLoader.js +60 -67
  207. package/Source/Scene/MetadataTable.js +14 -0
  208. package/Source/Scene/MetadataTableProperty.js +14 -0
  209. package/Source/Scene/Model/B3dmLoader.js +216 -224
  210. package/Source/Scene/Model/CustomShader.js +6 -1
  211. package/Source/Scene/Model/CustomShaderPipelineStage.js +122 -7
  212. package/Source/Scene/Model/GeoJsonLoader.js +53 -61
  213. package/Source/Scene/Model/GeometryPipelineStage.js +17 -3
  214. package/Source/Scene/Model/I3dmLoader.js +232 -240
  215. package/Source/Scene/Model/MaterialPipelineStage.js +17 -0
  216. package/Source/Scene/Model/MetadataPipelineStage.js +438 -22
  217. package/Source/Scene/Model/Model.js +1 -1
  218. package/Source/Scene/Model/PntsLoader.js +78 -89
  219. package/Source/Scene/ModelComponents.js +10 -0
  220. package/Source/Scene/Panorama.js +53 -0
  221. package/Source/Scene/PanoramaProvider.js +43 -0
  222. package/Source/Scene/ParticleSystem.js +2 -2
  223. package/Source/Scene/PointPrimitive.js +1 -1
  224. package/Source/Scene/PointPrimitiveCollection.js +14 -22
  225. package/Source/Scene/Polyline.js +0 -1
  226. package/Source/Scene/PolylineCollection.js +1 -4
  227. package/Source/Scene/PolylineColorAppearance.js +1 -6
  228. package/Source/Scene/PolylineMaterialAppearance.js +1 -6
  229. package/Source/Scene/PostProcessStageCollection.js +1 -1
  230. package/Source/Scene/PropertyTable.js +43 -0
  231. package/Source/Scene/PropertyTexture.js +1 -1
  232. package/Source/Scene/PropertyTextureProperty.js +0 -97
  233. package/Source/Scene/QuadtreePrimitive.js +6 -3
  234. package/Source/Scene/ResourceLoader.js +84 -92
  235. package/Source/Scene/Scene.js +12 -0
  236. package/Source/Scene/ShadowMap.js +1 -2
  237. package/Source/Scene/SkyBox.js +29 -164
  238. package/Source/Scene/StructuralMetadata.js +18 -3
  239. package/Source/Scene/Vector3DTileClampedPolylines.js +1 -5
  240. package/Source/Scene/Vector3DTilePolylines.js +1 -5
  241. package/Source/Scene/VoxelPrimitive.js +16 -33
  242. package/Source/Scene/VoxelRenderResources.js +1 -8
  243. package/Source/Scene/VoxelTraversal.js +16 -61
  244. package/Source/Scene/WebMapTileServiceImageryProvider.js +1 -1
  245. package/Source/Scene/createElevationBandMaterial.js +1 -1
  246. package/Source/Scene/parseStructuralMetadata.js +244 -0
  247. package/Source/Scene/processVoxelProperties.js +1 -1
  248. package/Source/Shaders/BillboardCollectionFS.glsl +66 -40
  249. package/Source/Shaders/BillboardCollectionFS.js +67 -40
  250. package/Source/Shaders/BillboardCollectionVS.glsl +22 -31
  251. package/Source/Shaders/BillboardCollectionVS.js +22 -31
  252. package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
  253. package/Source/Shaders/Builtin/Functions/columbusViewMorph.glsl +8 -1
  254. package/Source/Shaders/Builtin/Functions/columbusViewMorph.js +8 -1
  255. package/Source/Shaders/Builtin/Functions/decodeRGB8.glsl +22 -0
  256. package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
  257. package/Source/Shaders/Builtin/Functions/unpackTexture.glsl +35 -0
  258. package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
  259. package/Source/Shaders/CubeMapPanoramaVS.glsl +11 -0
  260. package/Source/Shaders/CubeMapPanoramaVS.js +13 -0
  261. package/Source/Shaders/Model/MetadataStageFS.glsl +2 -1
  262. package/Source/Shaders/Model/MetadataStageFS.js +2 -1
  263. package/Source/Shaders/Model/MetadataStageVS.glsl +2 -1
  264. package/Source/Shaders/Model/MetadataStageVS.js +2 -1
  265. package/Source/Shaders/Model/ModelFS.glsl +9 -1
  266. package/Source/Shaders/Model/ModelFS.js +9 -1
  267. package/Source/Shaders/Model/ModelVS.glsl +4 -2
  268. package/Source/Shaders/Model/ModelVS.js +4 -2
  269. package/Source/Shaders/PointPrimitiveCollectionVS.glsl +8 -39
  270. package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
  271. package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -1
  272. package/Source/Shaders/Voxels/IntersectionUtils.js +1 -1
  273. package/Source/Shaders/Voxels/Megatexture.glsl +15 -83
  274. package/Source/Shaders/Voxels/Megatexture.js +15 -83
  275. package/Source/Shaders/Voxels/Octree.glsl +6 -9
  276. package/Source/Shaders/Voxels/Octree.js +6 -9
  277. package/Source/Widget/CesiumWidget.js +1 -1
  278. package/Source/Workers/incrementallyBuildTerrainPicker.js +16 -2
  279. package/index.d.ts +582 -193
  280. package/index.js +91 -83
  281. package/package.json +2 -1
  282. package/Build/Workers/chunk-ZGWX2R5I.js +0 -1443
@@ -1,708 +1,694 @@
1
+ // @ts-check
2
+
1
3
  import Check from "./Check.js";
2
4
  import defined from "./defined.js";
3
5
  import DeveloperError from "./DeveloperError.js";
4
6
  import CesiumMath from "./Math.js";
5
7
 
8
+ /** @import {TypedArray} from "./globalTypes.js"; */
9
+ /** @import Color from "./Color.js"; */
10
+
6
11
  /**
7
12
  * A 4D Cartesian point.
8
- * @alias Cartesian4
9
- * @constructor
10
- *
11
- * @param {number} [x=0.0] The X component.
12
- * @param {number} [y=0.0] The Y component.
13
- * @param {number} [z=0.0] The Z component.
14
- * @param {number} [w=0.0] The W component.
15
13
  *
16
14
  * @see Cartesian2
17
15
  * @see Cartesian3
18
16
  * @see Packable
19
17
  */
20
- function Cartesian4(x, y, z, w) {
18
+ class Cartesian4 {
21
19
  /**
22
- * The X component.
23
- * @type {number}
24
- * @default 0.0
20
+ * @param {number} [x=0.0] The X component.
21
+ * @param {number} [y=0.0] The Y component.
22
+ * @param {number} [z=0.0] The Z component.
23
+ * @param {number} [w=0.0] The W component.
25
24
  */
26
- this.x = x ?? 0.0;
25
+ constructor(x, y, z, w) {
26
+ /**
27
+ * The X component.
28
+ * @type {number}
29
+ * @default 0.0
30
+ */
31
+ this.x = x ?? 0.0;
32
+
33
+ /**
34
+ * The Y component.
35
+ * @type {number}
36
+ * @default 0.0
37
+ */
38
+ this.y = y ?? 0.0;
39
+
40
+ /**
41
+ * The Z component.
42
+ * @type {number}
43
+ * @default 0.0
44
+ */
45
+ this.z = z ?? 0.0;
46
+
47
+ /**
48
+ * The W component.
49
+ * @type {number}
50
+ * @default 0.0
51
+ */
52
+ this.w = w ?? 0.0;
53
+ }
27
54
 
28
55
  /**
29
- * The Y component.
30
- * @type {number}
31
- * @default 0.0
56
+ * Creates a Cartesian4 instance from x, y, z and w coordinates.
57
+ *
58
+ * @param {number} x The x coordinate.
59
+ * @param {number} y The y coordinate.
60
+ * @param {number} z The z coordinate.
61
+ * @param {number} w The w coordinate.
62
+ * @param {Cartesian4} [result] The object onto which to store the result.
63
+ * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
32
64
  */
33
- this.y = y ?? 0.0;
65
+ static fromElements(x, y, z, w, result) {
66
+ if (!defined(result)) {
67
+ return new Cartesian4(x, y, z, w);
68
+ }
34
69
 
35
- /**
36
- * The Z component.
37
- * @type {number}
38
- * @default 0.0
39
- */
40
- this.z = z ?? 0.0;
70
+ result.x = x;
71
+ result.y = y;
72
+ result.z = z;
73
+ result.w = w;
74
+ return result;
75
+ }
41
76
 
42
77
  /**
43
- * The W component.
44
- * @type {number}
45
- * @default 0.0
78
+ * Creates a Cartesian4 instance from a {@link Color}. <code>red</code>, <code>green</code>, <code>blue</code>,
79
+ * and <code>alpha</code> map to <code>x</code>, <code>y</code>, <code>z</code>, and <code>w</code>, respectively.
80
+ *
81
+ * @param {Color} color The source color.
82
+ * @param {Cartesian4} [result] The object onto which to store the result.
83
+ * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
46
84
  */
47
- this.w = w ?? 0.0;
48
- }
85
+ static fromColor(color, result) {
86
+ //>>includeStart('debug', pragmas.debug);
87
+ Check.typeOf.object("color", color);
88
+ //>>includeEnd('debug');
89
+ if (!defined(result)) {
90
+ return new Cartesian4(color.red, color.green, color.blue, color.alpha);
91
+ }
49
92
 
50
- /**
51
- * Creates a Cartesian4 instance from x, y, z and w coordinates.
52
- *
53
- * @param {number} x The x coordinate.
54
- * @param {number} y The y coordinate.
55
- * @param {number} z The z coordinate.
56
- * @param {number} w The w coordinate.
57
- * @param {Cartesian4} [result] The object onto which to store the result.
58
- * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
59
- */
60
- Cartesian4.fromElements = function (x, y, z, w, result) {
61
- if (!defined(result)) {
62
- return new Cartesian4(x, y, z, w);
93
+ result.x = color.red;
94
+ result.y = color.green;
95
+ result.z = color.blue;
96
+ result.w = color.alpha;
97
+ return result;
63
98
  }
64
99
 
65
- result.x = x;
66
- result.y = y;
67
- result.z = z;
68
- result.w = w;
69
- return result;
70
- };
100
+ /**
101
+ * Duplicates a Cartesian4 instance.
102
+ *
103
+ * @param {Cartesian4} cartesian The Cartesian to duplicate.
104
+ * @param {Cartesian4} [result] The object onto which to store the result.
105
+ * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided. (Returns undefined if cartesian is undefined)
106
+ */
107
+ static clone(cartesian, result) {
108
+ if (!defined(cartesian)) {
109
+ return undefined;
110
+ }
111
+
112
+ if (!defined(result)) {
113
+ return new Cartesian4(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
114
+ }
71
115
 
72
- /**
73
- * Creates a Cartesian4 instance from a {@link Color}. <code>red</code>, <code>green</code>, <code>blue</code>,
74
- * and <code>alpha</code> map to <code>x</code>, <code>y</code>, <code>z</code>, and <code>w</code>, respectively.
75
- *
76
- * @param {Color} color The source color.
77
- * @param {Cartesian4} [result] The object onto which to store the result.
78
- * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
79
- */
80
- Cartesian4.fromColor = function (color, result) {
81
- //>>includeStart('debug', pragmas.debug);
82
- Check.typeOf.object("color", color);
83
- //>>includeEnd('debug');
84
- if (!defined(result)) {
85
- return new Cartesian4(color.red, color.green, color.blue, color.alpha);
116
+ result.x = cartesian.x;
117
+ result.y = cartesian.y;
118
+ result.z = cartesian.z;
119
+ result.w = cartesian.w;
120
+ return result;
86
121
  }
87
122
 
88
- result.x = color.red;
89
- result.y = color.green;
90
- result.z = color.blue;
91
- result.w = color.alpha;
92
- return result;
93
- };
123
+ /**
124
+ * Stores the provided instance into the provided array.
125
+ *
126
+ * @param {Cartesian4} value The value to pack.
127
+ * @param {number[]|TypedArray} array The array to pack into.
128
+ * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
129
+ *
130
+ * @returns {number[]|TypedArray} The array that was packed into
131
+ */
132
+ static pack(value, array, startingIndex) {
133
+ //>>includeStart('debug', pragmas.debug);
134
+ Check.typeOf.object("value", value);
135
+ Check.defined("array", array);
136
+ //>>includeEnd('debug');
94
137
 
95
- /**
96
- * Duplicates a Cartesian4 instance.
97
- *
98
- * @param {Cartesian4} cartesian The Cartesian to duplicate.
99
- * @param {Cartesian4} [result] The object onto which to store the result.
100
- * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided. (Returns undefined if cartesian is undefined)
101
- */
102
- Cartesian4.clone = function (cartesian, result) {
103
- if (!defined(cartesian)) {
104
- return undefined;
105
- }
138
+ startingIndex = startingIndex ?? 0;
106
139
 
107
- if (!defined(result)) {
108
- return new Cartesian4(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
140
+ array[startingIndex++] = value.x;
141
+ array[startingIndex++] = value.y;
142
+ array[startingIndex++] = value.z;
143
+ array[startingIndex] = value.w;
144
+
145
+ return array;
109
146
  }
110
147
 
111
- result.x = cartesian.x;
112
- result.y = cartesian.y;
113
- result.z = cartesian.z;
114
- result.w = cartesian.w;
115
- return result;
116
- };
148
+ /**
149
+ * Retrieves an instance from a packed array.
150
+ *
151
+ * @param {number[]|TypedArray} array The packed array.
152
+ * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
153
+ * @param {Cartesian4} [result] The object into which to store the result.
154
+ * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
155
+ */
156
+ static unpack(array, startingIndex, result) {
157
+ //>>includeStart('debug', pragmas.debug);
158
+ Check.defined("array", array);
159
+ //>>includeEnd('debug');
117
160
 
118
- /**
119
- * The number of elements used to pack the object into an array.
120
- * @type {number}
121
- */
122
- Cartesian4.packedLength = 4;
161
+ startingIndex = startingIndex ?? 0;
123
162
 
124
- /**
125
- * Stores the provided instance into the provided array.
126
- *
127
- * @param {Cartesian4} value The value to pack.
128
- * @param {number[]} array The array to pack into.
129
- * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
130
- *
131
- * @returns {number[]} The array that was packed into
132
- */
133
- Cartesian4.pack = function (value, array, startingIndex) {
134
- //>>includeStart('debug', pragmas.debug);
135
- Check.typeOf.object("value", value);
136
- Check.defined("array", array);
137
- //>>includeEnd('debug');
163
+ if (!defined(result)) {
164
+ result = new Cartesian4();
165
+ }
166
+ result.x = array[startingIndex++];
167
+ result.y = array[startingIndex++];
168
+ result.z = array[startingIndex++];
169
+ result.w = array[startingIndex];
170
+ return result;
171
+ }
138
172
 
139
- startingIndex = startingIndex ?? 0;
173
+ /**
174
+ * Flattens an array of Cartesian4s into an array of components.
175
+ *
176
+ * @param {Cartesian4[]} array The array of cartesians to pack.
177
+ * @param {number[]|TypedArray} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.
178
+ * @returns {number[]|TypedArray} The packed array.
179
+ */
180
+ static packArray(array, result) {
181
+ //>>includeStart('debug', pragmas.debug);
182
+ Check.defined("array", array);
183
+ //>>includeEnd('debug');
140
184
 
141
- array[startingIndex++] = value.x;
142
- array[startingIndex++] = value.y;
143
- array[startingIndex++] = value.z;
144
- array[startingIndex] = value.w;
185
+ const length = array.length;
186
+ const resultLength = length * 4;
187
+ if (!defined(result)) {
188
+ result = new Array(resultLength);
189
+ } else if (!Array.isArray(result) && result.length !== resultLength) {
190
+ //>>includeStart('debug', pragmas.debug);
191
+ throw new DeveloperError(
192
+ "If result is a typed array, it must have exactly array.length * 4 elements",
193
+ );
194
+ //>>includeEnd('debug');
195
+ } else if (result.length !== resultLength) {
196
+ /** @type {number[]} */ (result).length = resultLength;
197
+ }
145
198
 
146
- return array;
147
- };
199
+ for (let i = 0; i < length; ++i) {
200
+ Cartesian4.pack(array[i], result, i * 4);
201
+ }
202
+ return result;
203
+ }
148
204
 
149
- /**
150
- * Retrieves an instance from a packed array.
151
- *
152
- * @param {number[]} array The packed array.
153
- * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
154
- * @param {Cartesian4} [result] The object into which to store the result.
155
- * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
156
- */
157
- Cartesian4.unpack = function (array, startingIndex, result) {
158
- //>>includeStart('debug', pragmas.debug);
159
- Check.defined("array", array);
160
- //>>includeEnd('debug');
205
+ /**
206
+ * Unpacks an array of cartesian components into an array of Cartesian4s.
207
+ *
208
+ * @param {number[]|TypedArray} array The array of components to unpack.
209
+ * @param {Cartesian4[]} [result] The array onto which to store the result.
210
+ * @returns {Cartesian4[]} The unpacked array.
211
+ */
212
+ static unpackArray(array, result) {
213
+ //>>includeStart('debug', pragmas.debug);
214
+ Check.defined("array", array);
215
+ Check.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
216
+ if (array.length % 4 !== 0) {
217
+ throw new DeveloperError("array length must be a multiple of 4.");
218
+ }
219
+ //>>includeEnd('debug');
161
220
 
162
- startingIndex = startingIndex ?? 0;
221
+ const length = array.length;
222
+ if (!defined(result)) {
223
+ result = new Array(length / 4);
224
+ } else {
225
+ result.length = length / 4;
226
+ }
163
227
 
164
- if (!defined(result)) {
165
- result = new Cartesian4();
228
+ for (let i = 0; i < length; i += 4) {
229
+ const index = i / 4;
230
+ result[index] = Cartesian4.unpack(array, i, result[index]);
231
+ }
232
+ return result;
166
233
  }
167
- result.x = array[startingIndex++];
168
- result.y = array[startingIndex++];
169
- result.z = array[startingIndex++];
170
- result.w = array[startingIndex];
171
- return result;
172
- };
173
234
 
174
- /**
175
- * Flattens an array of Cartesian4s into an array of components.
176
- *
177
- * @param {Cartesian4[]} array The array of cartesians to pack.
178
- * @param {number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.
179
- * @returns {number[]} The packed array.
180
- */
181
- Cartesian4.packArray = function (array, result) {
182
- //>>includeStart('debug', pragmas.debug);
183
- Check.defined("array", array);
184
- //>>includeEnd('debug');
185
-
186
- const length = array.length;
187
- const resultLength = length * 4;
188
- if (!defined(result)) {
189
- result = new Array(resultLength);
190
- } else if (!Array.isArray(result) && result.length !== resultLength) {
235
+ /**
236
+ * Computes the value of the maximum component for the supplied Cartesian.
237
+ *
238
+ * @param {Cartesian4} cartesian The cartesian to use.
239
+ * @returns {number} The value of the maximum component.
240
+ */
241
+ static maximumComponent(cartesian) {
191
242
  //>>includeStart('debug', pragmas.debug);
192
- throw new DeveloperError(
193
- "If result is a typed array, it must have exactly array.length * 4 elements",
194
- );
243
+ Check.typeOf.object("cartesian", cartesian);
195
244
  //>>includeEnd('debug');
196
- } else if (result.length !== resultLength) {
197
- result.length = resultLength;
198
- }
199
245
 
200
- for (let i = 0; i < length; ++i) {
201
- Cartesian4.pack(array[i], result, i * 4);
246
+ return Math.max(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
202
247
  }
203
- return result;
204
- };
205
248
 
206
- /**
207
- * Unpacks an array of cartesian components into an array of Cartesian4s.
208
- *
209
- * @param {number[]} array The array of components to unpack.
210
- * @param {Cartesian4[]} [result] The array onto which to store the result.
211
- * @returns {Cartesian4[]} The unpacked array.
212
- */
213
- Cartesian4.unpackArray = function (array, result) {
214
- //>>includeStart('debug', pragmas.debug);
215
- Check.defined("array", array);
216
- Check.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
217
- if (array.length % 4 !== 0) {
218
- throw new DeveloperError("array length must be a multiple of 4.");
249
+ /**
250
+ * Computes the value of the minimum component for the supplied Cartesian.
251
+ *
252
+ * @param {Cartesian4} cartesian The cartesian to use.
253
+ * @returns {number} The value of the minimum component.
254
+ */
255
+ static minimumComponent(cartesian) {
256
+ //>>includeStart('debug', pragmas.debug);
257
+ Check.typeOf.object("cartesian", cartesian);
258
+ //>>includeEnd('debug');
259
+
260
+ return Math.min(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
219
261
  }
220
- //>>includeEnd('debug');
221
262
 
222
- const length = array.length;
223
- if (!defined(result)) {
224
- result = new Array(length / 4);
225
- } else {
226
- result.length = length / 4;
263
+ /**
264
+ * Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
265
+ *
266
+ * @param {Cartesian4} first A cartesian to compare.
267
+ * @param {Cartesian4} second A cartesian to compare.
268
+ * @param {Cartesian4} result The object into which to store the result.
269
+ * @returns {Cartesian4} A cartesian with the minimum components.
270
+ */
271
+ static minimumByComponent(first, second, result) {
272
+ //>>includeStart('debug', pragmas.debug);
273
+ Check.typeOf.object("first", first);
274
+ Check.typeOf.object("second", second);
275
+ Check.typeOf.object("result", result);
276
+ //>>includeEnd('debug');
277
+
278
+ result.x = Math.min(first.x, second.x);
279
+ result.y = Math.min(first.y, second.y);
280
+ result.z = Math.min(first.z, second.z);
281
+ result.w = Math.min(first.w, second.w);
282
+
283
+ return result;
227
284
  }
228
285
 
229
- for (let i = 0; i < length; i += 4) {
230
- const index = i / 4;
231
- result[index] = Cartesian4.unpack(array, i, result[index]);
286
+ /**
287
+ * Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
288
+ *
289
+ * @param {Cartesian4} first A cartesian to compare.
290
+ * @param {Cartesian4} second A cartesian to compare.
291
+ * @param {Cartesian4} result The object into which to store the result.
292
+ * @returns {Cartesian4} A cartesian with the maximum components.
293
+ */
294
+ static maximumByComponent(first, second, result) {
295
+ //>>includeStart('debug', pragmas.debug);
296
+ Check.typeOf.object("first", first);
297
+ Check.typeOf.object("second", second);
298
+ Check.typeOf.object("result", result);
299
+ //>>includeEnd('debug');
300
+
301
+ result.x = Math.max(first.x, second.x);
302
+ result.y = Math.max(first.y, second.y);
303
+ result.z = Math.max(first.z, second.z);
304
+ result.w = Math.max(first.w, second.w);
305
+
306
+ return result;
232
307
  }
233
- return result;
234
- };
235
308
 
236
- /**
237
- * Creates a Cartesian4 from four consecutive elements in an array.
238
- * @function
239
- *
240
- * @param {number[]} array The array whose four consecutive elements correspond to the x, y, z, and w components, respectively.
241
- * @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.
242
- * @param {Cartesian4} [result] The object onto which to store the result.
243
- * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
244
- *
245
- * @example
246
- * // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0)
247
- * const v = [1.0, 2.0, 3.0, 4.0];
248
- * const p = Cesium.Cartesian4.fromArray(v);
249
- *
250
- * // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0) using an offset into an array
251
- * const v2 = [0.0, 0.0, 1.0, 2.0, 3.0, 4.0];
252
- * const p2 = Cesium.Cartesian4.fromArray(v2, 2);
253
- */
254
- Cartesian4.fromArray = Cartesian4.unpack;
309
+ /**
310
+ * Constrain a value to lie between two values.
311
+ *
312
+ * @param {Cartesian4} value The value to clamp.
313
+ * @param {Cartesian4} min The minimum bound.
314
+ * @param {Cartesian4} max The maximum bound.
315
+ * @param {Cartesian4} result The object into which to store the result.
316
+ * @returns {Cartesian4} The clamped value such that min <= result <= max.
317
+ */
318
+ static clamp(value, min, max, result) {
319
+ //>>includeStart('debug', pragmas.debug);
320
+ Check.typeOf.object("value", value);
321
+ Check.typeOf.object("min", min);
322
+ Check.typeOf.object("max", max);
323
+ Check.typeOf.object("result", result);
324
+ //>>includeEnd('debug');
255
325
 
256
- /**
257
- * Computes the value of the maximum component for the supplied Cartesian.
258
- *
259
- * @param {Cartesian4} cartesian The cartesian to use.
260
- * @returns {number} The value of the maximum component.
261
- */
262
- Cartesian4.maximumComponent = function (cartesian) {
263
- //>>includeStart('debug', pragmas.debug);
264
- Check.typeOf.object("cartesian", cartesian);
265
- //>>includeEnd('debug');
326
+ const x = CesiumMath.clamp(value.x, min.x, max.x);
327
+ const y = CesiumMath.clamp(value.y, min.y, max.y);
328
+ const z = CesiumMath.clamp(value.z, min.z, max.z);
329
+ const w = CesiumMath.clamp(value.w, min.w, max.w);
266
330
 
267
- return Math.max(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
268
- };
331
+ result.x = x;
332
+ result.y = y;
333
+ result.z = z;
334
+ result.w = w;
269
335
 
270
- /**
271
- * Computes the value of the minimum component for the supplied Cartesian.
272
- *
273
- * @param {Cartesian4} cartesian The cartesian to use.
274
- * @returns {number} The value of the minimum component.
275
- */
276
- Cartesian4.minimumComponent = function (cartesian) {
277
- //>>includeStart('debug', pragmas.debug);
278
- Check.typeOf.object("cartesian", cartesian);
279
- //>>includeEnd('debug');
336
+ return result;
337
+ }
280
338
 
281
- return Math.min(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
282
- };
339
+ /**
340
+ * Computes the provided Cartesian's squared magnitude.
341
+ *
342
+ * @param {Cartesian4} cartesian The Cartesian instance whose squared magnitude is to be computed.
343
+ * @returns {number} The squared magnitude.
344
+ */
345
+ static magnitudeSquared(cartesian) {
346
+ //>>includeStart('debug', pragmas.debug);
347
+ Check.typeOf.object("cartesian", cartesian);
348
+ //>>includeEnd('debug');
283
349
 
284
- /**
285
- * Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
286
- *
287
- * @param {Cartesian4} first A cartesian to compare.
288
- * @param {Cartesian4} second A cartesian to compare.
289
- * @param {Cartesian4} result The object into which to store the result.
290
- * @returns {Cartesian4} A cartesian with the minimum components.
291
- */
292
- Cartesian4.minimumByComponent = function (first, second, result) {
293
- //>>includeStart('debug', pragmas.debug);
294
- Check.typeOf.object("first", first);
295
- Check.typeOf.object("second", second);
296
- Check.typeOf.object("result", result);
297
- //>>includeEnd('debug');
350
+ return (
351
+ cartesian.x * cartesian.x +
352
+ cartesian.y * cartesian.y +
353
+ cartesian.z * cartesian.z +
354
+ cartesian.w * cartesian.w
355
+ );
356
+ }
298
357
 
299
- result.x = Math.min(first.x, second.x);
300
- result.y = Math.min(first.y, second.y);
301
- result.z = Math.min(first.z, second.z);
302
- result.w = Math.min(first.w, second.w);
358
+ /**
359
+ * Computes the Cartesian's magnitude (length).
360
+ *
361
+ * @param {Cartesian4} cartesian The Cartesian instance whose magnitude is to be computed.
362
+ * @returns {number} The magnitude.
363
+ */
364
+ static magnitude(cartesian) {
365
+ return Math.sqrt(Cartesian4.magnitudeSquared(cartesian));
366
+ }
303
367
 
304
- return result;
305
- };
368
+ /**
369
+ * Computes the 4-space distance between two points.
370
+ *
371
+ * @param {Cartesian4} left The first point to compute the distance from.
372
+ * @param {Cartesian4} right The second point to compute the distance to.
373
+ * @returns {number} The distance between two points.
374
+ *
375
+ * @example
376
+ * // Returns 1.0
377
+ * const d = Cesium.Cartesian4.distance(
378
+ * new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
379
+ * new Cesium.Cartesian4(2.0, 0.0, 0.0, 0.0));
380
+ */
381
+ static distance(left, right) {
382
+ //>>includeStart('debug', pragmas.debug);
383
+ Check.typeOf.object("left", left);
384
+ Check.typeOf.object("right", right);
385
+ //>>includeEnd('debug');
306
386
 
307
- /**
308
- * Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
309
- *
310
- * @param {Cartesian4} first A cartesian to compare.
311
- * @param {Cartesian4} second A cartesian to compare.
312
- * @param {Cartesian4} result The object into which to store the result.
313
- * @returns {Cartesian4} A cartesian with the maximum components.
314
- */
315
- Cartesian4.maximumByComponent = function (first, second, result) {
316
- //>>includeStart('debug', pragmas.debug);
317
- Check.typeOf.object("first", first);
318
- Check.typeOf.object("second", second);
319
- Check.typeOf.object("result", result);
320
- //>>includeEnd('debug');
387
+ Cartesian4.subtract(left, right, distanceScratch);
388
+ return Cartesian4.magnitude(distanceScratch);
389
+ }
321
390
 
322
- result.x = Math.max(first.x, second.x);
323
- result.y = Math.max(first.y, second.y);
324
- result.z = Math.max(first.z, second.z);
325
- result.w = Math.max(first.w, second.w);
391
+ /**
392
+ * Computes the squared distance between two points. Comparing squared distances
393
+ * using this function is more efficient than comparing distances using {@link Cartesian4#distance}.
394
+ *
395
+ * @param {Cartesian4} left The first point to compute the distance from.
396
+ * @param {Cartesian4} right The second point to compute the distance to.
397
+ * @returns {number} The distance between two points.
398
+ *
399
+ * @example
400
+ * // Returns 4.0, not 2.0
401
+ * const d = Cesium.Cartesian4.distance(
402
+ * new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
403
+ * new Cesium.Cartesian4(3.0, 0.0, 0.0, 0.0));
404
+ */
405
+ static distanceSquared(left, right) {
406
+ //>>includeStart('debug', pragmas.debug);
407
+ Check.typeOf.object("left", left);
408
+ Check.typeOf.object("right", right);
409
+ //>>includeEnd('debug');
326
410
 
327
- return result;
328
- };
411
+ Cartesian4.subtract(left, right, distanceScratch);
412
+ return Cartesian4.magnitudeSquared(distanceScratch);
413
+ }
329
414
 
330
- /**
331
- * Constrain a value to lie between two values.
332
- *
333
- * @param {Cartesian4} value The value to clamp.
334
- * @param {Cartesian4} min The minimum bound.
335
- * @param {Cartesian4} max The maximum bound.
336
- * @param {Cartesian4} result The object into which to store the result.
337
- * @returns {Cartesian4} The clamped value such that min <= result <= max.
338
- */
339
- Cartesian4.clamp = function (value, min, max, result) {
340
- //>>includeStart('debug', pragmas.debug);
341
- Check.typeOf.object("value", value);
342
- Check.typeOf.object("min", min);
343
- Check.typeOf.object("max", max);
344
- Check.typeOf.object("result", result);
345
- //>>includeEnd('debug');
346
-
347
- const x = CesiumMath.clamp(value.x, min.x, max.x);
348
- const y = CesiumMath.clamp(value.y, min.y, max.y);
349
- const z = CesiumMath.clamp(value.z, min.z, max.z);
350
- const w = CesiumMath.clamp(value.w, min.w, max.w);
351
-
352
- result.x = x;
353
- result.y = y;
354
- result.z = z;
355
- result.w = w;
356
-
357
- return result;
358
- };
415
+ /**
416
+ * Computes the normalized form of the supplied Cartesian.
417
+ *
418
+ * @param {Cartesian4} cartesian The Cartesian to be normalized.
419
+ * @param {Cartesian4} result The object onto which to store the result.
420
+ * @returns {Cartesian4} The modified result parameter.
421
+ */
422
+ static normalize(cartesian, result) {
423
+ //>>includeStart('debug', pragmas.debug);
424
+ Check.typeOf.object("cartesian", cartesian);
425
+ Check.typeOf.object("result", result);
426
+ //>>includeEnd('debug');
359
427
 
360
- /**
361
- * Computes the provided Cartesian's squared magnitude.
362
- *
363
- * @param {Cartesian4} cartesian The Cartesian instance whose squared magnitude is to be computed.
364
- * @returns {number} The squared magnitude.
365
- */
366
- Cartesian4.magnitudeSquared = function (cartesian) {
367
- //>>includeStart('debug', pragmas.debug);
368
- Check.typeOf.object("cartesian", cartesian);
369
- //>>includeEnd('debug');
370
-
371
- return (
372
- cartesian.x * cartesian.x +
373
- cartesian.y * cartesian.y +
374
- cartesian.z * cartesian.z +
375
- cartesian.w * cartesian.w
376
- );
377
- };
428
+ const magnitude = Cartesian4.magnitude(cartesian);
378
429
 
379
- /**
380
- * Computes the Cartesian's magnitude (length).
381
- *
382
- * @param {Cartesian4} cartesian The Cartesian instance whose magnitude is to be computed.
383
- * @returns {number} The magnitude.
384
- */
385
- Cartesian4.magnitude = function (cartesian) {
386
- return Math.sqrt(Cartesian4.magnitudeSquared(cartesian));
387
- };
430
+ result.x = cartesian.x / magnitude;
431
+ result.y = cartesian.y / magnitude;
432
+ result.z = cartesian.z / magnitude;
433
+ result.w = cartesian.w / magnitude;
388
434
 
389
- const distanceScratch = new Cartesian4();
435
+ //>>includeStart('debug', pragmas.debug);
436
+ if (
437
+ isNaN(result.x) ||
438
+ isNaN(result.y) ||
439
+ isNaN(result.z) ||
440
+ isNaN(result.w)
441
+ ) {
442
+ throw new DeveloperError("normalized result is not a number");
443
+ }
444
+ //>>includeEnd('debug');
390
445
 
391
- /**
392
- * Computes the 4-space distance between two points.
393
- *
394
- * @param {Cartesian4} left The first point to compute the distance from.
395
- * @param {Cartesian4} right The second point to compute the distance to.
396
- * @returns {number} The distance between two points.
397
- *
398
- * @example
399
- * // Returns 1.0
400
- * const d = Cesium.Cartesian4.distance(
401
- * new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
402
- * new Cesium.Cartesian4(2.0, 0.0, 0.0, 0.0));
403
- */
404
- Cartesian4.distance = function (left, right) {
405
- //>>includeStart('debug', pragmas.debug);
406
- Check.typeOf.object("left", left);
407
- Check.typeOf.object("right", right);
408
- //>>includeEnd('debug');
446
+ return result;
447
+ }
409
448
 
410
- Cartesian4.subtract(left, right, distanceScratch);
411
- return Cartesian4.magnitude(distanceScratch);
412
- };
449
+ /**
450
+ * Computes the dot (scalar) product of two Cartesians.
451
+ *
452
+ * @param {Cartesian4} left The first Cartesian.
453
+ * @param {Cartesian4} right The second Cartesian.
454
+ * @returns {number} The dot product.
455
+ */
456
+ static dot(left, right) {
457
+ //>>includeStart('debug', pragmas.debug);
458
+ Check.typeOf.object("left", left);
459
+ Check.typeOf.object("right", right);
460
+ //>>includeEnd('debug');
413
461
 
414
- /**
415
- * Computes the squared distance between two points. Comparing squared distances
416
- * using this function is more efficient than comparing distances using {@link Cartesian4#distance}.
417
- *
418
- * @param {Cartesian4} left The first point to compute the distance from.
419
- * @param {Cartesian4} right The second point to compute the distance to.
420
- * @returns {number} The distance between two points.
421
- *
422
- * @example
423
- * // Returns 4.0, not 2.0
424
- * const d = Cesium.Cartesian4.distance(
425
- * new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
426
- * new Cesium.Cartesian4(3.0, 0.0, 0.0, 0.0));
427
- */
428
- Cartesian4.distanceSquared = function (left, right) {
429
- //>>includeStart('debug', pragmas.debug);
430
- Check.typeOf.object("left", left);
431
- Check.typeOf.object("right", right);
432
- //>>includeEnd('debug');
462
+ return (
463
+ left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w
464
+ );
465
+ }
433
466
 
434
- Cartesian4.subtract(left, right, distanceScratch);
435
- return Cartesian4.magnitudeSquared(distanceScratch);
436
- };
467
+ /**
468
+ * Computes the componentwise product of two Cartesians.
469
+ *
470
+ * @param {Cartesian4} left The first Cartesian.
471
+ * @param {Cartesian4} right The second Cartesian.
472
+ * @param {Cartesian4} result The object onto which to store the result.
473
+ * @returns {Cartesian4} The modified result parameter.
474
+ */
475
+ static multiplyComponents(left, right, result) {
476
+ //>>includeStart('debug', pragmas.debug);
477
+ Check.typeOf.object("left", left);
478
+ Check.typeOf.object("right", right);
479
+ Check.typeOf.object("result", result);
480
+ //>>includeEnd('debug');
437
481
 
438
- /**
439
- * Computes the normalized form of the supplied Cartesian.
440
- *
441
- * @param {Cartesian4} cartesian The Cartesian to be normalized.
442
- * @param {Cartesian4} result The object onto which to store the result.
443
- * @returns {Cartesian4} The modified result parameter.
444
- */
445
- Cartesian4.normalize = function (cartesian, result) {
446
- //>>includeStart('debug', pragmas.debug);
447
- Check.typeOf.object("cartesian", cartesian);
448
- Check.typeOf.object("result", result);
449
- //>>includeEnd('debug');
482
+ result.x = left.x * right.x;
483
+ result.y = left.y * right.y;
484
+ result.z = left.z * right.z;
485
+ result.w = left.w * right.w;
486
+ return result;
487
+ }
450
488
 
451
- const magnitude = Cartesian4.magnitude(cartesian);
489
+ /**
490
+ * Computes the componentwise quotient of two Cartesians.
491
+ *
492
+ * @param {Cartesian4} left The first Cartesian.
493
+ * @param {Cartesian4} right The second Cartesian.
494
+ * @param {Cartesian4} result The object onto which to store the result.
495
+ * @returns {Cartesian4} The modified result parameter.
496
+ */
497
+ static divideComponents(left, right, result) {
498
+ //>>includeStart('debug', pragmas.debug);
499
+ Check.typeOf.object("left", left);
500
+ Check.typeOf.object("right", right);
501
+ Check.typeOf.object("result", result);
502
+ //>>includeEnd('debug');
503
+
504
+ result.x = left.x / right.x;
505
+ result.y = left.y / right.y;
506
+ result.z = left.z / right.z;
507
+ result.w = left.w / right.w;
508
+ return result;
509
+ }
452
510
 
453
- result.x = cartesian.x / magnitude;
454
- result.y = cartesian.y / magnitude;
455
- result.z = cartesian.z / magnitude;
456
- result.w = cartesian.w / magnitude;
511
+ /**
512
+ * Computes the componentwise sum of two Cartesians.
513
+ *
514
+ * @param {Cartesian4} left The first Cartesian.
515
+ * @param {Cartesian4} right The second Cartesian.
516
+ * @param {Cartesian4} result The object onto which to store the result.
517
+ * @returns {Cartesian4} The modified result parameter.
518
+ */
519
+ static add(left, right, result) {
520
+ //>>includeStart('debug', pragmas.debug);
521
+ Check.typeOf.object("left", left);
522
+ Check.typeOf.object("right", right);
523
+ Check.typeOf.object("result", result);
524
+ //>>includeEnd('debug');
457
525
 
458
- //>>includeStart('debug', pragmas.debug);
459
- if (
460
- isNaN(result.x) ||
461
- isNaN(result.y) ||
462
- isNaN(result.z) ||
463
- isNaN(result.w)
464
- ) {
465
- throw new DeveloperError("normalized result is not a number");
526
+ result.x = left.x + right.x;
527
+ result.y = left.y + right.y;
528
+ result.z = left.z + right.z;
529
+ result.w = left.w + right.w;
530
+ return result;
466
531
  }
467
- //>>includeEnd('debug');
468
532
 
469
- return result;
470
- };
533
+ /**
534
+ * Computes the componentwise difference of two Cartesians.
535
+ *
536
+ * @param {Cartesian4} left The first Cartesian.
537
+ * @param {Cartesian4} right The second Cartesian.
538
+ * @param {Cartesian4} result The object onto which to store the result.
539
+ * @returns {Cartesian4} The modified result parameter.
540
+ */
541
+ static subtract(left, right, result) {
542
+ //>>includeStart('debug', pragmas.debug);
543
+ Check.typeOf.object("left", left);
544
+ Check.typeOf.object("right", right);
545
+ Check.typeOf.object("result", result);
546
+ //>>includeEnd('debug');
471
547
 
472
- /**
473
- * Computes the dot (scalar) product of two Cartesians.
474
- *
475
- * @param {Cartesian4} left The first Cartesian.
476
- * @param {Cartesian4} right The second Cartesian.
477
- * @returns {number} The dot product.
478
- */
479
- Cartesian4.dot = function (left, right) {
480
- //>>includeStart('debug', pragmas.debug);
481
- Check.typeOf.object("left", left);
482
- Check.typeOf.object("right", right);
483
- //>>includeEnd('debug');
548
+ result.x = left.x - right.x;
549
+ result.y = left.y - right.y;
550
+ result.z = left.z - right.z;
551
+ result.w = left.w - right.w;
552
+ return result;
553
+ }
484
554
 
485
- return (
486
- left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w
487
- );
488
- };
555
+ /**
556
+ * Multiplies the provided Cartesian componentwise by the provided scalar.
557
+ *
558
+ * @param {Cartesian4} cartesian The Cartesian to be scaled.
559
+ * @param {number} scalar The scalar to multiply with.
560
+ * @param {Cartesian4} result The object onto which to store the result.
561
+ * @returns {Cartesian4} The modified result parameter.
562
+ */
563
+ static multiplyByScalar(cartesian, scalar, result) {
564
+ //>>includeStart('debug', pragmas.debug);
565
+ Check.typeOf.object("cartesian", cartesian);
566
+ Check.typeOf.number("scalar", scalar);
567
+ Check.typeOf.object("result", result);
568
+ //>>includeEnd('debug');
489
569
 
490
- /**
491
- * Computes the componentwise product of two Cartesians.
492
- *
493
- * @param {Cartesian4} left The first Cartesian.
494
- * @param {Cartesian4} right The second Cartesian.
495
- * @param {Cartesian4} result The object onto which to store the result.
496
- * @returns {Cartesian4} The modified result parameter.
497
- */
498
- Cartesian4.multiplyComponents = function (left, right, result) {
499
- //>>includeStart('debug', pragmas.debug);
500
- Check.typeOf.object("left", left);
501
- Check.typeOf.object("right", right);
502
- Check.typeOf.object("result", result);
503
- //>>includeEnd('debug');
504
-
505
- result.x = left.x * right.x;
506
- result.y = left.y * right.y;
507
- result.z = left.z * right.z;
508
- result.w = left.w * right.w;
509
- return result;
510
- };
570
+ result.x = cartesian.x * scalar;
571
+ result.y = cartesian.y * scalar;
572
+ result.z = cartesian.z * scalar;
573
+ result.w = cartesian.w * scalar;
574
+ return result;
575
+ }
511
576
 
512
- /**
513
- * Computes the componentwise quotient of two Cartesians.
514
- *
515
- * @param {Cartesian4} left The first Cartesian.
516
- * @param {Cartesian4} right The second Cartesian.
517
- * @param {Cartesian4} result The object onto which to store the result.
518
- * @returns {Cartesian4} The modified result parameter.
519
- */
520
- Cartesian4.divideComponents = function (left, right, result) {
521
- //>>includeStart('debug', pragmas.debug);
522
- Check.typeOf.object("left", left);
523
- Check.typeOf.object("right", right);
524
- Check.typeOf.object("result", result);
525
- //>>includeEnd('debug');
526
-
527
- result.x = left.x / right.x;
528
- result.y = left.y / right.y;
529
- result.z = left.z / right.z;
530
- result.w = left.w / right.w;
531
- return result;
532
- };
577
+ /**
578
+ * Divides the provided Cartesian componentwise by the provided scalar.
579
+ *
580
+ * @param {Cartesian4} cartesian The Cartesian to be divided.
581
+ * @param {number} scalar The scalar to divide by.
582
+ * @param {Cartesian4} result The object onto which to store the result.
583
+ * @returns {Cartesian4} The modified result parameter.
584
+ */
585
+ static divideByScalar(cartesian, scalar, result) {
586
+ //>>includeStart('debug', pragmas.debug);
587
+ Check.typeOf.object("cartesian", cartesian);
588
+ Check.typeOf.number("scalar", scalar);
589
+ Check.typeOf.object("result", result);
590
+ //>>includeEnd('debug');
533
591
 
534
- /**
535
- * Computes the componentwise sum of two Cartesians.
536
- *
537
- * @param {Cartesian4} left The first Cartesian.
538
- * @param {Cartesian4} right The second Cartesian.
539
- * @param {Cartesian4} result The object onto which to store the result.
540
- * @returns {Cartesian4} The modified result parameter.
541
- */
542
- Cartesian4.add = function (left, right, result) {
543
- //>>includeStart('debug', pragmas.debug);
544
- Check.typeOf.object("left", left);
545
- Check.typeOf.object("right", right);
546
- Check.typeOf.object("result", result);
547
- //>>includeEnd('debug');
548
-
549
- result.x = left.x + right.x;
550
- result.y = left.y + right.y;
551
- result.z = left.z + right.z;
552
- result.w = left.w + right.w;
553
- return result;
554
- };
592
+ result.x = cartesian.x / scalar;
593
+ result.y = cartesian.y / scalar;
594
+ result.z = cartesian.z / scalar;
595
+ result.w = cartesian.w / scalar;
596
+ return result;
597
+ }
555
598
 
556
- /**
557
- * Computes the componentwise difference of two Cartesians.
558
- *
559
- * @param {Cartesian4} left The first Cartesian.
560
- * @param {Cartesian4} right The second Cartesian.
561
- * @param {Cartesian4} result The object onto which to store the result.
562
- * @returns {Cartesian4} The modified result parameter.
563
- */
564
- Cartesian4.subtract = function (left, right, result) {
565
- //>>includeStart('debug', pragmas.debug);
566
- Check.typeOf.object("left", left);
567
- Check.typeOf.object("right", right);
568
- Check.typeOf.object("result", result);
569
- //>>includeEnd('debug');
570
-
571
- result.x = left.x - right.x;
572
- result.y = left.y - right.y;
573
- result.z = left.z - right.z;
574
- result.w = left.w - right.w;
575
- return result;
576
- };
599
+ /**
600
+ * Negates the provided Cartesian.
601
+ *
602
+ * @param {Cartesian4} cartesian The Cartesian to be negated.
603
+ * @param {Cartesian4} result The object onto which to store the result.
604
+ * @returns {Cartesian4} The modified result parameter.
605
+ */
606
+ static negate(cartesian, result) {
607
+ //>>includeStart('debug', pragmas.debug);
608
+ Check.typeOf.object("cartesian", cartesian);
609
+ Check.typeOf.object("result", result);
610
+ //>>includeEnd('debug');
577
611
 
578
- /**
579
- * Multiplies the provided Cartesian componentwise by the provided scalar.
580
- *
581
- * @param {Cartesian4} cartesian The Cartesian to be scaled.
582
- * @param {number} scalar The scalar to multiply with.
583
- * @param {Cartesian4} result The object onto which to store the result.
584
- * @returns {Cartesian4} The modified result parameter.
585
- */
586
- Cartesian4.multiplyByScalar = function (cartesian, scalar, result) {
587
- //>>includeStart('debug', pragmas.debug);
588
- Check.typeOf.object("cartesian", cartesian);
589
- Check.typeOf.number("scalar", scalar);
590
- Check.typeOf.object("result", result);
591
- //>>includeEnd('debug');
592
-
593
- result.x = cartesian.x * scalar;
594
- result.y = cartesian.y * scalar;
595
- result.z = cartesian.z * scalar;
596
- result.w = cartesian.w * scalar;
597
- return result;
598
- };
612
+ result.x = -cartesian.x;
613
+ result.y = -cartesian.y;
614
+ result.z = -cartesian.z;
615
+ result.w = -cartesian.w;
616
+ return result;
617
+ }
599
618
 
600
- /**
601
- * Divides the provided Cartesian componentwise by the provided scalar.
602
- *
603
- * @param {Cartesian4} cartesian The Cartesian to be divided.
604
- * @param {number} scalar The scalar to divide by.
605
- * @param {Cartesian4} result The object onto which to store the result.
606
- * @returns {Cartesian4} The modified result parameter.
607
- */
608
- Cartesian4.divideByScalar = function (cartesian, scalar, result) {
609
- //>>includeStart('debug', pragmas.debug);
610
- Check.typeOf.object("cartesian", cartesian);
611
- Check.typeOf.number("scalar", scalar);
612
- Check.typeOf.object("result", result);
613
- //>>includeEnd('debug');
614
-
615
- result.x = cartesian.x / scalar;
616
- result.y = cartesian.y / scalar;
617
- result.z = cartesian.z / scalar;
618
- result.w = cartesian.w / scalar;
619
- return result;
620
- };
619
+ /**
620
+ * Computes the absolute value of the provided Cartesian.
621
+ *
622
+ * @param {Cartesian4} cartesian The Cartesian whose absolute value is to be computed.
623
+ * @param {Cartesian4} result The object onto which to store the result.
624
+ * @returns {Cartesian4} The modified result parameter.
625
+ */
626
+ static abs(cartesian, result) {
627
+ //>>includeStart('debug', pragmas.debug);
628
+ Check.typeOf.object("cartesian", cartesian);
629
+ Check.typeOf.object("result", result);
630
+ //>>includeEnd('debug');
621
631
 
622
- /**
623
- * Negates the provided Cartesian.
624
- *
625
- * @param {Cartesian4} cartesian The Cartesian to be negated.
626
- * @param {Cartesian4} result The object onto which to store the result.
627
- * @returns {Cartesian4} The modified result parameter.
628
- */
629
- Cartesian4.negate = function (cartesian, result) {
630
- //>>includeStart('debug', pragmas.debug);
631
- Check.typeOf.object("cartesian", cartesian);
632
- Check.typeOf.object("result", result);
633
- //>>includeEnd('debug');
634
-
635
- result.x = -cartesian.x;
636
- result.y = -cartesian.y;
637
- result.z = -cartesian.z;
638
- result.w = -cartesian.w;
639
- return result;
640
- };
632
+ result.x = Math.abs(cartesian.x);
633
+ result.y = Math.abs(cartesian.y);
634
+ result.z = Math.abs(cartesian.z);
635
+ result.w = Math.abs(cartesian.w);
636
+ return result;
637
+ }
641
638
 
642
- /**
643
- * Computes the absolute value of the provided Cartesian.
644
- *
645
- * @param {Cartesian4} cartesian The Cartesian whose absolute value is to be computed.
646
- * @param {Cartesian4} result The object onto which to store the result.
647
- * @returns {Cartesian4} The modified result parameter.
648
- */
649
- Cartesian4.abs = function (cartesian, result) {
650
- //>>includeStart('debug', pragmas.debug);
651
- Check.typeOf.object("cartesian", cartesian);
652
- Check.typeOf.object("result", result);
653
- //>>includeEnd('debug');
654
-
655
- result.x = Math.abs(cartesian.x);
656
- result.y = Math.abs(cartesian.y);
657
- result.z = Math.abs(cartesian.z);
658
- result.w = Math.abs(cartesian.w);
659
- return result;
660
- };
639
+ /**
640
+ * Computes the linear interpolation or extrapolation at t using the provided cartesians.
641
+ *
642
+ * @param {Cartesian4} start The value corresponding to t at 0.0.
643
+ * @param {Cartesian4}end The value corresponding to t at 1.0.
644
+ * @param {number} t The point along t at which to interpolate.
645
+ * @param {Cartesian4} result The object onto which to store the result.
646
+ * @returns {Cartesian4} The modified result parameter.
647
+ */
648
+ static lerp(start, end, t, result) {
649
+ //>>includeStart('debug', pragmas.debug);
650
+ Check.typeOf.object("start", start);
651
+ Check.typeOf.object("end", end);
652
+ Check.typeOf.number("t", t);
653
+ Check.typeOf.object("result", result);
654
+ //>>includeEnd('debug');
661
655
 
662
- const lerpScratch = new Cartesian4();
663
- /**
664
- * Computes the linear interpolation or extrapolation at t using the provided cartesians.
665
- *
666
- * @param {Cartesian4} start The value corresponding to t at 0.0.
667
- * @param {Cartesian4}end The value corresponding to t at 1.0.
668
- * @param {number} t The point along t at which to interpolate.
669
- * @param {Cartesian4} result The object onto which to store the result.
670
- * @returns {Cartesian4} The modified result parameter.
671
- */
672
- Cartesian4.lerp = function (start, end, t, result) {
673
- //>>includeStart('debug', pragmas.debug);
674
- Check.typeOf.object("start", start);
675
- Check.typeOf.object("end", end);
676
- Check.typeOf.number("t", t);
677
- Check.typeOf.object("result", result);
678
- //>>includeEnd('debug');
679
-
680
- Cartesian4.multiplyByScalar(end, t, lerpScratch);
681
- result = Cartesian4.multiplyByScalar(start, 1.0 - t, result);
682
- return Cartesian4.add(lerpScratch, result, result);
683
- };
656
+ Cartesian4.multiplyByScalar(end, t, lerpScratch);
657
+ result = Cartesian4.multiplyByScalar(start, 1.0 - t, result);
658
+ return Cartesian4.add(lerpScratch, result, result);
659
+ }
684
660
 
685
- const mostOrthogonalAxisScratch = new Cartesian4();
686
- /**
687
- * Returns the axis that is most orthogonal to the provided Cartesian.
688
- *
689
- * @param {Cartesian4} cartesian The Cartesian on which to find the most orthogonal axis.
690
- * @param {Cartesian4} result The object onto which to store the result.
691
- * @returns {Cartesian4} The most orthogonal axis.
692
- */
693
- Cartesian4.mostOrthogonalAxis = function (cartesian, result) {
694
- //>>includeStart('debug', pragmas.debug);
695
- Check.typeOf.object("cartesian", cartesian);
696
- Check.typeOf.object("result", result);
697
- //>>includeEnd('debug');
698
-
699
- const f = Cartesian4.normalize(cartesian, mostOrthogonalAxisScratch);
700
- Cartesian4.abs(f, f);
701
-
702
- if (f.x <= f.y) {
703
- if (f.x <= f.z) {
704
- if (f.x <= f.w) {
705
- result = Cartesian4.clone(Cartesian4.UNIT_X, result);
661
+ /**
662
+ * Returns the axis that is most orthogonal to the provided Cartesian.
663
+ *
664
+ * @param {Cartesian4} cartesian The Cartesian on which to find the most orthogonal axis.
665
+ * @param {Cartesian4} result The object onto which to store the result.
666
+ * @returns {Cartesian4} The most orthogonal axis.
667
+ */
668
+ static mostOrthogonalAxis(cartesian, result) {
669
+ //>>includeStart('debug', pragmas.debug);
670
+ Check.typeOf.object("cartesian", cartesian);
671
+ Check.typeOf.object("result", result);
672
+ //>>includeEnd('debug');
673
+
674
+ const f = Cartesian4.normalize(cartesian, mostOrthogonalAxisScratch);
675
+ Cartesian4.abs(f, f);
676
+
677
+ if (f.x <= f.y) {
678
+ if (f.x <= f.z) {
679
+ if (f.x <= f.w) {
680
+ result = Cartesian4.clone(Cartesian4.UNIT_X, result);
681
+ } else {
682
+ result = Cartesian4.clone(Cartesian4.UNIT_W, result);
683
+ }
684
+ } else if (f.z <= f.w) {
685
+ result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
686
+ } else {
687
+ result = Cartesian4.clone(Cartesian4.UNIT_W, result);
688
+ }
689
+ } else if (f.y <= f.z) {
690
+ if (f.y <= f.w) {
691
+ result = Cartesian4.clone(Cartesian4.UNIT_Y, result);
706
692
  } else {
707
693
  result = Cartesian4.clone(Cartesian4.UNIT_W, result);
708
694
  }
@@ -711,100 +697,231 @@ Cartesian4.mostOrthogonalAxis = function (cartesian, result) {
711
697
  } else {
712
698
  result = Cartesian4.clone(Cartesian4.UNIT_W, result);
713
699
  }
714
- } else if (f.y <= f.z) {
715
- if (f.y <= f.w) {
716
- result = Cartesian4.clone(Cartesian4.UNIT_Y, result);
700
+
701
+ return result;
702
+ }
703
+
704
+ /**
705
+ * Compares the provided Cartesians componentwise and returns
706
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
707
+ *
708
+ * @param {Cartesian4} [left] The first Cartesian.
709
+ * @param {Cartesian4} [right] The second Cartesian.
710
+ * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
711
+ */
712
+ static equals(left, right) {
713
+ return (
714
+ left === right ||
715
+ (defined(left) &&
716
+ defined(right) &&
717
+ left.x === right.x &&
718
+ left.y === right.y &&
719
+ left.z === right.z &&
720
+ left.w === right.w)
721
+ );
722
+ }
723
+
724
+ /**
725
+ * @param {Cartesian4} cartesian
726
+ * @param {number[]} array
727
+ * @param {number} offset
728
+ * @private
729
+ */
730
+ static equalsArray(cartesian, array, offset) {
731
+ return (
732
+ cartesian.x === array[offset] &&
733
+ cartesian.y === array[offset + 1] &&
734
+ cartesian.z === array[offset + 2] &&
735
+ cartesian.w === array[offset + 3]
736
+ );
737
+ }
738
+
739
+ /**
740
+ * Compares the provided Cartesians componentwise and returns
741
+ * <code>true</code> if they pass an absolute or relative tolerance test,
742
+ * <code>false</code> otherwise.
743
+ *
744
+ * @param {Cartesian4} [left] The first Cartesian.
745
+ * @param {Cartesian4} [right] The second Cartesian.
746
+ * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
747
+ * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
748
+ * @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
749
+ */
750
+ static equalsEpsilon(left, right, relativeEpsilon, absoluteEpsilon) {
751
+ return (
752
+ left === right ||
753
+ (defined(left) &&
754
+ defined(right) &&
755
+ CesiumMath.equalsEpsilon(
756
+ left.x,
757
+ right.x,
758
+ relativeEpsilon,
759
+ absoluteEpsilon,
760
+ ) &&
761
+ CesiumMath.equalsEpsilon(
762
+ left.y,
763
+ right.y,
764
+ relativeEpsilon,
765
+ absoluteEpsilon,
766
+ ) &&
767
+ CesiumMath.equalsEpsilon(
768
+ left.z,
769
+ right.z,
770
+ relativeEpsilon,
771
+ absoluteEpsilon,
772
+ ) &&
773
+ CesiumMath.equalsEpsilon(
774
+ left.w,
775
+ right.w,
776
+ relativeEpsilon,
777
+ absoluteEpsilon,
778
+ ))
779
+ );
780
+ }
781
+
782
+ /**
783
+ * Duplicates this Cartesian4 instance.
784
+ *
785
+ * @param {Cartesian4} [result] The object onto which to store the result.
786
+ * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
787
+ */
788
+ clone(result) {
789
+ return Cartesian4.clone(this, result);
790
+ }
791
+
792
+ /**
793
+ * Compares this Cartesian against the provided Cartesian componentwise and returns
794
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
795
+ *
796
+ * @param {Cartesian4} [right] The right hand side Cartesian.
797
+ * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
798
+ */
799
+ equals(right) {
800
+ return Cartesian4.equals(this, right);
801
+ }
802
+
803
+ /**
804
+ * Compares this Cartesian against the provided Cartesian componentwise and returns
805
+ * <code>true</code> if they pass an absolute or relative tolerance test,
806
+ * <code>false</code> otherwise.
807
+ *
808
+ * @param {Cartesian4} [right] The right hand side Cartesian.
809
+ * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
810
+ * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
811
+ * @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
812
+ */
813
+ equalsEpsilon(right, relativeEpsilon, absoluteEpsilon) {
814
+ return Cartesian4.equalsEpsilon(
815
+ this,
816
+ right,
817
+ relativeEpsilon,
818
+ absoluteEpsilon,
819
+ );
820
+ }
821
+
822
+ /**
823
+ * Creates a string representing this Cartesian in the format '(x, y, z, w)'.
824
+ *
825
+ * @returns {string} A string representing the provided Cartesian in the format '(x, y, z, w)'.
826
+ */
827
+ toString() {
828
+ return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
829
+ }
830
+
831
+ /**
832
+ * Packs an arbitrary floating point value to 4 values representable using uint8.
833
+ *
834
+ * @param {number} value A floating point number.
835
+ * @param {Cartesian4} [result] The Cartesian4 that will contain the packed float.
836
+ * @returns {Cartesian4} A Cartesian4 representing the float packed to values in x, y, z, and w.
837
+ */
838
+ static packFloat(value, result) {
839
+ //>>includeStart('debug', pragmas.debug);
840
+ Check.typeOf.number("value", value);
841
+ //>>includeEnd('debug');
842
+
843
+ if (!defined(result)) {
844
+ result = new Cartesian4();
845
+ }
846
+
847
+ // scratchU8Array and scratchF32Array are views into the same buffer
848
+ scratchF32Array[0] = value;
849
+
850
+ if (littleEndian) {
851
+ result.x = scratchU8Array[0];
852
+ result.y = scratchU8Array[1];
853
+ result.z = scratchU8Array[2];
854
+ result.w = scratchU8Array[3];
717
855
  } else {
718
- result = Cartesian4.clone(Cartesian4.UNIT_W, result);
856
+ // convert from big-endian to little-endian
857
+ result.x = scratchU8Array[3];
858
+ result.y = scratchU8Array[2];
859
+ result.z = scratchU8Array[1];
860
+ result.w = scratchU8Array[0];
719
861
  }
720
- } else if (f.z <= f.w) {
721
- result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
722
- } else {
723
- result = Cartesian4.clone(Cartesian4.UNIT_W, result);
862
+ return result;
724
863
  }
725
864
 
726
- return result;
727
- };
865
+ /**
866
+ * Unpacks a float packed using Cartesian4.packFloat.
867
+ *
868
+ * @param {Cartesian4} packedFloat A Cartesian4 containing a float packed to 4 values representable using uint8.
869
+ * @returns {number} The unpacked float.
870
+ * @private
871
+ */
872
+ static unpackFloat(packedFloat) {
873
+ //>>includeStart('debug', pragmas.debug);
874
+ Check.typeOf.object("packedFloat", packedFloat);
875
+ //>>includeEnd('debug');
728
876
 
729
- /**
730
- * Compares the provided Cartesians componentwise and returns
731
- * <code>true</code> if they are equal, <code>false</code> otherwise.
732
- *
733
- * @param {Cartesian4} [left] The first Cartesian.
734
- * @param {Cartesian4} [right] The second Cartesian.
735
- * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
736
- */
737
- Cartesian4.equals = function (left, right) {
738
- return (
739
- left === right ||
740
- (defined(left) &&
741
- defined(right) &&
742
- left.x === right.x &&
743
- left.y === right.y &&
744
- left.z === right.z &&
745
- left.w === right.w)
746
- );
747
- };
877
+ // scratchU8Array and scratchF32Array are views into the same buffer
878
+ if (littleEndian) {
879
+ scratchU8Array[0] = packedFloat.x;
880
+ scratchU8Array[1] = packedFloat.y;
881
+ scratchU8Array[2] = packedFloat.z;
882
+ scratchU8Array[3] = packedFloat.w;
883
+ } else {
884
+ // convert from little-endian to big-endian
885
+ scratchU8Array[0] = packedFloat.w;
886
+ scratchU8Array[1] = packedFloat.z;
887
+ scratchU8Array[2] = packedFloat.y;
888
+ scratchU8Array[3] = packedFloat.x;
889
+ }
890
+ return scratchF32Array[0];
891
+ }
892
+ }
748
893
 
749
894
  /**
750
- * @private
895
+ * The number of elements used to pack the object into an array.
896
+ * @type {number}
751
897
  */
752
- Cartesian4.equalsArray = function (cartesian, array, offset) {
753
- return (
754
- cartesian.x === array[offset] &&
755
- cartesian.y === array[offset + 1] &&
756
- cartesian.z === array[offset + 2] &&
757
- cartesian.w === array[offset + 3]
758
- );
759
- };
898
+ Cartesian4.packedLength = 4;
760
899
 
761
900
  /**
762
- * Compares the provided Cartesians componentwise and returns
763
- * <code>true</code> if they pass an absolute or relative tolerance test,
764
- * <code>false</code> otherwise.
901
+ * Creates a Cartesian4 from four consecutive elements in an array.
902
+ * @function
903
+ *
904
+ * @param {number[]} array The array whose four consecutive elements correspond to the x, y, z, and w components, respectively.
905
+ * @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.
906
+ * @param {Cartesian4} [result] The object onto which to store the result.
907
+ * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
908
+ *
909
+ * @example
910
+ * // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0)
911
+ * const v = [1.0, 2.0, 3.0, 4.0];
912
+ * const p = Cesium.Cartesian4.fromArray(v);
765
913
  *
766
- * @param {Cartesian4} [left] The first Cartesian.
767
- * @param {Cartesian4} [right] The second Cartesian.
768
- * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
769
- * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
770
- * @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
914
+ * // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0) using an offset into an array
915
+ * const v2 = [0.0, 0.0, 1.0, 2.0, 3.0, 4.0];
916
+ * const p2 = Cesium.Cartesian4.fromArray(v2, 2);
771
917
  */
772
- Cartesian4.equalsEpsilon = function (
773
- left,
774
- right,
775
- relativeEpsilon,
776
- absoluteEpsilon,
777
- ) {
778
- return (
779
- left === right ||
780
- (defined(left) &&
781
- defined(right) &&
782
- CesiumMath.equalsEpsilon(
783
- left.x,
784
- right.x,
785
- relativeEpsilon,
786
- absoluteEpsilon,
787
- ) &&
788
- CesiumMath.equalsEpsilon(
789
- left.y,
790
- right.y,
791
- relativeEpsilon,
792
- absoluteEpsilon,
793
- ) &&
794
- CesiumMath.equalsEpsilon(
795
- left.z,
796
- right.z,
797
- relativeEpsilon,
798
- absoluteEpsilon,
799
- ) &&
800
- CesiumMath.equalsEpsilon(
801
- left.w,
802
- right.w,
803
- relativeEpsilon,
804
- absoluteEpsilon,
805
- ))
806
- );
807
- };
918
+ Cartesian4.fromArray = Cartesian4.unpack;
919
+
920
+ const distanceScratch = new Cartesian4();
921
+
922
+ const lerpScratch = new Cartesian4();
923
+
924
+ const mostOrthogonalAxisScratch = new Cartesian4();
808
925
 
809
926
  /**
810
927
  * An immutable Cartesian4 instance initialized to (0.0, 0.0, 0.0, 0.0).
@@ -854,59 +971,6 @@ Cartesian4.UNIT_Z = Object.freeze(new Cartesian4(0.0, 0.0, 1.0, 0.0));
854
971
  */
855
972
  Cartesian4.UNIT_W = Object.freeze(new Cartesian4(0.0, 0.0, 0.0, 1.0));
856
973
 
857
- /**
858
- * Duplicates this Cartesian4 instance.
859
- *
860
- * @param {Cartesian4} [result] The object onto which to store the result.
861
- * @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
862
- */
863
- Cartesian4.prototype.clone = function (result) {
864
- return Cartesian4.clone(this, result);
865
- };
866
-
867
- /**
868
- * Compares this Cartesian against the provided Cartesian componentwise and returns
869
- * <code>true</code> if they are equal, <code>false</code> otherwise.
870
- *
871
- * @param {Cartesian4} [right] The right hand side Cartesian.
872
- * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
873
- */
874
- Cartesian4.prototype.equals = function (right) {
875
- return Cartesian4.equals(this, right);
876
- };
877
-
878
- /**
879
- * Compares this Cartesian against the provided Cartesian componentwise and returns
880
- * <code>true</code> if they pass an absolute or relative tolerance test,
881
- * <code>false</code> otherwise.
882
- *
883
- * @param {Cartesian4} [right] The right hand side Cartesian.
884
- * @param {number} [relativeEpsilon=0] The relative epsilon tolerance to use for equality testing.
885
- * @param {number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
886
- * @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
887
- */
888
- Cartesian4.prototype.equalsEpsilon = function (
889
- right,
890
- relativeEpsilon,
891
- absoluteEpsilon,
892
- ) {
893
- return Cartesian4.equalsEpsilon(
894
- this,
895
- right,
896
- relativeEpsilon,
897
- absoluteEpsilon,
898
- );
899
- };
900
-
901
- /**
902
- * Creates a string representing this Cartesian in the format '(x, y, z, w)'.
903
- *
904
- * @returns {string} A string representing the provided Cartesian in the format '(x, y, z, w)'.
905
- */
906
- Cartesian4.prototype.toString = function () {
907
- return `(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
908
- };
909
-
910
974
  // scratchU8Array and scratchF32Array are views into the same buffer
911
975
  const scratchF32Array = new Float32Array(1);
912
976
  const scratchU8Array = new Uint8Array(scratchF32Array.buffer);
@@ -915,65 +979,4 @@ const testU32 = new Uint32Array([0x11223344]);
915
979
  const testU8 = new Uint8Array(testU32.buffer);
916
980
  const littleEndian = testU8[0] === 0x44;
917
981
 
918
- /**
919
- * Packs an arbitrary floating point value to 4 values representable using uint8.
920
- *
921
- * @param {number} value A floating point number.
922
- * @param {Cartesian4} [result] The Cartesian4 that will contain the packed float.
923
- * @returns {Cartesian4} A Cartesian4 representing the float packed to values in x, y, z, and w.
924
- */
925
- Cartesian4.packFloat = function (value, result) {
926
- //>>includeStart('debug', pragmas.debug);
927
- Check.typeOf.number("value", value);
928
- //>>includeEnd('debug');
929
-
930
- if (!defined(result)) {
931
- result = new Cartesian4();
932
- }
933
-
934
- // scratchU8Array and scratchF32Array are views into the same buffer
935
- scratchF32Array[0] = value;
936
-
937
- if (littleEndian) {
938
- result.x = scratchU8Array[0];
939
- result.y = scratchU8Array[1];
940
- result.z = scratchU8Array[2];
941
- result.w = scratchU8Array[3];
942
- } else {
943
- // convert from big-endian to little-endian
944
- result.x = scratchU8Array[3];
945
- result.y = scratchU8Array[2];
946
- result.z = scratchU8Array[1];
947
- result.w = scratchU8Array[0];
948
- }
949
- return result;
950
- };
951
-
952
- /**
953
- * Unpacks a float packed using Cartesian4.packFloat.
954
- *
955
- * @param {Cartesian4} packedFloat A Cartesian4 containing a float packed to 4 values representable using uint8.
956
- * @returns {number} The unpacked float.
957
- * @private
958
- */
959
- Cartesian4.unpackFloat = function (packedFloat) {
960
- //>>includeStart('debug', pragmas.debug);
961
- Check.typeOf.object("packedFloat", packedFloat);
962
- //>>includeEnd('debug');
963
-
964
- // scratchU8Array and scratchF32Array are views into the same buffer
965
- if (littleEndian) {
966
- scratchU8Array[0] = packedFloat.x;
967
- scratchU8Array[1] = packedFloat.y;
968
- scratchU8Array[2] = packedFloat.z;
969
- scratchU8Array[3] = packedFloat.w;
970
- } else {
971
- // convert from little-endian to big-endian
972
- scratchU8Array[0] = packedFloat.w;
973
- scratchU8Array[1] = packedFloat.z;
974
- scratchU8Array[2] = packedFloat.y;
975
- scratchU8Array[3] = packedFloat.x;
976
- }
977
- return scratchF32Array[0];
978
- };
979
982
  export default Cartesian4;