From a9896ad8cea135060f0259de8c1fbb645cdb0a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Tue, 28 May 2024 14:59:05 +0200 Subject: [PATCH] Add grid; serve WASM locally --- ui.js | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/ui.js b/ui.js index a027f45..5aea55a 100644 --- a/ui.js +++ b/ui.js @@ -28,8 +28,19 @@ Actions.init = function (container) { components.init(); this.world = world; this.components = components; - - return {components, world}; +} +/** + * @param {HTMLElement} container The scene container element + * @returns {OBC.Components} + */ +Actions.createScene = function (container) { + this.init(container); + this.world.scene.setup(); + // Add a grid to the scene + const grids = this.components.get(OBC.Grids); + const grid = grids.create(this.world); + // (zoom_level, position) + this.world.camera.controls.setLookAt(15, 15, 15, 0, 0, 0); } /** * @todo Serve web-ifc.wasm locally via AJAX @@ -43,13 +54,11 @@ Actions.loadIfc = async function (buffer) { const fragmentIfcLoader = this.components.get(OBC.IfcLoader); // NOTE: loads web-ifc WASM from https://unpkg.com/web-ifc@0.0.53/ - await fragmentIfcLoader.setup(); - /* + //await fragmentIfcLoader.setup(); fragmentIfcLoader.settings.wasm = { - path: "./vendor/web-ifc/web-ifc.wasm", + path: "./vendor/web-ifc/", absolute: false - } - */ + }; // Excludes IFC categories from the fragment const excludedCats = [ WEBIFC.IFCTENDONANCHOR, @@ -71,19 +80,6 @@ Actions.loadIfc = async function (buffer) { return fragments; } -/** - * @param {HTMLElement} container The scene container element - * @returns {OBC.Components} - */ -Actions.createScene = function (container) { - //const {components, world} = - this.init(container); - - this.world.scene.setup(); - this.world.camera.controls.setLookAt(3, 3, 3, 0, 0, 0); - - //return components; -} /** * @namespace UI */ @@ -94,7 +90,7 @@ const UI = {}; * @param {HTMLElement} container The scene container element */ UI.setScene = function (container) { - this.components = Actions.createScene(container); + Actions.createScene(container); } /** * @param {string} uiContainer The UI div's id