Three.js学习笔记-Lights(灯光)

Light

是灯光抽象的基类,其他类型的灯光继承自它
构造函数
Light(color: Integer,intensity: Float)
可选的十六进制颜色表示法,默认0xffffff
可选的灯光的强度,默认1
特性
- color/intensity
- isLight: Boolean 检查此类或者派生类是否是灯,默认true
方法
- copy(source: Light)
- toJSON(meta: String)

AmbientLight

在场景中照亮所有的物体(将灯的颜色叠加到对象上)
该光不能投下阴影,因为它没有方向
构造函数
AmbientLight(color: Integer,intensity: Float)
特性
- castShadow: Boolean 被设置为undefined,在构造函数中环境光不能投下阴影
- isAmbientLight: Boolean
方法
继承Light

DirectionalLight

沿特定方向发出光,一般模拟日光。该光线可以投下阴影,详细看DirectionLightShadow
构造函数
DirectionalLight(color: Integer,intensity: Float)
特性
- isDirectionalLight: Boolean
- castShadow: Boolean 默认false。设置为true,灯光将投下动态的阴影,代价比较高
- position: Vector3 Object3D.DefaultUp设为(0,1,0),以便光从上到下发光
- shadow: DirectionalLightShadow DirectionalLightShadow 来计算光的投影方向的光影
- target: Object3D DirectionalLight从它位置指向target位置,默认(0,0,0),场景中的默认位置需要发生变化时light.target = newObj;
方法
- copy(source: DirectionLight)

PointLight

从过一个点向四面八方飞出的光,能投射阴影,详细参考LightShadow
构造函数
PointLight(color: Integer,indensity: Float,distance: Number,decay: Float)
distance 距离光强的距离。 默认0,光永远不会停止
decay 沿着光的距离减弱的量,默认1,物理照明可以设为2
特性
- decay/distance
- isPointLight
- power: Float 在physically correct模式,光的强度,默认4Math.PI
- shadow: LightShadow 计算灯光下的阴影,
方法
- copy(source: PointLight)

SpotLight

光从一个方向上的一个点发出,沿着一个圆锥体,类似聚光灯
构造函数
SpotLight(color: Integer,intensity: Float,distnace: Float,angle: Radians,penumber: Float,decay: Float)
distance: 距离灯光的最远距离
angle: 光线散射角度(锥形的顶角视宽),最大Math.PI/2
penumber: 设置半影的衰减,取值0~1,默认0
decay: 衰减光的强度
特性
- angle/decay/distance/penumber
- castShadow: Boolean
- isSpotLight: Boolean
- power: Float
- position: Vector3
- shadow: SpotLightShadow
- target: Object3D
方法
- copy(source: SpotLight)

RectAreaLight

在一个矩形平面上均匀的发出光,模拟照明的窗户或条形照明
不支持阴影,仅仅MeshStandardMaterial和MeshPhysicalMaterial支持
还需要RectAreaLightUniformsLib.js
构造函数
ReactAreaLight(color: Integer,intensity: Float,width: Float,height: Float)
特性
- 继承Light类
- isRectAreaLight: Boolean
方法
- copy(source: RectAreaLight)

HemisphereLight

一种直接位于场景上方的的光源,颜色从天空颜色逐渐褪色到地面颜色
不能用于投射阴影
构造函数
HemisphereLight(skyColor: Integer,groundColor: Integer,indensity: Float)
特性
继承Light类
- castShadow/color/groundColor/position/isHemisphereLight
方法
copy(source: HemisphereLight)


Lights/Shadows

LightShadow

是其他阴影类的基类,被用在PointLight上计算阴影
构造函数
LightShadow(camera: Camera)
camera 灯在世界中的视角
特性
- camera
- bias: Float 阴影贴图偏差
- map: WebGLRendertarget 使用内置摄像头生成的深度图;超出像素深度的位置在阴影中。在渲染期间内部计算
- mapSize: Vertor2 阴影的宽高,为2的幂
- matrix: Matri4 模拟阴影相机空间,计算阴影贴图中的位置和深度
- radius: Float 将此值设置为大于1的值将模糊阴影的边缘
方法
- copy(source: LightShadow)
- clone()
- toJSON()

DirectionalLightShadow

用在OrthographicCamera,从DirectionalLight来的光线是平行的
构造函数
DirectionalLightShadow() 创建的实例再DirectionalLight内部调用
特性
继承LightShadow
- camera: Camera
方法
继承LightShadow

SpotLightShadow

SpotLight内部使用来计算阴影
构造函数
SpotLightShadow() 创建一个PerspectiveCamera来管理阴影
特性
继承LightShadow
- camera: Camera
- isSpotLightShadow
方法
继承LightShadow
- update(light: SpotLight)

猜你喜欢

转载自blog.csdn.net/u013270347/article/details/81099204