I am working through your code as an exercise for me; I do enjoy the daily challenges.
Click for Code
//Requires this library:
//https://github.com/bohnacker/p5js-screenPosition
var faceXYZ = [];
var faceXY = [];
var th = 0;
function setup()
{
createCanvas(500, 500, WEBGL);
addScreenPositionFunction();
noFill();
strokeWeight(2);
faceXYZ[0] = [10,0,0, 50,0,0, 50,0,25, 10,0,25];
faceXYZ[1] = [10,0,25, 50,0,25, 50,-25,25, 10,-25,25];
faceXYZ[2] = [50,0,25, 50,0,0, 50,-25,0, 50,-25,25];
faceXYZ[3] = [10,-25,25, 50,-25,25, 50,-25,0, 10,-25,0];
faceXYZ[4] = [10,-25,25, 10,-25,0, 10,0,0, 10,0,25];
faceXYZ[5] = [10,-25,0, 50,-25,0, 50,0,0, 10,0,0];
for (var i = 0; i < 6; i++ )
{
faceXY[i] = [0, 0, 50, 0, 0, 50, 0, 50, 0, 50, 0, 0];
}
ortho();
}
function draw()
{
background(204);
translate(0, 0, 100);
//XYZ World
push();
scale(2);
rotateX(PI/8);
if (mouseIsPressed) th = th + PI/180;
rotateY(th);
stroke(150);
line(0, 0, 0, 0, 0, -80); // y-axis aka -z gray
stroke(150);
line(0, 0, 0, 80, 0, 0); // x-axis aka +x gray
stroke(0);
line(0, 0, 0, 0, -80, 0); // vertical axis aka -y white
for (var i = 0; i < 6; i++ )
{
polyDrawXYZ(i);
}
pop();
// XY Screen
for (var k = 0; k < 6; k++ )
{
polyDrawXY(k);
}
}
//********************************************************************************************
function polyDrawXYZ(j)
{
// Draw 1 side of block using XYZ world cooordinates
stroke('magenta');
beginShape();
for (var i = 0; i < 12; i += 3)
{
vertex(faceXYZ[j][i], faceXYZ[j][i+1], faceXYZ[j][i+2]);
var p1 = screenPosition(faceXYZ[j][i], faceXYZ[j][i+1], faceXYZ[j][i+2]);
//faceXY[j][i] ...
}
endShape(CLOSE);
}
function polyDrawXY(k)
{
// Draw 1 side of block using XY screen coordinates
// faceXY[k][i]
}
I found it easier to pass around the array element (face) when working through this.
You have to fill in the missing pieces if you want to try this.