import { Controller } from "@hotwired/stimulus"
import AppState from "../state.js";

export default class extends Controller {
    static targets = ['ao', 'shadows'];

    connect() {
        console.log('#settings controller connected');
        this.aoTarget.checked = AppState.ambientOcclusion;
        this.shadowsTarget.checked = AppState.shadows;
    }
    /**
     * Toggle Ambient Occlusion
     * @param {Event} event 
     */
    toggleAO(event) {
        ATON.FX.togglePass(ATON.FX.PASS_AO, event.target.checked);
        AppState.ambientOcclusion = event.target.checked;
    }
    /**
     * Toggle shadows
     * @param {Event} event 
     */
    toggleShadows(event) {
        ATON.toggleShadows(event.target.checked);
        AppState.shadows = event.target.checked;
    }
}
