Include IFC file name
TODO: move UI routines to Stimulus
This commit is contained in:
@@ -16,7 +16,12 @@ export default class extends Controller {
|
||||
|
||||
if (event.currentTarget === this.buildingFormTarget) {
|
||||
const options = this.prepare(
|
||||
JSON.stringify({name: this.buildingTarget.value}),
|
||||
JSON.stringify(
|
||||
{
|
||||
name: this.buildingTarget.value,
|
||||
ifc: localStorage.getItem('loaded-ifc'),
|
||||
}
|
||||
),
|
||||
'POST'
|
||||
);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import BIM from './bim.js';
|
||||
|
||||
/**
|
||||
* @todo Move to Stimulus?
|
||||
* @namespace UI
|
||||
*/
|
||||
const UI = {};
|
||||
@@ -20,12 +21,15 @@ UI.setScene = function (container) {
|
||||
*/
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user