@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
@@ -28,938 +28,947 @@ function hue2rgb(m1, m2, h) {
28
28
  /**
29
29
  * A color, specified using red, green, blue, and alpha values,
30
30
  * which range from <code>0</code> (no intensity) to <code>1.0</code> (full intensity).
31
- * @param {number} [red=1.0] The red component.
32
- * @param {number} [green=1.0] The green component.
33
- * @param {number} [blue=1.0] The blue component.
34
- * @param {number} [alpha=1.0] The alpha component.
35
- *
36
- * @constructor
37
- * @alias Color
38
31
  *
39
32
  * @see Packable
40
33
  */
41
- function Color(red, green, blue, alpha) {
34
+ class Color {
42
35
  /**
43
- * The red component.
44
- * @type {number}
45
- * @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.
46
40
  */
47
- 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
+
48
68
  /**
49
- * The green component.
50
- * @type {number}
51
- * @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.
52
75
  */
53
- 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
+
54
92
  /**
55
- * The blue component.
56
- * @type {number}
57
- * @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.
58
102
  */
59
- 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
+
60
120
  /**
61
- * The alpha component.
62
- * @type {number}
63
- * @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);
64
130
  */
65
- this.alpha = alpha ?? 1.0;
66
- }
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');
67
136
 
68
- /**
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.
75
- */
76
- Color.fromCartesian4 = function (cartesian, result) {
77
- //>>includeStart('debug', pragmas.debug);
78
- Check.typeOf.object("cartesian", cartesian);
79
- //>>includeEnd('debug');
137
+ if (!defined(result)) {
138
+ return new Color(color.red, color.green, color.blue, alpha);
139
+ }
80
140
 
81
- if (!defined(result)) {
82
- 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;
83
146
  }
84
147
 
85
- result.red = cartesian.x;
86
- result.green = cartesian.y;
87
- result.blue = cartesian.z;
88
- result.alpha = cartesian.w;
89
- return result;
90
- };
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
+ }
91
172
 
92
- /**
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.
102
- */
103
- Color.fromBytes = function (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);
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
+ }
108
212
 
109
- if (!defined(result)) {
110
- 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;
111
218
  }
112
219
 
113
- result.red = red;
114
- result.green = green;
115
- result.blue = blue;
116
- result.alpha = alpha;
117
- return result;
118
- };
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
+ }
119
283
 
120
- /**
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);
130
- */
131
- Color.fromAlpha = function (color, alpha, result) {
132
- //>>includeStart('debug', pragmas.debug);
133
- Check.typeOf.object("color", color);
134
- Check.typeOf.number("alpha", alpha);
135
- //>>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
+ }
136
300
 
137
- if (!defined(result)) {
138
- return new Color(color.red, color.green, color.blue, alpha);
139
- }
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
+ }
140
318
 
141
- result.red = color.red;
142
- result.green = color.green;
143
- result.blue = color.blue;
144
- result.alpha = alpha;
145
- return result;
146
- };
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
+ }
147
336
 
148
- let scratchArrayBuffer;
149
- let scratchUint32Array;
150
- let scratchUint8Array;
151
- if (FeatureDetection.supportsTypedArrays()) {
152
- scratchArrayBuffer = new ArrayBuffer(4);
153
- scratchUint32Array = new Uint32Array(scratchArrayBuffer);
154
- scratchUint8Array = new Uint8Array(scratchArrayBuffer);
155
- }
337
+ if (!defined(result)) {
338
+ return new Color(red, green, blue, alpha);
339
+ }
156
340
 
157
- /**
158
- * Creates a new Color from a single numeric unsigned 32-bit RGBA value, using the endianness
159
- * of the system.
160
- *
161
- * @param {number} rgba A single numeric unsigned 32-bit RGBA value.
162
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
163
- * @returns {Color} The color object.
164
- *
165
- * @example
166
- * const color = Cesium.Color.fromRgba(0x67ADDFFF);
167
- *
168
- * @see Color#toRgba
169
- */
170
- Color.fromRgba = function (rgba, result) {
171
- // scratchUint32Array and scratchUint8Array share an underlying array buffer
172
- scratchUint32Array[0] = rgba;
173
- return Color.fromBytes(
174
- scratchUint8Array[0],
175
- scratchUint8Array[1],
176
- scratchUint8Array[2],
177
- scratchUint8Array[3],
178
- result,
179
- );
180
- };
341
+ result.red = red;
342
+ result.green = green;
343
+ result.blue = blue;
344
+ result.alpha = alpha;
345
+ return result;
346
+ }
181
347
 
182
- /**
183
- * Creates a Color instance from hue, saturation, and lightness.
184
- *
185
- * @param {number} [hue=0] The hue angle 0...1
186
- * @param {number} [saturation=0] The saturation value 0...1
187
- * @param {number} [lightness=0] The lightness value 0...1
188
- * @param {number} [alpha=1.0] The alpha component 0...1
189
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
190
- * @returns {Color} The color object.
191
- *
192
- * @see {@link http://www.w3.org/TR/css3-color/#hsl-color|CSS color values}
193
- */
194
- Color.fromHsl = function (hue, saturation, lightness, alpha, result) {
195
- hue = (hue ?? 0.0) % 1.0;
196
- saturation = saturation ?? 0.0;
197
- lightness = lightness ?? 0.0;
198
- 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');
199
366
 
200
- let red = lightness;
201
- let green = lightness;
202
- let blue = lightness;
367
+ if (!defined(result)) {
368
+ result = new Color();
369
+ }
370
+
371
+ // Remove all surrounding whitespaces from the color string
372
+ color = color.trim();
203
373
 
204
- if (saturation !== 0) {
205
- let m2;
206
- if (lightness < 0.5) {
207
- m2 = lightness * (1 + saturation);
208
- } else {
209
- m2 = lightness + saturation - lightness * saturation;
374
+ const namedColor = Color[color.toUpperCase()];
375
+ if (defined(namedColor)) {
376
+ Color.clone(namedColor, result);
377
+ return result;
210
378
  }
211
379
 
212
- const m1 = 2.0 * lightness - m2;
213
- red = hue2rgb(m1, m2, hue + 1 / 3);
214
- green = hue2rgb(m1, m2, hue);
215
- blue = hue2rgb(m1, m2, hue - 1 / 3);
216
- }
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
+ }
217
388
 
218
- if (!defined(result)) {
219
- return new Color(red, green, blue, alpha);
220
- }
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
+ }
221
397
 
222
- result.red = red;
223
- result.green = green;
224
- result.blue = blue;
225
- result.alpha = alpha;
226
- return result;
227
- };
228
-
229
- /**
230
- * Creates a random color using the provided options. For reproducible random colors, you should
231
- * call {@link CesiumMath#setRandomNumberSeed} once at the beginning of your application.
232
- *
233
- * @param {object} [options] Object with the following properties:
234
- * @param {number} [options.red] If specified, the red component to use instead of a randomized value.
235
- * @param {number} [options.minimumRed=0.0] The maximum red value to generate if none was specified.
236
- * @param {number} [options.maximumRed=1.0] The minimum red value to generate if none was specified.
237
- * @param {number} [options.green] If specified, the green component to use instead of a randomized value.
238
- * @param {number} [options.minimumGreen=0.0] The maximum green value to generate if none was specified.
239
- * @param {number} [options.maximumGreen=1.0] The minimum green value to generate if none was specified.
240
- * @param {number} [options.blue] If specified, the blue component to use instead of a randomized value.
241
- * @param {number} [options.minimumBlue=0.0] The maximum blue value to generate if none was specified.
242
- * @param {number} [options.maximumBlue=1.0] The minimum blue value to generate if none was specified.
243
- * @param {number} [options.alpha] If specified, the alpha component to use instead of a randomized value.
244
- * @param {number} [options.minimumAlpha=0.0] The maximum alpha value to generate if none was specified.
245
- * @param {number} [options.maximumAlpha=1.0] The minimum alpha value to generate if none was specified.
246
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
247
- * @returns {Color} The modified result parameter or a new instance if result was undefined.
248
- *
249
- * @exception {DeveloperError} minimumRed must be less than or equal to maximumRed.
250
- * @exception {DeveloperError} minimumGreen must be less than or equal to maximumGreen.
251
- * @exception {DeveloperError} minimumBlue must be less than or equal to maximumBlue.
252
- * @exception {DeveloperError} minimumAlpha must be less than or equal to maximumAlpha.
253
- *
254
- * @example
255
- * //Create a completely random color
256
- * const color = Cesium.Color.fromRandom();
257
- *
258
- * //Create a random shade of yellow.
259
- * const color1 = Cesium.Color.fromRandom({
260
- * red : 1.0,
261
- * green : 1.0,
262
- * alpha : 1.0
263
- * });
264
- *
265
- * //Create a random bright color.
266
- * const color2 = Cesium.Color.fromRandom({
267
- * minimumRed : 0.75,
268
- * minimumGreen : 0.75,
269
- * minimumBlue : 0.75,
270
- * alpha : 1.0
271
- * });
272
- */
273
- Color.fromRandom = function (options, result) {
274
- options = options ?? Frozen.EMPTY_OBJECT;
275
-
276
- let red = options.red;
277
- if (!defined(red)) {
278
- const minimumRed = options.minimumRed ?? 0;
279
- 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
+ }
280
412
 
281
- //>>includeStart('debug', pragmas.debug);
282
- Check.typeOf.number.lessThanOrEquals("minimumRed", minimumRed, maximumRed);
283
- //>>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
+ }
284
423
 
285
- red =
286
- minimumRed + CesiumMath.nextRandomNumber() * (maximumRed - minimumRed);
424
+ result = undefined;
425
+ return result;
287
426
  }
288
427
 
289
- let green = options.green;
290
- if (!defined(green)) {
291
- const minimumGreen = options.minimumGreen ?? 0;
292
- const maximumGreen = options.maximumGreen ?? 1.0;
293
-
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) {
294
438
  //>>includeStart('debug', pragmas.debug);
295
- Check.typeOf.number.lessThanOrEquals(
296
- "minimumGreen",
297
- minimumGreen,
298
- maximumGreen,
299
- );
439
+ Check.typeOf.object("value", value);
440
+ Check.defined("array", array);
300
441
  //>>includeEnd('debug');
301
- green =
302
- minimumGreen +
303
- CesiumMath.nextRandomNumber() * (maximumGreen - minimumGreen);
304
- }
305
442
 
306
- let blue = options.blue;
307
- if (!defined(blue)) {
308
- const minimumBlue = options.minimumBlue ?? 0;
309
- 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;
310
448
 
449
+ return array;
450
+ }
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) {
311
461
  //>>includeStart('debug', pragmas.debug);
312
- Check.typeOf.number.lessThanOrEquals(
313
- "minimumBlue",
314
- minimumBlue,
315
- maximumBlue,
316
- );
462
+ Check.defined("array", array);
317
463
  //>>includeEnd('debug');
318
464
 
319
- blue =
320
- 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;
321
474
  }
322
475
 
323
- let alpha = options.alpha;
324
- if (!defined(alpha)) {
325
- const minimumAlpha = options.minimumAlpha ?? 0;
326
- 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
+ }
327
486
 
328
- //>>includeStart('debug', pragmas.debug);
329
- Check.typeOf.number.lessThanOrEquals(
330
- "minimumAlpha",
331
- minimumAlpha,
332
- maximumAlpha,
333
- );
334
- //>>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
+ }
335
497
 
336
- alpha =
337
- minimumAlpha +
338
- 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;
339
517
  }
340
518
 
341
- if (!defined(result)) {
342
- 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
+ );
343
536
  }
344
537
 
345
- result.red = red;
346
- result.green = green;
347
- result.blue = blue;
348
- result.alpha = alpha;
349
- return result;
350
- };
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
+ }
351
549
 
352
- //#rgba
353
- const rgbaMatcher = /^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i;
354
- //#rrggbbaa
355
- const rrggbbaaMatcher =
356
- /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i;
357
- //rgb(), rgba(), or rgb%()
358
- const rgbParenthesesMatcher =
359
- /^rgba?\s*\(\s*([0-9.]+%?)\s*[,\s]+\s*([0-9.]+%?)\s*[,\s]+\s*([0-9.]+%?)(?:\s*[,\s/]+\s*([0-9.]+))?\s*\)$/i;
360
- //hsl() or hsla()
361
- const hslParenthesesMatcher =
362
- /^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
+ }
363
559
 
364
- /**
365
- * Creates a Color instance from a CSS color value.
366
- *
367
- * @param {string} color The CSS color value in #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(), rgba(), hsl(), or hsla() format.
368
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
369
- * @returns {Color} The color object, or undefined if the string was not a valid CSS color.
370
- *
371
- *
372
- * @example
373
- * const cesiumBlue = Cesium.Color.fromCssColorString('#67ADDF');
374
- * const green = Cesium.Color.fromCssColorString('green');
375
- *
376
- * @see {@link http://www.w3.org/TR/css3-color|CSS color values}
377
- */
378
- Color.fromCssColorString = function (color, result) {
379
- //>>includeStart('debug', pragmas.debug);
380
- Check.typeOf.string("color", color);
381
- //>>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
+ }
382
569
 
383
- if (!defined(result)) {
384
- 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
+ );
385
586
  }
386
587
 
387
- // Remove all surrounding whitespaces from the color string
388
- 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
+ }
389
596
 
390
- const namedColor = Color[color.toUpperCase()];
391
- if (defined(namedColor)) {
392
- Color.clone(namedColor, result);
393
- 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})`;
394
612
  }
395
613
 
396
- let matches = rgbaMatcher.exec(color);
397
- if (matches !== null) {
398
- result.red = parseInt(matches[1], 16) / 15;
399
- result.green = parseInt(matches[2], 16) / 15.0;
400
- result.blue = parseInt(matches[3], 16) / 15.0;
401
- result.alpha = parseInt(matches[4] ?? "f", 16) / 15.0;
402
- 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}`;
403
640
  }
404
641
 
405
- matches = rrggbbaaMatcher.exec(color);
406
- if (matches !== null) {
407
- result.red = parseInt(matches[1], 16) / 255.0;
408
- result.green = parseInt(matches[2], 16) / 255.0;
409
- result.blue = parseInt(matches[3], 16) / 255.0;
410
- 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;
411
662
  return result;
412
663
  }
413
664
 
414
- matches = rgbParenthesesMatcher.exec(color);
415
- if (matches !== null) {
416
- result.red =
417
- parseFloat(matches[1]) / ("%" === matches[1].substr(-1) ? 100.0 : 255.0);
418
- result.green =
419
- parseFloat(matches[2]) / ("%" === matches[2].substr(-1) ? 100.0 : 255.0);
420
- result.blue =
421
- parseFloat(matches[3]) / ("%" === matches[3].substr(-1) ? 100.0 : 255.0);
422
- result.alpha = parseFloat(matches[4] ?? "1.0");
423
- 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];
424
680
  }
425
681
 
426
- matches = hslParenthesesMatcher.exec(color);
427
- if (matches !== null) {
428
- return Color.fromHsl(
429
- parseFloat(matches[1]) / 360.0,
430
- parseFloat(matches[2]) / 100.0,
431
- parseFloat(matches[3]) / 100.0,
432
- parseFloat(matches[4] ?? "1.0"),
433
- 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),
434
700
  );
435
701
  }
436
702
 
437
- result = undefined;
438
- return result;
439
- };
440
-
441
- /**
442
- * The number of elements used to pack the object into an array.
443
- * @type {number}
444
- */
445
- Color.packedLength = 4;
446
-
447
- /**
448
- * Stores the provided instance into the provided array.
449
- *
450
- * @param {Color} value The value to pack.
451
- * @param {number[]|TypedArray} array The array to pack into.
452
- * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
453
- *
454
- * @returns {number[]|TypedArray} The array that was packed into
455
- */
456
- Color.pack = function (value, array, startingIndex) {
457
- //>>includeStart('debug', pragmas.debug);
458
- Check.typeOf.object("value", value);
459
- Check.defined("array", array);
460
- //>>includeEnd('debug');
461
-
462
- startingIndex = startingIndex ?? 0;
463
- array[startingIndex++] = value.red;
464
- array[startingIndex++] = value.green;
465
- array[startingIndex++] = value.blue;
466
- 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');
467
719
 
468
- return array;
469
- };
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
+ }
470
727
 
471
- /**
472
- * Retrieves an instance from a packed array.
473
- *
474
- * @param {number[]|TypedArray} array The packed array.
475
- * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
476
- * @param {Color} [result] The object into which to store the result.
477
- * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
478
- */
479
- Color.unpack = function (array, startingIndex, result) {
480
- //>>includeStart('debug', pragmas.debug);
481
- Check.defined("array", array);
482
- //>>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');
483
744
 
484
- startingIndex = startingIndex ?? 0;
485
- if (!defined(result)) {
486
- 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;
487
751
  }
488
- result.red = array[startingIndex++];
489
- result.green = array[startingIndex++];
490
- result.blue = array[startingIndex++];
491
- result.alpha = array[startingIndex];
492
- return result;
493
- };
494
752
 
495
- /**
496
- * Converts a 'byte' color component in the range of 0 to 255 into
497
- * a 'float' color component in the range of 0 to 1.0.
498
- *
499
- * @param {number} number The number to be converted.
500
- * @returns {number} The converted number.
501
- */
502
- Color.byteToFloat = function (number) {
503
- return number / 255.0;
504
- };
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
+ }
505
766
 
506
- /**
507
- * Converts a 'float' color component in the range of 0 to 1.0 into
508
- * a 'byte' color component in the range of 0 to 255.
509
- *
510
- * @param {number} number The number to be converted.
511
- * @returns {number} The converted number.
512
- */
513
- Color.floatToByte = function (number) {
514
- return number === 1.0 ? 255.0 : (number * 256.0) | 0;
515
- };
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');
516
781
 
517
- /**
518
- * Duplicates a Color.
519
- *
520
- * @param {Color} color The Color to duplicate.
521
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
522
- * @returns {Color} The modified result parameter or a new instance if result was undefined. (Returns undefined if color is undefined)
523
- */
524
- Color.clone = function (color, result) {
525
- if (!defined(color)) {
526
- return undefined;
527
- }
528
- if (!defined(result)) {
529
- 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;
530
787
  }
531
- result.red = color.red;
532
- result.green = color.green;
533
- result.blue = color.blue;
534
- result.alpha = color.alpha;
535
- return result;
536
- };
537
788
 
538
- /**
539
- * Returns true if the first Color equals the second color.
540
- *
541
- * @param {Color} [left] The first Color to compare for equality.
542
- * @param {Color} [right] The second Color to compare for equality.
543
- * @returns {boolean} <code>true</code> if the Colors are equal; otherwise, <code>false</code>.
544
- */
545
- Color.equals = function (left, right) {
546
- return (
547
- left === right || //
548
- (defined(left) && //
549
- defined(right) && //
550
- left.red === right.red && //
551
- left.green === right.green && //
552
- left.blue === right.blue && //
553
- left.alpha === right.alpha)
554
- );
555
- };
556
-
557
- /**
558
- * @private
559
- */
560
- Color.equalsArray = function (color, array, offset) {
561
- return (
562
- color.red === array[offset] &&
563
- color.green === array[offset + 1] &&
564
- color.blue === array[offset + 2] &&
565
- color.alpha === array[offset + 3]
566
- );
567
- };
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');
568
803
 
569
- /**
570
- * Returns a duplicate of a Color instance.
571
- *
572
- * @param {Color} [result] The object to store the result in, if undefined a new instance will be created.
573
- * @returns {Color} The modified result parameter or a new instance if result was undefined.
574
- */
575
- Color.prototype.clone = function (result) {
576
- return Color.clone(this, result);
577
- };
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
+ }
578
810
 
579
- /**
580
- * Returns true if this Color equals other.
581
- *
582
- * @param {Color} [other] The Color to compare for equality.
583
- * @returns {boolean} <code>true</code> if the Colors are equal; otherwise, <code>false</code>.
584
- */
585
- Color.prototype.equals = function (other) {
586
- return Color.equals(this, other);
587
- };
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');
588
825
 
589
- /**
590
- * Returns <code>true</code> if this Color equals other componentwise within the specified epsilon.
591
- *
592
- * @param {Color} other The Color to compare for equality.
593
- * @param {number} [epsilon=0.0] The epsilon to use for equality testing.
594
- * @returns {boolean} <code>true</code> if the Colors are equal within the specified epsilon; otherwise, <code>false</code>.
595
- */
596
- Color.prototype.equalsEpsilon = function (other, epsilon) {
597
- return (
598
- this === other || //
599
- (defined(other) && //
600
- Math.abs(this.red - other.red) <= epsilon && //
601
- Math.abs(this.green - other.green) <= epsilon && //
602
- Math.abs(this.blue - other.blue) <= epsilon && //
603
- Math.abs(this.alpha - other.alpha) <= epsilon)
604
- );
605
- };
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
+ }
606
832
 
607
- /**
608
- * Creates a string representing this Color in the format '(red, green, blue, alpha)'.
609
- *
610
- * @returns {string} A string representing this Color in the format '(red, green, blue, alpha)'.
611
- */
612
- Color.prototype.toString = function () {
613
- return `(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;
614
- };
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');
615
847
 
616
- /**
617
- * Creates a string containing the CSS color value for this color.
618
- *
619
- * @returns {string} The CSS equivalent of this color.
620
- *
621
- * @see {@link http://www.w3.org/TR/css3-color/#rgba-color|CSS RGB or RGBA color values}
622
- */
623
- Color.prototype.toCssColorString = function () {
624
- const red = Color.floatToByte(this.red);
625
- const green = Color.floatToByte(this.green);
626
- const blue = Color.floatToByte(this.blue);
627
- if (this.alpha === 1) {
628
- 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;
629
853
  }
630
- return `rgba(${red},${green},${blue},${this.alpha})`;
631
- };
632
854
 
633
- /**
634
- * Creates a string containing CSS hex string color value for this color.
635
- *
636
- * @returns {string} The CSS hex string equivalent of this color.
637
- */
638
- Color.prototype.toCssHexString = function () {
639
- let r = Color.floatToByte(this.red).toString(16);
640
- if (r.length < 2) {
641
- r = `0${r}`;
642
- }
643
- let g = Color.floatToByte(this.green).toString(16);
644
- if (g.length < 2) {
645
- g = `0${g}`;
646
- }
647
- let b = Color.floatToByte(this.blue).toString(16);
648
- if (b.length < 2) {
649
- b = `0${b}`;
650
- }
651
- if (this.alpha < 1) {
652
- let hexAlpha = Color.floatToByte(this.alpha).toString(16);
653
- if (hexAlpha.length < 2) {
654
- hexAlpha = `0${hexAlpha}`;
655
- }
656
- 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;
657
875
  }
658
- return `#${r}${g}${b}`;
659
- };
660
876
 
661
- /**
662
- * Converts this color to an array of red, green, blue, and alpha values
663
- * that are in the range of 0 to 255.
664
- *
665
- * @param {number[]} [result] The array to store the result in, if undefined a new instance will be created.
666
- * @returns {number[]} The modified result parameter or a new instance if result was undefined.
667
- */
668
- Color.prototype.toBytes = function (result) {
669
- const red = Color.floatToByte(this.red);
670
- const green = Color.floatToByte(this.green);
671
- const blue = Color.floatToByte(this.blue);
672
- 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');
673
893
 
674
- if (!defined(result)) {
675
- 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;
676
899
  }
677
- result[0] = red;
678
- result[1] = green;
679
- result[2] = blue;
680
- result[3] = alpha;
681
- return result;
682
- };
683
900
 
684
- /**
685
- * Converts RGBA values in bytes to a single numeric unsigned 32-bit RGBA value, using the endianness
686
- * of the system.
687
- *
688
- * @returns {number} A single numeric unsigned 32-bit RGBA value.
689
- *
690
- * @see Color.toRgba
691
- */
692
- Color.bytesToRgba = function (red, green, blue, alpha) {
693
- // scratchUint32Array and scratchUint8Array share an underlying array buffer
694
- scratchUint8Array[0] = red;
695
- scratchUint8Array[1] = green;
696
- scratchUint8Array[2] = blue;
697
- scratchUint8Array[3] = alpha;
698
- return scratchUint32Array[0];
699
- };
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');
700
915
 
701
- /**
702
- * Converts this color to a single numeric unsigned 32-bit RGBA value, using the endianness
703
- * of the system.
704
- *
705
- * @returns {number} A single numeric unsigned 32-bit RGBA value.
706
- *
707
- *
708
- * @example
709
- * const rgba = Cesium.Color.BLUE.toRgba();
710
- *
711
- * @see Color.fromRgba
712
- */
713
- Color.prototype.toRgba = function () {
714
- return Color.bytesToRgba(
715
- Color.floatToByte(this.red),
716
- Color.floatToByte(this.green),
717
- Color.floatToByte(this.blue),
718
- Color.floatToByte(this.alpha),
719
- );
720
- };
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
+ }
721
922
 
722
- /**
723
- * Brightens this color by the provided magnitude.
724
- *
725
- * @param {number} magnitude A positive number indicating the amount to brighten.
726
- * @param {Color} result The object onto which to store the result.
727
- * @returns {Color} The modified result parameter.
728
- *
729
- * @example
730
- * const brightBlue = Cesium.Color.BLUE.brighten(0.5, new Cesium.Color());
731
- */
732
- Color.prototype.brighten = function (magnitude, result) {
733
- //>>includeStart('debug', pragmas.debug);
734
- Check.typeOf.number("magnitude", magnitude);
735
- Check.typeOf.number.greaterThanOrEquals("magnitude", magnitude, 0.0);
736
- Check.typeOf.object("result", result);
737
- //>>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');
738
937
 
739
- magnitude = 1.0 - magnitude;
740
- result.red = 1.0 - (1.0 - this.red) * magnitude;
741
- result.green = 1.0 - (1.0 - this.green) * magnitude;
742
- result.blue = 1.0 - (1.0 - this.blue) * magnitude;
743
- result.alpha = this.alpha;
744
- return result;
745
- };
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
+ }
746
945
 
747
- /**
748
- * Darkens this color by the provided magnitude.
749
- *
750
- * @param {number} magnitude A positive number indicating the amount to darken.
751
- * @param {Color} result The object onto which to store the result.
752
- * @returns {Color} The modified result parameter.
753
- *
754
- * @example
755
- * const darkBlue = Cesium.Color.BLUE.darken(0.5, new Cesium.Color());
756
- */
757
- Color.prototype.darken = function (magnitude, result) {
758
- //>>includeStart('debug', pragmas.debug);
759
- Check.typeOf.number("magnitude", magnitude);
760
- Check.typeOf.number.greaterThanOrEquals("magnitude", magnitude, 0.0);
761
- Check.typeOf.object("result", result);
762
- //>>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
+ }
763
954
 
764
- magnitude = 1.0 - magnitude;
765
- result.red = this.red * magnitude;
766
- result.green = this.green * magnitude;
767
- result.blue = this.blue * magnitude;
768
- result.alpha = this.alpha;
769
- return result;
770
- };
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;
771
966
 
772
967
  /**
773
- * Creates a new Color that has the same red, green, and blue components
774
- * as this Color, but with the specified alpha value.
775
- *
776
- * @param {number} alpha The new alpha component.
777
- * @param {Color} [result] The object onto which to store the result.
778
- * @returns {Color} The modified result parameter or a new Color instance if one was not provided.
779
- *
780
- * @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}
781
970
  */
782
- Color.prototype.withAlpha = function (alpha, result) {
783
- return Color.fromAlpha(this, alpha, result);
784
- };
785
-
786
- /**
787
- * Computes the componentwise sum of two Colors.
788
- *
789
- * @param {Color} left The first Color.
790
- * @param {Color} right The second Color.
791
- * @param {Color} result The object onto which to store the result.
792
- * @returns {Color} The modified result parameter.
793
- */
794
- Color.add = function (left, right, result) {
795
- //>>includeStart('debug', pragmas.debug);
796
- Check.typeOf.object("left", left);
797
- Check.typeOf.object("right", right);
798
- Check.typeOf.object("result", result);
799
- //>>includeEnd('debug');
800
-
801
- result.red = left.red + right.red;
802
- result.green = left.green + right.green;
803
- result.blue = left.blue + right.blue;
804
- result.alpha = left.alpha + right.alpha;
805
- return result;
806
- };
807
-
808
- /**
809
- * Computes the componentwise difference of two Colors.
810
- *
811
- * @param {Color} left The first Color.
812
- * @param {Color} right The second Color.
813
- * @param {Color} result The object onto which to store the result.
814
- * @returns {Color} The modified result parameter.
815
- */
816
- Color.subtract = function (left, right, result) {
817
- //>>includeStart('debug', pragmas.debug);
818
- Check.typeOf.object("left", left);
819
- Check.typeOf.object("right", right);
820
- Check.typeOf.object("result", result);
821
- //>>includeEnd('debug');
822
-
823
- result.red = left.red - right.red;
824
- result.green = left.green - right.green;
825
- result.blue = left.blue - right.blue;
826
- result.alpha = left.alpha - right.alpha;
827
- return result;
828
- };
829
-
830
- /**
831
- * Computes the componentwise product of two Colors.
832
- *
833
- * @param {Color} left The first Color.
834
- * @param {Color} right The second Color.
835
- * @param {Color} result The object onto which to store the result.
836
- * @returns {Color} The modified result parameter.
837
- */
838
- Color.multiply = function (left, right, result) {
839
- //>>includeStart('debug', pragmas.debug);
840
- Check.typeOf.object("left", left);
841
- Check.typeOf.object("right", right);
842
- Check.typeOf.object("result", result);
843
- //>>includeEnd('debug');
844
-
845
- result.red = left.red * right.red;
846
- result.green = left.green * right.green;
847
- result.blue = left.blue * right.blue;
848
- result.alpha = left.alpha * right.alpha;
849
- return result;
850
- };
851
-
852
- /**
853
- * Computes the componentwise quotient of two Colors.
854
- *
855
- * @param {Color} left The first Color.
856
- * @param {Color} right The second Color.
857
- * @param {Color} result The object onto which to store the result.
858
- * @returns {Color} The modified result parameter.
859
- */
860
- Color.divide = function (left, right, result) {
861
- //>>includeStart('debug', pragmas.debug);
862
- Check.typeOf.object("left", left);
863
- Check.typeOf.object("right", right);
864
- Check.typeOf.object("result", result);
865
- //>>includeEnd('debug');
866
-
867
- result.red = left.red / right.red;
868
- result.green = left.green / right.green;
869
- result.blue = left.blue / right.blue;
870
- result.alpha = left.alpha / right.alpha;
871
- return result;
872
- };
873
-
874
- /**
875
- * Computes the componentwise modulus of two Colors.
876
- *
877
- * @param {Color} left The first Color.
878
- * @param {Color} right The second Color.
879
- * @param {Color} result The object onto which to store the result.
880
- * @returns {Color} The modified result parameter.
881
- */
882
- Color.mod = function (left, right, result) {
883
- //>>includeStart('debug', pragmas.debug);
884
- Check.typeOf.object("left", left);
885
- Check.typeOf.object("right", right);
886
- Check.typeOf.object("result", result);
887
- //>>includeEnd('debug');
888
-
889
- result.red = left.red % right.red;
890
- result.green = left.green % right.green;
891
- result.blue = left.blue % right.blue;
892
- result.alpha = left.alpha % right.alpha;
893
- return result;
894
- };
895
-
896
- /**
897
- * Computes the linear interpolation or extrapolation at t between the provided colors.
898
- *
899
- * @param {Color} start The color corresponding to t at 0.0.
900
- * @param {Color} end The color corresponding to t at 1.0.
901
- * @param {number} t The point along t at which to interpolate.
902
- * @param {Color} result The object onto which to store the result.
903
- * @returns {Color} The modified result parameter.
904
- */
905
- Color.lerp = function (start, end, t, result) {
906
- //>>includeStart('debug', pragmas.debug);
907
- Check.typeOf.object("start", start);
908
- Check.typeOf.object("end", end);
909
- Check.typeOf.number("t", t);
910
- Check.typeOf.object("result", result);
911
- //>>includeEnd('debug');
912
-
913
- result.red = CesiumMath.lerp(start.red, end.red, t);
914
- result.green = CesiumMath.lerp(start.green, end.green, t);
915
- result.blue = CesiumMath.lerp(start.blue, end.blue, t);
916
- result.alpha = CesiumMath.lerp(start.alpha, end.alpha, t);
917
- return result;
918
- };
919
-
920
- /**
921
- * Multiplies the provided Color componentwise by the provided scalar.
922
- *
923
- * @param {Color} color The Color to be scaled.
924
- * @param {number} scalar The scalar to multiply with.
925
- * @param {Color} result The object onto which to store the result.
926
- * @returns {Color} The modified result parameter.
927
- */
928
- Color.multiplyByScalar = function (color, scalar, result) {
929
- //>>includeStart('debug', pragmas.debug);
930
- Check.typeOf.object("color", color);
931
- Check.typeOf.number("scalar", scalar);
932
- Check.typeOf.object("result", result);
933
- //>>includeEnd('debug');
934
-
935
- result.red = color.red * scalar;
936
- result.green = color.green * scalar;
937
- result.blue = color.blue * scalar;
938
- result.alpha = color.alpha * scalar;
939
- return result;
940
- };
941
-
942
- /**
943
- * Divides the provided Color componentwise by the provided scalar.
944
- *
945
- * @param {Color} color The Color to be divided.
946
- * @param {number} scalar The scalar to divide with.
947
- * @param {Color} result The object onto which to store the result.
948
- * @returns {Color} The modified result parameter.
949
- */
950
- Color.divideByScalar = function (color, scalar, result) {
951
- //>>includeStart('debug', pragmas.debug);
952
- Check.typeOf.object("color", color);
953
- Check.typeOf.number("scalar", scalar);
954
- Check.typeOf.object("result", result);
955
- //>>includeEnd('debug');
956
-
957
- result.red = color.red / scalar;
958
- result.green = color.green / scalar;
959
- result.blue = color.blue / scalar;
960
- result.alpha = color.alpha / scalar;
961
- return result;
962
- };
971
+ Color.packedLength = 4;
963
972
 
964
973
  /**
965
974
  * An immutable Color instance initialized to CSS color #F0F8FF