I’m currently trying to get a meshopt compressed .glb to load. For this I use the code from this project: load-glb-model-with-meshopt
This code seems to be taken from the viewer itself (as stated in the comments).
The loading of the .glb works, as long as the compressed .glb doesn’t also contain compressed textures. Meaning as long as you don’t use meshopts commands for compressing textures -tc (and optionally -tq x you are fine).
However, I exactly want and need these compressed textures. Manually compressing every texture, loading and assigning them seems to be unnecessarily difficult.
Here’s the error thrown by the code and the viewer because of the compressed textures.
Is there a workaround for compressed textures with meshopt?
launch.js:15178 RangeError: Offset is outside the bounds of the DataView
at DataView.getUint32 (<anonymous>)
at parseGlb (playcanvas-1.51.4.dbg.js:33300)
at parseChunk (playcanvas-1.51.4.dbg.js:33360)
at Function.parseAsync (playcanvas-1.51.4.dbg.js:33426)
at Object.callback (playcanvas-1.51.4.dbg.js:33515)
at Http._onSuccess (playcanvas-1.51.4.dbg.js:2187)
at Http._onReadyStateChange (playcanvas-1.51.4.dbg.js:2139)
at XMLHttpRequest.xhr.onreadystatechange (playcanvas-1.51.4.dbg.js:2075)
I tried it by simply exchanging the glb with the compressed one on the server and it downloads but doesn’t show.
This error gets thrown:
playcanvas-stable.min.js:6 RangeError: Invalid typed array length: 1849440
at new Uint8Array (<anonymous>)
at Tl.r (playcanvas-stable.min.js:6:610208)
at Tl (playcanvas-stable.min.js:6:610516)
at c (playcanvas-stable.min.js:6:611123)
at o (playcanvas-stable.min.js:6:611002)
Does the compressed one load in the viewer? Do you have WASM modules for meshopt set up? Try this with debug version of the engine to get some callstack (min version is not very handy here), or even put breakpoint and see what the problem might be.
I’m not sure how meshopt works but assuming you take a GLB, run it through the meshopt tool to get a GLB back out: You can use the REST API to download the build (that has all the WASM modules in the project), unzip it, parse config.json, for each GLB asset filepath, convert the GLB file and zip up the whole project again.
Thanks for the links, but this seems too time consuming for me right now. Maybe if this method is sometimes in the future simpler to manage I’d use it.
Loading the compressed glb in via custom script has to suffice for now.