how to add vertices on cube

hi, I need to add vertices on cube and I have problem with writing triangles array. for example to add on plane 1 vertex it will be so:

the triangles array was 6 and now it’s 12. I’m wondering how to write triangles successively for big objects. I know that it must be done in for cycle and there will be something tricky to write this triangles successively, but I can’t apprehend it . :roll: