刚学习聚光灯属性时发现没有光照效果,后来发现是聚光灯的 decay 属性影,初始必须添加这个属性才会有灯照效果:
代码:
| const spotLight = new three.SpotLight(0xffffff, 0.5) | |
| spotLight.position.set(5, 5, 5) | |
| spotLight.castShadow = true // 开启光照投射阴影 | |
| // 设置阴影贴图模糊度 | |
| spotLight.shadow.radius = 20 | |
| // 设置阴影贴图的分辨率 | |
| spotLight.shadow.mapSize.set(4096, 4096) | |
| // 沿着光照距离的衰减 | |
| spotLight.decay = 0 | |
| this.scene.add(spotLight) | |
| const cameraHelper = new three.CameraHelper(spotLight.shadow.camera) | |
| this.scene.add(cameraHelper) | 
