【问题标题】:How to update three.js BufferGeometry positions in Typescript如何更新 Typescript 中的 three.js BufferGeometry 位置
【发布时间】:2020-07-03 22:36:53
【问题描述】:

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

但是我使用的是打字稿,当我尝试更改 line.geometry.attributes.position.array 上的值时,就像在示例中所做的那样

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

它会抛出一个错误TS2542: Index signature in type 'ArrayLike<number>' only permits reading.

还有其他方法可以在运行时更新 BufferGeometry 吗?

【问题讨论】:

  • 看看.setXYZ()的方法THREE.BufferAttribute()
  • 如果是真的,那听起来像a bug

标签: typescript three.js


【解决方案1】:

正如 prisioner849 所说,BufferAttribute 有一个 .setXYZ() 方法,应该使用它而不是直接更新某个索引处的位置。

【讨论】:

    猜你喜欢
    • 2013-12-16
    • 1970-01-01
    • 2017-09-22
    • 1970-01-01
    • 2013-04-11
    • 2015-04-01
    • 2016-07-26
    • 1970-01-01
    • 2019-02-04
    相关资源
    最近更新 更多