skin = loadImage("https://minotar.net/skin/cartoon");
canvas = createCanvas(windowWidth, windowHeight, WEBGL);
tex = canvas.getTexture(skin);
tex.setInterpolation(NEAREST, NEAREST);
playerModel = new p5.Geometry();
addRect(-1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 2, 2);
addRect(-1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 4, 1, 3, 2);
addRect(1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 2, 1, 3, 2);
addRect(-1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 0, 2);
addRect(-1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 2, 0);
function addRect(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, u1, v1, u2, v2) {
a = playerModel.vertices.length;
playerModel.vertices.push(createVector(x1, y1, -z1));
playerModel.vertices.push(createVector(x2, y2, -z2));
playerModel.vertices.push(createVector(x3, y3, -z3));
playerModel.vertices.push(createVector(x4, y4, -z4));
playerModel.uvs.push([u1/8, v1/8]);
playerModel.uvs.push([u2/8, v1/8]);
playerModel.uvs.push([u2/8, v2/8]);
playerModel.uvs.push([u1/8, v2/8]);
playerModel.faces.push([a, a+1, a+2]);
playerModel.faces.push([a+2, a+3, a]);