How to draw a triangle?

I’d like to be able to draw a triangle by supplying the (x,y,z) coordinates for each vertex. This was asked on StackOverflow a while ago, but the answer no longer works since it relies on the now deprecated THREE.Geometry object.

A new answer was added in August of this year, which leveraged THREE.Shape and drew some lines to each point, but this doesn’t let me set the z-coordinate of each vertex.

What’s the best way to draw a triangle that allows the user to specify the full (x,y,z) coordinate of each vertex?

See from the Collection of examples from discourse.threejs.org
BufferGeometryNormals

and
BufferGeometry
//https://hofk.de/main/threejs/BufferGeometry/01_buffer.html
Indexed BufferGeometry
//https://hofk.de/main/threejs/BufferGeometry/02_buffer.html

Note!
addAttribute is now setAttribute


Addendum:
This dynamic example clearly shows the place where you can set the coordinates arbitrarily.

ColorWave

			// --- calculate here the coordinates according to your wishes ---
			
			x = j / 10 - 2;
			y = c * Math.sin(  2 * Math.PI * j / 100  + t );
			z = i  ;