'use strict';

import UI from './ui.js';
import BIM from './bim.js';
import { Application } from '@hotwired/stimulus';
import FormController from './controllers/form_controller.js';

document.addEventListener('DOMContentLoaded', () => {
    // Register Stimulus controllers
    initStimulus();

    const container = document.querySelector('#scene');
    UI.setScene(container);
    const model = UI.ifcLoader(container);
    container.ondblclick = () => BIM.activateClipper();
    container.onkeydown = event => {
        if (event.code === 'Delete' || event.code === 'Backspace') {
            BIM.deleteClipper();
        }
    }
});

function initStimulus() {
    window.Stimulus = Application.start();
    Stimulus.register('form', FormController);
}