Parse the IFC

This is where the fun begins!

We are going to modify the orignal source code. Take a look at IFC.js.

src/IFC.js
function loadIfc(ifcData) {
    const loaded = loadIfcFileItems(ifcData);
    const structured = constructProject(loaded);
    return buildGeometry(structured);
}

As we discuessed earlier, we cannot build the entire gemoetry inside the Web Worker.

example/web-worker/worker/worker.js
onmessage = (e) => {
    const ifcData = e.data; 
    const loaded = IFCjs.loadIfcFileItems(ifcData);
    const structured = IFCjs.constructProject(loaded);
    postMessage(structured);
};

If we run this code, it won't work. The Web Worker has no idea what IFC.js is. We must import the scripts.

example/web-worker/worker/worker.js
importScripts('../../build/IFC.js');
onmessage = (e) => {
    const ifcData = e.data; 
    const loaded = IFCjs.loadIfcFileItems(ifcData);
    const structured = IFCjs.constructProject(loaded);
    postMessage(structured);
};

Again, please note that this will not work! The Web Worker will complain that Three and Chevrotain is missing.

Again, to clarify - WE CANNOT USE THREE INSIDE THE WEB WORKER.

Last updated