PIXI JS - 如何更新网格 UV?

PIXI JS - How to update mesh UVs?

我想知道如何更新网格 UV。

UV 似乎在初始化时应用得很好。 但是,如果它动态修改,则 UV 不会反映它。 这是 PIXI JS 中的错误吗?还是我的错?

...
uvs: Float32Array = new Float32Array([ 0, 0, 1, 0, 1, 1, 0, 1 ]);
mesh: PIXI.mesh.Mesh = new PIXI.mesh.Mesh(texture, vertices, uvs, indices);

运行时

this.mesh.uvs[2] += this.offset;
this.mesh.uvs[4] += this.offset;

无效。

PixiJS 提供给你的数据在 CPU 上,但是 GPU 渲染的网格使用 GPU 中的数据。

你只更新了CPU数据,要让它对GPU可用,你必须增加YourMesh.dirty,这样PixiJS就知道数据已经改变了,他需要更新GPU数据。

你应该有这样的东西:

this.mesh.uvs[2] += this.offset;
this.mesh.uvs[4] += this.offset;
this.mesh.dirty ++;