I have managed to create the pattern shown in the image successfully. Currently, I am looking for a way to automate this process. Specifically, every second square needs to be mirrored.
If you have any suggestions on an easier approach, please share them with me.
This is how my code is structured:
// Generating vertices for widthSegments
for (let x = 0; x < world.plane.widthSegments; x++){
for (let y = 0; y < world.plane.heightSegments; y++){
vertices.push(x, y, 0) // 0, 4, 8, 12, 16, 20, 24, 28, 32,
vertices.push(x+1, y, 0) // 1, 5, 9, 13, 17, 21, 25, 29, 33,
vertices.push(x+1, y+1, 0) // 2, 6, 10, 14, 18, 22, 26, 30, 34,
vertices.push(x, y+1, 0) // 3, 7, 11, 15, 19, 23, 27, 31, 35,
}
}
planeMesh.geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(vertices), 3))
planeMesh.geometry.setIndex([ // The desired automatic generation
0, 1, 3, 3, 1, 2,
2, 6, 3, 3, 6, 7,
7, 6, 11, 11, 6, 10,
10, 14, 11, 11, 14, 15,
1, 17, 18, 18, 2, 1,
2, 18, 6, 6, 18, 22,
6, 22, 26, 26, 10, 6,
10, 26, 14, 14, 26, 30,
17, 33, 18, 18, 33, 34,
18, 34, 38, 38, 22, 18,
22, 38, 26, 26, 38, 42,
26, 42, 46, 46, 30, 26,
33, 49, 50, 50, 34, 33,
34, 50, 38, 38, 50, 54,
38, 54, 58, 58, 42, 38,
42, 58, 46, 46, 58, 62,
]);