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