I am now trying to access the mesh’s vertex buffer and change the vertices’ positions. It can be done on a sphere created by MeshBuilder.CreateSphere, but fails for a mesh imported by SceneLoader.ImportMesh (such as a .gltf file).
Really confused now… Are there any extra steps to update an imported mesh?
Below is a playground to demonstrate this, in which the sphere is successfully changed but the skull is not.
I’ve checked the code and it looks like geometry loaded by gltfloader is not updatable. I guess you can clone and swap the Geometry to make it updatable.
You should use
setVerticesData instead of
updateVerticesData, which only works if the buffer has been created as updatable in the first place.
Maybe we can add a flag to tell the loader to use updatable buffers?
@KimiZhong If you want this, please file a feature request on GitHub.