Build the Geometry

Let's head back to our main JS file.

example/web-worker/main.js
function readFile(input) {
    const reader = new FileReader();
    reader.onload = () => {
        toggleLoader();
        const ifcWorker = new Worker('worker/worker.js');
        
        ifcWorker.onmessage = function (e) {
            let structured = e.data;
            structured.MainObject = mainObject;
            structured = buildGeometry(structured);
            scene.add(structured.MainObject);
        };
        
        ifcWorker.postMessage(reader.result); 
    };
    reader.readAsText(input.files[0]);
}

Let's focus on the ifcWorker.onmessage. The first thing we are going to do is add back the mainObject.

To clarify; we are now outside of the Web Worker. We can use Three.js as expected. Then, we build the geometry and add it to the scene.

Last updated