随时改变spotLight.shadowCameraFov'

时间:2013-11-03 10:37:30

标签: three.js

我正在尝试使用onChange方法更改spot light对象的shadowCameraFov属性,这里是代码:

    gui.add(controls, 'spotCameraFov', 30, 270).onChange( function (e) {
            spotLight.shadowCameraFov = e;
            console.log(e);
    });

我可以看到值正在改变(来自console.log),但它实际上对spot lightcameraFov没有影响。关于如何使其有效的任何建议?

1 个答案:

答案 0 :(得分:1)

以下是您需要遵循的模式:

gui.add( controls, 'shadowCameraFov', 30, 120 ).onChange( function() {

    spotLight.shadowCameraFov = controls.shadowCameraFov;
    spotLight.shadowCamera.fov = spotLight.shadowCameraFov;
    spotLight.shadowCamera.updateProjectionMatrix();

});

您可以在此处查看实时示例:http://threejs.org/examples/webgl_shading_physical.html。控件位于右上方。

three.js r.62

相关问题