Intelligent mesh warping (cube -> trapezoid, e.g.)

https://playground.babylonjs.com/#VE6GP#288

I started playing around with ^ changing vertices in a square… but it seems to be guesswork, not science.

I’m making buildings out of many cubes, and I thought it would be cool to maybe randomize let’s say the top left corner of the cube.

But when I change a vertex, it “detaches” from the other sides of the cube, making it a cube with a plain sticking out, rather than a trapezoid.

Is there some easy method to “deform” meshes while also retaining their integrity?

For this to work you would need to update the vertices that are at the same position than the vertex you want to modify. Indeed, the CreateBox method (and all others from MeshBuilder) is duplicating the vertices so that they each get their own normal corresponding to the face they pertain to:

https://playground.babylonjs.com/#VE6GP#289