Here is a simple example for 3D. You can make minor program changes to see what happens. I find making changes is the best way to understand what’s going on. Also, having a simple program helps too.

```
-- 3d example
function setup()
displayMode(STANDARD)
setVerts()
parameter("Size",1,100,25)
parameter("CameraHeight", 0, 1000, 0)
parameter("Angle",-180, 180, 0)
parameter("FieldOfView", 1, 140, 100)
end
function draw()
perspective(FieldOfView, WIDTH/HEIGHT)
camera(0,CameraHeight,-300, 0,0,0, 0,1,0)
background(40, 40, 50)
rotate(Angle,0,1,0)
s = Size*0.25
scale(s,s,s)
mg:draw()
end
function setVerts()
-- define 3d coordinates to be used
vertices =
{
vec3(-12,-4,16),
vec3(12,-4,16),
vec3(12,4,16),
vec3(-12,4,16),
vec3(-12,-4,-16),
vec3(12,-4,-16),
vec3(12,4,-16),
vec3(-12,4,-16),
vec3(13,4,16),
vec3(0,4,16),
vec3(0,8,16),
vec3(-13,4,16),
vec3(0,4,16),
vec3(0,8,16),
vec3(13,4,-16),
vec3(0,4,-16),
vec3(0,8,-16),
vec3(-13,4,-16),
vec3(0,4,-16),
vec3(0,8,-16),
vec3(-4,-4,16),
vec3(0,-4,16),
vec3(0,4,16),
}
-- construct a rectangle out of the 3d coordinates
-- rectangles are made from 2 triangles
rects = {
-- Front
vertices[1], vertices[2], vertices[3],
vertices[1], vertices[3], vertices[4],
-- Right
vertices[2], vertices[6], vertices[7],
vertices[2], vertices[7], vertices[3],
-- Back
vertices[6], vertices[5], vertices[8],
vertices[6], vertices[8], vertices[7],
-- Left
vertices[5], vertices[1], vertices[4],
vertices[5], vertices[4], vertices[8],
-- Top
vertices[4], vertices[3], vertices[7],
vertices[4], vertices[7], vertices[8],
-- Bottom
vertices[5], vertices[6], vertices[2],
vertices[5], vertices[2], vertices[1],
vertices[9], vertices[10], vertices[11],
vertices[12], vertices[13], vertices[14],
vertices[15], vertices[16], vertices[17],
vertices[18], vertices[19], vertices[20]
}
mg = mesh()
mg.vertices = rects
mg:setColors(0,0,255,255) -- set initial color to blue
-- set individual color for each vertices
mg:color(1,0,255,0) -- color for vertices 1
mg:color(2,0,255,0) -- color for vertices 2 etc.
mg:color(3,0,255,0)
mg:color(4,255,0,0)
mg:color(5,255,0,0)
mg:color(6,255,0,0)
mg:color(7,0,255,0)
mg:color(8,0,255,0)
mg:color(9,0,255,0)
mg:color(10,0,0,255)
mg:color(11,0,0,255)
mg:color(22,0,0,255)
mg:color(28,255,255,255)
mg:color(29,255,255,255)
mg:color(30,255,255,255)
mg:color(25,255,255,255)
mg:color(26,255,255,255)
mg:color(27,255,255,255)
mg:color(37,0,255,0)
mg:color(38,0,255,0)
mg:color(39,0,255,0)
mg:color(40,0,255,0)
mg:color(41,0,255,0)
mg:color(42,0,255,0)
mg:color(43,0,255,0)
mg:color(44,0,255,0)
mg:color(45,0,255,0)
mg:color(46,0,255,0)
mg:color(47,0,255,0)
mg:color(48,0,255,0)
end
```