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.add()

Color.add() 方法用于将两个颜色相加,并返回结果。

语法

add(color: Color): Color

参数

  • color: 需要添加的颜色。类型为 Color 对象。

返回值

返回一个新的 Color 对象。

示例

const color1 = new THREE.Color(0xFF0000);
const color2 = new THREE.Color(0x00FF00);

const result = color1.add(color2);
console.log(result); // 输出颜色为:#ffff00

注意事项

  • 如果要将新的颜色值直接应用于材质,需要使用 material.color.copy(result)

  • Color.add() 方法不会改变原始颜色,而是返回一个新的颜色。

  • 颜色值的范围为 0~1 之间的值,因此在设置颜色时需要使用小数表示。

  • 两个颜色值相加时,会将两个颜色的分量分别相加,例如:

    color1 = (r1, g1, b1)
    color2 = (r2, g2, b2)
    result = (r1 + r2, g1 + g2, b1 + b2)
    
  • 如果相加的两个颜色值超出了0~1范围,颜色值会被自动截取到0~1之间。