Three.js. Why does Spotlight not allow the near/far to be reset?

时间:2019-04-08 12:57:37

标签: three.js

I created a spotlight thusly:

let spotLight = new THREE.SpotLight( color, intensity );

spotLight.castShadow = true;

spotLight.shadow.mapSize.width = shadowSize;
spotLight.shadow.mapSize.height = shadowSize;
spotLight.shadow.camera.near = near;
spotLight.shadow.camera.far = far;

Works fine. In then tried to change the near and far:

this.spotLight.shadow.camera.near = near;
this.spotLight.shadow.camera.far = far;

this.spotLight.shadow.update(this.spotLight);

Nothing happens. What am I missing here?

1 个答案:

答案 0 :(得分:2)

如果更改相机的构造函数参数,则需要更新相机的投影矩阵。阴影摄像机也是如此。

light.shadow.camera.updateProjectionMatrix();

three.js r.103