I've been working on giving my cylinder geometry a wavy surface, aiming for a look like this: https://i.sstatic.net/aCaV7.png
However, after implementing the following code, it ended up looking quite distorted as shown in these images: https://i.sstatic.net/7dxVN.png and here from a different angle: https://i.sstatic.net/jWzXJ.png
The approach I took was iterating through all the vertices and applying the sine function to them like so:
STC.WarpControls.prototype.waves = function(){
var geometry = this.threeDHandler.threeD_meshes[0].geometry;
for (let i = 0; i < geometry.vertices.length; i++) {
geometry.vertices[i].y = Math.sin(( i + 0.00002)) * (geometry.vertices[i].y);
}
geometry.verticesNeedUpdate = true;
}
I'm puzzled by why my shape turned out weird. Can anyone shed some light on what might have caused this distortion and provide insights into achieving a wavy shape on a cylinder? Your help is greatly appreciated!