在Three.js中的verticesNeedUpdate [英] verticesNeedUpdate in Three.js

查看:1352
本文介绍了在Three.js中的verticesNeedUpdate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用dat.GUI来操作网格顶点的坐标。

I want to use dat.GUI to manipulate the coordinates of a mesh vertices.

起初我以为我可以删除每一帧我的网格重新创建它们,但后来我看到这里,这不是一个好方法。

At first I thought I could have removed every frame my meshes to recreate them anew, but then I saw here that it's not a good way.

我应该使用verticesNeedUpdate吗?它似乎不在Three.js文档上

Is verticesNeedUpdate that I should use? It seems not to be on Three.js documentation

推荐答案

如果你的几何是 THREE.Geometry ,然后您可以使用如下模式更新顶点:

If your geometry is THREE.Geometry, then your can update the vertices by using a pattern like so:

geometry.vertices[ 0 ].set( x, y, z );

geometry.verticesNeedUpdate = true;

如果你的几何是 THREE.BufferGeometry ,那么你可以使用这种模式:

If your geometry is THREE.BufferGeometry, then you can use this pattern:

geometry.attributes.position.setXYZ( index, x, y, z );

geometry.attributes.position.needsUpdate = true;

在任何一种情况下,您只需要设置 needsUpdate 标记几何体是否先前已渲染过。

In either case, you only need to set the needsUpdate flag if the geometry has been previously-rendered.

此外,您无法调整缓冲区的大小;您只能更改数据值。有关其他信息,请参阅Wiki文章如何更新事物

Also, you cannot resize buffers; you can only change the data values. See the Wiki article How to Update Things for additional information.

three.js r.85

three.js r.85

这篇关于在Three.js中的verticesNeedUpdate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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