@cesium/engine 24.0.0 → 26.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 (362) hide show
  1. package/Build/Workers/{chunk-6WLHJFD3.js → chunk-3VFEWOBI.js} +59 -32
  2. package/Build/Workers/{chunk-UQU4RXLT.js → chunk-424RNO3D.js} +50 -45
  3. package/Build/Workers/chunk-4MGMYHOO.js +147 -0
  4. package/Build/Workers/{chunk-AMIHNSST.js → chunk-4S7IE3LB.js} +2 -2
  5. package/Build/Workers/{chunk-J6AW5YHS.js → chunk-52JDLOEM.js} +14 -14
  6. package/Build/Workers/{chunk-6RMS4S72.js → chunk-54I6Y66F.js} +6 -6
  7. package/Build/Workers/{chunk-C6P4IG5P.js → chunk-6YEE6JDR.js} +6 -6
  8. package/Build/Workers/{chunk-72VYSVEW.js → chunk-7J2HKPRH.js} +11 -10
  9. package/Build/Workers/{chunk-7O5XJTVE.js → chunk-7WM2PX4V.js} +5 -5
  10. package/Build/Workers/{chunk-5A2SW66E.js → chunk-ACXQXN46.js} +16 -16
  11. package/Build/Workers/{chunk-VLDEUTOP.js → chunk-AYKR4VBR.js} +2 -2
  12. package/Build/Workers/{chunk-YQFTYQMZ.js → chunk-C6J67V5A.js} +3 -2
  13. package/Build/Workers/{chunk-D4EJ2NXG.js → chunk-C6KNZ7T4.js} +17 -17
  14. package/Build/Workers/{chunk-7MDYBRYJ.js → chunk-CFQP6LYM.js} +4 -4
  15. package/Build/Workers/{chunk-YAOZMOFL.js → chunk-CXOYE2WM.js} +5 -5
  16. package/Build/Workers/{chunk-B6SCUUFP.js → chunk-CZEYZU4N.js} +10 -10
  17. package/Build/Workers/{chunk-NPF7SSHZ.js → chunk-DBOEKL43.js} +7 -7
  18. package/Build/Workers/{chunk-44EMEGKW.js → chunk-DDWSZVMY.js} +5 -5
  19. package/Build/Workers/{chunk-7X322WP2.js → chunk-DOBXCNC3.js} +13 -13
  20. package/Build/Workers/{chunk-JCI63T3K.js → chunk-E7VQ76KE.js} +6 -6
  21. package/Build/Workers/{chunk-7TYLCBGK.js → chunk-EBSIOBXY.js} +12 -10
  22. package/Build/Workers/{chunk-GQUNK2XC.js → chunk-EF2QYXGA.js} +14 -14
  23. package/Build/Workers/{chunk-BJD6QGXZ.js → chunk-EPYXRCDB.js} +12 -12
  24. package/Build/Workers/{chunk-63SIWPLS.js → chunk-F6QDY6HU.js} +13 -13
  25. package/Build/Workers/{chunk-XY6HMDGI.js → chunk-FRQZECAO.js} +5 -5
  26. package/Build/Workers/{chunk-VMVOUQ5J.js → chunk-G7PXZRVF.js} +7 -7
  27. package/Build/Workers/{chunk-N65BAKSH.js → chunk-INUEEEQA.js} +8 -8
  28. package/Build/Workers/{chunk-7QRFIKWQ.js → chunk-IRBKFCEJ.js} +2 -2
  29. package/Build/Workers/{chunk-UIGVOKKI.js → chunk-IYOUHCZB.js} +3 -2
  30. package/Build/Workers/{chunk-5GXYJQ2K.js → chunk-J6BWOHUF.js} +3 -3
  31. package/Build/Workers/{chunk-A47HVBC5.js → chunk-KFSTQKNM.js} +7 -7
  32. package/Build/Workers/{chunk-EV3VGO6Y.js → chunk-KKOSKAZB.js} +17 -17
  33. package/Build/Workers/{chunk-6MPGQEHA.js → chunk-KSSWJIZW.js} +2 -2
  34. package/Build/Workers/{chunk-DHKPFLSJ.js → chunk-M3B5JKSM.js} +3 -2
  35. package/Build/Workers/chunk-MPZHGZU6.js +2342 -0
  36. package/Build/Workers/{chunk-YJZGW74L.js → chunk-MYP774IS.js} +2213 -1349
  37. package/Build/Workers/{chunk-LIB2H534.js → chunk-O3EA5HS7.js} +12 -11
  38. package/Build/Workers/{chunk-ILMFADZA.js → chunk-P3CK7MCY.js} +27 -5
  39. package/Build/Workers/chunk-Q3PY526V.js +3201 -0
  40. package/Build/Workers/chunk-QN67VG36.js +973 -0
  41. package/Build/Workers/{chunk-XJRBB253.js → chunk-QRWGUWI6.js} +11 -11
  42. package/Build/Workers/{chunk-AF3MU2RL.js → chunk-S4MCOY6I.js} +7 -6
  43. package/Build/Workers/{chunk-Y7HNNPNK.js → chunk-SMQZZOW6.js} +10 -10
  44. package/Build/Workers/{chunk-PVV64VFW.js → chunk-TKKIREQ6.js} +3 -2
  45. package/Build/Workers/{chunk-MKM27KGV.js → chunk-U3ZA64U7.js} +2 -2
  46. package/Build/Workers/{chunk-2N4KDHS3.js → chunk-UA25D5MX.js} +12 -11
  47. package/Build/Workers/{chunk-RQNJD3O4.js → chunk-UOOIQ3KX.js} +12 -12
  48. package/Build/Workers/{chunk-GOQBUCXH.js → chunk-V7VQKN6N.js} +709 -431
  49. package/Build/Workers/{chunk-LXMCPFFS.js → chunk-VQYETPWC.js} +4 -4
  50. package/Build/Workers/{chunk-NKT5K3K3.js → chunk-VWV2IJRB.js} +13 -12
  51. package/Build/Workers/chunk-XZMBNNDX.js +1287 -0
  52. package/Build/Workers/{chunk-ISY4EZCA.js → chunk-Y57HREW5.js} +4 -4
  53. package/Build/Workers/{chunk-EDXL4W76.js → chunk-Y5BF6AFU.js} +2 -2
  54. package/Build/Workers/{chunk-Q3C6VQH6.js → chunk-YLY7NKAB.js} +4 -4
  55. package/Build/Workers/{chunk-4TIG36AW.js → chunk-ZK3CF7ZD.js} +12 -12
  56. package/Build/Workers/{chunk-AJLTU6PF.js → chunk-ZP7JMQV4.js} +4 -1
  57. package/Build/Workers/{chunk-HXJMS2ZI.js → chunk-ZZ46LWL6.js} +1 -1
  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 +175 -118
  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 +24 -23
  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 +12 -9
  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/ArcType.js +6 -1
  112. package/Source/Core/ArticulationStageType.js +5 -1
  113. package/Source/Core/AssociativeArray.js +100 -94
  114. package/Source/Core/BoundingSphere.js +1296 -1300
  115. package/Source/Core/Cartesian2.js +1 -1
  116. package/Source/Core/Cartesian3.js +2 -3
  117. package/Source/Core/Cartesian4.js +1 -1
  118. package/Source/Core/Cartographic.js +257 -249
  119. package/Source/Core/ClockRange.js +6 -1
  120. package/Source/Core/ClockStep.js +6 -1
  121. package/Source/Core/Color.js +844 -835
  122. package/Source/Core/ComponentDatatype.js +39 -1
  123. package/Source/Core/CornerType.js +6 -1
  124. package/Source/Core/Credit.js +121 -124
  125. package/Source/Core/Ellipsoid.js +637 -660
  126. package/Source/Core/ExtrapolationType.js +6 -1
  127. package/Source/Core/GeocodeType.js +6 -1
  128. package/Source/Core/GeographicProjection.js +74 -74
  129. package/Source/Core/GeographicTilingScheme.js +179 -198
  130. package/Source/Core/GeometryOffsetAttribute.js +7 -1
  131. package/Source/Core/GeometryType.js +7 -1
  132. package/Source/Core/HeightmapEncoding.js +6 -1
  133. package/Source/Core/Iau2006XysData.js +24 -13
  134. package/Source/Core/IndexDatatype.js +3 -1
  135. package/Source/Core/InterpolationType.js +5 -1
  136. package/Source/Core/Intersect.js +6 -1
  137. package/Source/Core/Ion.js +1 -1
  138. package/Source/Core/IonGeocodeProviderType.js +5 -1
  139. package/Source/Core/JulianDate.js +850 -848
  140. package/Source/Core/KeyboardEventModifier.js +6 -1
  141. package/Source/Core/MapProjection.js +40 -44
  142. package/Source/Core/Matrix2.js +906 -893
  143. package/Source/Core/Matrix3.js +1643 -1575
  144. package/Source/Core/Matrix4.js +2903 -2872
  145. package/Source/Core/PixelFormat.js +3 -1
  146. package/Source/Core/PrimitiveType.js +11 -1
  147. package/Source/Core/Ray.js +62 -60
  148. package/Source/Core/Rectangle.js +913 -904
  149. package/Source/Core/ReferenceFrame.js +6 -1
  150. package/Source/Core/RequestScheduler.js +8 -3
  151. package/Source/Core/RequestState.js +6 -1
  152. package/Source/Core/RequestType.js +6 -1
  153. package/Source/Core/Resource.js +1 -1
  154. package/Source/Core/ScreenSpaceEventHandler.js +51 -41
  155. package/Source/Core/ScreenSpaceEventType.js +6 -1
  156. package/Source/Core/TerrainQuantization.js +6 -1
  157. package/Source/Core/TilingScheme.js +100 -98
  158. package/Source/Core/TimeConstants.js +6 -1
  159. package/Source/Core/TimeStandard.js +6 -1
  160. package/Source/Core/TrackingReferenceFrame.js +6 -1
  161. package/Source/Core/Visibility.js +6 -1
  162. package/Source/Core/VulkanConstants.js +6 -1
  163. package/Source/Core/WebGLConstants.js +6 -1
  164. package/Source/Core/WebMercatorProjection.js +108 -109
  165. package/Source/Core/WebMercatorTilingScheme.js +246 -242
  166. package/Source/Core/WindingOrder.js +3 -1
  167. package/Source/Core/createColorRamp.js +37 -0
  168. package/Source/Core/globalTypes.js +25 -0
  169. package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +1 -0
  170. package/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +1 -0
  171. package/Source/DataSources/StripeOrientation.js +6 -1
  172. package/Source/Renderer/BufferUsage.js +20 -9
  173. package/Source/Renderer/Context.js +2 -29
  174. package/Source/Renderer/DrawCommand.js +435 -403
  175. package/Source/Renderer/MipmapHint.js +5 -1
  176. package/Source/Renderer/Pass.js +10 -3
  177. package/Source/Renderer/PickId.js +44 -0
  178. package/Source/Renderer/PixelDatatype.js +3 -1
  179. package/Source/Renderer/RenderbufferFormat.js +5 -1
  180. package/Source/Renderer/ShaderDestination.js +4 -1
  181. package/Source/Renderer/TextureMagnificationFilter.js +3 -1
  182. package/Source/Renderer/TextureMinificationFilter.js +3 -1
  183. package/Source/Renderer/TextureWrap.js +5 -1
  184. package/Source/Renderer/createUniform.js +346 -239
  185. package/Source/Renderer/createUniformArray.js +494 -381
  186. package/Source/Scene/AlphaMode.js +5 -1
  187. package/Source/Scene/ArcGisBaseMapType.js +6 -1
  188. package/Source/Scene/ArcGisMapService.js +1 -1
  189. package/Source/Scene/AttributeType.js +3 -1
  190. package/Source/Scene/Axis.js +3 -1
  191. package/Source/Scene/BingMapsStyle.js +6 -1
  192. package/Source/Scene/BlendEquation.js +6 -1
  193. package/Source/Scene/BlendFunction.js +6 -1
  194. package/Source/Scene/BlendOption.js +6 -1
  195. package/Source/Scene/BlendingState.js +6 -1
  196. package/Source/Scene/BufferLoader.js +0 -2
  197. package/Source/Scene/BufferPoint.js +1 -0
  198. package/Source/Scene/BufferPointCollection.js +17 -1
  199. package/Source/Scene/BufferPolygon.js +3 -2
  200. package/Source/Scene/BufferPolygonCollection.js +13 -1
  201. package/Source/Scene/BufferPolyline.js +1 -0
  202. package/Source/Scene/BufferPolylineCollection.js +5 -1
  203. package/Source/Scene/BufferPrimitiveCollection.js +210 -43
  204. package/Source/Scene/CameraEventAggregator.js +30 -18
  205. package/Source/Scene/CameraEventType.js +6 -1
  206. package/Source/Scene/Cesium3DTile.js +54 -1
  207. package/Source/Scene/Cesium3DTileColorBlendMode.js +6 -1
  208. package/Source/Scene/Cesium3DTileContent.js +195 -254
  209. package/Source/Scene/Cesium3DTileContentFactory.js +10 -2
  210. package/Source/Scene/Cesium3DTileContentState.js +6 -1
  211. package/Source/Scene/Cesium3DTileContentType.js +3 -1
  212. package/Source/Scene/Cesium3DTileFeature.js +289 -306
  213. package/Source/Scene/Cesium3DTileOptimizationHint.js +6 -1
  214. package/Source/Scene/Cesium3DTilePass.js +5 -1
  215. package/Source/Scene/Cesium3DTilePointFeature.js +433 -511
  216. package/Source/Scene/Cesium3DTileRefine.js +6 -1
  217. package/Source/Scene/Cesium3DTileVectorFeature.js +586 -0
  218. package/Source/Scene/Cesium3DTileset.js +46 -6
  219. package/Source/Scene/ClassificationType.js +3 -1
  220. package/Source/Scene/CloudType.js +3 -1
  221. package/Source/Scene/ColorBlendMode.js +4 -1
  222. package/Source/Scene/Composite3DTileContent.js +254 -292
  223. package/Source/Scene/CullFace.js +6 -1
  224. package/Source/Scene/DepthFunction.js +6 -1
  225. package/Source/Scene/DynamicAtmosphereLightingType.js +3 -1
  226. package/Source/Scene/EdgeDisplayMode.js +50 -0
  227. package/Source/Scene/Empty3DTileContent.js +100 -132
  228. package/Source/Scene/EquirectangularPanorama.js +1 -0
  229. package/Source/Scene/ExpressionNodeType.js +6 -1
  230. package/Source/Scene/GaussianSplat3DTileContent.js +436 -478
  231. package/Source/Scene/GeoJsonPrimitive.js +874 -0
  232. package/Source/Scene/Geometry3DTileContent.js +151 -185
  233. package/Source/Scene/GltfBufferViewLoader.js +0 -2
  234. package/Source/Scene/GltfDracoLoader.js +0 -2
  235. package/Source/Scene/GltfImageLoader.js +0 -3
  236. package/Source/Scene/GltfIndexBufferLoader.js +0 -4
  237. package/Source/Scene/GltfJsonLoader.js +0 -2
  238. package/Source/Scene/GltfLoader.js +109 -5
  239. package/Source/Scene/GltfLoaderUtil.js +14 -0
  240. package/Source/Scene/GltfSpzLoader.js +0 -2
  241. package/Source/Scene/GltfStructuralMetadataLoader.js +0 -2
  242. package/Source/Scene/GltfTextureLoader.js +0 -2
  243. package/Source/Scene/GltfVertexBufferLoader.js +0 -4
  244. package/Source/Scene/HeightReference.js +5 -1
  245. package/Source/Scene/HorizontalOrigin.js +6 -1
  246. package/Source/Scene/ImageryProvider.js +1 -1
  247. package/Source/Scene/ImageryState.js +6 -1
  248. package/Source/Scene/Implicit3DTileContent.js +179 -214
  249. package/Source/Scene/ImplicitSubdivisionScheme.js +3 -1
  250. package/Source/Scene/InstanceAttributeSemantic.js +3 -1
  251. package/Source/Scene/IonWorldImageryStyle.js +6 -1
  252. package/Source/Scene/JobType.js +6 -1
  253. package/Source/Scene/LabelStyle.js +6 -1
  254. package/Source/Scene/MVTDataProvider.js +147 -0
  255. package/Source/Scene/MapMode2D.js +6 -1
  256. package/Source/Scene/MetadataComponentType.js +3 -1
  257. package/Source/Scene/MetadataSchemaLoader.js +0 -2
  258. package/Source/Scene/MetadataSemantic.js +6 -2
  259. package/Source/Scene/MetadataType.js +3 -1
  260. package/Source/Scene/Model/B3dmLoader.js +0 -3
  261. package/Source/Scene/Model/CustomShaderMode.js +3 -1
  262. package/Source/Scene/Model/CustomShaderTranslucencyMode.js +5 -1
  263. package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +78 -337
  264. package/Source/Scene/Model/Extensions/Gpm/PpeSource.js +5 -1
  265. package/Source/Scene/Model/Extensions/Gpm/StorageType.js +5 -1
  266. package/Source/Scene/Model/GeoJsonLoader.js +0 -2
  267. package/Source/Scene/Model/I3dmLoader.js +0 -3
  268. package/Source/Scene/Model/InstancingPipelineStage.js +1 -1
  269. package/Source/Scene/Model/LightingModel.js +5 -1
  270. package/Source/Scene/Model/MaterialPipelineStage.js +184 -3
  271. package/Source/Scene/Model/Model.js +34 -0
  272. package/Source/Scene/Model/Model3DTileContent.js +424 -458
  273. package/Source/Scene/Model/ModelDrawCommand.js +31 -3
  274. package/Source/Scene/Model/ModelReader.js +474 -3
  275. package/Source/Scene/Model/ModelRuntimePrimitive.js +2 -1
  276. package/Source/Scene/Model/ModelType.js +3 -1
  277. package/Source/Scene/Model/ModelUtility.js +4 -0
  278. package/Source/Scene/Model/PntsLoader.js +4 -3
  279. package/Source/Scene/Model/StyleCommandsNeeded.js +3 -1
  280. package/Source/Scene/Model/UniformType.js +5 -1
  281. package/Source/Scene/Model/VaryingType.js +5 -1
  282. package/Source/Scene/Model/createVectorTileBuffersFromModelComponents.js +500 -139
  283. package/Source/Scene/Model/pickModel.js +94 -299
  284. package/Source/Scene/ModelAnimationLoop.js +6 -1
  285. package/Source/Scene/ModelAnimationState.js +6 -1
  286. package/Source/Scene/ModelComponents.js +47 -2
  287. package/Source/Scene/Multiple3DTileContent.js +291 -334
  288. package/Source/Scene/PrimitiveState.js +7 -1
  289. package/Source/Scene/QuadtreeOccluders.js +20 -15
  290. package/Source/Scene/QuadtreeTile.js +547 -541
  291. package/Source/Scene/QuadtreeTileLoadState.js +6 -1
  292. package/Source/Scene/QuadtreeTileProvider.js +159 -175
  293. package/Source/Scene/ResourceLoader.js +0 -1
  294. package/Source/Scene/ResourceLoaderState.js +7 -1
  295. package/Source/Scene/Scene.js +26 -0
  296. package/Source/Scene/SceneMode.js +4 -1
  297. package/Source/Scene/ShadowMode.js +3 -1
  298. package/Source/Scene/SkyBox.js +1 -1
  299. package/Source/Scene/SplitDirection.js +6 -1
  300. package/Source/Scene/StencilFunction.js +6 -1
  301. package/Source/Scene/StencilOperation.js +6 -1
  302. package/Source/Scene/TerrainState.js +7 -1
  303. package/Source/Scene/TileState.js +7 -1
  304. package/Source/Scene/Tileset3DTileContent.js +113 -146
  305. package/Source/Scene/Tonemapper.js +5 -1
  306. package/Source/Scene/UrlTemplate3DTilesDataProvider.js +499 -0
  307. package/Source/Scene/Vector3DTileContent.js +205 -234
  308. package/Source/Scene/VectorGltf3DTileContent.js +131 -61
  309. package/Source/Scene/VertexAttributeSemantic.js +3 -1
  310. package/Source/Scene/VerticalOrigin.js +6 -1
  311. package/Source/Scene/VoxelBoxShape.js +12 -6
  312. package/Source/Scene/VoxelContent.js +2 -0
  313. package/Source/Scene/VoxelCylinderShape.js +39 -38
  314. package/Source/Scene/VoxelEllipsoidShape.js +46 -96
  315. package/Source/Scene/VoxelMetadataOrder.js +6 -1
  316. package/Source/Scene/VoxelPrimitive.js +159 -175
  317. package/Source/Scene/VoxelProvider.js +64 -90
  318. package/Source/Scene/VoxelShapeType.js +3 -1
  319. package/Source/Scene/buildVectorGltfFromMVT.js +1059 -0
  320. package/Source/Scene/buildVoxelCustomShader.js +199 -0
  321. package/Source/Scene/decodeMVT.js +634 -0
  322. package/Source/Scene/renderBufferPointCollection.js +124 -127
  323. package/Source/Scene/renderBufferPolygonCollection.js +122 -122
  324. package/Source/Scene/renderBufferPolylineCollection.js +386 -238
  325. package/Source/Shaders/BufferPointMaterialFS.glsl +1 -0
  326. package/Source/Shaders/BufferPointMaterialFS.js +1 -0
  327. package/Source/Shaders/BufferPointMaterialVS.glsl +19 -9
  328. package/Source/Shaders/BufferPointMaterialVS.js +20 -10
  329. package/Source/Shaders/BufferPolygonMaterialVS.glsl +13 -4
  330. package/Source/Shaders/BufferPolygonMaterialVS.js +14 -5
  331. package/Source/Shaders/BufferPolylineMaterialVS.glsl +16 -2
  332. package/Source/Shaders/BufferPolylineMaterialVS.js +17 -3
  333. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.glsl +9 -0
  334. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.js +11 -0
  335. package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
  336. package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
  337. package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
  338. package/Source/Shaders/Builtin/Functions/computeTextureTransform.glsl +24 -0
  339. package/Source/Shaders/Builtin/Functions/computeTextureTransform.js +25 -0
  340. package/Source/Shaders/Model/ConstantLodStageFS.glsl +60 -0
  341. package/Source/Shaders/Model/ConstantLodStageFS.js +62 -0
  342. package/Source/Shaders/Model/ConstantLodStageVS.glsl +12 -0
  343. package/Source/Shaders/Model/ConstantLodStageVS.js +13 -0
  344. package/Source/Shaders/Model/EdgeVisibilityStageVS.glsl +0 -1
  345. package/Source/Shaders/Model/EdgeVisibilityStageVS.js +0 -1
  346. package/Source/Shaders/Model/MaterialStageFS.glsl +46 -20
  347. package/Source/Shaders/Model/MaterialStageFS.js +46 -20
  348. package/Source/Shaders/Voxels/convertLocalToBoxUv.glsl +0 -1
  349. package/Source/Shaders/Voxels/convertLocalToBoxUv.js +0 -1
  350. package/Source/Shaders/Voxels/convertLocalToCylinderUv.glsl +7 -9
  351. package/Source/Shaders/Voxels/convertLocalToCylinderUv.js +7 -9
  352. package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.glsl +7 -17
  353. package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.js +7 -17
  354. package/Source/Widget/CesiumWidget.js +11 -4
  355. package/index.d.ts +595 -343
  356. package/index.js +392 -378
  357. package/package.json +3 -3
  358. package/Build/Workers/chunk-DVB56LG7.js +0 -114
  359. package/Build/Workers/chunk-HKUES6UG.js +0 -2357
  360. package/Build/Workers/chunk-HRHRYFHS.js +0 -940
  361. package/Build/Workers/chunk-KLPGTXS3.js +0 -642
  362. package/Build/Workers/chunk-ZBZRTRJB.js +0 -1829
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+
1
3
  import Cartesian2 from "./Cartesian2.js";
2
4
  import Check from "./Check.js";
3
5
  import defined from "./defined.js";
@@ -6,14 +8,8 @@ import DeveloperError from "./DeveloperError.js";
6
8
  /**
7
9
  * A 2x2 matrix, indexable as a column-major order array.
8
10
  * Constructor parameters are in row-major order for code readability.
9
- * @alias Matrix2
10
- * @constructor
11
- * @implements {ArrayLike<number>}
12
11
  *
13
- * @param {number} [column0Row0=0.0] The value for column 0, row 0.
14
- * @param {number} [column1Row0=0.0] The value for column 1, row 0.
15
- * @param {number} [column0Row1=0.0] The value for column 0, row 1.
16
- * @param {number} [column1Row1=0.0] The value for column 1, row 1.
12
+ * @implements {ArrayLike<number>}
17
13
  *
18
14
  * @see Matrix2.fromArray
19
15
  * @see Matrix2.fromColumnMajorArray
@@ -24,949 +20,1016 @@ import DeveloperError from "./DeveloperError.js";
24
20
  * @see Matrix3
25
21
  * @see Matrix4
26
22
  */
27
- function Matrix2(column0Row0, column1Row0, column0Row1, column1Row1) {
28
- this[0] = column0Row0 ?? 0.0;
29
- this[1] = column0Row1 ?? 0.0;
30
- this[2] = column1Row0 ?? 0.0;
31
- this[3] = column1Row1 ?? 0.0;
32
- }
23
+ // @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
24
+ class Matrix2 {
25
+ /**
26
+ * @param {number} [column0Row0=0.0] The value for column 0, row 0.
27
+ * @param {number} [column1Row0=0.0] The value for column 1, row 0.
28
+ * @param {number} [column0Row1=0.0] The value for column 0, row 1.
29
+ * @param {number} [column1Row1=0.0] The value for column 1, row 1.
30
+ */
31
+ constructor(column0Row0, column1Row0, column0Row1, column1Row1) {
32
+ this[0] = column0Row0 ?? 0.0;
33
+ this[1] = column0Row1 ?? 0.0;
34
+ this[2] = column1Row0 ?? 0.0;
35
+ this[3] = column1Row1 ?? 0.0;
36
+ }
33
37
 
34
- /**
35
- * The number of elements used to pack the object into an array.
36
- * @type {number}
37
- */
38
- Matrix2.packedLength = 4;
38
+ /**
39
+ * Stores the provided instance into the provided array.
40
+ *
41
+ * @param {Matrix2} value The value to pack.
42
+ * @param {number[]} array The array to pack into.
43
+ * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
44
+ *
45
+ * @returns {number[]} The array that was packed into
46
+ */
47
+ static pack(value, array, startingIndex) {
48
+ //>>includeStart('debug', pragmas.debug);
49
+ Check.typeOf.object("value", value);
50
+ Check.defined("array", array);
51
+ //>>includeEnd('debug');
39
52
 
40
- /**
41
- * Stores the provided instance into the provided array.
42
- *
43
- * @param {Matrix2} value The value to pack.
44
- * @param {number[]} array The array to pack into.
45
- * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
46
- *
47
- * @returns {number[]} The array that was packed into
48
- */
49
- Matrix2.pack = function (value, array, startingIndex) {
50
- //>>includeStart('debug', pragmas.debug);
51
- Check.typeOf.object("value", value);
52
- Check.defined("array", array);
53
- //>>includeEnd('debug');
53
+ startingIndex = startingIndex ?? 0;
54
54
 
55
- startingIndex = startingIndex ?? 0;
55
+ array[startingIndex++] = value[0];
56
+ array[startingIndex++] = value[1];
57
+ array[startingIndex++] = value[2];
58
+ array[startingIndex++] = value[3];
56
59
 
57
- array[startingIndex++] = value[0];
58
- array[startingIndex++] = value[1];
59
- array[startingIndex++] = value[2];
60
- array[startingIndex++] = value[3];
60
+ return array;
61
+ }
61
62
 
62
- return array;
63
- };
63
+ /**
64
+ * Retrieves an instance from a packed array.
65
+ *
66
+ * @param {number[]} array The packed array.
67
+ * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
68
+ * @param {Matrix2} [result] The object into which to store the result.
69
+ * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.
70
+ */
71
+ static unpack(array, startingIndex, result) {
72
+ //>>includeStart('debug', pragmas.debug);
73
+ Check.defined("array", array);
74
+ //>>includeEnd('debug');
64
75
 
65
- /**
66
- * Retrieves an instance from a packed array.
67
- *
68
- * @param {number[]} array The packed array.
69
- * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
70
- * @param {Matrix2} [result] The object into which to store the result.
71
- * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.
72
- */
73
- Matrix2.unpack = function (array, startingIndex, result) {
74
- //>>includeStart('debug', pragmas.debug);
75
- Check.defined("array", array);
76
- //>>includeEnd('debug');
76
+ startingIndex = startingIndex ?? 0;
77
77
 
78
- startingIndex = startingIndex ?? 0;
78
+ if (!defined(result)) {
79
+ result = new Matrix2();
80
+ }
79
81
 
80
- if (!defined(result)) {
81
- result = new Matrix2();
82
+ result[0] = array[startingIndex++];
83
+ result[1] = array[startingIndex++];
84
+ result[2] = array[startingIndex++];
85
+ result[3] = array[startingIndex++];
86
+ return result;
82
87
  }
83
88
 
84
- result[0] = array[startingIndex++];
85
- result[1] = array[startingIndex++];
86
- result[2] = array[startingIndex++];
87
- result[3] = array[startingIndex++];
88
- return result;
89
- };
90
-
91
- /**
92
- * Flattens an array of Matrix2s into an array of components. The components
93
- * are stored in column-major order.
94
- *
95
- * @param {Matrix2[]} array The array of matrices to pack.
96
- * @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.
97
- * @returns {number[]} The packed array.
98
- */
99
- Matrix2.packArray = function (array, result) {
100
- //>>includeStart('debug', pragmas.debug);
101
- Check.defined("array", array);
102
- //>>includeEnd('debug');
103
-
104
- const length = array.length;
105
- const resultLength = length * 4;
106
- if (!defined(result)) {
107
- result = new Array(resultLength);
108
- } else if (!Array.isArray(result) && result.length !== resultLength) {
89
+ /**
90
+ * Flattens an array of Matrix2s into an array of components. The components
91
+ * are stored in column-major order.
92
+ *
93
+ * @param {Matrix2[]} array The array of matrices to pack.
94
+ * @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.
95
+ * @returns {number[]} The packed array.
96
+ */
97
+ static packArray(array, result) {
109
98
  //>>includeStart('debug', pragmas.debug);
110
- throw new DeveloperError(
111
- "If result is a typed array, it must have exactly array.length * 4 elements",
112
- );
99
+ Check.defined("array", array);
113
100
  //>>includeEnd('debug');
114
- } else if (result.length !== resultLength) {
115
- result.length = resultLength;
116
- }
117
101
 
118
- for (let i = 0; i < length; ++i) {
119
- Matrix2.pack(array[i], result, i * 4);
102
+ const length = array.length;
103
+ const resultLength = length * 4;
104
+ if (!defined(result)) {
105
+ result = new Array(resultLength);
106
+ // @ts-expect-error TODO(tsd-jsdoc): Requires conditional TypedArray types.
107
+ } else if (!Array.isArray(result) && result.length !== resultLength) {
108
+ //>>includeStart('debug', pragmas.debug);
109
+ throw new DeveloperError(
110
+ "If result is a typed array, it must have exactly array.length * 4 elements",
111
+ );
112
+ //>>includeEnd('debug');
113
+ } else if (result.length !== resultLength) {
114
+ /** @type {number[]} */ (result).length = resultLength;
115
+ }
116
+
117
+ for (let i = 0; i < length; ++i) {
118
+ Matrix2.pack(array[i], result, i * 4);
119
+ }
120
+
121
+ return result;
120
122
  }
121
- return result;
122
- };
123
123
 
124
- /**
125
- * Unpacks an array of column-major matrix components into an array of Matrix2s.
126
- *
127
- * @param {number[]} array The array of components to unpack.
128
- * @param {Matrix2[]} [result] The array onto which to store the result.
129
- * @returns {Matrix2[]} The unpacked array.
130
- */
131
- Matrix2.unpackArray = function (array, result) {
132
- //>>includeStart('debug', pragmas.debug);
133
- Check.defined("array", array);
134
- Check.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
135
- if (array.length % 4 !== 0) {
136
- throw new DeveloperError("array length must be a multiple of 4.");
124
+ /**
125
+ * Unpacks an array of column-major matrix components into an array of Matrix2s.
126
+ *
127
+ * @param {number[]} array The array of components to unpack.
128
+ * @param {Matrix2[]} [result] The array onto which to store the result.
129
+ * @returns {Matrix2[]} The unpacked array.
130
+ */
131
+ static unpackArray(array, result) {
132
+ //>>includeStart('debug', pragmas.debug);
133
+ Check.defined("array", array);
134
+ Check.typeOf.number.greaterThanOrEquals("array.length", array.length, 4);
135
+ if (array.length % 4 !== 0) {
136
+ throw new DeveloperError("array length must be a multiple of 4.");
137
+ }
138
+ //>>includeEnd('debug');
139
+
140
+ const length = array.length;
141
+ if (!defined(result)) {
142
+ result = new Array(length / 4);
143
+ } else {
144
+ result.length = length / 4;
145
+ }
146
+
147
+ for (let i = 0; i < length; i += 4) {
148
+ const index = i / 4;
149
+ result[index] = Matrix2.unpack(array, i, result[index]);
150
+ }
151
+ return result;
137
152
  }
138
- //>>includeEnd('debug');
139
153
 
140
- const length = array.length;
141
- if (!defined(result)) {
142
- result = new Array(length / 4);
143
- } else {
144
- result.length = length / 4;
154
+ /**
155
+ * Duplicates a Matrix2 instance.
156
+ *
157
+ * @param {Matrix2} matrix The matrix to duplicate.
158
+ * @param {Matrix2} [result] The object onto which to store the result.
159
+ * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided. (Returns undefined if matrix is undefined)
160
+ */
161
+ static clone(matrix, result) {
162
+ if (!defined(matrix)) {
163
+ return undefined;
164
+ }
165
+ if (!defined(result)) {
166
+ return new Matrix2(matrix[0], matrix[2], matrix[1], matrix[3]);
167
+ }
168
+ result[0] = matrix[0];
169
+ result[1] = matrix[1];
170
+ result[2] = matrix[2];
171
+ result[3] = matrix[3];
172
+ return result;
145
173
  }
146
174
 
147
- for (let i = 0; i < length; i += 4) {
148
- const index = i / 4;
149
- result[index] = Matrix2.unpack(array, i, result[index]);
175
+ /**
176
+ * Creates a Matrix2 instance from a column-major order array.
177
+ *
178
+ * @param {number[]} values The column-major order array.
179
+ * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.
180
+ * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.
181
+ */
182
+ static fromColumnMajorArray(values, result) {
183
+ //>>includeStart('debug', pragmas.debug);
184
+ Check.defined("values", values);
185
+ //>>includeEnd('debug');
186
+
187
+ // @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
188
+ return Matrix2.clone(values, result);
150
189
  }
151
- return result;
152
- };
153
190
 
154
- /**
155
- * Duplicates a Matrix2 instance.
156
- *
157
- * @param {Matrix2} matrix The matrix to duplicate.
158
- * @param {Matrix2} [result] The object onto which to store the result.
159
- * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided. (Returns undefined if matrix is undefined)
160
- */
161
- Matrix2.clone = function (matrix, result) {
162
- if (!defined(matrix)) {
163
- return undefined;
191
+ /**
192
+ * Creates a Matrix2 instance from a row-major order array.
193
+ * The resulting matrix will be in column-major order.
194
+ *
195
+ * @param {number[]} values The row-major order array.
196
+ * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.
197
+ * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.
198
+ */
199
+ static fromRowMajorArray(values, result) {
200
+ //>>includeStart('debug', pragmas.debug);
201
+ Check.defined("values", values);
202
+ //>>includeEnd('debug');
203
+
204
+ if (!defined(result)) {
205
+ return new Matrix2(values[0], values[1], values[2], values[3]);
206
+ }
207
+ result[0] = values[0];
208
+ result[1] = values[2];
209
+ result[2] = values[1];
210
+ result[3] = values[3];
211
+ return result;
164
212
  }
165
- if (!defined(result)) {
166
- return new Matrix2(matrix[0], matrix[2], matrix[1], matrix[3]);
213
+
214
+ /**
215
+ * Computes a Matrix2 instance representing a non-uniform scale.
216
+ *
217
+ * @param {Cartesian2} scale The x and y scale factors.
218
+ * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.
219
+ * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.
220
+ *
221
+ * @example
222
+ * // Creates
223
+ * // [7.0, 0.0]
224
+ * // [0.0, 8.0]
225
+ * const m = Cesium.Matrix2.fromScale(new Cesium.Cartesian2(7.0, 8.0));
226
+ */
227
+ static fromScale(scale, result) {
228
+ //>>includeStart('debug', pragmas.debug);
229
+ Check.typeOf.object("scale", scale);
230
+ //>>includeEnd('debug');
231
+
232
+ if (!defined(result)) {
233
+ return new Matrix2(scale.x, 0.0, 0.0, scale.y);
234
+ }
235
+
236
+ result[0] = scale.x;
237
+ result[1] = 0.0;
238
+ result[2] = 0.0;
239
+ result[3] = scale.y;
240
+ return result;
167
241
  }
168
- result[0] = matrix[0];
169
- result[1] = matrix[1];
170
- result[2] = matrix[2];
171
- result[3] = matrix[3];
172
- return result;
173
- };
174
242
 
175
- /**
176
- * Creates a Matrix2 from 4 consecutive elements in an array.
177
- *
178
- * @function
179
- * @param {number[]} array The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.
180
- * @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to first column first row position in the matrix.
181
- * @param {Matrix2} [result] The object onto which to store the result.
182
- * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.
183
- *
184
- * @example
185
- * // Create the Matrix2:
186
- * // [1.0, 2.0]
187
- * // [1.0, 2.0]
188
- *
189
- * const v = [1.0, 1.0, 2.0, 2.0];
190
- * const m = Cesium.Matrix2.fromArray(v);
191
- *
192
- * // Create same Matrix2 with using an offset into an array
193
- * const v2 = [0.0, 0.0, 1.0, 1.0, 2.0, 2.0];
194
- * const m2 = Cesium.Matrix2.fromArray(v2, 2);
195
- */
196
- Matrix2.fromArray = Matrix2.unpack;
197
- /**
198
- * Creates a Matrix2 instance from a column-major order array.
199
- *
200
- * @param {number[]} values The column-major order array.
201
- * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.
202
- * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.
203
- */
204
- Matrix2.fromColumnMajorArray = function (values, result) {
205
- //>>includeStart('debug', pragmas.debug);
206
- Check.defined("values", values);
207
- //>>includeEnd('debug');
243
+ /**
244
+ * Computes a Matrix2 instance representing a uniform scale.
245
+ *
246
+ * @param {number} scale The uniform scale factor.
247
+ * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.
248
+ * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.
249
+ *
250
+ * @example
251
+ * // Creates
252
+ * // [2.0, 0.0]
253
+ * // [0.0, 2.0]
254
+ * const m = Cesium.Matrix2.fromUniformScale(2.0);
255
+ */
256
+ static fromUniformScale(scale, result) {
257
+ //>>includeStart('debug', pragmas.debug);
258
+ Check.typeOf.number("scale", scale);
259
+ //>>includeEnd('debug');
208
260
 
209
- return Matrix2.clone(values, result);
210
- };
261
+ if (!defined(result)) {
262
+ return new Matrix2(scale, 0.0, 0.0, scale);
263
+ }
211
264
 
212
- /**
213
- * Creates a Matrix2 instance from a row-major order array.
214
- * The resulting matrix will be in column-major order.
215
- *
216
- * @param {number[]} values The row-major order array.
217
- * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.
218
- * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.
219
- */
220
- Matrix2.fromRowMajorArray = function (values, result) {
221
- //>>includeStart('debug', pragmas.debug);
222
- Check.defined("values", values);
223
- //>>includeEnd('debug');
265
+ result[0] = scale;
266
+ result[1] = 0.0;
267
+ result[2] = 0.0;
268
+ result[3] = scale;
269
+ return result;
270
+ }
271
+
272
+ /**
273
+ * Creates a rotation matrix.
274
+ *
275
+ * @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.
276
+ * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.
277
+ * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.
278
+ *
279
+ * @example
280
+ * // Rotate a point 45 degrees counterclockwise.
281
+ * const p = new Cesium.Cartesian2(5, 6);
282
+ * const m = Cesium.Matrix2.fromRotation(Cesium.Math.toRadians(45.0));
283
+ * const rotated = Cesium.Matrix2.multiplyByVector(m, p, new Cesium.Cartesian2());
284
+ */
285
+ static fromRotation(angle, result) {
286
+ //>>includeStart('debug', pragmas.debug);
287
+ Check.typeOf.number("angle", angle);
288
+ //>>includeEnd('debug');
224
289
 
225
- if (!defined(result)) {
226
- return new Matrix2(values[0], values[1], values[2], values[3]);
290
+ const cosAngle = Math.cos(angle);
291
+ const sinAngle = Math.sin(angle);
292
+
293
+ if (!defined(result)) {
294
+ return new Matrix2(cosAngle, -sinAngle, sinAngle, cosAngle);
295
+ }
296
+ result[0] = cosAngle;
297
+ result[1] = sinAngle;
298
+ result[2] = -sinAngle;
299
+ result[3] = cosAngle;
300
+ return result;
227
301
  }
228
- result[0] = values[0];
229
- result[1] = values[2];
230
- result[2] = values[1];
231
- result[3] = values[3];
232
- return result;
233
- };
234
302
 
235
- /**
236
- * Computes a Matrix2 instance representing a non-uniform scale.
237
- *
238
- * @param {Cartesian2} scale The x and y scale factors.
239
- * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.
240
- * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.
241
- *
242
- * @example
243
- * // Creates
244
- * // [7.0, 0.0]
245
- * // [0.0, 8.0]
246
- * const m = Cesium.Matrix2.fromScale(new Cesium.Cartesian2(7.0, 8.0));
247
- */
248
- Matrix2.fromScale = function (scale, result) {
249
- //>>includeStart('debug', pragmas.debug);
250
- Check.typeOf.object("scale", scale);
251
- //>>includeEnd('debug');
303
+ /**
304
+ * Creates an Array from the provided Matrix2 instance.
305
+ * The array will be in column-major order.
306
+ *
307
+ * @param {Matrix2} matrix The matrix to use..
308
+ * @param {number[]} [result] The Array onto which to store the result.
309
+ * @returns {number[]} The modified Array parameter or a new Array instance if one was not provided.
310
+ */
311
+ static toArray(matrix, result) {
312
+ //>>includeStart('debug', pragmas.debug);
313
+ Check.typeOf.object("matrix", matrix);
314
+ //>>includeEnd('debug');
252
315
 
253
- if (!defined(result)) {
254
- return new Matrix2(scale.x, 0.0, 0.0, scale.y);
316
+ if (!defined(result)) {
317
+ return [matrix[0], matrix[1], matrix[2], matrix[3]];
318
+ }
319
+ result[0] = matrix[0];
320
+ result[1] = matrix[1];
321
+ result[2] = matrix[2];
322
+ result[3] = matrix[3];
323
+ return result;
255
324
  }
256
325
 
257
- result[0] = scale.x;
258
- result[1] = 0.0;
259
- result[2] = 0.0;
260
- result[3] = scale.y;
261
- return result;
262
- };
326
+ /**
327
+ * Computes the array index of the element at the provided row and column.
328
+ *
329
+ * @param {number} row The zero-based index of the row.
330
+ * @param {number} column The zero-based index of the column.
331
+ * @returns {number} The index of the element at the provided row and column.
332
+ *
333
+ * @exception {DeveloperError} row must be 0 or 1.
334
+ * @exception {DeveloperError} column must be 0 or 1.
335
+ *
336
+ * @example
337
+ * const myMatrix = new Cesium.Matrix2();
338
+ * const column1Row0Index = Cesium.Matrix2.getElementIndex(1, 0);
339
+ * const column1Row0 = myMatrix[column1Row0Index]
340
+ * myMatrix[column1Row0Index] = 10.0;
341
+ */
342
+ static getElementIndex(column, row) {
343
+ //>>includeStart('debug', pragmas.debug);
344
+ Check.typeOf.number.greaterThanOrEquals("row", row, 0);
345
+ Check.typeOf.number.lessThanOrEquals("row", row, 1);
263
346
 
264
- /**
265
- * Computes a Matrix2 instance representing a uniform scale.
266
- *
267
- * @param {number} scale The uniform scale factor.
268
- * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.
269
- * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.
270
- *
271
- * @example
272
- * // Creates
273
- * // [2.0, 0.0]
274
- * // [0.0, 2.0]
275
- * const m = Cesium.Matrix2.fromUniformScale(2.0);
276
- */
277
- Matrix2.fromUniformScale = function (scale, result) {
278
- //>>includeStart('debug', pragmas.debug);
279
- Check.typeOf.number("scale", scale);
280
- //>>includeEnd('debug');
347
+ Check.typeOf.number.greaterThanOrEquals("column", column, 0);
348
+ Check.typeOf.number.lessThanOrEquals("column", column, 1);
349
+ //>>includeEnd('debug');
281
350
 
282
- if (!defined(result)) {
283
- return new Matrix2(scale, 0.0, 0.0, scale);
351
+ return column * 2 + row;
284
352
  }
285
353
 
286
- result[0] = scale;
287
- result[1] = 0.0;
288
- result[2] = 0.0;
289
- result[3] = scale;
290
- return result;
291
- };
354
+ /**
355
+ * Retrieves a copy of the matrix column at the provided index as a Cartesian2 instance.
356
+ *
357
+ * @param {Matrix2} matrix The matrix to use.
358
+ * @param {number} index The zero-based index of the column to retrieve.
359
+ * @param {Cartesian2} result The object onto which to store the result.
360
+ * @returns {Cartesian2} The modified result parameter.
361
+ *
362
+ * @exception {DeveloperError} index must be 0 or 1.
363
+ */
364
+ static getColumn(matrix, index, result) {
365
+ //>>includeStart('debug', pragmas.debug);
366
+ Check.typeOf.object("matrix", matrix);
292
367
 
293
- /**
294
- * Creates a rotation matrix.
295
- *
296
- * @param {number} angle The angle, in radians, of the rotation. Positive angles are counterclockwise.
297
- * @param {Matrix2} [result] The object in which the result will be stored, if undefined a new instance will be created.
298
- * @returns {Matrix2} The modified result parameter, or a new Matrix2 instance if one was not provided.
299
- *
300
- * @example
301
- * // Rotate a point 45 degrees counterclockwise.
302
- * const p = new Cesium.Cartesian2(5, 6);
303
- * const m = Cesium.Matrix2.fromRotation(Cesium.Math.toRadians(45.0));
304
- * const rotated = Cesium.Matrix2.multiplyByVector(m, p, new Cesium.Cartesian2());
305
- */
306
- Matrix2.fromRotation = function (angle, result) {
307
- //>>includeStart('debug', pragmas.debug);
308
- Check.typeOf.number("angle", angle);
309
- //>>includeEnd('debug');
368
+ Check.typeOf.number.greaterThanOrEquals("index", index, 0);
369
+ Check.typeOf.number.lessThanOrEquals("index", index, 1);
370
+
371
+ Check.typeOf.object("result", result);
372
+ //>>includeEnd('debug');
310
373
 
311
- const cosAngle = Math.cos(angle);
312
- const sinAngle = Math.sin(angle);
374
+ const startIndex = index * 2;
375
+ // @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
376
+ const x = matrix[startIndex];
377
+ // @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
378
+ const y = matrix[startIndex + 1];
313
379
 
314
- if (!defined(result)) {
315
- return new Matrix2(cosAngle, -sinAngle, sinAngle, cosAngle);
380
+ result.x = x;
381
+ result.y = y;
382
+ return result;
316
383
  }
317
- result[0] = cosAngle;
318
- result[1] = sinAngle;
319
- result[2] = -sinAngle;
320
- result[3] = cosAngle;
321
- return result;
322
- };
323
384
 
324
- /**
325
- * Creates an Array from the provided Matrix2 instance.
326
- * The array will be in column-major order.
327
- *
328
- * @param {Matrix2} matrix The matrix to use..
329
- * @param {number[]} [result] The Array onto which to store the result.
330
- * @returns {number[]} The modified Array parameter or a new Array instance if one was not provided.
331
- */
332
- Matrix2.toArray = function (matrix, result) {
333
- //>>includeStart('debug', pragmas.debug);
334
- Check.typeOf.object("matrix", matrix);
335
- //>>includeEnd('debug');
385
+ /**
386
+ * Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian2 instance.
387
+ *
388
+ * @param {Matrix2} matrix The matrix to use.
389
+ * @param {number} index The zero-based index of the column to set.
390
+ * @param {Cartesian2} cartesian The Cartesian whose values will be assigned to the specified column.
391
+ * @param {Matrix2} result The object onto which to store the result.
392
+ * @returns {Matrix2} The modified result parameter.
393
+ *
394
+ * @exception {DeveloperError} index must be 0 or 1.
395
+ */
396
+ static setColumn(matrix, index, cartesian, result) {
397
+ //>>includeStart('debug', pragmas.debug);
398
+ Check.typeOf.object("matrix", matrix);
336
399
 
337
- if (!defined(result)) {
338
- return [matrix[0], matrix[1], matrix[2], matrix[3]];
339
- }
340
- result[0] = matrix[0];
341
- result[1] = matrix[1];
342
- result[2] = matrix[2];
343
- result[3] = matrix[3];
344
- return result;
345
- };
400
+ Check.typeOf.number.greaterThanOrEquals("index", index, 0);
401
+ Check.typeOf.number.lessThanOrEquals("index", index, 1);
346
402
 
347
- /**
348
- * Computes the array index of the element at the provided row and column.
349
- *
350
- * @param {number} row The zero-based index of the row.
351
- * @param {number} column The zero-based index of the column.
352
- * @returns {number} The index of the element at the provided row and column.
353
- *
354
- * @exception {DeveloperError} row must be 0 or 1.
355
- * @exception {DeveloperError} column must be 0 or 1.
356
- *
357
- * @example
358
- * const myMatrix = new Cesium.Matrix2();
359
- * const column1Row0Index = Cesium.Matrix2.getElementIndex(1, 0);
360
- * const column1Row0 = myMatrix[column1Row0Index]
361
- * myMatrix[column1Row0Index] = 10.0;
362
- */
363
- Matrix2.getElementIndex = function (column, row) {
364
- //>>includeStart('debug', pragmas.debug);
365
- Check.typeOf.number.greaterThanOrEquals("row", row, 0);
366
- Check.typeOf.number.lessThanOrEquals("row", row, 1);
403
+ Check.typeOf.object("cartesian", cartesian);
404
+ Check.typeOf.object("result", result);
405
+ //>>includeEnd('debug');
367
406
 
368
- Check.typeOf.number.greaterThanOrEquals("column", column, 0);
369
- Check.typeOf.number.lessThanOrEquals("column", column, 1);
370
- //>>includeEnd('debug');
407
+ result = Matrix2.clone(matrix, result);
408
+ const startIndex = index * 2;
409
+ // @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
410
+ result[startIndex] = cartesian.x;
411
+ // @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
412
+ result[startIndex + 1] = cartesian.y;
413
+ return result;
414
+ }
371
415
 
372
- return column * 2 + row;
373
- };
416
+ /**
417
+ * Retrieves a copy of the matrix row at the provided index as a Cartesian2 instance.
418
+ *
419
+ * @param {Matrix2} matrix The matrix to use.
420
+ * @param {number} index The zero-based index of the row to retrieve.
421
+ * @param {Cartesian2} result The object onto which to store the result.
422
+ * @returns {Cartesian2} The modified result parameter.
423
+ *
424
+ * @exception {DeveloperError} index must be 0 or 1.
425
+ */
426
+ static getRow(matrix, index, result) {
427
+ //>>includeStart('debug', pragmas.debug);
428
+ Check.typeOf.object("matrix", matrix);
374
429
 
375
- /**
376
- * Retrieves a copy of the matrix column at the provided index as a Cartesian2 instance.
377
- *
378
- * @param {Matrix2} matrix The matrix to use.
379
- * @param {number} index The zero-based index of the column to retrieve.
380
- * @param {Cartesian2} result The object onto which to store the result.
381
- * @returns {Cartesian2} The modified result parameter.
382
- *
383
- * @exception {DeveloperError} index must be 0 or 1.
384
- */
385
- Matrix2.getColumn = function (matrix, index, result) {
386
- //>>includeStart('debug', pragmas.debug);
387
- Check.typeOf.object("matrix", matrix);
430
+ Check.typeOf.number.greaterThanOrEquals("index", index, 0);
431
+ Check.typeOf.number.lessThanOrEquals("index", index, 1);
388
432
 
389
- Check.typeOf.number.greaterThanOrEquals("index", index, 0);
390
- Check.typeOf.number.lessThanOrEquals("index", index, 1);
433
+ Check.typeOf.object("result", result);
434
+ //>>includeEnd('debug');
391
435
 
392
- Check.typeOf.object("result", result);
393
- //>>includeEnd('debug');
436
+ // @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
437
+ const x = matrix[index];
438
+ // @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
439
+ const y = matrix[index + 2];
394
440
 
395
- const startIndex = index * 2;
396
- const x = matrix[startIndex];
397
- const y = matrix[startIndex + 1];
441
+ result.x = x;
442
+ result.y = y;
443
+ return result;
444
+ }
398
445
 
399
- result.x = x;
400
- result.y = y;
401
- return result;
402
- };
446
+ /**
447
+ * Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian2 instance.
448
+ *
449
+ * @param {Matrix2} matrix The matrix to use.
450
+ * @param {number} index The zero-based index of the row to set.
451
+ * @param {Cartesian2} cartesian The Cartesian whose values will be assigned to the specified row.
452
+ * @param {Matrix2} result The object onto which to store the result.
453
+ * @returns {Matrix2} The modified result parameter.
454
+ *
455
+ * @exception {DeveloperError} index must be 0 or 1.
456
+ */
457
+ static setRow(matrix, index, cartesian, result) {
458
+ //>>includeStart('debug', pragmas.debug);
459
+ Check.typeOf.object("matrix", matrix);
403
460
 
404
- /**
405
- * Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian2 instance.
406
- *
407
- * @param {Matrix2} matrix The matrix to use.
408
- * @param {number} index The zero-based index of the column to set.
409
- * @param {Cartesian2} cartesian The Cartesian whose values will be assigned to the specified column.
410
- * @param {Cartesian2} result The object onto which to store the result.
411
- * @returns {Matrix2} The modified result parameter.
412
- *
413
- * @exception {DeveloperError} index must be 0 or 1.
414
- */
415
- Matrix2.setColumn = function (matrix, index, cartesian, result) {
416
- //>>includeStart('debug', pragmas.debug);
417
- Check.typeOf.object("matrix", matrix);
461
+ Check.typeOf.number.greaterThanOrEquals("index", index, 0);
462
+ Check.typeOf.number.lessThanOrEquals("index", index, 1);
418
463
 
419
- Check.typeOf.number.greaterThanOrEquals("index", index, 0);
420
- Check.typeOf.number.lessThanOrEquals("index", index, 1);
464
+ Check.typeOf.object("cartesian", cartesian);
465
+ Check.typeOf.object("result", result);
466
+ //>>includeEnd('debug');
421
467
 
422
- Check.typeOf.object("cartesian", cartesian);
423
- Check.typeOf.object("result", result);
424
- //>>includeEnd('debug');
468
+ result = Matrix2.clone(matrix, result);
469
+ // @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
470
+ result[index] = cartesian.x;
471
+ // @ts-expect-error TODO(tsd-jsdoc): Requires index signature support.
472
+ result[index + 2] = cartesian.y;
473
+ return result;
474
+ }
425
475
 
426
- result = Matrix2.clone(matrix, result);
427
- const startIndex = index * 2;
428
- result[startIndex] = cartesian.x;
429
- result[startIndex + 1] = cartesian.y;
430
- return result;
431
- };
476
+ /**
477
+ * Computes a new matrix that replaces the scale with the provided scale.
478
+ * This assumes the matrix is an affine transformation.
479
+ *
480
+ * @param {Matrix2} matrix The matrix to use.
481
+ * @param {Cartesian2} scale The scale that replaces the scale of the provided matrix.
482
+ * @param {Matrix2} result The object onto which to store the result.
483
+ * @returns {Matrix2} The modified result parameter.
484
+ *
485
+ * @see Matrix2.setUniformScale
486
+ * @see Matrix2.fromScale
487
+ * @see Matrix2.fromUniformScale
488
+ * @see Matrix2.multiplyByScale
489
+ * @see Matrix2.multiplyByUniformScale
490
+ * @see Matrix2.getScale
491
+ */
492
+ static setScale(matrix, scale, result) {
493
+ //>>includeStart('debug', pragmas.debug);
494
+ Check.typeOf.object("matrix", matrix);
495
+ Check.typeOf.object("scale", scale);
496
+ Check.typeOf.object("result", result);
497
+ //>>includeEnd('debug');
432
498
 
433
- /**
434
- * Retrieves a copy of the matrix row at the provided index as a Cartesian2 instance.
435
- *
436
- * @param {Matrix2} matrix The matrix to use.
437
- * @param {number} index The zero-based index of the row to retrieve.
438
- * @param {Cartesian2} result The object onto which to store the result.
439
- * @returns {Cartesian2} The modified result parameter.
440
- *
441
- * @exception {DeveloperError} index must be 0 or 1.
442
- */
443
- Matrix2.getRow = function (matrix, index, result) {
444
- //>>includeStart('debug', pragmas.debug);
445
- Check.typeOf.object("matrix", matrix);
499
+ const existingScale = Matrix2.getScale(matrix, scaleScratch1);
500
+ const scaleRatioX = scale.x / existingScale.x;
501
+ const scaleRatioY = scale.y / existingScale.y;
446
502
 
447
- Check.typeOf.number.greaterThanOrEquals("index", index, 0);
448
- Check.typeOf.number.lessThanOrEquals("index", index, 1);
503
+ result[0] = matrix[0] * scaleRatioX;
504
+ result[1] = matrix[1] * scaleRatioX;
505
+ result[2] = matrix[2] * scaleRatioY;
506
+ result[3] = matrix[3] * scaleRatioY;
449
507
 
450
- Check.typeOf.object("result", result);
451
- //>>includeEnd('debug');
508
+ return result;
509
+ }
452
510
 
453
- const x = matrix[index];
454
- const y = matrix[index + 2];
511
+ /**
512
+ * Computes a new matrix that replaces the scale with the provided uniform scale.
513
+ * This assumes the matrix is an affine transformation.
514
+ *
515
+ * @param {Matrix2} matrix The matrix to use.
516
+ * @param {number} scale The uniform scale that replaces the scale of the provided matrix.
517
+ * @param {Matrix2} result The object onto which to store the result.
518
+ * @returns {Matrix2} The modified result parameter.
519
+ *
520
+ * @see Matrix2.setScale
521
+ * @see Matrix2.fromScale
522
+ * @see Matrix2.fromUniformScale
523
+ * @see Matrix2.multiplyByScale
524
+ * @see Matrix2.multiplyByUniformScale
525
+ * @see Matrix2.getScale
526
+ */
527
+ static setUniformScale(matrix, scale, result) {
528
+ //>>includeStart('debug', pragmas.debug);
529
+ Check.typeOf.object("matrix", matrix);
530
+ Check.typeOf.number("scale", scale);
531
+ Check.typeOf.object("result", result);
532
+ //>>includeEnd('debug');
455
533
 
456
- result.x = x;
457
- result.y = y;
458
- return result;
459
- };
534
+ const existingScale = Matrix2.getScale(matrix, scaleScratch2);
535
+ const scaleRatioX = scale / existingScale.x;
536
+ const scaleRatioY = scale / existingScale.y;
460
537
 
461
- /**
462
- * Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian2 instance.
463
- *
464
- * @param {Matrix2} matrix The matrix to use.
465
- * @param {number} index The zero-based index of the row to set.
466
- * @param {Cartesian2} cartesian The Cartesian whose values will be assigned to the specified row.
467
- * @param {Matrix2} result The object onto which to store the result.
468
- * @returns {Matrix2} The modified result parameter.
469
- *
470
- * @exception {DeveloperError} index must be 0 or 1.
471
- */
472
- Matrix2.setRow = function (matrix, index, cartesian, result) {
473
- //>>includeStart('debug', pragmas.debug);
474
- Check.typeOf.object("matrix", matrix);
538
+ result[0] = matrix[0] * scaleRatioX;
539
+ result[1] = matrix[1] * scaleRatioX;
540
+ result[2] = matrix[2] * scaleRatioY;
541
+ result[3] = matrix[3] * scaleRatioY;
475
542
 
476
- Check.typeOf.number.greaterThanOrEquals("index", index, 0);
477
- Check.typeOf.number.lessThanOrEquals("index", index, 1);
543
+ return result;
544
+ }
478
545
 
479
- Check.typeOf.object("cartesian", cartesian);
480
- Check.typeOf.object("result", result);
481
- //>>includeEnd('debug');
546
+ /**
547
+ * Extracts the non-uniform scale assuming the matrix is an affine transformation.
548
+ *
549
+ * @param {Matrix2} matrix The matrix.
550
+ * @param {Cartesian2} result The object onto which to store the result.
551
+ * @returns {Cartesian2} The modified result parameter.
552
+ *
553
+ * @see Matrix2.multiplyByScale
554
+ * @see Matrix2.multiplyByUniformScale
555
+ * @see Matrix2.fromScale
556
+ * @see Matrix2.fromUniformScale
557
+ * @see Matrix2.setScale
558
+ * @see Matrix2.setUniformScale
559
+ */
560
+ static getScale(matrix, result) {
561
+ //>>includeStart('debug', pragmas.debug);
562
+ Check.typeOf.object("matrix", matrix);
563
+ Check.typeOf.object("result", result);
564
+ //>>includeEnd('debug');
482
565
 
483
- result = Matrix2.clone(matrix, result);
484
- result[index] = cartesian.x;
485
- result[index + 2] = cartesian.y;
486
- return result;
487
- };
566
+ result.x = Cartesian2.magnitude(
567
+ Cartesian2.fromElements(matrix[0], matrix[1], scratchColumn),
568
+ );
569
+ result.y = Cartesian2.magnitude(
570
+ Cartesian2.fromElements(matrix[2], matrix[3], scratchColumn),
571
+ );
572
+ return result;
573
+ }
488
574
 
489
- const scaleScratch1 = new Cartesian2();
575
+ /**
576
+ * Computes the maximum scale assuming the matrix is an affine transformation.
577
+ * The maximum scale is the maximum length of the column vectors.
578
+ *
579
+ * @param {Matrix2} matrix The matrix.
580
+ * @returns {number} The maximum scale.
581
+ */
582
+ static getMaximumScale(matrix) {
583
+ Matrix2.getScale(matrix, scaleScratch3);
584
+ return Cartesian2.maximumComponent(scaleScratch3);
585
+ }
490
586
 
491
- /**
492
- * Computes a new matrix that replaces the scale with the provided scale.
493
- * This assumes the matrix is an affine transformation.
494
- *
495
- * @param {Matrix2} matrix The matrix to use.
496
- * @param {Cartesian2} scale The scale that replaces the scale of the provided matrix.
497
- * @param {Matrix2} result The object onto which to store the result.
498
- * @returns {Matrix2} The modified result parameter.
499
- *
500
- * @see Matrix2.setUniformScale
501
- * @see Matrix2.fromScale
502
- * @see Matrix2.fromUniformScale
503
- * @see Matrix2.multiplyByScale
504
- * @see Matrix2.multiplyByUniformScale
505
- * @see Matrix2.getScale
506
- */
507
- Matrix2.setScale = function (matrix, scale, result) {
508
- //>>includeStart('debug', pragmas.debug);
509
- Check.typeOf.object("matrix", matrix);
510
- Check.typeOf.object("scale", scale);
511
- Check.typeOf.object("result", result);
512
- //>>includeEnd('debug');
587
+ /**
588
+ * Sets the rotation assuming the matrix is an affine transformation.
589
+ *
590
+ * @param {Matrix2} matrix The matrix.
591
+ * @param {Matrix2} rotation The rotation matrix.
592
+ * @param {Matrix2} result The object onto which to store the result.
593
+ * @returns {Matrix2} The modified result parameter.
594
+ *
595
+ * @see Matrix2.fromRotation
596
+ * @see Matrix2.getRotation
597
+ */
598
+ static setRotation(matrix, rotation, result) {
599
+ //>>includeStart('debug', pragmas.debug);
600
+ Check.typeOf.object("matrix", matrix);
601
+ Check.typeOf.object("result", result);
602
+ //>>includeEnd('debug');
513
603
 
514
- const existingScale = Matrix2.getScale(matrix, scaleScratch1);
515
- const scaleRatioX = scale.x / existingScale.x;
516
- const scaleRatioY = scale.y / existingScale.y;
604
+ const scale = Matrix2.getScale(matrix, scaleScratch4);
517
605
 
518
- result[0] = matrix[0] * scaleRatioX;
519
- result[1] = matrix[1] * scaleRatioX;
520
- result[2] = matrix[2] * scaleRatioY;
521
- result[3] = matrix[3] * scaleRatioY;
606
+ result[0] = rotation[0] * scale.x;
607
+ result[1] = rotation[1] * scale.x;
608
+ result[2] = rotation[2] * scale.y;
609
+ result[3] = rotation[3] * scale.y;
522
610
 
523
- return result;
524
- };
611
+ return result;
612
+ }
525
613
 
526
- const scaleScratch2 = new Cartesian2();
614
+ /**
615
+ * Extracts the rotation matrix assuming the matrix is an affine transformation.
616
+ *
617
+ * @param {Matrix2} matrix The matrix.
618
+ * @param {Matrix2} result The object onto which to store the result.
619
+ * @returns {Matrix2} The modified result parameter.
620
+ *
621
+ * @see Matrix2.setRotation
622
+ * @see Matrix2.fromRotation
623
+ */
624
+ static getRotation(matrix, result) {
625
+ //>>includeStart('debug', pragmas.debug);
626
+ Check.typeOf.object("matrix", matrix);
627
+ Check.typeOf.object("result", result);
628
+ //>>includeEnd('debug');
527
629
 
528
- /**
529
- * Computes a new matrix that replaces the scale with the provided uniform scale.
530
- * This assumes the matrix is an affine transformation.
531
- *
532
- * @param {Matrix2} matrix The matrix to use.
533
- * @param {number} scale The uniform scale that replaces the scale of the provided matrix.
534
- * @param {Matrix2} result The object onto which to store the result.
535
- * @returns {Matrix2} The modified result parameter.
536
- *
537
- * @see Matrix2.setScale
538
- * @see Matrix2.fromScale
539
- * @see Matrix2.fromUniformScale
540
- * @see Matrix2.multiplyByScale
541
- * @see Matrix2.multiplyByUniformScale
542
- * @see Matrix2.getScale
543
- */
544
- Matrix2.setUniformScale = function (matrix, scale, result) {
545
- //>>includeStart('debug', pragmas.debug);
546
- Check.typeOf.object("matrix", matrix);
547
- Check.typeOf.number("scale", scale);
548
- Check.typeOf.object("result", result);
549
- //>>includeEnd('debug');
630
+ const scale = Matrix2.getScale(matrix, scaleScratch5);
550
631
 
551
- const existingScale = Matrix2.getScale(matrix, scaleScratch2);
552
- const scaleRatioX = scale / existingScale.x;
553
- const scaleRatioY = scale / existingScale.y;
632
+ result[0] = matrix[0] / scale.x;
633
+ result[1] = matrix[1] / scale.x;
634
+ result[2] = matrix[2] / scale.y;
635
+ result[3] = matrix[3] / scale.y;
554
636
 
555
- result[0] = matrix[0] * scaleRatioX;
556
- result[1] = matrix[1] * scaleRatioX;
557
- result[2] = matrix[2] * scaleRatioY;
558
- result[3] = matrix[3] * scaleRatioY;
637
+ return result;
638
+ }
559
639
 
560
- return result;
561
- };
640
+ /**
641
+ * Computes the product of two matrices.
642
+ *
643
+ * @param {Matrix2} left The first matrix.
644
+ * @param {Matrix2} right The second matrix.
645
+ * @param {Matrix2} result The object onto which to store the result.
646
+ * @returns {Matrix2} The modified result parameter.
647
+ */
648
+ static multiply(left, right, result) {
649
+ //>>includeStart('debug', pragmas.debug);
650
+ Check.typeOf.object("left", left);
651
+ Check.typeOf.object("right", right);
652
+ Check.typeOf.object("result", result);
653
+ //>>includeEnd('debug');
562
654
 
563
- const scratchColumn = new Cartesian2();
655
+ const column0Row0 = left[0] * right[0] + left[2] * right[1];
656
+ const column1Row0 = left[0] * right[2] + left[2] * right[3];
657
+ const column0Row1 = left[1] * right[0] + left[3] * right[1];
658
+ const column1Row1 = left[1] * right[2] + left[3] * right[3];
564
659
 
565
- /**
566
- * Extracts the non-uniform scale assuming the matrix is an affine transformation.
567
- *
568
- * @param {Matrix2} matrix The matrix.
569
- * @param {Cartesian2} result The object onto which to store the result.
570
- * @returns {Cartesian2} The modified result parameter.
571
- *
572
- * @see Matrix2.multiplyByScale
573
- * @see Matrix2.multiplyByUniformScale
574
- * @see Matrix2.fromScale
575
- * @see Matrix2.fromUniformScale
576
- * @see Matrix2.setScale
577
- * @see Matrix2.setUniformScale
578
- */
579
- Matrix2.getScale = function (matrix, result) {
580
- //>>includeStart('debug', pragmas.debug);
581
- Check.typeOf.object("matrix", matrix);
582
- Check.typeOf.object("result", result);
583
- //>>includeEnd('debug');
584
-
585
- result.x = Cartesian2.magnitude(
586
- Cartesian2.fromElements(matrix[0], matrix[1], scratchColumn),
587
- );
588
- result.y = Cartesian2.magnitude(
589
- Cartesian2.fromElements(matrix[2], matrix[3], scratchColumn),
590
- );
591
- return result;
592
- };
660
+ result[0] = column0Row0;
661
+ result[1] = column0Row1;
662
+ result[2] = column1Row0;
663
+ result[3] = column1Row1;
664
+ return result;
665
+ }
593
666
 
594
- const scaleScratch3 = new Cartesian2();
667
+ /**
668
+ * Computes the sum of two matrices.
669
+ *
670
+ * @param {Matrix2} left The first matrix.
671
+ * @param {Matrix2} right The second matrix.
672
+ * @param {Matrix2} result The object onto which to store the result.
673
+ * @returns {Matrix2} The modified result parameter.
674
+ */
675
+ static add(left, right, result) {
676
+ //>>includeStart('debug', pragmas.debug);
677
+ Check.typeOf.object("left", left);
678
+ Check.typeOf.object("right", right);
679
+ Check.typeOf.object("result", result);
680
+ //>>includeEnd('debug');
595
681
 
596
- /**
597
- * Computes the maximum scale assuming the matrix is an affine transformation.
598
- * The maximum scale is the maximum length of the column vectors.
599
- *
600
- * @param {Matrix2} matrix The matrix.
601
- * @returns {number} The maximum scale.
602
- */
603
- Matrix2.getMaximumScale = function (matrix) {
604
- Matrix2.getScale(matrix, scaleScratch3);
605
- return Cartesian2.maximumComponent(scaleScratch3);
606
- };
682
+ result[0] = left[0] + right[0];
683
+ result[1] = left[1] + right[1];
684
+ result[2] = left[2] + right[2];
685
+ result[3] = left[3] + right[3];
686
+ return result;
687
+ }
607
688
 
608
- const scaleScratch4 = new Cartesian2();
689
+ /**
690
+ * Computes the difference of two matrices.
691
+ *
692
+ * @param {Matrix2} left The first matrix.
693
+ * @param {Matrix2} right The second matrix.
694
+ * @param {Matrix2} result The object onto which to store the result.
695
+ * @returns {Matrix2} The modified result parameter.
696
+ */
697
+ static subtract(left, right, result) {
698
+ //>>includeStart('debug', pragmas.debug);
699
+ Check.typeOf.object("left", left);
700
+ Check.typeOf.object("right", right);
701
+ Check.typeOf.object("result", result);
702
+ //>>includeEnd('debug');
609
703
 
610
- /**
611
- * Sets the rotation assuming the matrix is an affine transformation.
612
- *
613
- * @param {Matrix2} matrix The matrix.
614
- * @param {Matrix2} rotation The rotation matrix.
615
- * @param {Matrix2} result The object onto which to store the result.
616
- * @returns {Matrix2} The modified result parameter.
617
- *
618
- * @see Matrix2.fromRotation
619
- * @see Matrix2.getRotation
620
- */
621
- Matrix2.setRotation = function (matrix, rotation, result) {
622
- //>>includeStart('debug', pragmas.debug);
623
- Check.typeOf.object("matrix", matrix);
624
- Check.typeOf.object("result", result);
625
- //>>includeEnd('debug');
704
+ result[0] = left[0] - right[0];
705
+ result[1] = left[1] - right[1];
706
+ result[2] = left[2] - right[2];
707
+ result[3] = left[3] - right[3];
708
+ return result;
709
+ }
626
710
 
627
- const scale = Matrix2.getScale(matrix, scaleScratch4);
711
+ /**
712
+ * Computes the product of a matrix and a column vector.
713
+ *
714
+ * @param {Matrix2} matrix The matrix.
715
+ * @param {Cartesian2} cartesian The column.
716
+ * @param {Cartesian2} result The object onto which to store the result.
717
+ * @returns {Cartesian2} The modified result parameter.
718
+ */
719
+ static multiplyByVector(matrix, cartesian, result) {
720
+ //>>includeStart('debug', pragmas.debug);
721
+ Check.typeOf.object("matrix", matrix);
722
+ Check.typeOf.object("cartesian", cartesian);
723
+ Check.typeOf.object("result", result);
724
+ //>>includeEnd('debug');
628
725
 
629
- result[0] = rotation[0] * scale.x;
630
- result[1] = rotation[1] * scale.x;
631
- result[2] = rotation[2] * scale.y;
632
- result[3] = rotation[3] * scale.y;
726
+ const x = matrix[0] * cartesian.x + matrix[2] * cartesian.y;
727
+ const y = matrix[1] * cartesian.x + matrix[3] * cartesian.y;
633
728
 
634
- return result;
635
- };
729
+ result.x = x;
730
+ result.y = y;
731
+ return result;
732
+ }
636
733
 
637
- const scaleScratch5 = new Cartesian2();
734
+ /**
735
+ * Computes the product of a matrix and a scalar.
736
+ *
737
+ * @param {Matrix2} matrix The matrix.
738
+ * @param {number} scalar The number to multiply by.
739
+ * @param {Matrix2} result The object onto which to store the result.
740
+ * @returns {Matrix2} The modified result parameter.
741
+ */
742
+ static multiplyByScalar(matrix, scalar, result) {
743
+ //>>includeStart('debug', pragmas.debug);
744
+ Check.typeOf.object("matrix", matrix);
745
+ Check.typeOf.number("scalar", scalar);
746
+ Check.typeOf.object("result", result);
747
+ //>>includeEnd('debug');
638
748
 
639
- /**
640
- * Extracts the rotation matrix assuming the matrix is an affine transformation.
641
- *
642
- * @param {Matrix2} matrix The matrix.
643
- * @param {Matrix2} result The object onto which to store the result.
644
- * @returns {Matrix2} The modified result parameter.
645
- *
646
- * @see Matrix2.setRotation
647
- * @see Matrix2.fromRotation
648
- */
649
- Matrix2.getRotation = function (matrix, result) {
650
- //>>includeStart('debug', pragmas.debug);
651
- Check.typeOf.object("matrix", matrix);
652
- Check.typeOf.object("result", result);
653
- //>>includeEnd('debug');
749
+ result[0] = matrix[0] * scalar;
750
+ result[1] = matrix[1] * scalar;
751
+ result[2] = matrix[2] * scalar;
752
+ result[3] = matrix[3] * scalar;
753
+ return result;
754
+ }
654
755
 
655
- const scale = Matrix2.getScale(matrix, scaleScratch5);
756
+ /**
757
+ * Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.
758
+ *
759
+ * @param {Matrix2} matrix The matrix on the left-hand side.
760
+ * @param {Cartesian2} scale The non-uniform scale on the right-hand side.
761
+ * @param {Matrix2} result The object onto which to store the result.
762
+ * @returns {Matrix2} The modified result parameter.
763
+ *
764
+ *
765
+ * @example
766
+ * // Instead of Cesium.Matrix2.multiply(m, Cesium.Matrix2.fromScale(scale), m);
767
+ * Cesium.Matrix2.multiplyByScale(m, scale, m);
768
+ *
769
+ * @see Matrix2.multiplyByUniformScale
770
+ * @see Matrix2.fromScale
771
+ * @see Matrix2.fromUniformScale
772
+ * @see Matrix2.setScale
773
+ * @see Matrix2.setUniformScale
774
+ * @see Matrix2.getScale
775
+ */
776
+ static multiplyByScale(matrix, scale, result) {
777
+ //>>includeStart('debug', pragmas.debug);
778
+ Check.typeOf.object("matrix", matrix);
779
+ Check.typeOf.object("scale", scale);
780
+ Check.typeOf.object("result", result);
781
+ //>>includeEnd('debug');
656
782
 
657
- result[0] = matrix[0] / scale.x;
658
- result[1] = matrix[1] / scale.x;
659
- result[2] = matrix[2] / scale.y;
660
- result[3] = matrix[3] / scale.y;
783
+ result[0] = matrix[0] * scale.x;
784
+ result[1] = matrix[1] * scale.x;
785
+ result[2] = matrix[2] * scale.y;
786
+ result[3] = matrix[3] * scale.y;
661
787
 
662
- return result;
663
- };
788
+ return result;
789
+ }
664
790
 
665
- /**
666
- * Computes the product of two matrices.
667
- *
668
- * @param {Matrix2} left The first matrix.
669
- * @param {Matrix2} right The second matrix.
670
- * @param {Matrix2} result The object onto which to store the result.
671
- * @returns {Matrix2} The modified result parameter.
672
- */
673
- Matrix2.multiply = function (left, right, result) {
674
- //>>includeStart('debug', pragmas.debug);
675
- Check.typeOf.object("left", left);
676
- Check.typeOf.object("right", right);
677
- Check.typeOf.object("result", result);
678
- //>>includeEnd('debug');
679
-
680
- const column0Row0 = left[0] * right[0] + left[2] * right[1];
681
- const column1Row0 = left[0] * right[2] + left[2] * right[3];
682
- const column0Row1 = left[1] * right[0] + left[3] * right[1];
683
- const column1Row1 = left[1] * right[2] + left[3] * right[3];
684
-
685
- result[0] = column0Row0;
686
- result[1] = column0Row1;
687
- result[2] = column1Row0;
688
- result[3] = column1Row1;
689
- return result;
690
- };
791
+ /**
792
+ * Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.
793
+ *
794
+ * @param {Matrix2} matrix The matrix on the left-hand side.
795
+ * @param {number} scale The uniform scale on the right-hand side.
796
+ * @param {Matrix2} result The object onto which to store the result.
797
+ * @returns {Matrix2} The modified result parameter.
798
+ *
799
+ * @example
800
+ * // Instead of Cesium.Matrix2.multiply(m, Cesium.Matrix2.fromUniformScale(scale), m);
801
+ * Cesium.Matrix2.multiplyByUniformScale(m, scale, m);
802
+ *
803
+ * @see Matrix2.multiplyByScale
804
+ * @see Matrix2.fromScale
805
+ * @see Matrix2.fromUniformScale
806
+ * @see Matrix2.setScale
807
+ * @see Matrix2.setUniformScale
808
+ * @see Matrix2.getScale
809
+ */
810
+ static multiplyByUniformScale(matrix, scale, result) {
811
+ //>>includeStart('debug', pragmas.debug);
812
+ Check.typeOf.object("matrix", matrix);
813
+ Check.typeOf.number("scale", scale);
814
+ Check.typeOf.object("result", result);
815
+ //>>includeEnd('debug');
691
816
 
692
- /**
693
- * Computes the sum of two matrices.
694
- *
695
- * @param {Matrix2} left The first matrix.
696
- * @param {Matrix2} right The second matrix.
697
- * @param {Matrix2} result The object onto which to store the result.
698
- * @returns {Matrix2} The modified result parameter.
699
- */
700
- Matrix2.add = function (left, right, result) {
701
- //>>includeStart('debug', pragmas.debug);
702
- Check.typeOf.object("left", left);
703
- Check.typeOf.object("right", right);
704
- Check.typeOf.object("result", result);
705
- //>>includeEnd('debug');
706
-
707
- result[0] = left[0] + right[0];
708
- result[1] = left[1] + right[1];
709
- result[2] = left[2] + right[2];
710
- result[3] = left[3] + right[3];
711
- return result;
712
- };
817
+ result[0] = matrix[0] * scale;
818
+ result[1] = matrix[1] * scale;
819
+ result[2] = matrix[2] * scale;
820
+ result[3] = matrix[3] * scale;
713
821
 
714
- /**
715
- * Computes the difference of two matrices.
716
- *
717
- * @param {Matrix2} left The first matrix.
718
- * @param {Matrix2} right The second matrix.
719
- * @param {Matrix2} result The object onto which to store the result.
720
- * @returns {Matrix2} The modified result parameter.
721
- */
722
- Matrix2.subtract = function (left, right, result) {
723
- //>>includeStart('debug', pragmas.debug);
724
- Check.typeOf.object("left", left);
725
- Check.typeOf.object("right", right);
726
- Check.typeOf.object("result", result);
727
- //>>includeEnd('debug');
728
-
729
- result[0] = left[0] - right[0];
730
- result[1] = left[1] - right[1];
731
- result[2] = left[2] - right[2];
732
- result[3] = left[3] - right[3];
733
- return result;
734
- };
822
+ return result;
823
+ }
735
824
 
736
- /**
737
- * Computes the product of a matrix and a column vector.
738
- *
739
- * @param {Matrix2} matrix The matrix.
740
- * @param {Cartesian2} cartesian The column.
741
- * @param {Cartesian2} result The object onto which to store the result.
742
- * @returns {Cartesian2} The modified result parameter.
743
- */
744
- Matrix2.multiplyByVector = function (matrix, cartesian, result) {
745
- //>>includeStart('debug', pragmas.debug);
746
- Check.typeOf.object("matrix", matrix);
747
- Check.typeOf.object("cartesian", cartesian);
748
- Check.typeOf.object("result", result);
749
- //>>includeEnd('debug');
825
+ /**
826
+ * Creates a negated copy of the provided matrix.
827
+ *
828
+ * @param {Matrix2} matrix The matrix to negate.
829
+ * @param {Matrix2} result The object onto which to store the result.
830
+ * @returns {Matrix2} The modified result parameter.
831
+ */
832
+ static negate(matrix, result) {
833
+ //>>includeStart('debug', pragmas.debug);
834
+ Check.typeOf.object("matrix", matrix);
835
+ Check.typeOf.object("result", result);
836
+ //>>includeEnd('debug');
750
837
 
751
- const x = matrix[0] * cartesian.x + matrix[2] * cartesian.y;
752
- const y = matrix[1] * cartesian.x + matrix[3] * cartesian.y;
838
+ result[0] = -matrix[0];
839
+ result[1] = -matrix[1];
840
+ result[2] = -matrix[2];
841
+ result[3] = -matrix[3];
842
+ return result;
843
+ }
753
844
 
754
- result.x = x;
755
- result.y = y;
756
- return result;
757
- };
845
+ /**
846
+ * Computes the transpose of the provided matrix.
847
+ *
848
+ * @param {Matrix2} matrix The matrix to transpose.
849
+ * @param {Matrix2} result The object onto which to store the result.
850
+ * @returns {Matrix2} The modified result parameter.
851
+ */
852
+ static transpose(matrix, result) {
853
+ //>>includeStart('debug', pragmas.debug);
854
+ Check.typeOf.object("matrix", matrix);
855
+ Check.typeOf.object("result", result);
856
+ //>>includeEnd('debug');
758
857
 
759
- /**
760
- * Computes the product of a matrix and a scalar.
761
- *
762
- * @param {Matrix2} matrix The matrix.
763
- * @param {number} scalar The number to multiply by.
764
- * @param {Matrix2} result The object onto which to store the result.
765
- * @returns {Matrix2} The modified result parameter.
766
- */
767
- Matrix2.multiplyByScalar = function (matrix, scalar, result) {
768
- //>>includeStart('debug', pragmas.debug);
769
- Check.typeOf.object("matrix", matrix);
770
- Check.typeOf.number("scalar", scalar);
771
- Check.typeOf.object("result", result);
772
- //>>includeEnd('debug');
773
-
774
- result[0] = matrix[0] * scalar;
775
- result[1] = matrix[1] * scalar;
776
- result[2] = matrix[2] * scalar;
777
- result[3] = matrix[3] * scalar;
778
- return result;
779
- };
858
+ const column0Row0 = matrix[0];
859
+ const column0Row1 = matrix[2];
860
+ const column1Row0 = matrix[1];
861
+ const column1Row1 = matrix[3];
780
862
 
781
- /**
782
- * Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.
783
- *
784
- * @param {Matrix2} matrix The matrix on the left-hand side.
785
- * @param {Cartesian2} scale The non-uniform scale on the right-hand side.
786
- * @param {Matrix2} result The object onto which to store the result.
787
- * @returns {Matrix2} The modified result parameter.
788
- *
789
- *
790
- * @example
791
- * // Instead of Cesium.Matrix2.multiply(m, Cesium.Matrix2.fromScale(scale), m);
792
- * Cesium.Matrix2.multiplyByScale(m, scale, m);
793
- *
794
- * @see Matrix2.multiplyByUniformScale
795
- * @see Matrix2.fromScale
796
- * @see Matrix2.fromUniformScale
797
- * @see Matrix2.setScale
798
- * @see Matrix2.setUniformScale
799
- * @see Matrix2.getScale
800
- */
801
- Matrix2.multiplyByScale = function (matrix, scale, result) {
802
- //>>includeStart('debug', pragmas.debug);
803
- Check.typeOf.object("matrix", matrix);
804
- Check.typeOf.object("scale", scale);
805
- Check.typeOf.object("result", result);
806
- //>>includeEnd('debug');
863
+ result[0] = column0Row0;
864
+ result[1] = column0Row1;
865
+ result[2] = column1Row0;
866
+ result[3] = column1Row1;
867
+ return result;
868
+ }
807
869
 
808
- result[0] = matrix[0] * scale.x;
809
- result[1] = matrix[1] * scale.x;
810
- result[2] = matrix[2] * scale.y;
811
- result[3] = matrix[3] * scale.y;
870
+ /**
871
+ * Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.
872
+ *
873
+ * @param {Matrix2} matrix The matrix with signed elements.
874
+ * @param {Matrix2} result The object onto which to store the result.
875
+ * @returns {Matrix2} The modified result parameter.
876
+ */
877
+ static abs(matrix, result) {
878
+ //>>includeStart('debug', pragmas.debug);
879
+ Check.typeOf.object("matrix", matrix);
880
+ Check.typeOf.object("result", result);
881
+ //>>includeEnd('debug');
812
882
 
813
- return result;
814
- };
883
+ result[0] = Math.abs(matrix[0]);
884
+ result[1] = Math.abs(matrix[1]);
885
+ result[2] = Math.abs(matrix[2]);
886
+ result[3] = Math.abs(matrix[3]);
815
887
 
816
- /**
817
- * Computes the product of a matrix times a uniform scale, as if the scale were a scale matrix.
818
- *
819
- * @param {Matrix2} matrix The matrix on the left-hand side.
820
- * @param {number} scale The uniform scale on the right-hand side.
821
- * @param {Matrix2} result The object onto which to store the result.
822
- * @returns {Matrix2} The modified result parameter.
823
- *
824
- * @example
825
- * // Instead of Cesium.Matrix2.multiply(m, Cesium.Matrix2.fromUniformScale(scale), m);
826
- * Cesium.Matrix2.multiplyByUniformScale(m, scale, m);
827
- *
828
- * @see Matrix2.multiplyByScale
829
- * @see Matrix2.fromScale
830
- * @see Matrix2.fromUniformScale
831
- * @see Matrix2.setScale
832
- * @see Matrix2.setUniformScale
833
- * @see Matrix2.getScale
834
- */
835
- Matrix2.multiplyByUniformScale = function (matrix, scale, result) {
836
- //>>includeStart('debug', pragmas.debug);
837
- Check.typeOf.object("matrix", matrix);
838
- Check.typeOf.number("scale", scale);
839
- Check.typeOf.object("result", result);
840
- //>>includeEnd('debug');
888
+ return result;
889
+ }
841
890
 
842
- result[0] = matrix[0] * scale;
843
- result[1] = matrix[1] * scale;
844
- result[2] = matrix[2] * scale;
845
- result[3] = matrix[3] * scale;
891
+ /**
892
+ * Compares the provided matrices componentwise and returns
893
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
894
+ *
895
+ * @param {Matrix2} [left] The first matrix.
896
+ * @param {Matrix2} [right] The second matrix.
897
+ * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
898
+ */
899
+ static equals(left, right) {
900
+ return (
901
+ left === right ||
902
+ (defined(left) &&
903
+ defined(right) &&
904
+ left[0] === right[0] &&
905
+ left[1] === right[1] &&
906
+ left[2] === right[2] &&
907
+ left[3] === right[3])
908
+ );
909
+ }
846
910
 
847
- return result;
848
- };
911
+ /**
912
+ * Compares provided matrix and array, starting from a given array offset.
913
+ *
914
+ * @param {Matrix2} matrix
915
+ * @param {number[]} array
916
+ * @param {number} offset
917
+ * @ignore
918
+ */
919
+ static equalsArray(matrix, array, offset) {
920
+ return (
921
+ matrix[0] === array[offset] &&
922
+ matrix[1] === array[offset + 1] &&
923
+ matrix[2] === array[offset + 2] &&
924
+ matrix[3] === array[offset + 3]
925
+ );
926
+ }
849
927
 
850
- /**
851
- * Creates a negated copy of the provided matrix.
852
- *
853
- * @param {Matrix2} matrix The matrix to negate.
854
- * @param {Matrix2} result The object onto which to store the result.
855
- * @returns {Matrix2} The modified result parameter.
856
- */
857
- Matrix2.negate = function (matrix, result) {
858
- //>>includeStart('debug', pragmas.debug);
859
- Check.typeOf.object("matrix", matrix);
860
- Check.typeOf.object("result", result);
861
- //>>includeEnd('debug');
862
-
863
- result[0] = -matrix[0];
864
- result[1] = -matrix[1];
865
- result[2] = -matrix[2];
866
- result[3] = -matrix[3];
867
- return result;
868
- };
928
+ /**
929
+ * Compares the provided matrices componentwise and returns
930
+ * <code>true</code> if they are within the provided epsilon,
931
+ * <code>false</code> otherwise.
932
+ *
933
+ * @param {Matrix2} [left] The first matrix.
934
+ * @param {Matrix2} [right] The second matrix.
935
+ * @param {number} [epsilon=0] The epsilon to use for equality testing.
936
+ * @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
937
+ */
938
+ static equalsEpsilon(left, right, epsilon) {
939
+ epsilon = epsilon ?? 0;
940
+ return (
941
+ left === right ||
942
+ (defined(left) &&
943
+ defined(right) &&
944
+ Math.abs(left[0] - right[0]) <= epsilon &&
945
+ Math.abs(left[1] - right[1]) <= epsilon &&
946
+ Math.abs(left[2] - right[2]) <= epsilon &&
947
+ Math.abs(left[3] - right[3]) <= epsilon)
948
+ );
949
+ }
869
950
 
870
- /**
871
- * Computes the transpose of the provided matrix.
872
- *
873
- * @param {Matrix2} matrix The matrix to transpose.
874
- * @param {Matrix2} result The object onto which to store the result.
875
- * @returns {Matrix2} The modified result parameter.
876
- */
877
- Matrix2.transpose = function (matrix, result) {
878
- //>>includeStart('debug', pragmas.debug);
879
- Check.typeOf.object("matrix", matrix);
880
- Check.typeOf.object("result", result);
881
- //>>includeEnd('debug');
882
-
883
- const column0Row0 = matrix[0];
884
- const column0Row1 = matrix[2];
885
- const column1Row0 = matrix[1];
886
- const column1Row1 = matrix[3];
887
-
888
- result[0] = column0Row0;
889
- result[1] = column0Row1;
890
- result[2] = column1Row0;
891
- result[3] = column1Row1;
892
- return result;
893
- };
951
+ /**
952
+ * Gets the number of items in the collection.
953
+ *
954
+ * @type {number}
955
+ */
956
+ get length() {
957
+ return Matrix2.packedLength;
958
+ }
894
959
 
895
- /**
896
- * Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.
897
- *
898
- * @param {Matrix2} matrix The matrix with signed elements.
899
- * @param {Matrix2} result The object onto which to store the result.
900
- * @returns {Matrix2} The modified result parameter.
901
- */
902
- Matrix2.abs = function (matrix, result) {
903
- //>>includeStart('debug', pragmas.debug);
904
- Check.typeOf.object("matrix", matrix);
905
- Check.typeOf.object("result", result);
906
- //>>includeEnd('debug');
960
+ /**
961
+ * Duplicates the provided Matrix2 instance.
962
+ *
963
+ * @param {Matrix2} [result] The object onto which to store the result.
964
+ * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.
965
+ */
966
+ clone(result) {
967
+ return Matrix2.clone(this, result);
968
+ }
907
969
 
908
- result[0] = Math.abs(matrix[0]);
909
- result[1] = Math.abs(matrix[1]);
910
- result[2] = Math.abs(matrix[2]);
911
- result[3] = Math.abs(matrix[3]);
970
+ /**
971
+ * Compares this matrix to the provided matrix componentwise and returns
972
+ * <code>true</code> if they are equal, <code>false</code> otherwise.
973
+ *
974
+ * @param {Matrix2} [right] The right hand side matrix.
975
+ * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
976
+ */
977
+ equals(right) {
978
+ return Matrix2.equals(this, right);
979
+ }
912
980
 
913
- return result;
914
- };
981
+ /**
982
+ * Compares this matrix to the provided matrix componentwise and returns
983
+ * <code>true</code> if they are within the provided epsilon,
984
+ * <code>false</code> otherwise.
985
+ *
986
+ * @param {Matrix2} [right] The right hand side matrix.
987
+ * @param {number} [epsilon=0] The epsilon to use for equality testing.
988
+ * @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
989
+ */
990
+ equalsEpsilon(right, epsilon) {
991
+ return Matrix2.equalsEpsilon(this, right, epsilon);
992
+ }
915
993
 
916
- /**
917
- * Compares the provided matrices componentwise and returns
918
- * <code>true</code> if they are equal, <code>false</code> otherwise.
919
- *
920
- * @param {Matrix2} [left] The first matrix.
921
- * @param {Matrix2} [right] The second matrix.
922
- * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
923
- */
924
- Matrix2.equals = function (left, right) {
925
- return (
926
- left === right ||
927
- (defined(left) &&
928
- defined(right) &&
929
- left[0] === right[0] &&
930
- left[1] === right[1] &&
931
- left[2] === right[2] &&
932
- left[3] === right[3])
933
- );
934
- };
994
+ /**
995
+ * Creates a string representing this Matrix with each row being
996
+ * on a separate line and in the format '(column0, column1)'.
997
+ *
998
+ * @returns {string} A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1)'.
999
+ */
1000
+ toString() {
1001
+ return `(${this[0]}, ${this[2]})\n` + `(${this[1]}, ${this[3]})`;
1002
+ }
1003
+ }
935
1004
 
936
1005
  /**
937
- * @private
1006
+ * The number of elements used to pack the object into an array.
1007
+ * @type {number}
938
1008
  */
939
- Matrix2.equalsArray = function (matrix, array, offset) {
940
- return (
941
- matrix[0] === array[offset] &&
942
- matrix[1] === array[offset + 1] &&
943
- matrix[2] === array[offset + 2] &&
944
- matrix[3] === array[offset + 3]
945
- );
946
- };
1009
+ Matrix2.packedLength = 4;
947
1010
 
948
1011
  /**
949
- * Compares the provided matrices componentwise and returns
950
- * <code>true</code> if they are within the provided epsilon,
951
- * <code>false</code> otherwise.
1012
+ * Creates a Matrix2 from 4 consecutive elements in an array.
1013
+ *
1014
+ * @function
1015
+ * @param {number[]} array The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order.
1016
+ * @param {number} [startingIndex=0] The offset into the array of the first element, which corresponds to first column first row position in the matrix.
1017
+ * @param {Matrix2} [result] The object onto which to store the result.
1018
+ * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.
952
1019
  *
953
- * @param {Matrix2} [left] The first matrix.
954
- * @param {Matrix2} [right] The second matrix.
955
- * @param {number} [epsilon=0] The epsilon to use for equality testing.
956
- * @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
1020
+ * @example
1021
+ * // Create the Matrix2:
1022
+ * // [1.0, 2.0]
1023
+ * // [1.0, 2.0]
1024
+ *
1025
+ * const v = [1.0, 1.0, 2.0, 2.0];
1026
+ * const m = Cesium.Matrix2.fromArray(v);
1027
+ *
1028
+ * // Create same Matrix2 with using an offset into an array
1029
+ * const v2 = [0.0, 0.0, 1.0, 1.0, 2.0, 2.0];
1030
+ * const m2 = Cesium.Matrix2.fromArray(v2, 2);
957
1031
  */
958
- Matrix2.equalsEpsilon = function (left, right, epsilon) {
959
- epsilon = epsilon ?? 0;
960
- return (
961
- left === right ||
962
- (defined(left) &&
963
- defined(right) &&
964
- Math.abs(left[0] - right[0]) <= epsilon &&
965
- Math.abs(left[1] - right[1]) <= epsilon &&
966
- Math.abs(left[2] - right[2]) <= epsilon &&
967
- Math.abs(left[3] - right[3]) <= epsilon)
968
- );
969
- };
1032
+ Matrix2.fromArray = Matrix2.unpack;
970
1033
 
971
1034
  /**
972
1035
  * An immutable Matrix2 instance initialized to the identity matrix.
@@ -1032,61 +1095,11 @@ Matrix2.COLUMN1ROW0 = 2;
1032
1095
  */
1033
1096
  Matrix2.COLUMN1ROW1 = 3;
1034
1097
 
1035
- Object.defineProperties(Matrix2.prototype, {
1036
- /**
1037
- * Gets the number of items in the collection.
1038
- * @memberof Matrix2.prototype
1039
- *
1040
- * @type {number}
1041
- */
1042
- length: {
1043
- get: function () {
1044
- return Matrix2.packedLength;
1045
- },
1046
- },
1047
- });
1048
-
1049
- /**
1050
- * Duplicates the provided Matrix2 instance.
1051
- *
1052
- * @param {Matrix2} [result] The object onto which to store the result.
1053
- * @returns {Matrix2} The modified result parameter or a new Matrix2 instance if one was not provided.
1054
- */
1055
- Matrix2.prototype.clone = function (result) {
1056
- return Matrix2.clone(this, result);
1057
- };
1058
-
1059
- /**
1060
- * Compares this matrix to the provided matrix componentwise and returns
1061
- * <code>true</code> if they are equal, <code>false</code> otherwise.
1062
- *
1063
- * @param {Matrix2} [right] The right hand side matrix.
1064
- * @returns {boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
1065
- */
1066
- Matrix2.prototype.equals = function (right) {
1067
- return Matrix2.equals(this, right);
1068
- };
1069
-
1070
- /**
1071
- * Compares this matrix to the provided matrix componentwise and returns
1072
- * <code>true</code> if they are within the provided epsilon,
1073
- * <code>false</code> otherwise.
1074
- *
1075
- * @param {Matrix2} [right] The right hand side matrix.
1076
- * @param {number} [epsilon=0] The epsilon to use for equality testing.
1077
- * @returns {boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
1078
- */
1079
- Matrix2.prototype.equalsEpsilon = function (right, epsilon) {
1080
- return Matrix2.equalsEpsilon(this, right, epsilon);
1081
- };
1098
+ const scaleScratch1 = new Cartesian2();
1099
+ const scaleScratch2 = new Cartesian2();
1100
+ const scratchColumn = new Cartesian2();
1101
+ const scaleScratch3 = new Cartesian2();
1102
+ const scaleScratch4 = new Cartesian2();
1103
+ const scaleScratch5 = new Cartesian2();
1082
1104
 
1083
- /**
1084
- * Creates a string representing this Matrix with each row being
1085
- * on a separate line and in the format '(column0, column1)'.
1086
- *
1087
- * @returns {string} A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1)'.
1088
- */
1089
- Matrix2.prototype.toString = function () {
1090
- return `(${this[0]}, ${this[2]})\n` + `(${this[1]}, ${this[3]})`;
1091
- };
1092
1105
  export default Matrix2;