import { Controller } from "@hotwired/stimulus"
import * as THREE from "three"
import BIM from '../bim.js';

export default class extends Controller {
    static targets = ['hex'];

    /**
     * @param {Event} event 
     */
    color(event) {
        let color = event.target.value;
        this.hexTarget.querySelector('span').textContent = color;
        BIM.clipper.config.color = new THREE.Color(color);
    }

    /**
     * @param {Event} event 
     */
    size(event) {
        BIM.clipper.config.size = event.target.value
    }

    deleteAll() {
        BIM.clipper.deleteAll();
    }

    /**
     * @todo Doesn't work...
     * @param {Event} event 
     */
    toggle(event) {
        BIM.clipper.enabled = event.target.value;
    }
}

