在 three 中查看 聚光灯,与环境光的使用后写下这篇文档,聚光灯如何调节聚光的大小,聚光灯的基本使用
如何控制聚光灯
- 控制聚光灯大小 angle 属性 赋值 Math.PI / 4 调整光锥形的角度, 4 调整为越大光锥越小 4 调整越小光锥越大
- 控制光源距离 distance 控制光源的距离 赋值
- 如何控制聚光灯的强度
使用示例
// 创建聚光灯
const spotLight = new THREE.SpotLight(0x00ff00);
spotLight.position.set(0, 50, 0);
spotLight.castShadow = true; // 使灯光投射阴影
spotLight.angle = Math.PI / 10;
spotLight.penumbra = 0.2;
spotLight.intensity = 100; // 光照强度
spotLight.decay = 1; // 值越大在聚光灯作用距离之外衰减越快
spotLight.distance = 60; // 聚光灯的作用距离
spotLight.target = cube; // 聚光灯的目标设为立方体
scene.add(spotLight);