package electrosphere.renderer.light;

import org.joml.Vector3f;

/**
 * A directional light source (global)
 */
public class DirectionalLight {

    //the direction of the light as a uniform vector
    Vector3f direction;

    //the ambient color
    Vector3f ambient;
    //the diffuse color
    Vector3f diffuse;
    //the specular color
    Vector3f specular;

    public void setDirection(Vector3f direction) {
        this.direction = direction;
    }

    public void setAmbient(Vector3f ambient) {
        this.ambient = ambient;
    }

    public void setDiffuse(Vector3f diffuse) {
        this.diffuse = diffuse;
    }

    public void setSpecular(Vector3f specular) {
        this.specular = specular;
    }

    public Vector3f getDirection() {
        return direction;
    }

    public Vector3f getAmbient() {
        return ambient;
    }

    public Vector3f getDiffuse() {
        return diffuse;
    }

    public Vector3f getSpecular() {
        return specular;
    }

    public DirectionalLight(Vector3f direction){
        this.direction = direction;
        ambient = new Vector3f(0.05f, 0.05f, 0.05f);
        diffuse = new Vector3f(0.4f, 0.4f, 0.4f);
        specular = new Vector3f(0.5f, 0.5f, 0.5f);
        this.direction.normalize();
        ambient.normalize();
        diffuse.normalize();
        specular.normalize();
    }

    public DirectionalLight(Vector3f direction, Vector3f color){
        this.direction = direction;
        ambient = new Vector3f( color.x * 0.05f, color.y * 0.05f, color.z * 0.05f);
        diffuse = new Vector3f( color.x * 0.4f,  color.y * 0.4f,  color.z * 0.4f);
        specular = new Vector3f(color.x * 0.5f,  color.y * 0.5f,  color.z * 0.5f);
        this.direction.normalize();
        ambient.normalize();
        diffuse.normalize();
        specular.normalize();
    }
}