Hello community,
I try to include the gltf pipeline into a react app. To improve performance I want to use a web worker but this is optional. Since gltf-pipeline is a node_module I have to convert it to a standalone js. Unfortunately it is not working with browserify as well as webpack.
My webpack.config.js looks like this:
module.exports = {
entry: './app.js',
output: {
path: __dirname + '/public',
filename: 'worker.js',
},
target: "webworker",
node: {
fs: 'empty'
}
}
My app.js looks like this:
const gltfPipeline = require('gltf-pipeline')
onmessage = e => {
const glb = e.data.map(file => {
gltfPipeline.gltfToGlb(file.data, options).then(results => {
console.log(results.glb)
})
})
}
After loading the worker this error appears:
Uncaught TypeError: Cannot read property 'native' of undefined
>> "function" == typeof r.realpath.native && (t.realpath.native = n(r.realpath.native))
If I remove the fs part in my config:
node: {
fs: 'empty'
}
I am not even able to generate the file:
Module not found: Error: Can't resolve 'fs' in '...node_modules/draco3d'
I would really appreciate your help. Since I want to avoid passing the files to a nodejs server just to convert it and pass it back, a solution within the browser would be much more convenient.
Thanks
Best