How to properly upgrade older version project?

Before three.js r125, my code looks like(I want to update my geometry vertices):

for (let i = 0; i < data.length; i++) { // data is a new array of vertices
      const [x, y, z] = data[i]
      myMesh.geometry.vertices[i].set(x, y, z)
    }
  myMesh.geometry.verticesNeedUpdate = true
  myMesh.geometry.computeBoundingSphere()
    

After up my three.js to r125 or later, my code run with errors:
myMesh.geometry.vertices is undefined

I read some changelog and realize the THREE.Geometry no longer exists and it was a BREAKING changeā€¦

then I found that I should use BufferGeometry instead but the code also need to modify, I think my code may modify like:

...
// todo change Geometry to BufferGeometry.... 
...
myMesh.geometry.attributes.position.set(x,y,z)
myMesh.geometry.attributes.position.needUpdate = true

But I still not sure it is the right way, any suggestions??

Try it with:

const positionAttribute = myMesh.geometry.getAttribute( 'position' );

for ( let i = 0; i < data.length; i ++ ) {
        const [x, y, z] = data[i];
        positionAttribute.setXYZ( i, x, y, z );

}
positionAttribute.needsUpdate = true;