pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.45k stars 290 forks source link

maxMemoryUsageInMB limit exceeded #133

Open dottodot opened 2 years ago

dottodot commented 2 years ago

when running npx gltfjsx scene.gltf -t -T I'm getting this error

Error: maxMemoryUsageInMB limit exceeded by at least 256MB
    at requestMemoryAllocation (/node_modules/gltfjsx/node_modules/jpeg-js/lib/decoder.js:1064:13)
    at prepareComponents (/node_modules/gltfjsx/node_modules/jpeg-js/lib/decoder.js:601:13)
    at constructor.parse (/node_modules/gltfjsx/node_modules/jpeg-js/lib/decoder.js:756:13)
    at Object.decode (/node_modules/gltfjsx/node_modules/jpeg-js/lib/decoder.js:1109:11)
    at handleJPEG (/node_modules/gltfjsx/node_modules/get-pixels/node-pixels.js:32:21)
    at doParse (/node_modules/gltfjsx/node_modules/get-pixels/node-pixels.js:114:7)
    at Object.getPixels [as default] (/node_modules/gltfjsx/node_modules/get-pixels/node-pixels.js:140:5)
    at /node_modules/gltfjsx/node_modules/ndarray-pixels/dist/ndarray-pixels.js:29:42
    at new Promise (<anonymous>)
    at Object.getPixels (/node_modules/gltfjsx/node_modules/ndarray-pixels/dist/ndarray-pixels.js:28:10)

Is there anyway to increase the memory limit, the model I'm using is one I downloaded from here https://sketchfab.com/3d-models/the-king-s-hall-d18155613363445b9b68c0c67196d98d

drcmda commented 2 years ago

before you go through gltfjsx make sure to prepare the model for the web. the model is almost 80mb, that is way too much. otherwise you would have to configure node to hold out a little longer, i don't know how accurate the information is but something like this perhaps https://support.circleci.com/hc/en-us/articles/360009208393-How-can-I-increase-the-max-memory-for-Node-

donmccurdy commented 2 years ago

Related:

The memory limit comes from the jpeg-js dependency, rather than the memory limit of Node.js itself. Other image resizing solutions (sharp, @squoosh/lib) would use memory more efficiently but aren't integrated into glTF Transform yet because they don't work in a web environment. Progress on that end: