BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

Color.addScalar()

Color.addScalar(scalar: number): Color

The Color.addScalar() method adds a scalar value to the red, green and blue components of a Color.

Syntax

color.addScalar(scalar);

Parameters

  • scalar - A number representing the scalar value to add to each component of the Color. This value will be added to the red, green and blue values of the color.

Return Value

  • Returns the modified Color object.

Description

The Color.addScalar() method adds a scalar value to the red, green and blue components of a Color. This is useful when applying color tinting or fading effects, as it allows a single value to be applied to all components simultaneously.

When a scalar value is added to a color component, the resulting value is clamped between 0 and 1. Therefore, adding a larger scalar value may not result in an expected change in color appearance.

Examples

const color = new THREE.Color(0xff0000); // red
color.addScalar(0.5); // adds 0.5 to the red, green and blue values

See Also