xxxxxxxxxx
79
function setup() {
colorMode(HSB)
createCanvas(windowWidth, windowHeight, WEBGL);
}
light_locations = []
function mouseClicked() {
let locX = mouseX - width / 2;
let locY = mouseY - height / 2;
if (light_locations.length >= 4) {
light_locations.shift()
}
light_locations.push([locX, locY])
}
function draw() {
orbitControl();
background(0);
// move your mouse to change light position
let locX = mouseX - width / 2;
let locY = mouseY - height / 2;
// to set the light position,
// think of the world's coordinate as:
// -width/2,-height/2 ----------- width/2,-height/2
// | |
// | 0,0 |
// | |
// -width/2,height/2 ----------- width/2,height/2
//stance = abs(Math.pow(locX, 2) + Math.pow(locY, 2))
//nsole.log(distance)
//bightness = 100 - map(distance, 0, Math.pow(windowWidth, 2) + Math.pow(windowHeight, 2), 0, 100)
//console.log(brightness)
lightFalloff(0.99, 0.01, 0)
for (var p of light_locations) {
b=100 + random(-20, 20)
c=25 + random(-5,5)
pointLight(locX, 50, b, p[0], p[1], 150);
circle(p[0], p[1], 15)
}
// brightness=10 + random(-5, 5)
// color=25 + random(-5,5)
// pointLight(color, 50, brightness, locX, locY, 5)
b=40 + random(-5, 5)
c=25 + random(-5,5)
pointLight(c, 50, b, locX, locY, 5)
noStroke();
specularMaterial(250);
//shininess(1);
sphere(100);
//torus(50, 30);
push();
rotateY(90);
// rotateZ(45);
translate(50,0,250)
plane(500, 600);
pop();
push();
emissiveMaterial(c)
translate(locX, locY)
sourceFlame = 20 + random(-2,2)
sphere(sourceFlame)
pop();
}