I was wondering, is there a way to change the faceUV of a mesh, specifically a box styled mesh, after it has been created?
Heres what i tried to do: https://www.babylonjs-playground.com/#20OAV9#443
However that doesnt seem to work, is there a way to do this, or will i need to create a new box all together?
Actually, I had never heard of a faceUV property before. Looks like this is just an option of the MeshBuilder object. UVâs are usually 2 values per vertex, not 4.
MeshBuilder must eventually create a UV vertex buffer. Once created you will need to update the vertex buffer directly. Add an initial value for FaceUVâs, and also add the MeshBuilder option updateable, setting it to true.
Then get the vertexBuffer:
let buffer = box2.getVertexData(BABYLON.VertexBuffer.UVKind);
This seems like it will work however, im still having trouble getting it working. Heres what i have:
I get an error when trying to use the box2.updateVerticesData(BABYLON.VertexBuffer.UVKind, buffer);
it says:
âArgument of type âVertexBufferâ is not assignable to parameter of type âFloatArrayâ.
Type âVertexBufferâ is missing the following properties from type âFloat32Arrayâ: BYTES_PER_ELEMENT, buffer, byteLength, copyWithin, and 23 more.ts(2345)â
faceUV is a parameter to allow the user to select what area to crop from an image and to apply it to the wanted side of some meshes supporting this feature (boxes, cylinders, etc).
As it modifies the internal geometry at construction time, it canât be changed afterwards.
The real way to change the UVs after a mesh is built is to set it as âupdatableâ at construction time and then to update its VerticeData about UVs like JCPalmer described in the former post.