Stupid selection...
This commit is contained in:
parent
44943e5972
commit
37012578b7
19
bim.js
19
bim.js
@ -1,5 +1,6 @@
|
|||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
import * as OBC from 'openbim-components';
|
import * as OBC from 'openbim-components';
|
||||||
|
import * as OBF from '@thatopen/components-front';
|
||||||
import * as WEBIFC from 'web-ifc';
|
import * as WEBIFC from 'web-ifc';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +34,7 @@ BIM.init = function (container) {
|
|||||||
*/
|
*/
|
||||||
BIM.createScene = function (container) {
|
BIM.createScene = function (container) {
|
||||||
this.init(container);
|
this.init(container);
|
||||||
|
|
||||||
this.world.scene.setup();
|
this.world.scene.setup();
|
||||||
// Add a grid to the scene
|
// Add a grid to the scene
|
||||||
const grids = this.components.get(OBC.Grids);
|
const grids = this.components.get(OBC.Grids);
|
||||||
@ -44,6 +46,7 @@ BIM.createScene = function (container) {
|
|||||||
* @todo Serve web-ifc.wasm locally via AJAX
|
* @todo Serve web-ifc.wasm locally via AJAX
|
||||||
* @param {OBC.Components} components
|
* @param {OBC.Components} components
|
||||||
* @param {ArrayBuffer} buffer The uploaded IFC file
|
* @param {ArrayBuffer} buffer The uploaded IFC file
|
||||||
|
* @returns {OBC.FragmentsGroup} model
|
||||||
*/
|
*/
|
||||||
BIM.loadIfc = async function (buffer) {
|
BIM.loadIfc = async function (buffer) {
|
||||||
const fragments = this.components.get(OBC.FragmentsManager);
|
const fragments = this.components.get(OBC.FragmentsManager);
|
||||||
@ -81,4 +84,20 @@ BIM.loadIfc = async function (buffer) {
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {OBC.FragmentsGroup} model The loaded IFC model
|
||||||
|
*/
|
||||||
|
BIM.setupHighligther = async function (model) {
|
||||||
|
const world = this.world;
|
||||||
|
const indexer = this.components.get(OBC.IfcRelationsIndexer);
|
||||||
|
await indexer.process(model);
|
||||||
|
|
||||||
|
const highlighter = this.components.get(OBF.Highlighter);
|
||||||
|
highlighter.setup({ world });
|
||||||
|
|
||||||
|
highlighter.events.select.onHighlight.add((property) => {
|
||||||
|
console.log(property);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export default BIM;
|
export default BIM;
|
13
index.html
13
index.html
@ -12,6 +12,7 @@
|
|||||||
"@thatopen/fragments": "./vendor/@thatopen/fragments/dist/index.mjs",
|
"@thatopen/fragments": "./vendor/@thatopen/fragments/dist/index.mjs",
|
||||||
"web-ifc": "./vendor/web-ifc/web-ifc-api.js",
|
"web-ifc": "./vendor/web-ifc/web-ifc-api.js",
|
||||||
"openbim-components": "./vendor/@thatopen/components/dist/index.mjs",
|
"openbim-components": "./vendor/@thatopen/components/dist/index.mjs",
|
||||||
|
"@thatopen/components-front": "./vendor/@thatopen/components-front/dist/index.js",
|
||||||
"lit": "./vendor/@lit-labs/ssr-dom-shim/index.js"
|
"lit": "./vendor/@lit-labs/ssr-dom-shim/index.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -21,12 +22,12 @@
|
|||||||
<body>
|
<body>
|
||||||
<nav class="navbar has-background-light" role="navigation" aria-label="main navigation">
|
<nav class="navbar has-background-light" role="navigation" aria-label="main navigation">
|
||||||
<div class="navbar-brand">
|
<div class="navbar-brand">
|
||||||
<a class="navbar-item" href="/">
|
<a class="navbar-item" href="/">
|
||||||
<span class="icon mr-2">
|
<span class="icon mr-2">
|
||||||
<i class="fas fa-home"></i>
|
<i class="fas fa-home"></i>
|
||||||
</span>
|
</span>
|
||||||
WebArchi
|
WebArchi
|
||||||
</a>
|
</a>
|
||||||
<!-- navbar items, navbar burger... -->
|
<!-- navbar items, navbar burger... -->
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
2
main.js
2
main.js
@ -4,5 +4,5 @@ import UI from './ui.js';
|
|||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
UI.setScene(document.querySelector('#scene'));
|
UI.setScene(document.querySelector('#scene'));
|
||||||
UI.ifcLoader();
|
const model = UI.ifcLoader();
|
||||||
});
|
});
|
8
ui.js
8
ui.js
@ -14,14 +14,20 @@ UI.setScene = function (container) {
|
|||||||
BIM.createScene(container);
|
BIM.createScene(container);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
* Returns the loaded model
|
||||||
* @param {string} btnId The loading button's id
|
* @param {string} btnId The loading button's id
|
||||||
*/
|
*/
|
||||||
UI.ifcLoader = function (btnId = 'load-ifc') {
|
UI.ifcLoader = function (btnId = 'load-ifc') {
|
||||||
const loadBtn = document.querySelector(`#${btnId}`);
|
const loadBtn = document.querySelector(`#${btnId}`);
|
||||||
|
let model = null;
|
||||||
loadBtn.onchange = async function () {
|
loadBtn.onchange = async function () {
|
||||||
const files = this.files;
|
const files = this.files;
|
||||||
BIM.loadIfc(new Uint8Array(await files[0].arrayBuffer()));
|
model = await BIM.loadIfc(new Uint8Array(await files[0].arrayBuffer()));
|
||||||
|
// Set a raycaster to select objects
|
||||||
|
BIM.setupHighligther(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return model;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default UI;
|
export default UI;
|
Loading…
Reference in New Issue
Block a user