在WebGLRenderer中动态打开/关闭抗锯齿和阴影 [英] Dynamically turn on/off antialiasing and shadows in WebGLRenderer

查看:1176
本文介绍了在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆