'use strict'; import BIM from './bim.js'; /** * @todo Move to Stimulus? * @namespace UI */ const UI = {}; /** * * @param {HTMLElement} container The scene container element */ UI.setScene = function (container) { BIM.createScene(container); } /** * Returns the loaded model * @param {HTMLElement} container The container element * @param {string} btnId The loading button's id */ UI.ifcLoader = function (container, btnId = 'load-ifc') { const loadBtn = document.querySelector(`#${btnId}`); const nameInput = document.querySelector('[data-form-target="building"]'); let model = null; loadBtn.onchange = async function () { const files = this.files; model = await BIM.loadIfc(new Uint8Array(await files[0].arrayBuffer()), files[0].name); // Set a raycaster to select objects BIM.setupHighligther(model); localStorage.setItem('loaded-ifc', files[0].name); nameInput.value = files[0].name.replace('.ifc', ''); } return model; }; export default UI;