WebWorker is not "statically analyse-able"
Answered
American Shorthair posted this in #help-forum
American ShorthairOP
Hello, I am importing some legacy .js code from a game engine I made awhile ago.
the issue is, this VoxelRenderer ends up using a Worker (as the rendering uses WebWorkers to mesh the game)
What am I doing wrong here? All the other code is imported properly on the client, it just doesn't like this part.
Thanks!
useEffect(() => {
const renderGame= async () => {
const VoxelRender = await import("../lib/VoxelRender");
VoxelRender.default();
};
renderGame();
});the issue is, this VoxelRenderer ends up using a Worker (as the rendering uses WebWorkers to mesh the game)
error TP1001 new Worker("/public/game/blockCulling.js") is not statically analyse-able
75 |
76 | //Start culling proccess and send chunk data
> 77 | var cullWorker = new Worker('/public/game/blockCulling.js'); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^What am I doing wrong here? All the other code is imported properly on the client, it just doesn't like this part.
Thanks!
Answered by American Shorthair
use
https://github.com/vercel/next.js/issues/74621#issuecomment-2585760180
window.Worker instead of Workerhttps://github.com/vercel/next.js/issues/74621#issuecomment-2585760180
2 Replies
American ShorthairOP
use
https://github.com/vercel/next.js/issues/74621#issuecomment-2585760180
window.Worker instead of Workerhttps://github.com/vercel/next.js/issues/74621#issuecomment-2585760180
Answer
American ShorthairOP
Can't mark my own message as answer?