我这里遇到一个小问题。我有一个 THREE.Line
对象,具有 Material 和几何形状。 init方法将2个顶点推送到几何体,将线添加到场景中,线渲染得很好。
但是我有一个事件监听器... Canvas 中的每次单击都会添加另一个顶点。但渲染场景时,只渲染原来的2个顶点。我已经输出了 scene.children
的转储,并且我确定该线位于场景中,并且几何形状已更改。
在文档中它说了一些关于申请的内容:
geometry.dynamic = true
geometry.verticesNeedUpdate = true
但是这些也不起作用。
最佳答案
参见 Three.js Wiki:https://github.com/mrdoob/three.js/wiki/Updates
You can only update content of buffers, you cannot resize buffers (this is very costly, basically equivalent to creating new geometry).
You can emulate resizing by pre-allocating larger buffer and then keeping unneeded vertices collapsed / hidden.
几何图形是通过具有固定大小的顶点缓冲区对象指定的。您可以创建和删除缓冲区,但无法调整它们的大小。
作为解决方法,您可以创建具有额外顶点的几何图形,并将不需要的顶点折叠为单个点。
三.js r.52
编辑: Drawing a line with three.js dynamically 中描述了一种更新的方法。 .
关于javascript - Three.js - 更新的几何体不是渲染变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13271367/