I am creating Cylinder using MeshBuilder.CreateCylinder. I pass some options. However, I want to be able to edit those options later such as diameter, subdivisions etc. I tried looking around for a while, but haven’t found anything.
let options = {height:5, diameter:5, tessellation:5};
var cone = BABYLON.MeshBuilder.CreateCylinder("cone", options, scene);
options.tessellation = 20; //doesn't work
I believe the reason this doesn’t work is because you have already declared your options and passed it into the mesh builder. It’s a linear execution passed by value, not by reference. What you want is to update properties on the cone object itself. Let me get an example for you.
Update: I just tried changing things in a PG but I think you will have to edit the vertices themselves in order to easily change the tessellation. Perhaps just deleting the current mesh and then creating a new one with your updated options.
As @msDestiny14 says once the parameters are used to build a mesh the mesh is not editable without adding/removing/editing the vertices and their properties directly. Since the code already exists to build the mesh with the new parameters the simplest way is to dispose of the existing mesh and use the new parameters to create a new one.
If the mesh has been positioned, rotated, scaled etc clone these values before creating the new mesh and then reapply.