typescript - PIXI JS - 如何更新网格 UV?
问题描述
我想知道如何更新网格 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 ++;
推荐阅读
- javascript - 我无法以位于另一个模式中的 mongodb 模式的语言环境字符串格式返回日期
- python - 有没有办法在运行时以类型库样式获取 Python 中的变量类型
- python - Python将返回类型注释为赋予函数的类型
- python - 是否可以创建一个在修改时实现其属性的对象?
- android - 如何在没有手机睡眠的情况下启用 Wi-Fi 调试 Android 手机
- android - 当我运行我的颤振项目时,我得到了一堆错误
- java - CassandraRepository - 输入“2021-01”没有可行的替代方案
- svg - 使用描边和全局定位的模式来设计 SVG 元素
- r - 从 R6 方法继承 Roxygen 文档
- python - 如何创建一个递归函数,返回给定两个列表的相同索引的总和列表。?