Light
光源的基类 - 所有其他的光类型都继承了该类描述的属性和方法。
构造器
color : Integer
color - (可选参数) 16进制表示光的颜色。 缺省值 0xffffff (白色)。
intensity : Float
intensity - (可选参数) 光照强度。 缺省值 1。
属性
公共属性请查看基类Object3D。
.color : Color
光源的颜色。如果构造的时候没有传递,默认会创建一个新的 Color 并设置为白色。
小于 1 分钟
光源的基类 - 所有其他的光类型都继承了该类描述的属性和方法。
color - (可选参数) 16进制表示光的颜色。 缺省值 0xffffff (白色)。
intensity - (可选参数) 光照强度。 缺省值 1。
公共属性请查看基类Object3D。
光源的颜色。如果构造的时候没有传递,默认会创建一个新的 Color 并设置为白色。
光源直接放置于场景之上,光照颜色从天空光线颜色渐变到地面光线颜色。
半球光不能投射阴影。
const light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 );
scene.add( light );
平行光是沿着特定方向发射的光。这种光的表现像是无限远,从它发出的光线都是平行的。常常用平行光来模拟太阳光 的效果; 太阳足够远,因此我们可以认为太阳的位置是无限远,所以我们认为从太阳发出的光线也都是平行的。
const directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
scene.add( directionalLight );
平面光光源从一个矩形平面上均匀地发射光线。这种光源可以用来模拟像明亮的窗户或者条状灯光光源。
注意事项:
const width = 10;
const height = 10;
const intensity = 1;
const rectLight = new THREE.RectAreaLight( 0xffffff, intensity, width, height );
rectLight.position.set( 5, 5, 0 );
rectLight.lookAt( 0, 0, 0 );
scene.add( rectLight )
rectLightHelper = new RectAreaLightHelper( rectLight );
scene.add( rectLightHelper );
从一个点向各个方向发射的光源。一个常见的例子是模拟一个灯泡发出的光。
const light = new THREE.PointLight( 0xff0000, 1, 100 );
light.position.set( 50, 50, 50 );
scene.add( light );
创建一个环境光对象。
const light = new THREE.AmbientLight( 0x404040 );
scene.add( light );
光线从一个点沿一个方向射出,随着光线照射的变远,光线圆锥体的尺寸也逐渐增大。创建一个新的聚光灯。
const spotLight = new THREE.SpotLight( 0xffffff );
spotLight.position.set( 100, 1000, 100 );
spotLight.map = new THREE.TextureLoader().load( url );
spotLight.castShadow = true;
spotLight.shadow.mapSize.width = 1024;
spotLight.shadow.mapSize.height = 1024;
spotLight.shadow.camera.near = 500;
spotLight.shadow.camera.far = 4000;
spotLight.shadow.camera.fov = 30;
scene.add( spotLight );