PIXI JS-如何更新网格UV



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

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

...
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 ++;

最新更新