@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.
- package/Build/Workers/{chunk-6WLHJFD3.js → chunk-3VFEWOBI.js} +59 -32
- package/Build/Workers/{chunk-UQU4RXLT.js → chunk-424RNO3D.js} +50 -45
- package/Build/Workers/chunk-4MGMYHOO.js +147 -0
- package/Build/Workers/{chunk-AMIHNSST.js → chunk-4S7IE3LB.js} +2 -2
- package/Build/Workers/{chunk-J6AW5YHS.js → chunk-52JDLOEM.js} +14 -14
- package/Build/Workers/{chunk-6RMS4S72.js → chunk-54I6Y66F.js} +6 -6
- package/Build/Workers/{chunk-C6P4IG5P.js → chunk-6YEE6JDR.js} +6 -6
- package/Build/Workers/{chunk-72VYSVEW.js → chunk-7J2HKPRH.js} +11 -10
- package/Build/Workers/{chunk-7O5XJTVE.js → chunk-7WM2PX4V.js} +5 -5
- package/Build/Workers/{chunk-5A2SW66E.js → chunk-ACXQXN46.js} +16 -16
- package/Build/Workers/{chunk-VLDEUTOP.js → chunk-AYKR4VBR.js} +2 -2
- package/Build/Workers/{chunk-YQFTYQMZ.js → chunk-C6J67V5A.js} +3 -2
- package/Build/Workers/{chunk-D4EJ2NXG.js → chunk-C6KNZ7T4.js} +17 -17
- package/Build/Workers/{chunk-7MDYBRYJ.js → chunk-CFQP6LYM.js} +4 -4
- package/Build/Workers/{chunk-YAOZMOFL.js → chunk-CXOYE2WM.js} +5 -5
- package/Build/Workers/{chunk-B6SCUUFP.js → chunk-CZEYZU4N.js} +10 -10
- package/Build/Workers/{chunk-NPF7SSHZ.js → chunk-DBOEKL43.js} +7 -7
- package/Build/Workers/{chunk-44EMEGKW.js → chunk-DDWSZVMY.js} +5 -5
- package/Build/Workers/{chunk-7X322WP2.js → chunk-DOBXCNC3.js} +13 -13
- package/Build/Workers/{chunk-JCI63T3K.js → chunk-E7VQ76KE.js} +6 -6
- package/Build/Workers/{chunk-7TYLCBGK.js → chunk-EBSIOBXY.js} +12 -10
- package/Build/Workers/{chunk-GQUNK2XC.js → chunk-EF2QYXGA.js} +14 -14
- package/Build/Workers/{chunk-BJD6QGXZ.js → chunk-EPYXRCDB.js} +12 -12
- package/Build/Workers/{chunk-63SIWPLS.js → chunk-F6QDY6HU.js} +13 -13
- package/Build/Workers/{chunk-XY6HMDGI.js → chunk-FRQZECAO.js} +5 -5
- package/Build/Workers/{chunk-VMVOUQ5J.js → chunk-G7PXZRVF.js} +7 -7
- package/Build/Workers/{chunk-N65BAKSH.js → chunk-INUEEEQA.js} +8 -8
- package/Build/Workers/{chunk-7QRFIKWQ.js → chunk-IRBKFCEJ.js} +2 -2
- package/Build/Workers/{chunk-UIGVOKKI.js → chunk-IYOUHCZB.js} +3 -2
- package/Build/Workers/{chunk-5GXYJQ2K.js → chunk-J6BWOHUF.js} +3 -3
- package/Build/Workers/{chunk-A47HVBC5.js → chunk-KFSTQKNM.js} +7 -7
- package/Build/Workers/{chunk-EV3VGO6Y.js → chunk-KKOSKAZB.js} +17 -17
- package/Build/Workers/{chunk-6MPGQEHA.js → chunk-KSSWJIZW.js} +2 -2
- package/Build/Workers/{chunk-DHKPFLSJ.js → chunk-M3B5JKSM.js} +3 -2
- package/Build/Workers/chunk-MPZHGZU6.js +2342 -0
- package/Build/Workers/{chunk-YJZGW74L.js → chunk-MYP774IS.js} +2213 -1349
- package/Build/Workers/{chunk-LIB2H534.js → chunk-O3EA5HS7.js} +12 -11
- package/Build/Workers/{chunk-ILMFADZA.js → chunk-P3CK7MCY.js} +27 -5
- package/Build/Workers/chunk-Q3PY526V.js +3201 -0
- package/Build/Workers/chunk-QN67VG36.js +973 -0
- package/Build/Workers/{chunk-XJRBB253.js → chunk-QRWGUWI6.js} +11 -11
- package/Build/Workers/{chunk-AF3MU2RL.js → chunk-S4MCOY6I.js} +7 -6
- package/Build/Workers/{chunk-Y7HNNPNK.js → chunk-SMQZZOW6.js} +10 -10
- package/Build/Workers/{chunk-PVV64VFW.js → chunk-TKKIREQ6.js} +3 -2
- package/Build/Workers/{chunk-MKM27KGV.js → chunk-U3ZA64U7.js} +2 -2
- package/Build/Workers/{chunk-2N4KDHS3.js → chunk-UA25D5MX.js} +12 -11
- package/Build/Workers/{chunk-RQNJD3O4.js → chunk-UOOIQ3KX.js} +12 -12
- package/Build/Workers/{chunk-GOQBUCXH.js → chunk-V7VQKN6N.js} +709 -431
- package/Build/Workers/{chunk-LXMCPFFS.js → chunk-VQYETPWC.js} +4 -4
- package/Build/Workers/{chunk-NKT5K3K3.js → chunk-VWV2IJRB.js} +13 -12
- package/Build/Workers/chunk-XZMBNNDX.js +1287 -0
- package/Build/Workers/{chunk-ISY4EZCA.js → chunk-Y57HREW5.js} +4 -4
- package/Build/Workers/{chunk-EDXL4W76.js → chunk-Y5BF6AFU.js} +2 -2
- package/Build/Workers/{chunk-Q3C6VQH6.js → chunk-YLY7NKAB.js} +4 -4
- package/Build/Workers/{chunk-4TIG36AW.js → chunk-ZK3CF7ZD.js} +12 -12
- package/Build/Workers/{chunk-AJLTU6PF.js → chunk-ZP7JMQV4.js} +4 -1
- package/Build/Workers/{chunk-HXJMS2ZI.js → chunk-ZZ46LWL6.js} +1 -1
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +24 -24
- package/Build/Workers/createGroundPolylineGeometry.js +175 -118
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +24 -23
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
- package/Build/Workers/transcodeKTX2.js +12 -9
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Core/ArcType.js +6 -1
- package/Source/Core/ArticulationStageType.js +5 -1
- package/Source/Core/AssociativeArray.js +100 -94
- package/Source/Core/BoundingSphere.js +1296 -1300
- package/Source/Core/Cartesian2.js +1 -1
- package/Source/Core/Cartesian3.js +2 -3
- package/Source/Core/Cartesian4.js +1 -1
- package/Source/Core/Cartographic.js +257 -249
- package/Source/Core/ClockRange.js +6 -1
- package/Source/Core/ClockStep.js +6 -1
- package/Source/Core/Color.js +844 -835
- package/Source/Core/ComponentDatatype.js +39 -1
- package/Source/Core/CornerType.js +6 -1
- package/Source/Core/Credit.js +121 -124
- package/Source/Core/Ellipsoid.js +637 -660
- package/Source/Core/ExtrapolationType.js +6 -1
- package/Source/Core/GeocodeType.js +6 -1
- package/Source/Core/GeographicProjection.js +74 -74
- package/Source/Core/GeographicTilingScheme.js +179 -198
- package/Source/Core/GeometryOffsetAttribute.js +7 -1
- package/Source/Core/GeometryType.js +7 -1
- package/Source/Core/HeightmapEncoding.js +6 -1
- package/Source/Core/Iau2006XysData.js +24 -13
- package/Source/Core/IndexDatatype.js +3 -1
- package/Source/Core/InterpolationType.js +5 -1
- package/Source/Core/Intersect.js +6 -1
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/IonGeocodeProviderType.js +5 -1
- package/Source/Core/JulianDate.js +850 -848
- package/Source/Core/KeyboardEventModifier.js +6 -1
- package/Source/Core/MapProjection.js +40 -44
- package/Source/Core/Matrix2.js +906 -893
- package/Source/Core/Matrix3.js +1643 -1575
- package/Source/Core/Matrix4.js +2903 -2872
- package/Source/Core/PixelFormat.js +3 -1
- package/Source/Core/PrimitiveType.js +11 -1
- package/Source/Core/Ray.js +62 -60
- package/Source/Core/Rectangle.js +913 -904
- package/Source/Core/ReferenceFrame.js +6 -1
- package/Source/Core/RequestScheduler.js +8 -3
- package/Source/Core/RequestState.js +6 -1
- package/Source/Core/RequestType.js +6 -1
- package/Source/Core/Resource.js +1 -1
- package/Source/Core/ScreenSpaceEventHandler.js +51 -41
- package/Source/Core/ScreenSpaceEventType.js +6 -1
- package/Source/Core/TerrainQuantization.js +6 -1
- package/Source/Core/TilingScheme.js +100 -98
- package/Source/Core/TimeConstants.js +6 -1
- package/Source/Core/TimeStandard.js +6 -1
- package/Source/Core/TrackingReferenceFrame.js +6 -1
- package/Source/Core/Visibility.js +6 -1
- package/Source/Core/VulkanConstants.js +6 -1
- package/Source/Core/WebGLConstants.js +6 -1
- package/Source/Core/WebMercatorProjection.js +108 -109
- package/Source/Core/WebMercatorTilingScheme.js +246 -242
- package/Source/Core/WindingOrder.js +3 -1
- package/Source/Core/createColorRamp.js +37 -0
- package/Source/Core/globalTypes.js +25 -0
- package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +1 -0
- package/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +1 -0
- package/Source/DataSources/StripeOrientation.js +6 -1
- package/Source/Renderer/BufferUsage.js +20 -9
- package/Source/Renderer/Context.js +2 -29
- package/Source/Renderer/DrawCommand.js +435 -403
- package/Source/Renderer/MipmapHint.js +5 -1
- package/Source/Renderer/Pass.js +10 -3
- package/Source/Renderer/PickId.js +44 -0
- package/Source/Renderer/PixelDatatype.js +3 -1
- package/Source/Renderer/RenderbufferFormat.js +5 -1
- package/Source/Renderer/ShaderDestination.js +4 -1
- package/Source/Renderer/TextureMagnificationFilter.js +3 -1
- package/Source/Renderer/TextureMinificationFilter.js +3 -1
- package/Source/Renderer/TextureWrap.js +5 -1
- package/Source/Renderer/createUniform.js +346 -239
- package/Source/Renderer/createUniformArray.js +494 -381
- package/Source/Scene/AlphaMode.js +5 -1
- package/Source/Scene/ArcGisBaseMapType.js +6 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/AttributeType.js +3 -1
- package/Source/Scene/Axis.js +3 -1
- package/Source/Scene/BingMapsStyle.js +6 -1
- package/Source/Scene/BlendEquation.js +6 -1
- package/Source/Scene/BlendFunction.js +6 -1
- package/Source/Scene/BlendOption.js +6 -1
- package/Source/Scene/BlendingState.js +6 -1
- package/Source/Scene/BufferLoader.js +0 -2
- package/Source/Scene/BufferPoint.js +1 -0
- package/Source/Scene/BufferPointCollection.js +17 -1
- package/Source/Scene/BufferPolygon.js +3 -2
- package/Source/Scene/BufferPolygonCollection.js +13 -1
- package/Source/Scene/BufferPolyline.js +1 -0
- package/Source/Scene/BufferPolylineCollection.js +5 -1
- package/Source/Scene/BufferPrimitiveCollection.js +210 -43
- package/Source/Scene/CameraEventAggregator.js +30 -18
- package/Source/Scene/CameraEventType.js +6 -1
- package/Source/Scene/Cesium3DTile.js +54 -1
- package/Source/Scene/Cesium3DTileColorBlendMode.js +6 -1
- package/Source/Scene/Cesium3DTileContent.js +195 -254
- package/Source/Scene/Cesium3DTileContentFactory.js +10 -2
- package/Source/Scene/Cesium3DTileContentState.js +6 -1
- package/Source/Scene/Cesium3DTileContentType.js +3 -1
- package/Source/Scene/Cesium3DTileFeature.js +289 -306
- package/Source/Scene/Cesium3DTileOptimizationHint.js +6 -1
- package/Source/Scene/Cesium3DTilePass.js +5 -1
- package/Source/Scene/Cesium3DTilePointFeature.js +433 -511
- package/Source/Scene/Cesium3DTileRefine.js +6 -1
- package/Source/Scene/Cesium3DTileVectorFeature.js +586 -0
- package/Source/Scene/Cesium3DTileset.js +46 -6
- package/Source/Scene/ClassificationType.js +3 -1
- package/Source/Scene/CloudType.js +3 -1
- package/Source/Scene/ColorBlendMode.js +4 -1
- package/Source/Scene/Composite3DTileContent.js +254 -292
- package/Source/Scene/CullFace.js +6 -1
- package/Source/Scene/DepthFunction.js +6 -1
- package/Source/Scene/DynamicAtmosphereLightingType.js +3 -1
- package/Source/Scene/EdgeDisplayMode.js +50 -0
- package/Source/Scene/Empty3DTileContent.js +100 -132
- package/Source/Scene/EquirectangularPanorama.js +1 -0
- package/Source/Scene/ExpressionNodeType.js +6 -1
- package/Source/Scene/GaussianSplat3DTileContent.js +436 -478
- package/Source/Scene/GeoJsonPrimitive.js +874 -0
- package/Source/Scene/Geometry3DTileContent.js +151 -185
- package/Source/Scene/GltfBufferViewLoader.js +0 -2
- package/Source/Scene/GltfDracoLoader.js +0 -2
- package/Source/Scene/GltfImageLoader.js +0 -3
- package/Source/Scene/GltfIndexBufferLoader.js +0 -4
- package/Source/Scene/GltfJsonLoader.js +0 -2
- package/Source/Scene/GltfLoader.js +109 -5
- package/Source/Scene/GltfLoaderUtil.js +14 -0
- package/Source/Scene/GltfSpzLoader.js +0 -2
- package/Source/Scene/GltfStructuralMetadataLoader.js +0 -2
- package/Source/Scene/GltfTextureLoader.js +0 -2
- package/Source/Scene/GltfVertexBufferLoader.js +0 -4
- package/Source/Scene/HeightReference.js +5 -1
- package/Source/Scene/HorizontalOrigin.js +6 -1
- package/Source/Scene/ImageryProvider.js +1 -1
- package/Source/Scene/ImageryState.js +6 -1
- package/Source/Scene/Implicit3DTileContent.js +179 -214
- package/Source/Scene/ImplicitSubdivisionScheme.js +3 -1
- package/Source/Scene/InstanceAttributeSemantic.js +3 -1
- package/Source/Scene/IonWorldImageryStyle.js +6 -1
- package/Source/Scene/JobType.js +6 -1
- package/Source/Scene/LabelStyle.js +6 -1
- package/Source/Scene/MVTDataProvider.js +147 -0
- package/Source/Scene/MapMode2D.js +6 -1
- package/Source/Scene/MetadataComponentType.js +3 -1
- package/Source/Scene/MetadataSchemaLoader.js +0 -2
- package/Source/Scene/MetadataSemantic.js +6 -2
- package/Source/Scene/MetadataType.js +3 -1
- package/Source/Scene/Model/B3dmLoader.js +0 -3
- package/Source/Scene/Model/CustomShaderMode.js +3 -1
- package/Source/Scene/Model/CustomShaderTranslucencyMode.js +5 -1
- package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +78 -337
- package/Source/Scene/Model/Extensions/Gpm/PpeSource.js +5 -1
- package/Source/Scene/Model/Extensions/Gpm/StorageType.js +5 -1
- package/Source/Scene/Model/GeoJsonLoader.js +0 -2
- package/Source/Scene/Model/I3dmLoader.js +0 -3
- package/Source/Scene/Model/InstancingPipelineStage.js +1 -1
- package/Source/Scene/Model/LightingModel.js +5 -1
- package/Source/Scene/Model/MaterialPipelineStage.js +184 -3
- package/Source/Scene/Model/Model.js +34 -0
- package/Source/Scene/Model/Model3DTileContent.js +424 -458
- package/Source/Scene/Model/ModelDrawCommand.js +31 -3
- package/Source/Scene/Model/ModelReader.js +474 -3
- package/Source/Scene/Model/ModelRuntimePrimitive.js +2 -1
- package/Source/Scene/Model/ModelType.js +3 -1
- package/Source/Scene/Model/ModelUtility.js +4 -0
- package/Source/Scene/Model/PntsLoader.js +4 -3
- package/Source/Scene/Model/StyleCommandsNeeded.js +3 -1
- package/Source/Scene/Model/UniformType.js +5 -1
- package/Source/Scene/Model/VaryingType.js +5 -1
- package/Source/Scene/Model/createVectorTileBuffersFromModelComponents.js +500 -139
- package/Source/Scene/Model/pickModel.js +94 -299
- package/Source/Scene/ModelAnimationLoop.js +6 -1
- package/Source/Scene/ModelAnimationState.js +6 -1
- package/Source/Scene/ModelComponents.js +47 -2
- package/Source/Scene/Multiple3DTileContent.js +291 -334
- package/Source/Scene/PrimitiveState.js +7 -1
- package/Source/Scene/QuadtreeOccluders.js +20 -15
- package/Source/Scene/QuadtreeTile.js +547 -541
- package/Source/Scene/QuadtreeTileLoadState.js +6 -1
- package/Source/Scene/QuadtreeTileProvider.js +159 -175
- package/Source/Scene/ResourceLoader.js +0 -1
- package/Source/Scene/ResourceLoaderState.js +7 -1
- package/Source/Scene/Scene.js +26 -0
- package/Source/Scene/SceneMode.js +4 -1
- package/Source/Scene/ShadowMode.js +3 -1
- package/Source/Scene/SkyBox.js +1 -1
- package/Source/Scene/SplitDirection.js +6 -1
- package/Source/Scene/StencilFunction.js +6 -1
- package/Source/Scene/StencilOperation.js +6 -1
- package/Source/Scene/TerrainState.js +7 -1
- package/Source/Scene/TileState.js +7 -1
- package/Source/Scene/Tileset3DTileContent.js +113 -146
- package/Source/Scene/Tonemapper.js +5 -1
- package/Source/Scene/UrlTemplate3DTilesDataProvider.js +499 -0
- package/Source/Scene/Vector3DTileContent.js +205 -234
- package/Source/Scene/VectorGltf3DTileContent.js +131 -61
- package/Source/Scene/VertexAttributeSemantic.js +3 -1
- package/Source/Scene/VerticalOrigin.js +6 -1
- package/Source/Scene/VoxelBoxShape.js +12 -6
- package/Source/Scene/VoxelContent.js +2 -0
- package/Source/Scene/VoxelCylinderShape.js +39 -38
- package/Source/Scene/VoxelEllipsoidShape.js +46 -96
- package/Source/Scene/VoxelMetadataOrder.js +6 -1
- package/Source/Scene/VoxelPrimitive.js +159 -175
- package/Source/Scene/VoxelProvider.js +64 -90
- package/Source/Scene/VoxelShapeType.js +3 -1
- package/Source/Scene/buildVectorGltfFromMVT.js +1059 -0
- package/Source/Scene/buildVoxelCustomShader.js +199 -0
- package/Source/Scene/decodeMVT.js +634 -0
- package/Source/Scene/renderBufferPointCollection.js +124 -127
- package/Source/Scene/renderBufferPolygonCollection.js +122 -122
- package/Source/Scene/renderBufferPolylineCollection.js +386 -238
- package/Source/Shaders/BufferPointMaterialFS.glsl +1 -0
- package/Source/Shaders/BufferPointMaterialFS.js +1 -0
- package/Source/Shaders/BufferPointMaterialVS.glsl +19 -9
- package/Source/Shaders/BufferPointMaterialVS.js +20 -10
- package/Source/Shaders/BufferPolygonMaterialVS.glsl +13 -4
- package/Source/Shaders/BufferPolygonMaterialVS.js +14 -5
- package/Source/Shaders/BufferPolylineMaterialVS.glsl +16 -2
- package/Source/Shaders/BufferPolylineMaterialVS.js +17 -3
- package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.glsl +9 -0
- package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.js +11 -0
- package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
- package/Source/Shaders/Builtin/Functions/computeTextureTransform.glsl +24 -0
- package/Source/Shaders/Builtin/Functions/computeTextureTransform.js +25 -0
- package/Source/Shaders/Model/ConstantLodStageFS.glsl +60 -0
- package/Source/Shaders/Model/ConstantLodStageFS.js +62 -0
- package/Source/Shaders/Model/ConstantLodStageVS.glsl +12 -0
- package/Source/Shaders/Model/ConstantLodStageVS.js +13 -0
- package/Source/Shaders/Model/EdgeVisibilityStageVS.glsl +0 -1
- package/Source/Shaders/Model/EdgeVisibilityStageVS.js +0 -1
- package/Source/Shaders/Model/MaterialStageFS.glsl +46 -20
- package/Source/Shaders/Model/MaterialStageFS.js +46 -20
- package/Source/Shaders/Voxels/convertLocalToBoxUv.glsl +0 -1
- package/Source/Shaders/Voxels/convertLocalToBoxUv.js +0 -1
- package/Source/Shaders/Voxels/convertLocalToCylinderUv.glsl +7 -9
- package/Source/Shaders/Voxels/convertLocalToCylinderUv.js +7 -9
- package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.glsl +7 -17
- package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.js +7 -17
- package/Source/Widget/CesiumWidget.js +11 -4
- package/index.d.ts +595 -343
- package/index.js +392 -378
- package/package.json +3 -3
- package/Build/Workers/chunk-DVB56LG7.js +0 -114
- package/Build/Workers/chunk-HKUES6UG.js +0 -2357
- package/Build/Workers/chunk-HRHRYFHS.js +0 -940
- package/Build/Workers/chunk-KLPGTXS3.js +0 -642
- package/Build/Workers/chunk-ZBZRTRJB.js +0 -1829
package/Source/Core/Color.js
CHANGED
|
@@ -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
|
-
|
|
34
|
+
class Color {
|
|
42
35
|
/**
|
|
43
|
-
* The red component.
|
|
44
|
-
* @
|
|
45
|
-
* @
|
|
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
|
-
|
|
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
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
70
|
-
|
|
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
|
-
|
|
82
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
110
|
-
|
|
213
|
+
result.red = red;
|
|
214
|
+
result.green = green;
|
|
215
|
+
result.blue = blue;
|
|
216
|
+
result.alpha = alpha;
|
|
217
|
+
return result;
|
|
111
218
|
}
|
|
112
219
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
138
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
|
|
219
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
286
|
-
|
|
424
|
+
result = undefined;
|
|
425
|
+
return result;
|
|
287
426
|
}
|
|
288
427
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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.
|
|
296
|
-
|
|
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
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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.
|
|
313
|
-
"minimumBlue",
|
|
314
|
-
minimumBlue,
|
|
315
|
-
maximumBlue,
|
|
316
|
-
);
|
|
462
|
+
Check.defined("array", array);
|
|
317
463
|
//>>includeEnd('debug');
|
|
318
464
|
|
|
319
|
-
|
|
320
|
-
|
|
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
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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
|
-
|
|
342
|
-
|
|
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
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
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
|
-
|
|
384
|
-
|
|
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
|
-
|
|
388
|
-
|
|
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
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
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
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
Color.
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
-
|
|
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
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
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
|
-
|
|
485
|
-
|
|
486
|
-
result =
|
|
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
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
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
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
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
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
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
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
(
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
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
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
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
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
Color
|
|
586
|
-
|
|
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
|
-
|
|
591
|
-
*
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
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
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
Color
|
|
613
|
-
|
|
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
|
-
|
|
618
|
-
|
|
619
|
-
|
|
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
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
Color
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
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
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
Color
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
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
|
-
|
|
675
|
-
|
|
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
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
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
|
-
|
|
703
|
-
|
|
704
|
-
*
|
|
705
|
-
|
|
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
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
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
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
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
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
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
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
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
|
-
*
|
|
774
|
-
*
|
|
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.
|
|
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
|