本文介绍了无法正确更新 DirectionalLight 阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的场景中有一个 DirectionalLight.当我第一次创建灯光时,阴影覆盖了预期的区域.当视口调整大小(画布大小)时,我更新了 shadowCamera 参数(右、左、上、下)以及灯光的位置和目标,但阴影仅覆盖更新前的区域.

I have a DirectionalLight in my scene. When I first create the light the shadow covers the intended area. When the viewport is resized (canvas size) I update the shadowCamera parameters (right,left,top,bottom), and the light's position and target, but the shadow only covers the area before the update.

我必须设置什么标志才能正确更新阴影以反映新设置?

What flag do I have to set to get the shadow properly updated to reflect the new settings?

推荐答案

以下是动态更新阴影相机所需遵循的模式:

Here is the pattern you need to follow to update a shadow camera on-the-fly:

light.shadowCameraLeft = -100;
light.shadowCameraRight = 100;

light.shadowCamera.left = light.shadowCameraLeft;
light.shadowCamera.right = light.shadowCameraRight;

...

light.shadowCamera.updateProjectionMatrix();

three.js r.64

three.js r.64

这篇关于无法正确更新 DirectionalLight 阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 19:46