ThatOpen / web-ifc-three

The official IFC Loader for Three.js.
https://ifcjs.github.io/info/
MIT License
521 stars 133 forks source link

IFCWorker.js setup in Next.js #154

Open kuo-cheng-wu opened 1 year ago

kuo-cheng-wu commented 1 year ago

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?

TUGTEN commented 1 year ago

Were you able to setup WASM successfully?

kuo-cheng-wu commented 1 year ago

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

sinedie commented 1 year ago

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

ywouterr commented 1 year ago

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