Name

lights()

Description

Sets the default ambient light, directional light, falloff, and specular values. The defaults are ambientLight(128, 128, 128) and directionalLight(128, 128, 128, 0, 0, -1), lightFalloff(1, 0, 0), and lightSpecular(0, 0, 0). Lights need to be included in the draw() to remain persistent in a looping program. Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop.

Examples

  • size(400, 400, P3D);
    background(0);
    noStroke();
    // Sets the default ambient 
    // and directional light
    lights();
    translate(80, 200, 0);
    sphere(120);
    translate(240, 0, 0);
    sphere(120);
    Image output for example 1
  • void setup() {
      size(400, 400, P3D);
      background(0);
      noStroke();
    }
    
    void draw() {
      // Include lights() at the beginning
      // of draw() to keep them persistent 
      lights();
      translate(80, 200, 0);
      sphere(120);
      translate(240, 0, 0);
      sphere(120);
    }
    Image output for example 2

Syntax

  • lights()

Return

  • void
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.