Currently PlaneGeometry has an option to change segment width and height but this has no effect on edges. Each segment currently has indexed positions to create an 'N' shape when viewing the geometry in wireframe mode:
Indexes currently are:
This gives us an 'N' shape for each segment with wireframes, however instead of this 'N' Shape i would like to create an 'X' shape with edges for every segment. Currently i'm using planes to create different heights and having an 'X' shape would make the result look less edgy shaped (screenshots below).
I think all required vertices already exists, but how is it possible to get an extra edge between point 0 and 3 for each segment?
I've tried looking for the answer online but couldn't find a clear answer on this matter, besides many articles are older than version R125 which made breaking changes to Geometries. Currently I'm using version R135.
I'm guessing i will need to create a custom Buffer Geometry, but am in doubt of how to execute this properly and not losing too much performance.
Thanks in advance!
It took me a fair amount of attempts but in the end it didn't turn out to be too hard. I've created this custom PlaneGeometry by creating a custom BufferGeometry. Although it's probably 3x heavier to use;
At the moment it holds 36 (12 * 3) positions per tile segment as where the default PlaneGeometry holds 12 (4 * 3) positions. Although i'm not sure if 3x more positions automatically means 3x more performance usage, but it definitely uses more than the default PlaneGeometry.
Here are the results (changes in height smoothen out prettier):
Code to create the geometry:
const geometry = new THREE.BufferGeometry();
const vertices = new Float32Array([
// (North Face)
.5, -.5, 0, // 0: Center
1, -1, 0, // 1: NE
1, 0, 0, // 2: NW
// (East Face)
.5, -.5, 0, // 3: Center
0, -1, 0, // 4: SE
1, -1, 0, // 5: NE
// (South Face)
.5, -.5, 0, // 6: Center
0, 0, 0, // 7: SW
0, -1, 0, // 8: SE
// (West Face)
.5, -.5, 0, // 9: Center
1, 0, 0, // 10: NW
0, 0, 0, // 11: SW
]);
geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
const material = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );
const mesh = new THREE.Mesh( geometry, material );
mesh.rotation.x = - Math.PI / 2;
scene.add( mesh );