如何在Typescript中更新three.js BufferGeometry的位置

4

我正在尝试按照此文档中提供的推荐步骤更新BufferGeometry:https://threejs.org/docs/#manual/en/introduction/How-to-update-things

但是我正在使用TypeScript,当我像示例中所做的那样更改line.geometry.attributes.position.array上的值时,出现了问题。

    positions[ index ++ ] = x;
    positions[ index ++ ] = y;
    positions[ index ++ ] = z;

出现错误TS2542: 数组类型的索引签名仅允许读取。

是否有其他方法在运行时更新BufferGeometry?


2
请查看THREE.BufferAttribute().setXYZ()方法。 - prisoner849
如果是真的,那听起来像是一个错误 - gman
还有一个 count 属性,如果你正在通过索引循环。 - vinesh_dodiya
1个回答

2

正如prisioner849所说,BufferAttribute有一个.setXYZ()方法,应该使用它来代替直接在特定索引处更新位置。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接