How to access and edit the coordinates of all UV (UV0, UV1...) data from a given mesh?

I saw in older posts (2017~2020) that you do it from entity.model , but in my case, this was undefined so I can’t access meshInstances.

I think now we need to access from entity.render._meshInstances

Thanks to some old examples from this forum I’m able to modify the vertices themselves, but not the UVs. A quick example bellow:

instance2Meshes = (instance) => (instance.render._meshInstances)
mesh = instance2Meshes('Monkey'))[0]
n = || / 4

buffer = mesh._mesh.vertexBuffer;
iterator = new pc.VertexIterator(buffer)
posSem = iterator.element[pc.SEMANTIC_POSITION];
original = [ Float32Array(]

goUp = new Float32Array([ Array(n)].map((e,i) => i%11 == 1 ? posSem.array[i] + 1 : original[i]))


Hi @dadiaar,

You can use the newer Mesh API, only thing you need is a reference to the original mesh. You can get it from a mesh instance like this:

const mesh = this.entity.render.meshInstances[0].mesh;

1 Like

have a look at this example:

it uses mesh.getPositions function. You can access UVs the same way:


Thanks, I’ll check and give a feedback