How to kill uv from mesh

Sorry for discussing this question as I’ve used it in my project before.
But I can’t remember it.
The gltf model file has many meshes, materials…
Some meshes have a small portion of the uv channel.
I’m trying to change another matte (pbrMat + videoTexture).
But the uv remains. So only part of the video is shown.
In conclusion, a method is needed to remove the divided uv applied to the mesh.


1

You can update the uvs maybe? Updating Vertices | Babylon.js Documentation (babylonjs.com) :slight_smile:

2 Likes

A repro in the playground would be helpfull cause of upu only need scale or translate you could change those on the texture itself.

1 Like

is this what it means

var uvs = mesh.getVerticesData(BABYLON.VertexBuffer.UVKind);
uvs.forEach((e)=>{
e = 1; (before 0.3~0.6 values) // test uv
})
mesh.updateVerticesData(BABYLON.VertexBuffer.UVKind, uvs);

but there was no change

@sebavan
here is based PG in my case

Am I trying something wrong?

Looks like you need to pass true to the makeItUnique parameter in updateVerticesData to create a new geometry and assign it to the mesh: Available Mesh BoomBox | Babylon.js Playground (babylonjs.com) (I changed the texture and created a non-modified copy of the mesh to make it easier to compare)

If you want to change the uvs uniformly through, instead of directly modifying the uvs, you can use uScale and vScale: Available Mesh BoomBox | Babylon.js Playground (babylonjs.com)

1 Like

Instead of transforming the original mesh called from gltf, you need to clone and replace it.
I didn’t understand the underlying reason why the original mesh wouldn’t deform, but that’s a good enough answer. thank you

Instead of creating a new geometry you can also just create a new vertex buffer. :slight_smile:

AFAIK the reason why the existing buffer can’t be updated is because the gltf loader creates static vertex buffers. But if you call setVertexData instead of updateVertexData, a new vertex buffer will be created for you. By default it will be static, but if you pass true as the third parameter then an updatable buffer will be created which would allow you to use updateVerticesData. If you’re only changing the data once though, it could be more optimal to create a static buffer.

2 Likes

That’s exactly the one!
I now know the cause, and I can solve it as I want.