let newFont;
function preload() {
newFont = loadFont('fonts/Montserrat.otf');
}
function setup() {
createCanvas(600, 300, WEBGL);
textFont(newFont, 15);
constantSlider = createSlider(0.1, 1, 0.1, 0.1);
constantSlider.position(20, 50);
linearSlider = createSlider(0, 0.01, 0, 0.0001);
linearSlider.position(20, 80);
quadraticSlider = createSlider(0, 0.0001, 0, 0.00001);
quadraticSlider.position(20, 110);
}
function draw() {
background('green');
text("Move the sliders to change the CONSTANT, LINEAR"
+ " and QUADRATIC values", -285, -125);
noStroke();
shininess(15);
constantValue = constantSlider.value();
linearValue = linearSlider.value();
quadraticValue = quadraticSlider.value();
lightFalloff(constantValue, linearValue, quadraticValue);
pointLight(0, 128, 255, -width / 2, -height / 2, 250);
specularMaterial(250);
sphere(100);
text("falloff = 1 / (" + constantValue + " + d * " +
linearValue + " + ( d * d ) * " +
quadraticValue + " )", -285, 125);
}