在渲染后向三个网格添加几何 [英] Adding geometry to a three.js mesh after render

查看:177
本文介绍了在渲染后向三个网格添加几何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个具有THREE.Geometry实例的网格,然后填充几何的顶点 faces 动态。几何被迭代地改进,在每次迭代时添加额外的顶点和面。如果我在将网格添加到场景之前优化几何,则会正确呈现。但是,如果我将网格添加到场景并进行渲染,那么修改它,只显示初始N面向第一个渲染中包含的几何。对这些面使用的顶点的位置的更改将被保留,但只会渲染N个面。



几何实例被标记为 dynamic = true ,我设置 verticesNeedUpdate elementsNeedUpdate buffersNeedUpdate 每次修改几何后。我也试过设置所有其他的脏标志,虽然我只希望需要设置这三个(即使这样,我不知道我应该需要buffersNeedUpdate)。



据我所见,几何的 geometryGroup geometryGroupList 属性正在构建并填充当网格首次渲染但不被重建以包括随后添加的面孔时存在的面孔。



我做错了什么?

解决方案

我假设您正在使用 WebGLRenderer



如3.js wiki文章如何更新事情所述,您只能更新缓冲区的内容,您无法调整缓冲区大小。



three.js r.59


I'm creating a mesh with a THREE.Geometry instance, then populating the geometry's vertices and faces arrays dynamically. The geometry is iteratively refined, adding additional vertices and faces at each iteration. If I refine the geometry before adding the mesh to the scene, it renders correctly. However, if I add the mesh to the scene and render it, then modify it, only the initial N faces the geometry contained on first render are shown. Changes to the position of the vertices used by those faces are honored, but only those N faces are rendered.

The geometry instance is marked dynamic = true, and I set verticesNeedUpdate, elementsNeedUpdate and buffersNeedUpdate each time after modifying the geometry. I've also tried setting all the other 'dirty' flags, though I only expect to need to set those three (and even then, I'm not certain I should need buffersNeedUpdate).

As far as I can see, the geometry's geometryGroup and geometryGroupList properties are being built and populated from the faces that exist when the mesh is first rendered, but are not being rebuilt to include the faces added subsequently.

What am I doing wrong?

解决方案

I assume you are using WebGLRenderer.

As stated in the three.js wiki article How to Update Things, you can only update the content of buffers, you cannot resize buffers.

three.js r.59

这篇关于在渲染后向三个网格添加几何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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