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

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

问题描述

我正在创建一个带有 THREE.Geometry 实例的网格,然后动态填充几何体的 verticesfaces 数组.几何图形被迭代细化,在每次迭代时添加额外的顶点和面.如果我在将网格添加到场景之前优化几何体,它会正确渲染.但是,如果我将网格添加到场景中并对其进行渲染,然后对其进行修改,则只会显示第一次渲染中包含的几何体的初始 N 面.这些面使用的顶点位置的更改受到尊重,但仅渲染这 N 个面.

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.

几何实例标记为dynamic = true,我每次设置verticesNeedUpdateelementsNeedUpdatebuffersNeedUpdate修改几何后.我还尝试设置所有其他脏"标志,但我只希望需要设置这三个标志(即使如此,我也不确定我是否需要 buffersNeedUpdate).

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).

据我所知,几何体的 geometryGroupgeometryGroupList 属性是从第一次渲染网格时存在的面构建和填充的,但不是正在重建以包括随后添加的面孔.

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.

我做错了什么?

推荐答案

我假设您正在使用 WebGLRenderer.

如three.js wiki 文章如何更新事物所述,您只能更新缓冲区的内容,您不能调整缓冲区的大小.

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

three.js r.59

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

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