@cesium/engine 23.0.1 → 25.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 (398) hide show
  1. package/Build/Workers/{chunk-ZEMJQKHD.js → chunk-35H3UBIO.js} +13 -12
  2. package/Build/Workers/{chunk-PQTSXJBJ.js → chunk-3LSD7OOA.js} +16 -16
  3. package/Build/Workers/{chunk-PUO7BYDY.js → chunk-3RFFPH4M.js} +1 -1
  4. package/Build/Workers/{chunk-PBECJOWF.js → chunk-3TKLDHV3.js} +2 -2
  5. package/Build/Workers/{chunk-TMCTZ5E3.js → chunk-3VDDRF2E.js} +14 -14
  6. package/Build/Workers/{chunk-FKU77FNM.js → chunk-3XY3MVPG.js} +4 -4
  7. package/Build/Workers/{chunk-2OBWHTIC.js → chunk-4GF4MVPY.js} +7 -7
  8. package/Build/Workers/{chunk-JUKGMJX7.js → chunk-4MTRQFJP.js} +3 -2
  9. package/Build/Workers/{chunk-66OWUDO7.js → chunk-4QQXGTCE.js} +8 -8
  10. package/Build/Workers/{chunk-ALTCIHRH.js → chunk-4XXHJI6Y.js} +17 -17
  11. package/Build/Workers/{chunk-K7UTK4OM.js → chunk-5T6QQAJW.js} +3 -2
  12. package/Build/Workers/{chunk-IJ3SUMK3.js → chunk-6SDGQI27.js} +3 -2
  13. package/Build/Workers/{chunk-FXSRA5UG.js → chunk-77RL3MBD.js} +6 -5
  14. package/Build/Workers/{chunk-G6MJ3ZW3.js → chunk-7LSFAEWF.js} +12 -11
  15. package/Build/Workers/{chunk-C6HHBKT5.js → chunk-A7A433MD.js} +5 -5
  16. package/Build/Workers/{chunk-PGZ3B6CB.js → chunk-A7ZBMVFS.js} +14 -14
  17. package/Build/Workers/{chunk-OZYB3AOR.js → chunk-ACFFCHHZ.js} +11 -11
  18. package/Build/Workers/{chunk-DNMASBMH.js → chunk-AEAVLYPS.js} +2 -2
  19. package/Build/Workers/{chunk-VPWYHFQA.js → chunk-AWFZHD2B.js} +4 -4
  20. package/Build/Workers/{chunk-TFPG3ZKW.js → chunk-BTX2NL3P.js} +59 -46
  21. package/Build/Workers/{chunk-TNXOPEIG.js → chunk-BVAIWR7O.js} +12 -12
  22. package/Build/Workers/chunk-CKQP3DSS.js +973 -0
  23. package/Build/Workers/{chunk-N6HRZLS6.js → chunk-CZ23Y3RM.js} +2 -2
  24. package/Build/Workers/{chunk-EIC3VAOZ.js → chunk-DFEI5MAV.js} +7 -7
  25. package/Build/Workers/{chunk-BTP3634E.js → chunk-DH26SNAB.js} +4 -1
  26. package/Build/Workers/{chunk-TXYQNXNW.js → chunk-DYT5NR6P.js} +3 -3
  27. package/Build/Workers/{chunk-O67UP5YO.js → chunk-EZARA5FJ.js} +13 -13
  28. package/Build/Workers/{chunk-YSJRB2UZ.js → chunk-FIBS5S7R.js} +2 -2
  29. package/Build/Workers/{chunk-2M7DKGLW.js → chunk-FVLVVOBQ.js} +10 -10
  30. package/Build/Workers/{chunk-B2VA6IEL.js → chunk-GL7DNVUS.js} +5 -5
  31. package/Build/Workers/{chunk-77DJBHMI.js → chunk-GPIGURCG.js} +59 -32
  32. package/Build/Workers/{chunk-QPXGGVHC.js → chunk-H2A4USJR.js} +10 -10
  33. package/Build/Workers/chunk-HSVQATK2.js +147 -0
  34. package/Build/Workers/{chunk-HXEPZWJN.js → chunk-HVMG6AG4.js} +11 -10
  35. package/Build/Workers/{chunk-H3TVRJLY.js → chunk-I3A6DXYZ.js} +4 -4
  36. package/Build/Workers/{chunk-UEWYSOFD.js → chunk-ITD2IN7N.js} +2 -2
  37. package/Build/Workers/{chunk-CYOPNGPX.js → chunk-J3OFS2RD.js} +12 -12
  38. package/Build/Workers/{chunk-RZX6LOG6.js → chunk-J647NNZW.js} +6 -6
  39. package/Build/Workers/{chunk-GLCPE2BJ.js → chunk-J7KQEKPK.js} +13 -13
  40. package/Build/Workers/{chunk-XPMXRJDD.js → chunk-K6NFIRFB.js} +5 -5
  41. package/Build/Workers/{chunk-CID5SY7L.js → chunk-LH5SF3XV.js} +7 -6
  42. package/Build/Workers/{chunk-UOQB7XQI.js → chunk-ND3NTTOF.js} +713 -435
  43. package/Build/Workers/chunk-QO2CGXMP.js +2342 -0
  44. package/Build/Workers/chunk-QSDY4NS7.js +1287 -0
  45. package/Build/Workers/chunk-QXNQQYPV.js +3201 -0
  46. package/Build/Workers/{chunk-CJ7ZDY77.js → chunk-ST2UWDUU.js} +5 -5
  47. package/Build/Workers/{chunk-YDR5LX5Z.js → chunk-TA777BGS.js} +3 -2
  48. package/Build/Workers/{chunk-U4SWB6TI.js → chunk-TAI4HLII.js} +4 -4
  49. package/Build/Workers/{chunk-VX774SWE.js → chunk-URUCCIPS.js} +6 -6
  50. package/Build/Workers/{chunk-MNSNOONX.js → chunk-VQKLRBIK.js} +7 -7
  51. package/Build/Workers/{chunk-CVAAIRNP.js → chunk-WC57YYBN.js} +2 -2
  52. package/Build/Workers/{chunk-QNABVTTP.js → chunk-WN6P5UDH.js} +12 -12
  53. package/Build/Workers/{chunk-CNLXMOPM.js → chunk-WNN5D4W3.js} +12 -11
  54. package/Build/Workers/{chunk-4JJQRZYL.js → chunk-WTQGE7Q6.js} +17 -17
  55. package/Build/Workers/{chunk-FCJQO4NC.js → chunk-WUBKZFF6.js} +2213 -1349
  56. package/Build/Workers/{chunk-3UQ2YMPP.js → chunk-ZAPOS52G.js} +12 -10
  57. package/Build/Workers/{chunk-LHFC4R7Z.js → chunk-ZCCIIBZT.js} +6 -6
  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 +25 -25
  100. package/Build/Workers/createWallOutlineGeometry.js +24 -24
  101. package/Build/Workers/decodeDraco.js +10 -10
  102. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  103. package/Build/Workers/decodeI3S.js +12 -12
  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 +7 -5
  116. package/Source/Core/Cartesian3.js +9 -8
  117. package/Source/Core/Cartesian4.js +8 -6
  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 +846 -835
  122. package/Source/Core/ComponentDatatype.js +4 -1
  123. package/Source/Core/CornerType.js +6 -1
  124. package/Source/Core/Credit.js +121 -124
  125. package/Source/Core/DeveloperError.js +2 -1
  126. package/Source/Core/Ellipsoid.js +637 -660
  127. package/Source/Core/ExtrapolationType.js +6 -1
  128. package/Source/Core/GeocodeType.js +6 -1
  129. package/Source/Core/GeographicProjection.js +74 -74
  130. package/Source/Core/GeographicTilingScheme.js +179 -198
  131. package/Source/Core/GeometryOffsetAttribute.js +7 -1
  132. package/Source/Core/GeometryType.js +7 -1
  133. package/Source/Core/HeightmapEncoding.js +6 -1
  134. package/Source/Core/ITwinPlatform.js +1 -0
  135. package/Source/Core/Iau2006XysData.js +24 -13
  136. package/Source/Core/IndexDatatype.js +3 -1
  137. package/Source/Core/InterpolationType.js +5 -1
  138. package/Source/Core/Intersect.js +6 -1
  139. package/Source/Core/Ion.js +1 -1
  140. package/Source/Core/IonGeocodeProviderType.js +5 -1
  141. package/Source/Core/JulianDate.js +850 -848
  142. package/Source/Core/KeyboardEventModifier.js +6 -1
  143. package/Source/Core/MapProjection.js +39 -44
  144. package/Source/Core/Matrix2.js +906 -893
  145. package/Source/Core/Matrix3.js +1643 -1575
  146. package/Source/Core/Matrix4.js +2903 -2872
  147. package/Source/Core/PixelFormat.js +3 -1
  148. package/Source/Core/PrimitiveType.js +11 -1
  149. package/Source/Core/Ray.js +62 -60
  150. package/Source/Core/Rectangle.js +913 -904
  151. package/Source/Core/ReferenceFrame.js +6 -1
  152. package/Source/Core/RequestScheduler.js +8 -3
  153. package/Source/Core/RequestState.js +6 -1
  154. package/Source/Core/RequestType.js +6 -1
  155. package/Source/Core/S2Cell.js +2 -2
  156. package/Source/Core/ScreenSpaceEventType.js +6 -1
  157. package/Source/Core/TerrainMesh.js +10 -1
  158. package/Source/Core/TerrainPicker.js +1 -0
  159. package/Source/Core/TerrainQuantization.js +6 -1
  160. package/Source/Core/TilingScheme.js +100 -98
  161. package/Source/Core/TimeConstants.js +6 -1
  162. package/Source/Core/TimeStandard.js +6 -1
  163. package/Source/Core/TrackingReferenceFrame.js +6 -1
  164. package/Source/Core/Visibility.js +6 -1
  165. package/Source/Core/VulkanConstants.js +6 -1
  166. package/Source/Core/WallGeometry.js +1 -1
  167. package/Source/Core/WallOutlineGeometry.js +1 -1
  168. package/Source/Core/WebGLConstants.js +6 -1
  169. package/Source/Core/WebMercatorProjection.js +108 -109
  170. package/Source/Core/WebMercatorTilingScheme.js +246 -242
  171. package/Source/Core/WindingOrder.js +3 -1
  172. package/Source/Core/assert.js +27 -0
  173. package/Source/Core/globalTypes.js +4 -0
  174. package/Source/DataSources/CzmlDataSource.js +9 -0
  175. package/Source/DataSources/PathGraphics.js +13 -0
  176. package/Source/DataSources/PathVisualizer.js +330 -18
  177. package/Source/DataSources/StaticGeometryColorBatch.js +7 -2
  178. package/Source/DataSources/StaticGeometryPerMaterialBatch.js +7 -2
  179. package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +4 -1
  180. package/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +4 -1
  181. package/Source/DataSources/StripeOrientation.js +6 -1
  182. package/Source/Renderer/BufferUsage.js +20 -9
  183. package/Source/Renderer/Context.js +2 -29
  184. package/Source/Renderer/DrawCommand.js +435 -403
  185. package/Source/Renderer/MipmapHint.js +5 -1
  186. package/Source/Renderer/Pass.js +7 -1
  187. package/Source/Renderer/PickId.js +44 -0
  188. package/Source/Renderer/PixelDatatype.js +3 -1
  189. package/Source/Renderer/RenderState.js +2 -2
  190. package/Source/Renderer/RenderbufferFormat.js +5 -1
  191. package/Source/Renderer/ShaderDestination.js +4 -1
  192. package/Source/Renderer/TextureMagnificationFilter.js +3 -1
  193. package/Source/Renderer/TextureMinificationFilter.js +3 -1
  194. package/Source/Renderer/TextureWrap.js +5 -1
  195. package/Source/Renderer/VertexArray.js +80 -0
  196. package/Source/Scene/AlphaMode.js +5 -1
  197. package/Source/Scene/ArcGisBaseMapType.js +6 -1
  198. package/Source/Scene/ArcGisMapService.js +1 -1
  199. package/Source/Scene/AttributeType.js +3 -1
  200. package/Source/Scene/Axis.js +3 -1
  201. package/Source/Scene/BillboardCollection.js +65 -364
  202. package/Source/Scene/BingMapsStyle.js +6 -1
  203. package/Source/Scene/BlendEquation.js +6 -1
  204. package/Source/Scene/BlendFunction.js +6 -1
  205. package/Source/Scene/BlendOption.js +6 -1
  206. package/Source/Scene/BlendingState.js +6 -1
  207. package/Source/Scene/BufferLoader.js +0 -2
  208. package/Source/Scene/BufferPoint.js +148 -0
  209. package/Source/Scene/BufferPointCollection.js +138 -0
  210. package/Source/Scene/BufferPointMaterial.js +95 -0
  211. package/Source/Scene/BufferPolygon.js +516 -0
  212. package/Source/Scene/BufferPolygonCollection.js +370 -0
  213. package/Source/Scene/BufferPolygonMaterial.js +41 -0
  214. package/Source/Scene/BufferPolyline.js +185 -0
  215. package/Source/Scene/BufferPolylineCollection.js +138 -0
  216. package/Source/Scene/BufferPolylineMaterial.js +93 -0
  217. package/Source/Scene/BufferPrimitive.js +347 -0
  218. package/Source/Scene/BufferPrimitiveCollection.js +818 -0
  219. package/Source/Scene/BufferPrimitiveMaterial.js +140 -0
  220. package/Source/Scene/CameraEventType.js +6 -1
  221. package/Source/Scene/Cesium3DTileColorBlendMode.js +6 -1
  222. package/Source/Scene/Cesium3DTileContent.js +5 -1
  223. package/Source/Scene/Cesium3DTileContentFactory.js +9 -0
  224. package/Source/Scene/Cesium3DTileContentState.js +6 -1
  225. package/Source/Scene/Cesium3DTileContentType.js +3 -1
  226. package/Source/Scene/Cesium3DTileFeature.js +289 -306
  227. package/Source/Scene/Cesium3DTileOptimizationHint.js +6 -1
  228. package/Source/Scene/Cesium3DTilePass.js +5 -1
  229. package/Source/Scene/Cesium3DTilePointFeature.js +433 -511
  230. package/Source/Scene/Cesium3DTileRefine.js +6 -1
  231. package/Source/Scene/Cesium3DTileStyle.js +22 -0
  232. package/Source/Scene/Cesium3DTileVectorFeature.js +586 -0
  233. package/Source/Scene/Cesium3DTileset.js +2 -1
  234. package/Source/Scene/ClassificationType.js +3 -1
  235. package/Source/Scene/ClippingPolygonCollection.js +270 -101
  236. package/Source/Scene/CloudType.js +3 -1
  237. package/Source/Scene/ColorBlendMode.js +4 -1
  238. package/Source/Scene/CubeMapPanorama.js +4 -4
  239. package/Source/Scene/CullFace.js +6 -1
  240. package/Source/Scene/DepthFunction.js +6 -1
  241. package/Source/Scene/DynamicAtmosphereLightingType.js +3 -1
  242. package/Source/Scene/EquirectangularPanorama.js +1 -0
  243. package/Source/Scene/ExpressionNodeType.js +6 -1
  244. package/Source/Scene/GaussianSplat3DTileContent.js +40 -46
  245. package/Source/Scene/GaussianSplatPrimitive.js +413 -70
  246. package/Source/Scene/GetFeatureInfoFormat.js +3 -3
  247. package/Source/Scene/GltfBufferViewLoader.js +0 -2
  248. package/Source/Scene/GltfDracoLoader.js +0 -2
  249. package/Source/Scene/GltfImageLoader.js +0 -3
  250. package/Source/Scene/GltfIndexBufferLoader.js +0 -4
  251. package/Source/Scene/GltfJsonLoader.js +0 -2
  252. package/Source/Scene/GltfLoader.js +215 -39
  253. package/Source/Scene/GltfLoaderUtil.js +14 -0
  254. package/Source/Scene/GltfSpzLoader.js +109 -2
  255. package/Source/Scene/GltfStructuralMetadataLoader.js +0 -2
  256. package/Source/Scene/GltfTextureLoader.js +0 -2
  257. package/Source/Scene/GltfVertexBufferLoader.js +0 -4
  258. package/Source/Scene/HeightReference.js +5 -1
  259. package/Source/Scene/HorizontalOrigin.js +6 -1
  260. package/Source/Scene/ITwinData.js +1 -0
  261. package/Source/Scene/ImageryProvider.js +1 -1
  262. package/Source/Scene/ImageryState.js +6 -1
  263. package/Source/Scene/ImplicitSubdivisionScheme.js +3 -1
  264. package/Source/Scene/InstanceAttributeSemantic.js +3 -1
  265. package/Source/Scene/IonWorldImageryStyle.js +6 -1
  266. package/Source/Scene/JobType.js +6 -1
  267. package/Source/Scene/Label.js +32 -0
  268. package/Source/Scene/LabelCollection.js +14 -13
  269. package/Source/Scene/LabelStyle.js +6 -1
  270. package/Source/Scene/MapMode2D.js +6 -1
  271. package/Source/Scene/Material.js +2 -0
  272. package/Source/Scene/Megatexture.js +1 -0
  273. package/Source/Scene/MetadataClassProperty.js +24 -10
  274. package/Source/Scene/MetadataComponentType.js +118 -24
  275. package/Source/Scene/MetadataSchemaLoader.js +0 -2
  276. package/Source/Scene/MetadataSemantic.js +6 -2
  277. package/Source/Scene/MetadataType.js +3 -1
  278. package/Source/Scene/Model/B3dmLoader.js +0 -3
  279. package/Source/Scene/Model/CustomShaderMode.js +3 -1
  280. package/Source/Scene/Model/CustomShaderPipelineStage.js +3 -1
  281. package/Source/Scene/Model/CustomShaderTranslucencyMode.js +5 -1
  282. package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +735 -264
  283. package/Source/Scene/Model/Extensions/Gpm/PpeSource.js +5 -1
  284. package/Source/Scene/Model/Extensions/Gpm/StorageType.js +5 -1
  285. package/Source/Scene/Model/GeoJsonLoader.js +0 -2
  286. package/Source/Scene/Model/I3dmLoader.js +0 -3
  287. package/Source/Scene/Model/InstancingPipelineStage.js +1 -1
  288. package/Source/Scene/Model/LightingModel.js +5 -1
  289. package/Source/Scene/Model/MaterialPipelineStage.js +331 -3
  290. package/Source/Scene/Model/MetadataPipelineStage.js +3 -3
  291. package/Source/Scene/Model/ModelDrawCommand.js +6 -0
  292. package/Source/Scene/Model/ModelReader.js +475 -4
  293. package/Source/Scene/Model/ModelRuntimePrimitive.js +2 -1
  294. package/Source/Scene/Model/ModelType.js +3 -1
  295. package/Source/Scene/Model/ModelUtility.js +3 -1
  296. package/Source/Scene/Model/PntsLoader.js +4 -3
  297. package/Source/Scene/Model/StyleCommandsNeeded.js +3 -1
  298. package/Source/Scene/Model/UniformType.js +5 -1
  299. package/Source/Scene/Model/VaryingType.js +5 -1
  300. package/Source/Scene/Model/createVectorTileBuffersFromModelComponents.js +375 -0
  301. package/Source/Scene/Model/pickModel.js +94 -299
  302. package/Source/Scene/ModelAnimationLoop.js +6 -1
  303. package/Source/Scene/ModelAnimationState.js +6 -1
  304. package/Source/Scene/ModelComponents.js +1639 -1542
  305. package/Source/Scene/PickedMetadataInfo.js +1 -0
  306. package/Source/Scene/PrimitiveState.js +7 -1
  307. package/Source/Scene/QuadtreeOccluders.js +20 -15
  308. package/Source/Scene/QuadtreeTile.js +547 -541
  309. package/Source/Scene/QuadtreeTileLoadState.js +6 -1
  310. package/Source/Scene/QuadtreeTileProvider.js +159 -175
  311. package/Source/Scene/ResourceLoader.js +0 -1
  312. package/Source/Scene/ResourceLoaderState.js +7 -1
  313. package/Source/Scene/SceneMode.js +4 -1
  314. package/Source/Scene/ScreenSpaceCameraController.js +13 -0
  315. package/Source/Scene/ShadowMode.js +3 -1
  316. package/Source/Scene/SkyBox.js +17 -8
  317. package/Source/Scene/SplitDirection.js +6 -1
  318. package/Source/Scene/StencilFunction.js +6 -1
  319. package/Source/Scene/StencilOperation.js +6 -1
  320. package/Source/Scene/TerrainState.js +7 -1
  321. package/Source/Scene/TileBoundingRegion.js +1 -1
  322. package/Source/Scene/TileBoundingS2Cell.js +1 -1
  323. package/Source/Scene/TileBoundingSphere.js +1 -1
  324. package/Source/Scene/TileState.js +7 -1
  325. package/Source/Scene/Tonemapper.js +5 -1
  326. package/Source/Scene/TweenCollection.js +7 -0
  327. package/Source/Scene/VectorGltf3DTileContent.js +403 -0
  328. package/Source/Scene/VertexAttributeSemantic.js +17 -1
  329. package/Source/Scene/VerticalOrigin.js +6 -1
  330. package/Source/Scene/VoxelBoxShape.js +12 -6
  331. package/Source/Scene/VoxelContent.js +2 -0
  332. package/Source/Scene/VoxelCylinderShape.js +39 -38
  333. package/Source/Scene/VoxelEllipsoidShape.js +46 -96
  334. package/Source/Scene/VoxelMetadataOrder.js +6 -1
  335. package/Source/Scene/VoxelProvider.js +1 -0
  336. package/Source/Scene/VoxelShapeType.js +3 -1
  337. package/Source/Scene/WebMapServiceImageryProvider.js +2 -2
  338. package/Source/Scene/WebMapTileServiceImageryProvider.js +366 -131
  339. package/Source/Scene/parseStructuralMetadata.js +97 -37
  340. package/Source/Scene/renderBufferPointCollection.js +285 -0
  341. package/Source/Scene/renderBufferPolygonCollection.js +339 -0
  342. package/Source/Scene/renderBufferPolylineCollection.js +478 -0
  343. package/Source/Shaders/BillboardCollectionFS.glsl +2 -77
  344. package/Source/Shaders/BillboardCollectionFS.js +2 -77
  345. package/Source/Shaders/BillboardCollectionVS.glsl +2 -60
  346. package/Source/Shaders/BillboardCollectionVS.js +2 -60
  347. package/Source/Shaders/BufferPointMaterialFS.glsl +27 -0
  348. package/Source/Shaders/BufferPointMaterialFS.js +29 -0
  349. package/Source/Shaders/BufferPointMaterialVS.glsl +48 -0
  350. package/Source/Shaders/BufferPointMaterialVS.js +50 -0
  351. package/Source/Shaders/BufferPolygonMaterialFS.glsl +13 -0
  352. package/Source/Shaders/BufferPolygonMaterialFS.js +15 -0
  353. package/Source/Shaders/BufferPolygonMaterialVS.glsl +30 -0
  354. package/Source/Shaders/BufferPolygonMaterialVS.js +32 -0
  355. package/Source/Shaders/BufferPolylineMaterialFS.glsl +13 -0
  356. package/Source/Shaders/BufferPolylineMaterialFS.js +15 -0
  357. package/Source/Shaders/BufferPolylineMaterialVS.glsl +49 -0
  358. package/Source/Shaders/BufferPolylineMaterialVS.js +51 -0
  359. package/Source/Shaders/Builtin/CzmBuiltins.js +2 -0
  360. package/Source/Shaders/Builtin/Functions/computeTextureTransform.glsl +24 -0
  361. package/Source/Shaders/Builtin/Functions/computeTextureTransform.js +25 -0
  362. package/Source/Shaders/Model/ConstantLodStageFS.glsl +60 -0
  363. package/Source/Shaders/Model/ConstantLodStageFS.js +62 -0
  364. package/Source/Shaders/Model/ConstantLodStageVS.glsl +12 -0
  365. package/Source/Shaders/Model/ConstantLodStageVS.js +13 -0
  366. package/Source/Shaders/Model/EdgeVisibilityStageFS.glsl +34 -48
  367. package/Source/Shaders/Model/EdgeVisibilityStageFS.js +34 -49
  368. package/Source/Shaders/Model/EdgeVisibilityStageVS.glsl +98 -0
  369. package/Source/Shaders/Model/EdgeVisibilityStageVS.js +100 -0
  370. package/Source/Shaders/Model/MaterialStageFS.glsl +46 -20
  371. package/Source/Shaders/Model/MaterialStageFS.js +46 -20
  372. package/Source/Shaders/Model/ModelFS.glsl +15 -0
  373. package/Source/Shaders/Model/ModelFS.js +15 -0
  374. package/Source/Shaders/Model/ModelVS.glsl +8 -0
  375. package/Source/Shaders/Model/ModelVS.js +8 -0
  376. package/Source/Shaders/PolygonSignedDistanceFS.glsl +64 -33
  377. package/Source/Shaders/PolygonSignedDistanceFS.js +64 -33
  378. package/Source/Shaders/PrimitiveGaussianSplatVS.glsl +9 -2
  379. package/Source/Shaders/PrimitiveGaussianSplatVS.js +9 -2
  380. package/Source/Shaders/Voxels/VoxelFS.glsl +1 -1
  381. package/Source/Shaders/Voxels/VoxelFS.js +1 -1
  382. package/Source/Shaders/Voxels/convertLocalToBoxUv.glsl +0 -1
  383. package/Source/Shaders/Voxels/convertLocalToBoxUv.js +0 -1
  384. package/Source/Shaders/Voxels/convertLocalToCylinderUv.glsl +7 -9
  385. package/Source/Shaders/Voxels/convertLocalToCylinderUv.js +7 -9
  386. package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.glsl +7 -17
  387. package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.js +7 -17
  388. package/Source/Widget/CesiumWidget.js +11 -4
  389. package/Source/Workers/decodeDraco.js +3 -0
  390. package/Source/Workers/decodeI3S.js +5 -2
  391. package/index.d.ts +1332 -402
  392. package/index.js +111 -81
  393. package/package.json +3 -3
  394. package/Build/Workers/chunk-54O3AGOA.js +0 -642
  395. package/Build/Workers/chunk-6U5QMZU3.js +0 -940
  396. package/Build/Workers/chunk-HNDE73JK.js +0 -1829
  397. package/Build/Workers/chunk-PAFMAR7A.js +0 -2357
  398. package/Build/Workers/chunk-S53HSRT6.js +0 -114
@@ -4,6 +4,8 @@ import defined from "./defined.js";
4
4
  import FeatureDetection from "./FeatureDetection.js";
5
5
  import CesiumMath from "./Math.js";
6
6
 
7
+ /** @import {TypedArray} from "../Core/globalTypes.js"; */
8
+
7
9
  function hue2rgb(m1, m2, h) {
8
10
  if (h < 0) {
9
11
  h += 1;
@@ -26,938 +28,947 @@ function hue2rgb(m1, m2, h) {
26
28
  /**
27
29
  * A color, specified using red, green, blue, and alpha values,
28
30
  * which range from <code>0</code> (no intensity) to <code>1.0</code> (full intensity).
29
- * @param {number} [red=1.0] The red component.
30
- * @param {number} [green=1.0] The green component.
31
- * @param {number} [blue=1.0] The blue component.
32
- * @param {number} [alpha=1.0] The alpha component.
33
- *
34
- * @constructor
35
- * @alias Color
36
31
  *
37
32
  * @see Packable
38
33
  */
39
- function Color(red, green, blue, alpha) {
34
+ class Color {
40
35
  /**
41
- * The red component.
42
- * @type {number}
43
- * @default 1.0
36
+ * @param {number} [red=1.0] The red component.
37
+ * @param {number} [green=1.0] The green component.
38
+ * @param {number} [blue=1.0] The blue component.
39
+ * @param {number} [alpha=1.0] The alpha component.
44
40
  */
45
- this.red = red ?? 1.0;
41
+ constructor(red, green, blue, alpha) {
42
+ /**
43
+ * The red component.
44
+ * @type {number}
45
+ * @default 1.0
46
+ */
47
+ this.red = red ?? 1.0;
48
+ /**
49
+ * The green component.
50
+ * @type {number}
51
+ * @default 1.0
52
+ */
53
+ this.green = green ?? 1.0;
54
+ /**
55
+ * The blue component.
56
+ * @type {number}
57
+ * @default 1.0
58
+ */
59
+ this.blue = blue ?? 1.0;
60
+ /**
61
+ * The alpha component.
62
+ * @type {number}
63
+ * @default 1.0
64
+ */
65
+ this.alpha = alpha ?? 1.0;
66
+ }
67
+
46
68
  /**
47
- * The green component.
48
- * @type {number}
49
- * @default 1.0
69
+ * Creates a Color instance from a {@link Cartesian4}. <code>x</code>, <code>y</code>, <code>z</code>,
70
+ * and <code>w</code> map to <code>red</code>, <code>green</code>, <code>blue</code>, and <code>alpha</code>, respectively.
71
+ *
72
+ * @param {Cartesian4} cartesian The source cartesian.
73
+ * @param {Color} [result] The object onto which to store the result.
74
+ * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
50
75
  */
51
- this.green = green ?? 1.0;
76
+ static fromCartesian4(cartesian, result) {
77
+ //>>includeStart('debug', pragmas.debug);
78
+ Check.typeOf.object("cartesian", cartesian);
79
+ //>>includeEnd('debug');
80
+
81
+ if (!defined(result)) {
82
+ return new Color(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
83
+ }
84
+
85
+ result.red = cartesian.x;
86
+ result.green = cartesian.y;
87
+ result.blue = cartesian.z;
88
+ result.alpha = cartesian.w;
89
+ return result;
90
+ }
91
+
52
92
  /**
53
- * The blue component.
54
- * @type {number}
55
- * @default 1.0
93
+ * Creates a new Color specified using red, green, blue, and alpha values
94
+ * that are in the range of 0 to 255, converting them internally to a range of 0.0 to 1.0.
95
+ *
96
+ * @param {number} [red=255] The red component.
97
+ * @param {number} [green=255] The green component.
98
+ * @param {number} [blue=255] The blue component.
99
+ * @param {number} [alpha=255] The alpha component.
100
+ * @param {Color} [result] The object onto which to store the result.
101
+ * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
56
102
  */
57
- this.blue = blue ?? 1.0;
103
+ static fromBytes(red, green, blue, alpha, result) {
104
+ red = Color.byteToFloat(red ?? 255.0);
105
+ green = Color.byteToFloat(green ?? 255.0);
106
+ blue = Color.byteToFloat(blue ?? 255.0);
107
+ alpha = Color.byteToFloat(alpha ?? 255.0);
108
+
109
+ if (!defined(result)) {
110
+ return new Color(red, green, blue, alpha);
111
+ }
112
+
113
+ result.red = red;
114
+ result.green = green;
115
+ result.blue = blue;
116
+ result.alpha = alpha;
117
+ return result;
118
+ }
119
+
58
120
  /**
59
- * The alpha component.
60
- * @type {number}
61
- * @default 1.0
121
+ * Creates a new Color that has the same red, green, and blue components
122
+ * of the specified color, but with the specified alpha value.
123
+ *
124
+ * @param {Color} color The base color
125
+ * @param {number} alpha The new alpha component.
126
+ * @param {Color} [result] The object onto which to store the result.
127
+ * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
128
+ *
129
+ * @example const translucentRed = Cesium.Color.fromAlpha(Cesium.Color.RED, 0.9);
62
130
  */
63
- this.alpha = alpha ?? 1.0;
64
- }
131
+ static fromAlpha(color, alpha, result) {
132
+ //>>includeStart('debug', pragmas.debug);
133
+ Check.typeOf.object("color", color);
134
+ Check.typeOf.number("alpha", alpha);
135
+ //>>includeEnd('debug');
65
136
 
66
- /**
67
- * Creates a Color instance from a {@link Cartesian4}. <code>x</code>, <code>y</code>, <code>z</code>,
68
- * and <code>w</code> map to <code>red</code>, <code>green</code>, <code>blue</code>, and <code>alpha</code>, respectively.
69
- *
70
- * @param {Cartesian4} cartesian The source cartesian.
71
- * @param {Color} [result] The object onto which to store the result.
72
- * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
73
- */
74
- Color.fromCartesian4 = function (cartesian, result) {
75
- //>>includeStart('debug', pragmas.debug);
76
- Check.typeOf.object("cartesian", cartesian);
77
- //>>includeEnd('debug');
137
+ if (!defined(result)) {
138
+ return new Color(color.red, color.green, color.blue, alpha);
139
+ }
78
140
 
79
- if (!defined(result)) {
80
- return new Color(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
141
+ result.red = color.red;
142
+ result.green = color.green;
143
+ result.blue = color.blue;
144
+ result.alpha = alpha;
145
+ return result;
81
146
  }
82
147
 
83
- result.red = cartesian.x;
84
- result.green = cartesian.y;
85
- result.blue = cartesian.z;
86
- result.alpha = cartesian.w;
87
- return result;
88
- };
148
+ /**
149
+ * Creates a new Color from a single numeric unsigned 32-bit RGBA value, using the endianness
150
+ * of the system.
151
+ *
152
+ * @param {number} rgba A single numeric unsigned 32-bit RGBA value.
153
+ * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
154
+ * @returns {Color} The color object.
155
+ *
156
+ * @example
157
+ * const color = Cesium.Color.fromRgba(0x67ADDFFF);
158
+ *
159
+ * @see Color#toRgba
160
+ */
161
+ static fromRgba(rgba, result) {
162
+ // scratchUint32Array and scratchUint8Array share an underlying array buffer
163
+ scratchUint32Array[0] = rgba;
164
+ return Color.fromBytes(
165
+ scratchUint8Array[0],
166
+ scratchUint8Array[1],
167
+ scratchUint8Array[2],
168
+ scratchUint8Array[3],
169
+ result,
170
+ );
171
+ }
89
172
 
90
- /**
91
- * Creates a new Color specified using red, green, blue, and alpha values
92
- * that are in the range of 0 to 255, converting them internally to a range of 0.0 to 1.0.
93
- *
94
- * @param {number} [red=255] The red component.
95
- * @param {number} [green=255] The green component.
96
- * @param {number} [blue=255] The blue component.
97
- * @param {number} [alpha=255] The alpha component.
98
- * @param {Color} [result] The object onto which to store the result.
99
- * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
100
- */
101
- Color.fromBytes = function (red, green, blue, alpha, result) {
102
- red = Color.byteToFloat(red ?? 255.0);
103
- green = Color.byteToFloat(green ?? 255.0);
104
- blue = Color.byteToFloat(blue ?? 255.0);
105
- alpha = Color.byteToFloat(alpha ?? 255.0);
173
+ /**
174
+ * Creates a Color instance from hue, saturation, and lightness.
175
+ *
176
+ * @param {number} [hue=0] The hue angle 0...1
177
+ * @param {number} [saturation=0] The saturation value 0...1
178
+ * @param {number} [lightness=0] The lightness value 0...1
179
+ * @param {number} [alpha=1.0] The alpha component 0...1
180
+ * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
181
+ * @returns {Color} The color object.
182
+ *
183
+ * @see {@link http://www.w3.org/TR/css3-color/#hsl-color|CSS color values}
184
+ */
185
+ static fromHsl(hue, saturation, lightness, alpha, result) {
186
+ hue = (hue ?? 0.0) % 1.0;
187
+ saturation = saturation ?? 0.0;
188
+ lightness = lightness ?? 0.0;
189
+ alpha = alpha ?? 1.0;
190
+
191
+ let red = lightness;
192
+ let green = lightness;
193
+ let blue = lightness;
194
+
195
+ if (saturation !== 0) {
196
+ let m2;
197
+ if (lightness < 0.5) {
198
+ m2 = lightness * (1 + saturation);
199
+ } else {
200
+ m2 = lightness + saturation - lightness * saturation;
201
+ }
202
+
203
+ const m1 = 2.0 * lightness - m2;
204
+ red = hue2rgb(m1, m2, hue + 1 / 3);
205
+ green = hue2rgb(m1, m2, hue);
206
+ blue = hue2rgb(m1, m2, hue - 1 / 3);
207
+ }
208
+
209
+ if (!defined(result)) {
210
+ return new Color(red, green, blue, alpha);
211
+ }
106
212
 
107
- if (!defined(result)) {
108
- return new Color(red, green, blue, alpha);
213
+ result.red = red;
214
+ result.green = green;
215
+ result.blue = blue;
216
+ result.alpha = alpha;
217
+ return result;
109
218
  }
110
219
 
111
- result.red = red;
112
- result.green = green;
113
- result.blue = blue;
114
- result.alpha = alpha;
115
- return result;
116
- };
220
+ /**
221
+ * Creates a random color using the provided options. For reproducible random colors, you should
222
+ * call {@link CesiumMath#setRandomNumberSeed} once at the beginning of your application.
223
+ *
224
+ * @param {object} [options] Object with the following properties:
225
+ * @param {number} [options.red] If specified, the red component to use instead of a randomized value.
226
+ * @param {number} [options.minimumRed=0.0] The maximum red value to generate if none was specified.
227
+ * @param {number} [options.maximumRed=1.0] The minimum red value to generate if none was specified.
228
+ * @param {number} [options.green] If specified, the green component to use instead of a randomized value.
229
+ * @param {number} [options.minimumGreen=0.0] The maximum green value to generate if none was specified.
230
+ * @param {number} [options.maximumGreen=1.0] The minimum green value to generate if none was specified.
231
+ * @param {number} [options.blue] If specified, the blue component to use instead of a randomized value.
232
+ * @param {number} [options.minimumBlue=0.0] The maximum blue value to generate if none was specified.
233
+ * @param {number} [options.maximumBlue=1.0] The minimum blue value to generate if none was specified.
234
+ * @param {number} [options.alpha] If specified, the alpha component to use instead of a randomized value.
235
+ * @param {number} [options.minimumAlpha=0.0] The maximum alpha value to generate if none was specified.
236
+ * @param {number} [options.maximumAlpha=1.0] The minimum alpha value to generate if none was specified.
237
+ * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
238
+ * @returns {Color} The modified result parameter or a new instance if result was undefined.
239
+ *
240
+ * @exception {DeveloperError} minimumRed must be less than or equal to maximumRed.
241
+ * @exception {DeveloperError} minimumGreen must be less than or equal to maximumGreen.
242
+ * @exception {DeveloperError} minimumBlue must be less than or equal to maximumBlue.
243
+ * @exception {DeveloperError} minimumAlpha must be less than or equal to maximumAlpha.
244
+ *
245
+ * @example
246
+ * //Create a completely random color
247
+ * const color = Cesium.Color.fromRandom();
248
+ *
249
+ * //Create a random shade of yellow.
250
+ * const color1 = Cesium.Color.fromRandom({
251
+ * red : 1.0,
252
+ * green : 1.0,
253
+ * alpha : 1.0
254
+ * });
255
+ *
256
+ * //Create a random bright color.
257
+ * const color2 = Cesium.Color.fromRandom({
258
+ * minimumRed : 0.75,
259
+ * minimumGreen : 0.75,
260
+ * minimumBlue : 0.75,
261
+ * alpha : 1.0
262
+ * });
263
+ */
264
+ static fromRandom(options, result) {
265
+ options = options ?? Frozen.EMPTY_OBJECT;
266
+
267
+ let red = options.red;
268
+ if (!defined(red)) {
269
+ const minimumRed = options.minimumRed ?? 0;
270
+ const maximumRed = options.maximumRed ?? 1.0;
271
+
272
+ //>>includeStart('debug', pragmas.debug);
273
+ Check.typeOf.number.lessThanOrEquals(
274
+ "minimumRed",
275
+ minimumRed,
276
+ maximumRed,
277
+ );
278
+ //>>includeEnd('debug');
279
+
280
+ red =
281
+ minimumRed + CesiumMath.nextRandomNumber() * (maximumRed - minimumRed);
282
+ }
117
283
 
118
- /**
119
- * Creates a new Color that has the same red, green, and blue components
120
- * of the specified color, but with the specified alpha value.
121
- *
122
- * @param {Color} color The base color
123
- * @param {number} alpha The new alpha component.
124
- * @param {Color} [result] The object onto which to store the result.
125
- * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
126
- *
127
- * @example const translucentRed = Cesium.Color.fromAlpha(Cesium.Color.RED, 0.9);
128
- */
129
- Color.fromAlpha = function (color, alpha, result) {
130
- //>>includeStart('debug', pragmas.debug);
131
- Check.typeOf.object("color", color);
132
- Check.typeOf.number("alpha", alpha);
133
- //>>includeEnd('debug');
284
+ let green = options.green;
285
+ if (!defined(green)) {
286
+ const minimumGreen = options.minimumGreen ?? 0;
287
+ const maximumGreen = options.maximumGreen ?? 1.0;
288
+
289
+ //>>includeStart('debug', pragmas.debug);
290
+ Check.typeOf.number.lessThanOrEquals(
291
+ "minimumGreen",
292
+ minimumGreen,
293
+ maximumGreen,
294
+ );
295
+ //>>includeEnd('debug');
296
+ green =
297
+ minimumGreen +
298
+ CesiumMath.nextRandomNumber() * (maximumGreen - minimumGreen);
299
+ }
134
300
 
135
- if (!defined(result)) {
136
- return new Color(color.red, color.green, color.blue, alpha);
137
- }
301
+ let blue = options.blue;
302
+ if (!defined(blue)) {
303
+ const minimumBlue = options.minimumBlue ?? 0;
304
+ const maximumBlue = options.maximumBlue ?? 1.0;
305
+
306
+ //>>includeStart('debug', pragmas.debug);
307
+ Check.typeOf.number.lessThanOrEquals(
308
+ "minimumBlue",
309
+ minimumBlue,
310
+ maximumBlue,
311
+ );
312
+ //>>includeEnd('debug');
313
+
314
+ blue =
315
+ minimumBlue +
316
+ CesiumMath.nextRandomNumber() * (maximumBlue - minimumBlue);
317
+ }
138
318
 
139
- result.red = color.red;
140
- result.green = color.green;
141
- result.blue = color.blue;
142
- result.alpha = alpha;
143
- return result;
144
- };
319
+ let alpha = options.alpha;
320
+ if (!defined(alpha)) {
321
+ const minimumAlpha = options.minimumAlpha ?? 0;
322
+ const maximumAlpha = options.maximumAlpha ?? 1.0;
323
+
324
+ //>>includeStart('debug', pragmas.debug);
325
+ Check.typeOf.number.lessThanOrEquals(
326
+ "minimumAlpha",
327
+ minimumAlpha,
328
+ maximumAlpha,
329
+ );
330
+ //>>includeEnd('debug');
331
+
332
+ alpha =
333
+ minimumAlpha +
334
+ CesiumMath.nextRandomNumber() * (maximumAlpha - minimumAlpha);
335
+ }
145
336
 
146
- let scratchArrayBuffer;
147
- let scratchUint32Array;
148
- let scratchUint8Array;
149
- if (FeatureDetection.supportsTypedArrays()) {
150
- scratchArrayBuffer = new ArrayBuffer(4);
151
- scratchUint32Array = new Uint32Array(scratchArrayBuffer);
152
- scratchUint8Array = new Uint8Array(scratchArrayBuffer);
153
- }
337
+ if (!defined(result)) {
338
+ return new Color(red, green, blue, alpha);
339
+ }
154
340
 
155
- /**
156
- * Creates a new Color from a single numeric unsigned 32-bit RGBA value, using the endianness
157
- * of the system.
158
- *
159
- * @param {number} rgba A single numeric unsigned 32-bit RGBA value.
160
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
161
- * @returns {Color} The color object.
162
- *
163
- * @example
164
- * const color = Cesium.Color.fromRgba(0x67ADDFFF);
165
- *
166
- * @see Color#toRgba
167
- */
168
- Color.fromRgba = function (rgba, result) {
169
- // scratchUint32Array and scratchUint8Array share an underlying array buffer
170
- scratchUint32Array[0] = rgba;
171
- return Color.fromBytes(
172
- scratchUint8Array[0],
173
- scratchUint8Array[1],
174
- scratchUint8Array[2],
175
- scratchUint8Array[3],
176
- result,
177
- );
178
- };
341
+ result.red = red;
342
+ result.green = green;
343
+ result.blue = blue;
344
+ result.alpha = alpha;
345
+ return result;
346
+ }
179
347
 
180
- /**
181
- * Creates a Color instance from hue, saturation, and lightness.
182
- *
183
- * @param {number} [hue=0] The hue angle 0...1
184
- * @param {number} [saturation=0] The saturation value 0...1
185
- * @param {number} [lightness=0] The lightness value 0...1
186
- * @param {number} [alpha=1.0] The alpha component 0...1
187
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
188
- * @returns {Color} The color object.
189
- *
190
- * @see {@link http://www.w3.org/TR/css3-color/#hsl-color|CSS color values}
191
- */
192
- Color.fromHsl = function (hue, saturation, lightness, alpha, result) {
193
- hue = (hue ?? 0.0) % 1.0;
194
- saturation = saturation ?? 0.0;
195
- lightness = lightness ?? 0.0;
196
- alpha = alpha ?? 1.0;
348
+ /**
349
+ * Creates a Color instance from a CSS color value.
350
+ *
351
+ * @param {string} color The CSS color value in #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(), rgba(), hsl(), or hsla() format.
352
+ * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
353
+ * @returns {Color} The color object, or undefined if the string was not a valid CSS color.
354
+ *
355
+ *
356
+ * @example
357
+ * const cesiumBlue = Cesium.Color.fromCssColorString('#67ADDF');
358
+ * const green = Cesium.Color.fromCssColorString('green');
359
+ *
360
+ * @see {@link http://www.w3.org/TR/css3-color|CSS color values}
361
+ */
362
+ static fromCssColorString(color, result) {
363
+ //>>includeStart('debug', pragmas.debug);
364
+ Check.typeOf.string("color", color);
365
+ //>>includeEnd('debug');
366
+
367
+ if (!defined(result)) {
368
+ result = new Color();
369
+ }
197
370
 
198
- let red = lightness;
199
- let green = lightness;
200
- let blue = lightness;
371
+ // Remove all surrounding whitespaces from the color string
372
+ color = color.trim();
201
373
 
202
- if (saturation !== 0) {
203
- let m2;
204
- if (lightness < 0.5) {
205
- m2 = lightness * (1 + saturation);
206
- } else {
207
- m2 = lightness + saturation - lightness * saturation;
374
+ const namedColor = Color[color.toUpperCase()];
375
+ if (defined(namedColor)) {
376
+ Color.clone(namedColor, result);
377
+ return result;
208
378
  }
209
379
 
210
- const m1 = 2.0 * lightness - m2;
211
- red = hue2rgb(m1, m2, hue + 1 / 3);
212
- green = hue2rgb(m1, m2, hue);
213
- blue = hue2rgb(m1, m2, hue - 1 / 3);
214
- }
380
+ let matches = rgbaMatcher.exec(color);
381
+ if (matches !== null) {
382
+ result.red = parseInt(matches[1], 16) / 15;
383
+ result.green = parseInt(matches[2], 16) / 15.0;
384
+ result.blue = parseInt(matches[3], 16) / 15.0;
385
+ result.alpha = parseInt(matches[4] ?? "f", 16) / 15.0;
386
+ return result;
387
+ }
215
388
 
216
- if (!defined(result)) {
217
- return new Color(red, green, blue, alpha);
218
- }
389
+ matches = rrggbbaaMatcher.exec(color);
390
+ if (matches !== null) {
391
+ result.red = parseInt(matches[1], 16) / 255.0;
392
+ result.green = parseInt(matches[2], 16) / 255.0;
393
+ result.blue = parseInt(matches[3], 16) / 255.0;
394
+ result.alpha = parseInt(matches[4] ?? "ff", 16) / 255.0;
395
+ return result;
396
+ }
219
397
 
220
- result.red = red;
221
- result.green = green;
222
- result.blue = blue;
223
- result.alpha = alpha;
224
- return result;
225
- };
226
-
227
- /**
228
- * Creates a random color using the provided options. For reproducible random colors, you should
229
- * call {@link CesiumMath#setRandomNumberSeed} once at the beginning of your application.
230
- *
231
- * @param {object} [options] Object with the following properties:
232
- * @param {number} [options.red] If specified, the red component to use instead of a randomized value.
233
- * @param {number} [options.minimumRed=0.0] The maximum red value to generate if none was specified.
234
- * @param {number} [options.maximumRed=1.0] The minimum red value to generate if none was specified.
235
- * @param {number} [options.green] If specified, the green component to use instead of a randomized value.
236
- * @param {number} [options.minimumGreen=0.0] The maximum green value to generate if none was specified.
237
- * @param {number} [options.maximumGreen=1.0] The minimum green value to generate if none was specified.
238
- * @param {number} [options.blue] If specified, the blue component to use instead of a randomized value.
239
- * @param {number} [options.minimumBlue=0.0] The maximum blue value to generate if none was specified.
240
- * @param {number} [options.maximumBlue=1.0] The minimum blue value to generate if none was specified.
241
- * @param {number} [options.alpha] If specified, the alpha component to use instead of a randomized value.
242
- * @param {number} [options.minimumAlpha=0.0] The maximum alpha value to generate if none was specified.
243
- * @param {number} [options.maximumAlpha=1.0] The minimum alpha value to generate if none was specified.
244
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
245
- * @returns {Color} The modified result parameter or a new instance if result was undefined.
246
- *
247
- * @exception {DeveloperError} minimumRed must be less than or equal to maximumRed.
248
- * @exception {DeveloperError} minimumGreen must be less than or equal to maximumGreen.
249
- * @exception {DeveloperError} minimumBlue must be less than or equal to maximumBlue.
250
- * @exception {DeveloperError} minimumAlpha must be less than or equal to maximumAlpha.
251
- *
252
- * @example
253
- * //Create a completely random color
254
- * const color = Cesium.Color.fromRandom();
255
- *
256
- * //Create a random shade of yellow.
257
- * const color1 = Cesium.Color.fromRandom({
258
- * red : 1.0,
259
- * green : 1.0,
260
- * alpha : 1.0
261
- * });
262
- *
263
- * //Create a random bright color.
264
- * const color2 = Cesium.Color.fromRandom({
265
- * minimumRed : 0.75,
266
- * minimumGreen : 0.75,
267
- * minimumBlue : 0.75,
268
- * alpha : 1.0
269
- * });
270
- */
271
- Color.fromRandom = function (options, result) {
272
- options = options ?? Frozen.EMPTY_OBJECT;
273
-
274
- let red = options.red;
275
- if (!defined(red)) {
276
- const minimumRed = options.minimumRed ?? 0;
277
- const maximumRed = options.maximumRed ?? 1.0;
398
+ matches = rgbParenthesesMatcher.exec(color);
399
+ if (matches !== null) {
400
+ result.red =
401
+ parseFloat(matches[1]) /
402
+ ("%" === matches[1].substr(-1) ? 100.0 : 255.0);
403
+ result.green =
404
+ parseFloat(matches[2]) /
405
+ ("%" === matches[2].substr(-1) ? 100.0 : 255.0);
406
+ result.blue =
407
+ parseFloat(matches[3]) /
408
+ ("%" === matches[3].substr(-1) ? 100.0 : 255.0);
409
+ result.alpha = parseFloat(matches[4] ?? "1.0");
410
+ return result;
411
+ }
278
412
 
279
- //>>includeStart('debug', pragmas.debug);
280
- Check.typeOf.number.lessThanOrEquals("minimumRed", minimumRed, maximumRed);
281
- //>>includeEnd('debug');
413
+ matches = hslParenthesesMatcher.exec(color);
414
+ if (matches !== null) {
415
+ return Color.fromHsl(
416
+ parseFloat(matches[1]) / 360.0,
417
+ parseFloat(matches[2]) / 100.0,
418
+ parseFloat(matches[3]) / 100.0,
419
+ parseFloat(matches[4] ?? "1.0"),
420
+ result,
421
+ );
422
+ }
282
423
 
283
- red =
284
- minimumRed + CesiumMath.nextRandomNumber() * (maximumRed - minimumRed);
424
+ result = undefined;
425
+ return result;
285
426
  }
286
427
 
287
- let green = options.green;
288
- if (!defined(green)) {
289
- const minimumGreen = options.minimumGreen ?? 0;
290
- const maximumGreen = options.maximumGreen ?? 1.0;
291
-
428
+ /**
429
+ * Stores the provided instance into the provided array.
430
+ *
431
+ * @param {Color} value The value to pack.
432
+ * @param {number[]|TypedArray} array The array to pack into.
433
+ * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
434
+ *
435
+ * @returns {number[]|TypedArray} The array that was packed into
436
+ */
437
+ static pack(value, array, startingIndex) {
292
438
  //>>includeStart('debug', pragmas.debug);
293
- Check.typeOf.number.lessThanOrEquals(
294
- "minimumGreen",
295
- minimumGreen,
296
- maximumGreen,
297
- );
439
+ Check.typeOf.object("value", value);
440
+ Check.defined("array", array);
298
441
  //>>includeEnd('debug');
299
- green =
300
- minimumGreen +
301
- CesiumMath.nextRandomNumber() * (maximumGreen - minimumGreen);
302
- }
303
442
 
304
- let blue = options.blue;
305
- if (!defined(blue)) {
306
- const minimumBlue = options.minimumBlue ?? 0;
307
- const maximumBlue = options.maximumBlue ?? 1.0;
443
+ startingIndex = startingIndex ?? 0;
444
+ array[startingIndex++] = value.red;
445
+ array[startingIndex++] = value.green;
446
+ array[startingIndex++] = value.blue;
447
+ array[startingIndex] = value.alpha;
448
+
449
+ return array;
450
+ }
308
451
 
452
+ /**
453
+ * Retrieves an instance from a packed array.
454
+ *
455
+ * @param {number[]|TypedArray} array The packed array.
456
+ * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
457
+ * @param {Color} [result] The object into which to store the result.
458
+ * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
459
+ */
460
+ static unpack(array, startingIndex, result) {
309
461
  //>>includeStart('debug', pragmas.debug);
310
- Check.typeOf.number.lessThanOrEquals(
311
- "minimumBlue",
312
- minimumBlue,
313
- maximumBlue,
314
- );
462
+ Check.defined("array", array);
315
463
  //>>includeEnd('debug');
316
464
 
317
- blue =
318
- minimumBlue + CesiumMath.nextRandomNumber() * (maximumBlue - minimumBlue);
465
+ startingIndex = startingIndex ?? 0;
466
+ if (!defined(result)) {
467
+ result = new Color();
468
+ }
469
+ result.red = array[startingIndex++];
470
+ result.green = array[startingIndex++];
471
+ result.blue = array[startingIndex++];
472
+ result.alpha = array[startingIndex];
473
+ return result;
319
474
  }
320
475
 
321
- let alpha = options.alpha;
322
- if (!defined(alpha)) {
323
- const minimumAlpha = options.minimumAlpha ?? 0;
324
- const maximumAlpha = options.maximumAlpha ?? 1.0;
476
+ /**
477
+ * Converts a 'byte' color component in the range of 0 to 255 into
478
+ * a 'float' color component in the range of 0 to 1.0.
479
+ *
480
+ * @param {number} number The number to be converted.
481
+ * @returns {number} The converted number.
482
+ */
483
+ static byteToFloat(number) {
484
+ return number / 255.0;
485
+ }
325
486
 
326
- //>>includeStart('debug', pragmas.debug);
327
- Check.typeOf.number.lessThanOrEquals(
328
- "minimumAlpha",
329
- minimumAlpha,
330
- maximumAlpha,
331
- );
332
- //>>includeEnd('debug');
487
+ /**
488
+ * Converts a 'float' color component in the range of 0 to 1.0 into
489
+ * a 'byte' color component in the range of 0 to 255.
490
+ *
491
+ * @param {number} number The number to be converted.
492
+ * @returns {number} The converted number.
493
+ */
494
+ static floatToByte(number) {
495
+ return number === 1.0 ? 255.0 : (number * 256.0) | 0;
496
+ }
333
497
 
334
- alpha =
335
- minimumAlpha +
336
- CesiumMath.nextRandomNumber() * (maximumAlpha - minimumAlpha);
498
+ /**
499
+ * Duplicates a Color.
500
+ *
501
+ * @param {Color} color The Color to duplicate.
502
+ * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
503
+ * @returns {Color} The modified result parameter or a new instance if result was undefined. (Returns undefined if color is undefined)
504
+ */
505
+ static clone(color, result) {
506
+ if (!defined(color)) {
507
+ return undefined;
508
+ }
509
+ if (!defined(result)) {
510
+ return new Color(color.red, color.green, color.blue, color.alpha);
511
+ }
512
+ result.red = color.red;
513
+ result.green = color.green;
514
+ result.blue = color.blue;
515
+ result.alpha = color.alpha;
516
+ return result;
337
517
  }
338
518
 
339
- if (!defined(result)) {
340
- return new Color(red, green, blue, alpha);
519
+ /**
520
+ * Returns true if the first Color equals the second color.
521
+ *
522
+ * @param {Color} [left] The first Color to compare for equality.
523
+ * @param {Color} [right] The second Color to compare for equality.
524
+ * @returns {boolean} <code>true</code> if the Colors are equal; otherwise, <code>false</code>.
525
+ */
526
+ static equals(left, right) {
527
+ return (
528
+ left === right || //
529
+ (defined(left) && //
530
+ defined(right) && //
531
+ left.red === right.red && //
532
+ left.green === right.green && //
533
+ left.blue === right.blue && //
534
+ left.alpha === right.alpha)
535
+ );
341
536
  }
342
537
 
343
- result.red = red;
344
- result.green = green;
345
- result.blue = blue;
346
- result.alpha = alpha;
347
- return result;
348
- };
538
+ /**
539
+ * @private
540
+ */
541
+ static equalsArray(color, array, offset) {
542
+ return (
543
+ color.red === array[offset] &&
544
+ color.green === array[offset + 1] &&
545
+ color.blue === array[offset + 2] &&
546
+ color.alpha === array[offset + 3]
547
+ );
548
+ }
349
549
 
350
- //#rgba
351
- const rgbaMatcher = /^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i;
352
- //#rrggbbaa
353
- const rrggbbaaMatcher =
354
- /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i;
355
- //rgb(), rgba(), or rgb%()
356
- const rgbParenthesesMatcher =
357
- /^rgba?\s*\(\s*([0-9.]+%?)\s*[,\s]+\s*([0-9.]+%?)\s*[,\s]+\s*([0-9.]+%?)(?:\s*[,\s/]+\s*([0-9.]+))?\s*\)$/i;
358
- //hsl() or hsla()
359
- const hslParenthesesMatcher =
360
- /^hsla?\s*\(\s*([0-9.]+)\s*[,\s]+\s*([0-9.]+%)\s*[,\s]+\s*([0-9.]+%)(?:\s*[,\s/]+\s*([0-9.]+))?\s*\)$/i;
550
+ /**
551
+ * Returns a duplicate of a Color instance.
552
+ *
553
+ * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
554
+ * @returns {Color} The modified result parameter or a new instance if result was undefined.
555
+ */
556
+ clone(result) {
557
+ return Color.clone(this, result);
558
+ }
361
559
 
362
- /**
363
- * Creates a Color instance from a CSS color value.
364
- *
365
- * @param {string} color The CSS color value in #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(), rgba(), hsl(), or hsla() format.
366
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
367
- * @returns {Color} The color object, or undefined if the string was not a valid CSS color.
368
- *
369
- *
370
- * @example
371
- * const cesiumBlue = Cesium.Color.fromCssColorString('#67ADDF');
372
- * const green = Cesium.Color.fromCssColorString('green');
373
- *
374
- * @see {@link http://www.w3.org/TR/css3-color|CSS color values}
375
- */
376
- Color.fromCssColorString = function (color, result) {
377
- //>>includeStart('debug', pragmas.debug);
378
- Check.typeOf.string("color", color);
379
- //>>includeEnd('debug');
560
+ /**
561
+ * Returns true if this Color equals other.
562
+ *
563
+ * @param {Color} [other] The Color to compare for equality.
564
+ * @returns {boolean} <code>true</code> if the Colors are equal; otherwise, <code>false</code>.
565
+ */
566
+ equals(other) {
567
+ return Color.equals(this, other);
568
+ }
380
569
 
381
- if (!defined(result)) {
382
- result = new Color();
570
+ /**
571
+ * Returns <code>true</code> if this Color equals other componentwise within the specified epsilon.
572
+ *
573
+ * @param {Color} other The Color to compare for equality.
574
+ * @param {number} [epsilon=0.0] The epsilon to use for equality testing.
575
+ * @returns {boolean} <code>true</code> if the Colors are equal within the specified epsilon; otherwise, <code>false</code>.
576
+ */
577
+ equalsEpsilon(other, epsilon) {
578
+ return (
579
+ this === other || //
580
+ (defined(other) && //
581
+ Math.abs(this.red - other.red) <= epsilon && //
582
+ Math.abs(this.green - other.green) <= epsilon && //
583
+ Math.abs(this.blue - other.blue) <= epsilon && //
584
+ Math.abs(this.alpha - other.alpha) <= epsilon)
585
+ );
383
586
  }
384
587
 
385
- // Remove all surrounding whitespaces from the color string
386
- color = color.trim();
588
+ /**
589
+ * Creates a string representing this Color in the format '(red, green, blue, alpha)'.
590
+ *
591
+ * @returns {string} A string representing this Color in the format '(red, green, blue, alpha)'.
592
+ */
593
+ toString() {
594
+ return `(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
595
+ }
387
596
 
388
- const namedColor = Color[color.toUpperCase()];
389
- if (defined(namedColor)) {
390
- Color.clone(namedColor, result);
391
- return result;
597
+ /**
598
+ * Creates a string containing the CSS color value for this color.
599
+ *
600
+ * @returns {string} The CSS equivalent of this color.
601
+ *
602
+ * @see {@link http://www.w3.org/TR/css3-color/#rgba-color|CSS RGB or RGBA color values}
603
+ */
604
+ toCssColorString() {
605
+ const red = Color.floatToByte(this.red);
606
+ const green = Color.floatToByte(this.green);
607
+ const blue = Color.floatToByte(this.blue);
608
+ if (this.alpha === 1) {
609
+ return `rgb(${red},${green},${blue})`;
610
+ }
611
+ return `rgba(${red},${green},${blue},${this.alpha})`;
392
612
  }
393
613
 
394
- let matches = rgbaMatcher.exec(color);
395
- if (matches !== null) {
396
- result.red = parseInt(matches[1], 16) / 15;
397
- result.green = parseInt(matches[2], 16) / 15.0;
398
- result.blue = parseInt(matches[3], 16) / 15.0;
399
- result.alpha = parseInt(matches[4] ?? "f", 16) / 15.0;
400
- return result;
614
+ /**
615
+ * Creates a string containing CSS hex string color value for this color.
616
+ *
617
+ * @returns {string} The CSS hex string equivalent of this color.
618
+ */
619
+ toCssHexString() {
620
+ let r = Color.floatToByte(this.red).toString(16);
621
+ if (r.length < 2) {
622
+ r = `0${r}`;
623
+ }
624
+ let g = Color.floatToByte(this.green).toString(16);
625
+ if (g.length < 2) {
626
+ g = `0${g}`;
627
+ }
628
+ let b = Color.floatToByte(this.blue).toString(16);
629
+ if (b.length < 2) {
630
+ b = `0${b}`;
631
+ }
632
+ if (this.alpha < 1) {
633
+ let hexAlpha = Color.floatToByte(this.alpha).toString(16);
634
+ if (hexAlpha.length < 2) {
635
+ hexAlpha = `0${hexAlpha}`;
636
+ }
637
+ return `#${r}${g}${b}${hexAlpha}`;
638
+ }
639
+ return `#${r}${g}${b}`;
401
640
  }
402
641
 
403
- matches = rrggbbaaMatcher.exec(color);
404
- if (matches !== null) {
405
- result.red = parseInt(matches[1], 16) / 255.0;
406
- result.green = parseInt(matches[2], 16) / 255.0;
407
- result.blue = parseInt(matches[3], 16) / 255.0;
408
- result.alpha = parseInt(matches[4] ?? "ff", 16) / 255.0;
642
+ /**
643
+ * Converts this color to an array of red, green, blue, and alpha values
644
+ * that are in the range of 0 to 255.
645
+ *
646
+ * @param {number[]} [result] The array to store the result in, if undefined a new instance will be created.
647
+ * @returns {number[]} The modified result parameter or a new instance if result was undefined.
648
+ */
649
+ toBytes(result) {
650
+ const red = Color.floatToByte(this.red);
651
+ const green = Color.floatToByte(this.green);
652
+ const blue = Color.floatToByte(this.blue);
653
+ const alpha = Color.floatToByte(this.alpha);
654
+
655
+ if (!defined(result)) {
656
+ return [red, green, blue, alpha];
657
+ }
658
+ result[0] = red;
659
+ result[1] = green;
660
+ result[2] = blue;
661
+ result[3] = alpha;
409
662
  return result;
410
663
  }
411
664
 
412
- matches = rgbParenthesesMatcher.exec(color);
413
- if (matches !== null) {
414
- result.red =
415
- parseFloat(matches[1]) / ("%" === matches[1].substr(-1) ? 100.0 : 255.0);
416
- result.green =
417
- parseFloat(matches[2]) / ("%" === matches[2].substr(-1) ? 100.0 : 255.0);
418
- result.blue =
419
- parseFloat(matches[3]) / ("%" === matches[3].substr(-1) ? 100.0 : 255.0);
420
- result.alpha = parseFloat(matches[4] ?? "1.0");
421
- return result;
665
+ /**
666
+ * Converts RGBA values in bytes to a single numeric unsigned 32-bit RGBA value, using the endianness
667
+ * of the system.
668
+ *
669
+ * @returns {number} A single numeric unsigned 32-bit RGBA value.
670
+ *
671
+ * @see Color.toRgba
672
+ */
673
+ static bytesToRgba(red, green, blue, alpha) {
674
+ // scratchUint32Array and scratchUint8Array share an underlying array buffer
675
+ scratchUint8Array[0] = red;
676
+ scratchUint8Array[1] = green;
677
+ scratchUint8Array[2] = blue;
678
+ scratchUint8Array[3] = alpha;
679
+ return scratchUint32Array[0];
422
680
  }
423
681
 
424
- matches = hslParenthesesMatcher.exec(color);
425
- if (matches !== null) {
426
- return Color.fromHsl(
427
- parseFloat(matches[1]) / 360.0,
428
- parseFloat(matches[2]) / 100.0,
429
- parseFloat(matches[3]) / 100.0,
430
- parseFloat(matches[4] ?? "1.0"),
431
- result,
682
+ /**
683
+ * Converts this color to a single numeric unsigned 32-bit RGBA value, using the endianness
684
+ * of the system.
685
+ *
686
+ * @returns {number} A single numeric unsigned 32-bit RGBA value.
687
+ *
688
+ *
689
+ * @example
690
+ * const rgba = Cesium.Color.BLUE.toRgba();
691
+ *
692
+ * @see Color.fromRgba
693
+ */
694
+ toRgba() {
695
+ return Color.bytesToRgba(
696
+ Color.floatToByte(this.red),
697
+ Color.floatToByte(this.green),
698
+ Color.floatToByte(this.blue),
699
+ Color.floatToByte(this.alpha),
432
700
  );
433
701
  }
434
702
 
435
- result = undefined;
436
- return result;
437
- };
438
-
439
- /**
440
- * The number of elements used to pack the object into an array.
441
- * @type {number}
442
- */
443
- Color.packedLength = 4;
444
-
445
- /**
446
- * Stores the provided instance into the provided array.
447
- *
448
- * @param {Color} value The value to pack.
449
- * @param {number[]} array The array to pack into.
450
- * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
451
- *
452
- * @returns {number[]} The array that was packed into
453
- */
454
- Color.pack = function (value, array, startingIndex) {
455
- //>>includeStart('debug', pragmas.debug);
456
- Check.typeOf.object("value", value);
457
- Check.defined("array", array);
458
- //>>includeEnd('debug');
459
-
460
- startingIndex = startingIndex ?? 0;
461
- array[startingIndex++] = value.red;
462
- array[startingIndex++] = value.green;
463
- array[startingIndex++] = value.blue;
464
- array[startingIndex] = value.alpha;
703
+ /**
704
+ * Brightens this color by the provided magnitude.
705
+ *
706
+ * @param {number} magnitude A positive number indicating the amount to brighten.
707
+ * @param {Color} result The object onto which to store the result.
708
+ * @returns {Color} The modified result parameter.
709
+ *
710
+ * @example
711
+ * const brightBlue = Cesium.Color.BLUE.brighten(0.5, new Cesium.Color());
712
+ */
713
+ brighten(magnitude, result) {
714
+ //>>includeStart('debug', pragmas.debug);
715
+ Check.typeOf.number("magnitude", magnitude);
716
+ Check.typeOf.number.greaterThanOrEquals("magnitude", magnitude, 0.0);
717
+ Check.typeOf.object("result", result);
718
+ //>>includeEnd('debug');
465
719
 
466
- return array;
467
- };
720
+ magnitude = 1.0 - magnitude;
721
+ result.red = 1.0 - (1.0 - this.red) * magnitude;
722
+ result.green = 1.0 - (1.0 - this.green) * magnitude;
723
+ result.blue = 1.0 - (1.0 - this.blue) * magnitude;
724
+ result.alpha = this.alpha;
725
+ return result;
726
+ }
468
727
 
469
- /**
470
- * Retrieves an instance from a packed array.
471
- *
472
- * @param {number[]} array The packed array.
473
- * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
474
- * @param {Color} [result] The object into which to store the result.
475
- * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
476
- */
477
- Color.unpack = function (array, startingIndex, result) {
478
- //>>includeStart('debug', pragmas.debug);
479
- Check.defined("array", array);
480
- //>>includeEnd('debug');
728
+ /**
729
+ * Darkens this color by the provided magnitude.
730
+ *
731
+ * @param {number} magnitude A positive number indicating the amount to darken.
732
+ * @param {Color} result The object onto which to store the result.
733
+ * @returns {Color} The modified result parameter.
734
+ *
735
+ * @example
736
+ * const darkBlue = Cesium.Color.BLUE.darken(0.5, new Cesium.Color());
737
+ */
738
+ darken(magnitude, result) {
739
+ //>>includeStart('debug', pragmas.debug);
740
+ Check.typeOf.number("magnitude", magnitude);
741
+ Check.typeOf.number.greaterThanOrEquals("magnitude", magnitude, 0.0);
742
+ Check.typeOf.object("result", result);
743
+ //>>includeEnd('debug');
481
744
 
482
- startingIndex = startingIndex ?? 0;
483
- if (!defined(result)) {
484
- result = new Color();
745
+ magnitude = 1.0 - magnitude;
746
+ result.red = this.red * magnitude;
747
+ result.green = this.green * magnitude;
748
+ result.blue = this.blue * magnitude;
749
+ result.alpha = this.alpha;
750
+ return result;
485
751
  }
486
- result.red = array[startingIndex++];
487
- result.green = array[startingIndex++];
488
- result.blue = array[startingIndex++];
489
- result.alpha = array[startingIndex];
490
- return result;
491
- };
492
752
 
493
- /**
494
- * Converts a 'byte' color component in the range of 0 to 255 into
495
- * a 'float' color component in the range of 0 to 1.0.
496
- *
497
- * @param {number} number The number to be converted.
498
- * @returns {number} The converted number.
499
- */
500
- Color.byteToFloat = function (number) {
501
- return number / 255.0;
502
- };
753
+ /**
754
+ * Creates a new Color that has the same red, green, and blue components
755
+ * as this Color, but with the specified alpha value.
756
+ *
757
+ * @param {number} alpha The new alpha component.
758
+ * @param {Color} [result] The object onto which to store the result.
759
+ * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
760
+ *
761
+ * @example const translucentRed = Cesium.Color.RED.withAlpha(0.9);
762
+ */
763
+ withAlpha(alpha, result) {
764
+ return Color.fromAlpha(this, alpha, result);
765
+ }
503
766
 
504
- /**
505
- * Converts a 'float' color component in the range of 0 to 1.0 into
506
- * a 'byte' color component in the range of 0 to 255.
507
- *
508
- * @param {number} number The number to be converted.
509
- * @returns {number} The converted number.
510
- */
511
- Color.floatToByte = function (number) {
512
- return number === 1.0 ? 255.0 : (number * 256.0) | 0;
513
- };
767
+ /**
768
+ * Computes the componentwise sum of two Colors.
769
+ *
770
+ * @param {Color} left The first Color.
771
+ * @param {Color} right The second Color.
772
+ * @param {Color} result The object onto which to store the result.
773
+ * @returns {Color} The modified result parameter.
774
+ */
775
+ static add(left, right, result) {
776
+ //>>includeStart('debug', pragmas.debug);
777
+ Check.typeOf.object("left", left);
778
+ Check.typeOf.object("right", right);
779
+ Check.typeOf.object("result", result);
780
+ //>>includeEnd('debug');
514
781
 
515
- /**
516
- * Duplicates a Color.
517
- *
518
- * @param {Color} color The Color to duplicate.
519
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
520
- * @returns {Color} The modified result parameter or a new instance if result was undefined. (Returns undefined if color is undefined)
521
- */
522
- Color.clone = function (color, result) {
523
- if (!defined(color)) {
524
- return undefined;
525
- }
526
- if (!defined(result)) {
527
- return new Color(color.red, color.green, color.blue, color.alpha);
782
+ result.red = left.red + right.red;
783
+ result.green = left.green + right.green;
784
+ result.blue = left.blue + right.blue;
785
+ result.alpha = left.alpha + right.alpha;
786
+ return result;
528
787
  }
529
- result.red = color.red;
530
- result.green = color.green;
531
- result.blue = color.blue;
532
- result.alpha = color.alpha;
533
- return result;
534
- };
535
788
 
536
- /**
537
- * Returns true if the first Color equals the second color.
538
- *
539
- * @param {Color} [left] The first Color to compare for equality.
540
- * @param {Color} [right] The second Color to compare for equality.
541
- * @returns {boolean} <code>true</code> if the Colors are equal; otherwise, <code>false</code>.
542
- */
543
- Color.equals = function (left, right) {
544
- return (
545
- left === right || //
546
- (defined(left) && //
547
- defined(right) && //
548
- left.red === right.red && //
549
- left.green === right.green && //
550
- left.blue === right.blue && //
551
- left.alpha === right.alpha)
552
- );
553
- };
554
-
555
- /**
556
- * @private
557
- */
558
- Color.equalsArray = function (color, array, offset) {
559
- return (
560
- color.red === array[offset] &&
561
- color.green === array[offset + 1] &&
562
- color.blue === array[offset + 2] &&
563
- color.alpha === array[offset + 3]
564
- );
565
- };
789
+ /**
790
+ * Computes the componentwise difference of two Colors.
791
+ *
792
+ * @param {Color} left The first Color.
793
+ * @param {Color} right The second Color.
794
+ * @param {Color} result The object onto which to store the result.
795
+ * @returns {Color} The modified result parameter.
796
+ */
797
+ static subtract(left, right, result) {
798
+ //>>includeStart('debug', pragmas.debug);
799
+ Check.typeOf.object("left", left);
800
+ Check.typeOf.object("right", right);
801
+ Check.typeOf.object("result", result);
802
+ //>>includeEnd('debug');
566
803
 
567
- /**
568
- * Returns a duplicate of a Color instance.
569
- *
570
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
571
- * @returns {Color} The modified result parameter or a new instance if result was undefined.
572
- */
573
- Color.prototype.clone = function (result) {
574
- return Color.clone(this, result);
575
- };
804
+ result.red = left.red - right.red;
805
+ result.green = left.green - right.green;
806
+ result.blue = left.blue - right.blue;
807
+ result.alpha = left.alpha - right.alpha;
808
+ return result;
809
+ }
576
810
 
577
- /**
578
- * Returns true if this Color equals other.
579
- *
580
- * @param {Color} [other] The Color to compare for equality.
581
- * @returns {boolean} <code>true</code> if the Colors are equal; otherwise, <code>false</code>.
582
- */
583
- Color.prototype.equals = function (other) {
584
- return Color.equals(this, other);
585
- };
811
+ /**
812
+ * Computes the componentwise product of two Colors.
813
+ *
814
+ * @param {Color} left The first Color.
815
+ * @param {Color} right The second Color.
816
+ * @param {Color} result The object onto which to store the result.
817
+ * @returns {Color} The modified result parameter.
818
+ */
819
+ static multiply(left, right, result) {
820
+ //>>includeStart('debug', pragmas.debug);
821
+ Check.typeOf.object("left", left);
822
+ Check.typeOf.object("right", right);
823
+ Check.typeOf.object("result", result);
824
+ //>>includeEnd('debug');
586
825
 
587
- /**
588
- * Returns <code>true</code> if this Color equals other componentwise within the specified epsilon.
589
- *
590
- * @param {Color} other The Color to compare for equality.
591
- * @param {number} [epsilon=0.0] The epsilon to use for equality testing.
592
- * @returns {boolean} <code>true</code> if the Colors are equal within the specified epsilon; otherwise, <code>false</code>.
593
- */
594
- Color.prototype.equalsEpsilon = function (other, epsilon) {
595
- return (
596
- this === other || //
597
- (defined(other) && //
598
- Math.abs(this.red - other.red) <= epsilon && //
599
- Math.abs(this.green - other.green) <= epsilon && //
600
- Math.abs(this.blue - other.blue) <= epsilon && //
601
- Math.abs(this.alpha - other.alpha) <= epsilon)
602
- );
603
- };
826
+ result.red = left.red * right.red;
827
+ result.green = left.green * right.green;
828
+ result.blue = left.blue * right.blue;
829
+ result.alpha = left.alpha * right.alpha;
830
+ return result;
831
+ }
604
832
 
605
- /**
606
- * Creates a string representing this Color in the format '(red, green, blue, alpha)'.
607
- *
608
- * @returns {string} A string representing this Color in the format '(red, green, blue, alpha)'.
609
- */
610
- Color.prototype.toString = function () {
611
- return `(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
612
- };
833
+ /**
834
+ * Computes the componentwise quotient of two Colors.
835
+ *
836
+ * @param {Color} left The first Color.
837
+ * @param {Color} right The second Color.
838
+ * @param {Color} result The object onto which to store the result.
839
+ * @returns {Color} The modified result parameter.
840
+ */
841
+ static divide(left, right, result) {
842
+ //>>includeStart('debug', pragmas.debug);
843
+ Check.typeOf.object("left", left);
844
+ Check.typeOf.object("right", right);
845
+ Check.typeOf.object("result", result);
846
+ //>>includeEnd('debug');
613
847
 
614
- /**
615
- * Creates a string containing the CSS color value for this color.
616
- *
617
- * @returns {string} The CSS equivalent of this color.
618
- *
619
- * @see {@link http://www.w3.org/TR/css3-color/#rgba-color|CSS RGB or RGBA color values}
620
- */
621
- Color.prototype.toCssColorString = function () {
622
- const red = Color.floatToByte(this.red);
623
- const green = Color.floatToByte(this.green);
624
- const blue = Color.floatToByte(this.blue);
625
- if (this.alpha === 1) {
626
- return `rgb(${red},${green},${blue})`;
848
+ result.red = left.red / right.red;
849
+ result.green = left.green / right.green;
850
+ result.blue = left.blue / right.blue;
851
+ result.alpha = left.alpha / right.alpha;
852
+ return result;
627
853
  }
628
- return `rgba(${red},${green},${blue},${this.alpha})`;
629
- };
630
854
 
631
- /**
632
- * Creates a string containing CSS hex string color value for this color.
633
- *
634
- * @returns {string} The CSS hex string equivalent of this color.
635
- */
636
- Color.prototype.toCssHexString = function () {
637
- let r = Color.floatToByte(this.red).toString(16);
638
- if (r.length < 2) {
639
- r = `0${r}`;
640
- }
641
- let g = Color.floatToByte(this.green).toString(16);
642
- if (g.length < 2) {
643
- g = `0${g}`;
644
- }
645
- let b = Color.floatToByte(this.blue).toString(16);
646
- if (b.length < 2) {
647
- b = `0${b}`;
648
- }
649
- if (this.alpha < 1) {
650
- let hexAlpha = Color.floatToByte(this.alpha).toString(16);
651
- if (hexAlpha.length < 2) {
652
- hexAlpha = `0${hexAlpha}`;
653
- }
654
- return `#${r}${g}${b}${hexAlpha}`;
855
+ /**
856
+ * Computes the componentwise modulus of two Colors.
857
+ *
858
+ * @param {Color} left The first Color.
859
+ * @param {Color} right The second Color.
860
+ * @param {Color} result The object onto which to store the result.
861
+ * @returns {Color} The modified result parameter.
862
+ */
863
+ static mod(left, right, result) {
864
+ //>>includeStart('debug', pragmas.debug);
865
+ Check.typeOf.object("left", left);
866
+ Check.typeOf.object("right", right);
867
+ Check.typeOf.object("result", result);
868
+ //>>includeEnd('debug');
869
+
870
+ result.red = left.red % right.red;
871
+ result.green = left.green % right.green;
872
+ result.blue = left.blue % right.blue;
873
+ result.alpha = left.alpha % right.alpha;
874
+ return result;
655
875
  }
656
- return `#${r}${g}${b}`;
657
- };
658
876
 
659
- /**
660
- * Converts this color to an array of red, green, blue, and alpha values
661
- * that are in the range of 0 to 255.
662
- *
663
- * @param {number[]} [result] The array to store the result in, if undefined a new instance will be created.
664
- * @returns {number[]} The modified result parameter or a new instance if result was undefined.
665
- */
666
- Color.prototype.toBytes = function (result) {
667
- const red = Color.floatToByte(this.red);
668
- const green = Color.floatToByte(this.green);
669
- const blue = Color.floatToByte(this.blue);
670
- const alpha = Color.floatToByte(this.alpha);
877
+ /**
878
+ * Computes the linear interpolation or extrapolation at t between the provided colors.
879
+ *
880
+ * @param {Color} start The color corresponding to t at 0.0.
881
+ * @param {Color} end The color corresponding to t at 1.0.
882
+ * @param {number} t The point along t at which to interpolate.
883
+ * @param {Color} result The object onto which to store the result.
884
+ * @returns {Color} The modified result parameter.
885
+ */
886
+ static lerp(start, end, t, result) {
887
+ //>>includeStart('debug', pragmas.debug);
888
+ Check.typeOf.object("start", start);
889
+ Check.typeOf.object("end", end);
890
+ Check.typeOf.number("t", t);
891
+ Check.typeOf.object("result", result);
892
+ //>>includeEnd('debug');
671
893
 
672
- if (!defined(result)) {
673
- return [red, green, blue, alpha];
894
+ result.red = CesiumMath.lerp(start.red, end.red, t);
895
+ result.green = CesiumMath.lerp(start.green, end.green, t);
896
+ result.blue = CesiumMath.lerp(start.blue, end.blue, t);
897
+ result.alpha = CesiumMath.lerp(start.alpha, end.alpha, t);
898
+ return result;
674
899
  }
675
- result[0] = red;
676
- result[1] = green;
677
- result[2] = blue;
678
- result[3] = alpha;
679
- return result;
680
- };
681
900
 
682
- /**
683
- * Converts RGBA values in bytes to a single numeric unsigned 32-bit RGBA value, using the endianness
684
- * of the system.
685
- *
686
- * @returns {number} A single numeric unsigned 32-bit RGBA value.
687
- *
688
- * @see Color.toRgba
689
- */
690
- Color.bytesToRgba = function (red, green, blue, alpha) {
691
- // scratchUint32Array and scratchUint8Array share an underlying array buffer
692
- scratchUint8Array[0] = red;
693
- scratchUint8Array[1] = green;
694
- scratchUint8Array[2] = blue;
695
- scratchUint8Array[3] = alpha;
696
- return scratchUint32Array[0];
697
- };
901
+ /**
902
+ * Multiplies the provided Color componentwise by the provided scalar.
903
+ *
904
+ * @param {Color} color The Color to be scaled.
905
+ * @param {number} scalar The scalar to multiply with.
906
+ * @param {Color} result The object onto which to store the result.
907
+ * @returns {Color} The modified result parameter.
908
+ */
909
+ static multiplyByScalar(color, scalar, result) {
910
+ //>>includeStart('debug', pragmas.debug);
911
+ Check.typeOf.object("color", color);
912
+ Check.typeOf.number("scalar", scalar);
913
+ Check.typeOf.object("result", result);
914
+ //>>includeEnd('debug');
698
915
 
699
- /**
700
- * Converts this color to a single numeric unsigned 32-bit RGBA value, using the endianness
701
- * of the system.
702
- *
703
- * @returns {number} A single numeric unsigned 32-bit RGBA value.
704
- *
705
- *
706
- * @example
707
- * const rgba = Cesium.Color.BLUE.toRgba();
708
- *
709
- * @see Color.fromRgba
710
- */
711
- Color.prototype.toRgba = function () {
712
- return Color.bytesToRgba(
713
- Color.floatToByte(this.red),
714
- Color.floatToByte(this.green),
715
- Color.floatToByte(this.blue),
716
- Color.floatToByte(this.alpha),
717
- );
718
- };
916
+ result.red = color.red * scalar;
917
+ result.green = color.green * scalar;
918
+ result.blue = color.blue * scalar;
919
+ result.alpha = color.alpha * scalar;
920
+ return result;
921
+ }
719
922
 
720
- /**
721
- * Brightens this color by the provided magnitude.
722
- *
723
- * @param {number} magnitude A positive number indicating the amount to brighten.
724
- * @param {Color} result The object onto which to store the result.
725
- * @returns {Color} The modified result parameter.
726
- *
727
- * @example
728
- * const brightBlue = Cesium.Color.BLUE.brighten(0.5, new Cesium.Color());
729
- */
730
- Color.prototype.brighten = function (magnitude, result) {
731
- //>>includeStart('debug', pragmas.debug);
732
- Check.typeOf.number("magnitude", magnitude);
733
- Check.typeOf.number.greaterThanOrEquals("magnitude", magnitude, 0.0);
734
- Check.typeOf.object("result", result);
735
- //>>includeEnd('debug');
923
+ /**
924
+ * Divides the provided Color componentwise by the provided scalar.
925
+ *
926
+ * @param {Color} color The Color to be divided.
927
+ * @param {number} scalar The scalar to divide with.
928
+ * @param {Color} result The object onto which to store the result.
929
+ * @returns {Color} The modified result parameter.
930
+ */
931
+ static divideByScalar(color, scalar, result) {
932
+ //>>includeStart('debug', pragmas.debug);
933
+ Check.typeOf.object("color", color);
934
+ Check.typeOf.number("scalar", scalar);
935
+ Check.typeOf.object("result", result);
936
+ //>>includeEnd('debug');
736
937
 
737
- magnitude = 1.0 - magnitude;
738
- result.red = 1.0 - (1.0 - this.red) * magnitude;
739
- result.green = 1.0 - (1.0 - this.green) * magnitude;
740
- result.blue = 1.0 - (1.0 - this.blue) * magnitude;
741
- result.alpha = this.alpha;
742
- return result;
743
- };
938
+ result.red = color.red / scalar;
939
+ result.green = color.green / scalar;
940
+ result.blue = color.blue / scalar;
941
+ result.alpha = color.alpha / scalar;
942
+ return result;
943
+ }
944
+ }
744
945
 
745
- /**
746
- * Darkens this color by the provided magnitude.
747
- *
748
- * @param {number} magnitude A positive number indicating the amount to darken.
749
- * @param {Color} result The object onto which to store the result.
750
- * @returns {Color} The modified result parameter.
751
- *
752
- * @example
753
- * const darkBlue = Cesium.Color.BLUE.darken(0.5, new Cesium.Color());
754
- */
755
- Color.prototype.darken = function (magnitude, result) {
756
- //>>includeStart('debug', pragmas.debug);
757
- Check.typeOf.number("magnitude", magnitude);
758
- Check.typeOf.number.greaterThanOrEquals("magnitude", magnitude, 0.0);
759
- Check.typeOf.object("result", result);
760
- //>>includeEnd('debug');
946
+ let scratchArrayBuffer;
947
+ let scratchUint32Array;
948
+ let scratchUint8Array;
949
+ if (FeatureDetection.supportsTypedArrays()) {
950
+ scratchArrayBuffer = new ArrayBuffer(4);
951
+ scratchUint32Array = new Uint32Array(scratchArrayBuffer);
952
+ scratchUint8Array = new Uint8Array(scratchArrayBuffer);
953
+ }
761
954
 
762
- magnitude = 1.0 - magnitude;
763
- result.red = this.red * magnitude;
764
- result.green = this.green * magnitude;
765
- result.blue = this.blue * magnitude;
766
- result.alpha = this.alpha;
767
- return result;
768
- };
955
+ //#rgba
956
+ const rgbaMatcher = /^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i;
957
+ //#rrggbbaa
958
+ const rrggbbaaMatcher =
959
+ /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i;
960
+ //rgb(), rgba(), or rgb%()
961
+ const rgbParenthesesMatcher =
962
+ /^rgba?\s*\(\s*([0-9.]+%?)\s*[,\s]+\s*([0-9.]+%?)\s*[,\s]+\s*([0-9.]+%?)(?:\s*[,\s/]+\s*([0-9.]+))?\s*\)$/i;
963
+ //hsl() or hsla()
964
+ const hslParenthesesMatcher =
965
+ /^hsla?\s*\(\s*([0-9.]+)\s*[,\s]+\s*([0-9.]+%)\s*[,\s]+\s*([0-9.]+%)(?:\s*[,\s/]+\s*([0-9.]+))?\s*\)$/i;
769
966
 
770
967
  /**
771
- * Creates a new Color that has the same red, green, and blue components
772
- * as this Color, but with the specified alpha value.
773
- *
774
- * @param {number} alpha The new alpha component.
775
- * @param {Color} [result] The object onto which to store the result.
776
- * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
777
- *
778
- * @example const translucentRed = Cesium.Color.RED.withAlpha(0.9);
968
+ * The number of elements used to pack the object into an array.
969
+ * @type {number}
779
970
  */
780
- Color.prototype.withAlpha = function (alpha, result) {
781
- return Color.fromAlpha(this, alpha, result);
782
- };
783
-
784
- /**
785
- * Computes the componentwise sum of two Colors.
786
- *
787
- * @param {Color} left The first Color.
788
- * @param {Color} right The second Color.
789
- * @param {Color} result The object onto which to store the result.
790
- * @returns {Color} The modified result parameter.
791
- */
792
- Color.add = function (left, right, result) {
793
- //>>includeStart('debug', pragmas.debug);
794
- Check.typeOf.object("left", left);
795
- Check.typeOf.object("right", right);
796
- Check.typeOf.object("result", result);
797
- //>>includeEnd('debug');
798
-
799
- result.red = left.red + right.red;
800
- result.green = left.green + right.green;
801
- result.blue = left.blue + right.blue;
802
- result.alpha = left.alpha + right.alpha;
803
- return result;
804
- };
805
-
806
- /**
807
- * Computes the componentwise difference of two Colors.
808
- *
809
- * @param {Color} left The first Color.
810
- * @param {Color} right The second Color.
811
- * @param {Color} result The object onto which to store the result.
812
- * @returns {Color} The modified result parameter.
813
- */
814
- Color.subtract = function (left, right, result) {
815
- //>>includeStart('debug', pragmas.debug);
816
- Check.typeOf.object("left", left);
817
- Check.typeOf.object("right", right);
818
- Check.typeOf.object("result", result);
819
- //>>includeEnd('debug');
820
-
821
- result.red = left.red - right.red;
822
- result.green = left.green - right.green;
823
- result.blue = left.blue - right.blue;
824
- result.alpha = left.alpha - right.alpha;
825
- return result;
826
- };
827
-
828
- /**
829
- * Computes the componentwise product of two Colors.
830
- *
831
- * @param {Color} left The first Color.
832
- * @param {Color} right The second Color.
833
- * @param {Color} result The object onto which to store the result.
834
- * @returns {Color} The modified result parameter.
835
- */
836
- Color.multiply = function (left, right, result) {
837
- //>>includeStart('debug', pragmas.debug);
838
- Check.typeOf.object("left", left);
839
- Check.typeOf.object("right", right);
840
- Check.typeOf.object("result", result);
841
- //>>includeEnd('debug');
842
-
843
- result.red = left.red * right.red;
844
- result.green = left.green * right.green;
845
- result.blue = left.blue * right.blue;
846
- result.alpha = left.alpha * right.alpha;
847
- return result;
848
- };
849
-
850
- /**
851
- * Computes the componentwise quotient of two Colors.
852
- *
853
- * @param {Color} left The first Color.
854
- * @param {Color} right The second Color.
855
- * @param {Color} result The object onto which to store the result.
856
- * @returns {Color} The modified result parameter.
857
- */
858
- Color.divide = function (left, right, result) {
859
- //>>includeStart('debug', pragmas.debug);
860
- Check.typeOf.object("left", left);
861
- Check.typeOf.object("right", right);
862
- Check.typeOf.object("result", result);
863
- //>>includeEnd('debug');
864
-
865
- result.red = left.red / right.red;
866
- result.green = left.green / right.green;
867
- result.blue = left.blue / right.blue;
868
- result.alpha = left.alpha / right.alpha;
869
- return result;
870
- };
871
-
872
- /**
873
- * Computes the componentwise modulus of two Colors.
874
- *
875
- * @param {Color} left The first Color.
876
- * @param {Color} right The second Color.
877
- * @param {Color} result The object onto which to store the result.
878
- * @returns {Color} The modified result parameter.
879
- */
880
- Color.mod = function (left, right, result) {
881
- //>>includeStart('debug', pragmas.debug);
882
- Check.typeOf.object("left", left);
883
- Check.typeOf.object("right", right);
884
- Check.typeOf.object("result", result);
885
- //>>includeEnd('debug');
886
-
887
- result.red = left.red % right.red;
888
- result.green = left.green % right.green;
889
- result.blue = left.blue % right.blue;
890
- result.alpha = left.alpha % right.alpha;
891
- return result;
892
- };
893
-
894
- /**
895
- * Computes the linear interpolation or extrapolation at t between the provided colors.
896
- *
897
- * @param {Color} start The color corresponding to t at 0.0.
898
- * @param {Color} end The color corresponding to t at 1.0.
899
- * @param {number} t The point along t at which to interpolate.
900
- * @param {Color} result The object onto which to store the result.
901
- * @returns {Color} The modified result parameter.
902
- */
903
- Color.lerp = function (start, end, t, result) {
904
- //>>includeStart('debug', pragmas.debug);
905
- Check.typeOf.object("start", start);
906
- Check.typeOf.object("end", end);
907
- Check.typeOf.number("t", t);
908
- Check.typeOf.object("result", result);
909
- //>>includeEnd('debug');
910
-
911
- result.red = CesiumMath.lerp(start.red, end.red, t);
912
- result.green = CesiumMath.lerp(start.green, end.green, t);
913
- result.blue = CesiumMath.lerp(start.blue, end.blue, t);
914
- result.alpha = CesiumMath.lerp(start.alpha, end.alpha, t);
915
- return result;
916
- };
917
-
918
- /**
919
- * Multiplies the provided Color componentwise by the provided scalar.
920
- *
921
- * @param {Color} color The Color to be scaled.
922
- * @param {number} scalar The scalar to multiply with.
923
- * @param {Color} result The object onto which to store the result.
924
- * @returns {Color} The modified result parameter.
925
- */
926
- Color.multiplyByScalar = function (color, scalar, result) {
927
- //>>includeStart('debug', pragmas.debug);
928
- Check.typeOf.object("color", color);
929
- Check.typeOf.number("scalar", scalar);
930
- Check.typeOf.object("result", result);
931
- //>>includeEnd('debug');
932
-
933
- result.red = color.red * scalar;
934
- result.green = color.green * scalar;
935
- result.blue = color.blue * scalar;
936
- result.alpha = color.alpha * scalar;
937
- return result;
938
- };
939
-
940
- /**
941
- * Divides the provided Color componentwise by the provided scalar.
942
- *
943
- * @param {Color} color The Color to be divided.
944
- * @param {number} scalar The scalar to divide with.
945
- * @param {Color} result The object onto which to store the result.
946
- * @returns {Color} The modified result parameter.
947
- */
948
- Color.divideByScalar = function (color, scalar, result) {
949
- //>>includeStart('debug', pragmas.debug);
950
- Check.typeOf.object("color", color);
951
- Check.typeOf.number("scalar", scalar);
952
- Check.typeOf.object("result", result);
953
- //>>includeEnd('debug');
954
-
955
- result.red = color.red / scalar;
956
- result.green = color.green / scalar;
957
- result.blue = color.blue / scalar;
958
- result.alpha = color.alpha / scalar;
959
- return result;
960
- };
971
+ Color.packedLength = 4;
961
972
 
962
973
  /**
963
974
  * An immutable Color instance initialized to CSS color #F0F8FF