web-ifc-three icon indicating copy to clipboard operation
web-ifc-three copied to clipboard

IFCWorker.js setup in Next.js

Open kuo-cheng-wu opened this issue 2 years ago • 4 comments

I have problem setting up the IFCWorker from 0.0.117 in Next.js environment. I tried the following

await manager.useWebWorkers(true, "IFCWorker.js"); // the IFCWorker.js is located in the same directory as the source code

but it resulted

error - node_modules/web-ifc-three/IFCLoader.js (2797:25) @ Worker
error - unhandledRejection: ReferenceError: Worker is not defined
    at new IFCWorkerHandler (webpack-internal:///./node_modules/web-ifc-three/IFCLoader.js:2502:30)
    at IFCManager.initializeWorkers (webpack-internal:///./node_modules/web-ifc-three/IFCLoader.js:2955:23)
    at IFCManager.useWebWorkers (webpack-internal:///./node_modules/web-ifc-three/IFCLoader.js:2843:24)
    at releaseMemory (webpack-internal:///./src/contexts/IfcLoaderContext.tsx:23:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
null

Has anyone encountered this issue?

kuo-cheng-wu avatar Feb 25 '23 16:02 kuo-cheng-wu

Were you able to setup WASM successfully?

TUGTEN avatar Mar 31 '23 21:03 TUGTEN

Yes, the WASM can be loaded without any issues.

I tried the following 2 approaches: 1: Load external hosted IFCWorker.js with CORS settings but having problem of 'Worker' Script at ... cannot be accessed from origin

2: Place both woker scripts and wasm files in Nextjs public folder. This does render the IFC file successfully but the Nextjs console shows the following error right after the startup. Not sure why IFC file can still be loaded using IFCLoader in this case. image

kuo-cheng-wu avatar Apr 01 '23 18:04 kuo-cheng-wu

Check this thread on discord https://discord.com/channels/799990228336115742/1091078047228235877

sinedie avatar May 09 '23 13:05 sinedie

hi is there a solution to this issue yet? I am using next js 13

ywouterr avatar Aug 24 '23 12:08 ywouterr