【问题标题】:PIXI JS - How to update mesh UVs?PIXI JS - 如何更新网格 UV?
【发布时间】:2019-04-24 18:24:36
【问题描述】:

我想知道如何更新网格 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;

不工作。

【问题讨论】:

    标签: typescript opengl-es mesh pixi.js


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-05
      • 2019-10-30
      • 1970-01-01
      • 1970-01-01
      • 2011-03-15
      • 2017-05-12
      • 2020-09-14
      相关资源
      最近更新 更多