let newFont;
let nolightsEnable =
false
;
function
preload() {
newFont = loadFont(
'fonts/Montserrat.otf'
);
}
function
setup() {
createCanvas(600, 300, WEBGL);
textFont(newFont, 18);
nolightsEnableCheck = createCheckbox(
"Enable noLights"
,
false
);
nolightsEnableCheck.position(20, 60);
nolightsEnableCheck.changed(() => {
nolightsEnable = !nolightsEnable;
});
}
function
draw() {
background(
"green"
);
text(
"Click on the checkbox to toggle the"
+
" noLights() function."
, -285, -125);
noStroke();
ambientLight(
'red'
);
translate(-100, 0, 0);
sphere(50);
translate(100, 0, 0);
if
(nolightsEnable) {
noLights();
text(
"Red ambient light disabled for"
+
" second sphere"
, -285, 125);
}
else
{
text(
"Red ambient light enabled for"
+
" second sphere"
, -285, 125);
}
ambientLight(
'blue'
);
translate(100, 0, 0);
sphere(50);
}