本文介绍了在 WebGLRenderer 中动态打开/关闭抗锯齿和阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 WebGLRenderer 中动态打开和关闭抗锯齿和阴影?

How can I dynamically turn on and off antialiasing and shadows in WebGLRenderer?

简单地改变抗锯齿和shadowMapEnable的属性是行不通的.查了一下源码,发现了一个方法updateShadowMap()但是在release 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 herehttps://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 中动态打开/关闭抗锯齿和阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 00:21