xxxxxxxxxx
54
let o
let l
var guiLens
var guiObject
let objectsArray = []
let lensArray = []
function setup() {
createCanvas(windowWidth,windowHeight - 100);
guiLens = []//new dat.GUI()
guiObject = []//new dat.GUI()
//o = new lensObject(width*0.5,height/2,100,color(random(0,255),random(0,255),random(0,255)))
for (i = 0; i < 1; i++) {
objectsArray[i] = new lensObject(width*random(0,1),height/2,100,color(random(0,255),random(0,255),random(0,255)))
guiObject[i] = new dat.GUI()
}
l = new lens(width/2,height/2,height/2,50,false)
guiLens[0] = new dat.GUI()
guiLens[0].add(l,"x",0,width).name("Lens X Coord")
guiLens[0].add(l,"height", height/8,height).name("Lens Height")
guiLens[0].add(l,"focalLength",1,width/2).name("Focal Length")
guiLens[0].add(l,"type").name("Lens Type")
for (i = 0; i < guiObject.length; i++) {
guiObject[i].add(objectsArray[i], "x", 0,width).name("Object X Coord")
guiObject[i].add(objectsArray[i], "height",-height/2,height/2).name("Object Height")
}
}
function draw() {
background(40);
for (i = 0; i < objectsArray.length; i++) {
objectsArray[i].show()
objectsArray[i].rayTrace(l)
}
l.show()
//l2.show()
//o.rayTrace(l)
//o.rayTrace(l2)
//o2.rayTrace(l)
//o2.rayTrace(l2)
//noLoop()
}