Fedor Posted June 7, 2017 Share Posted June 7, 2017 As far as I understand, updating the positions data on a mesh using updateMeshPositions - or other update* functions - only works when the mesh is set to be updateable. This setting can only be done at creation time. All basic shape creation* functions have the updateable option that can be set, but the standard mesh constructor has not. How do I make a custom shaped mesh updatable? I have thought of a workaround, by creating an updateable cube or something and replacing the vertices data with my custom mesh data. I have not tested this, but I will. And another question: it was my take that the updateMeshPositions is the fastest way to update the vertices positions. setVerticesData works also on non Updateables but seems to be slow. Is updateMeshPositions the fastest way to modify the vertices positions? And if not, what is? I am working on a sculpting app, my custom mesh has over 50K positions. Updating vertices is what the app is all about and I need it to be done as smooth and realtime as possible. Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 7, 2017 Share Posted June 7, 2017 Check this out http://babylonjsguide.github.io/advanced/Updating_Vertices#updating-the-data jerome and Fedor 2 Quote Link to comment Share on other sites More sharing options...
jerome Posted June 7, 2017 Share Posted June 7, 2017 #1 all shapes provided by BJS have the updatable option what means the underlying mesh vertex buffer can be updated without being destroyed/recreated once the mesh is created if we need to morph it. #1 bis. Among all these provided shapes only a part of them are called "parametric shapes" ( http://doc.babylonjs.com/tutorials/parametric_shapes ) . Only the parametric shapes provide a way to be updated directly by calling back their constructor with the parameter "instance" #1 ter. For any other updatable mesh, you can use the function updateMeshPositions(). This function is not faster nor slower than updateVerticesData() because it just calls it ! # 2 If you use another shape from another origin than the provided shapes (imported from blender, created by you from scratch, etc), you could then set the parameter updatable at the VertexData level : https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.vertexData.ts#L83 # 3 setVerticesData() creates a new vertex buffer on each call, this means that the garbage collector will have to clean up the house. If you need to really update some mesh of your own, it's better to create it with setVerticesData() and then only to update it with updateVerticesData() Fedor 1 Quote Link to comment Share on other sites More sharing options...
Fedor Posted June 7, 2017 Author Share Posted June 7, 2017 Tnx John and Jerome, this is great additional information to get a more in depth view of how Babylon works! @JohnK But why is there a second manual that would be a very nice addition to the one on the website? @jerome so updateVerticesData would be faster, My guess is it still does a copy of the entire buffer. Wouldn't it be nice to have a function to directly update a single vertice or a given range in the meshes own buffers? @Deltakosh Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 7, 2017 Share Posted June 7, 2017 4 hours ago, Fedor said: @JohnK But why is there a second manual that would be a very nice addition to the one on the website? That is because the guide is a manual I write and maintain as a compliment to the official documentation. This way I can keep the content in a manner and a style I want. You will see this is different than the official documentation. There is a link at the bottom of the official documentation to the guide. Quote Link to comment Share on other sites More sharing options...
Fedor Posted June 9, 2017 Author Share Posted June 9, 2017 Well, I sure find it a very good addition to the official manual. Thanks for this addition. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.