在WebGLRenderer中动态打开/关闭抗锯齿和阴影 [英] Dynamically turn on/off antialiasing and shadows in WebGLRenderer
问题描述
如何在WebGLRenderer中动态打开和关闭抗锯齿和阴影?
How can I dynamically turn on and off antialiasing and shadows in WebGLRenderer?
仅更改抗锯齿和shadowMapEnable的属性不起作用.我查看了源代码,发现了一个updateShadowMap()方法,但在版本69中将其删除.
Simply changing the properties of anti-aliasing and shadowMapEnable does not work. I looked in the source and found a method updateShadowMap () but it was removed in release 69.
更新:好的,我在这里找到的问题后半部分的答案 https://github.com/mrdoob/three.js/issues/2466
UPDATE: OK, the answer to the second half of the question I found here https://github.com/mrdoob/three.js/issues/2466
因此,以下代码可以正常工作:
As a result the following code works fine:
renderer.shadowMapEnabled = false;
for(var i in tiles.children)
tiles.children[i].material.needsUpdate=true;
renderer.clearTarget( sun.shadowMap );
推荐答案
创建后无法从WebGL上下文启用/禁用抗锯齿.唯一的方法是创建一个新的上下文,然后再次提交所有缓冲区和纹理.
You can't enable/diable antialiasing from a WebGL context after creation. The only way is to create a new context and submit all the buffers and textures again.
因此,理想情况下,您只需要使用antialias布尔值创建一个新的WebGLRenderer
.尚无法解决此问题,但我正在努力使其尽快运行.
So, ideally you would only need to create a new WebGLRenderer
with the antialias boolean. This doesn't work yet thought, but I'm working to have it working ASAP.
这篇关于在WebGLRenderer中动态打开/关闭抗锯齿和阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!