How to add both KTX2Loader and DracoLoader for compressed glb

Hello, I have compressed GLB, and I need to load that GLB into a scene, but it gives me an error


I used below code

Can someone guide me to where I am doing wrong? Thanks

You need to set the KTX2Loader instance via setKTX2Loader() before you load your glTF asset. Similar to how DRACOLoader is configured.

According to your code, your are doing this in the onLoad() callback.

Again facing error by changing like that -

and code is -

Are setDecoderPath and setTranscoderPath are correct?

If you use the latest three.js version, you have to change the paths from examples/js/libs to examples/jsm/libs.

JSM folder structure there is no draco and ktx2 present -


JS folder structure there is draco and ktx2 present -

and three js version is - “^0.139.2”

We don’t know how your application is structured because you haven’t shared that, but it’s unusual to make HTTP requests into the node_modules directory. I would suggest just copying those files out of examples/js/libs/{draco,basis} and hosting them as static files in your application folder.

1 Like

Thanks, it is working! :grin:

1 Like