灯光
- AmbientLight:环境光,均匀照亮场景种所有物体
- DirectionalLight:平行光,平行的光线,比如太阳光
- PointLight:点光源,从一个点发射的光源,比如灯泡
- SpotLight:聚光灯,照射出一个圆锥体,比如手电筒,舞台的灯光
- HemisphereLight:半球光,两种颜色的光,比如天空颜色、地面颜色相互叠加
- RectAreaLight:矩形平面光,类似窗户、LED 灯管等从一个面发光的效果
平行光
一般用来模拟太阳光,背面不可见
export const light = new THREE.DirectionalLight(0xffffff);
light.position.set(400, 500, 300);
light.lookAt(0, 0, 0);
const helper = new THREE.DirectionalLightHelper(light, 100);
mesh.add(helper);
点光源
背面不可见
export const light = new THREE.PointLight(0xffffff, 1000000);
light.position.set(400, 500, 300);
light.lookAt(0, 0, 0);
const helper = new THREE.PointLightHelper(light, 100);
mesh.add(helper);
环境光
背面可见
const ambientLight = new THREE.AmbientLight(0xffffff);
mesh.add(ambientLight);
聚光灯
export const light = new THREE.SpotLight(0xffffff, 1000000);
light.distance = 1000; light.angle = Math.PI / 6;
light.position.set(400, 500, 300);
light.lookAt(0, 0, 0);
const helper = new THREE.SpotLightHelper(light);
mesh.add(helper);
半球光
export const light = new THREE.HemisphereLight(
new THREE.Color('orange'),
new THREE.Color('green'),
1
);
light.position.set(400, 500, 300);
light.lookAt(0, 0, 0);
const helper = new THREE.HemisphereLightHelper(light, 100);
mesh.add(helper);
矩形平面光
只对MeshStandardMaterial生效
export const light = new THREE.RectAreaLight( new THREE.Color('red'), 20, 100, 100 );
light.position.set(400, 500, 300);
light.lookAt(0, 0, 0);
const helper = new RectAreaLightHelper(light);
mesh.add(helper);