# How to add both KTX2Loader and DracoLoader for compressed glb

**URL:** <https://discourse.threejs.org/t/how-to-add-both-ktx2loader-and-dracoloader-for-compressed-glb/46726>\
**Category:** Questions\
**Tags:** gltf-loader, ktx2\
**Created:** [January 10, 2023, 12:55pm UTC](https://discourse.threejs.org/t/how-to-add-both-ktx2loader-and-dracoloader-for-compressed-glb/46726 "2023-01-10T12:55:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gundeep\_Singh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gundeep_singh/32/25485_2.png) [@Gundeep\_Singh](https://discourse.threejs.org/u/Gundeep_Singh)\
**Post date:** [January 10, 2023, 12:55pm UTC](https://discourse.threejs.org/t/how-to-add-both-ktx2loader-and-dracoloader-for-compressed-glb/46726/1 "2023-01-10T12:55:01Z")

</div>

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

 ![Capture](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/0/1/01ef2a6c325cc1197231eb069bab9396cfb0fa89.jpeg)  
I used below code  
 ![Capture1](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/0/0/009cc5661928c90beb82a2d3602e0316298d2a44.jpeg)  
Can someone guide me to where I am doing wrong? Thanks

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [January 10, 2023, 1:02pm UTC](https://discourse.threejs.org/t/how-to-add-both-ktx2loader-and-dracoloader-for-compressed-glb/46726/2 "2023-01-10T13:02:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Gundeep\_Singh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gundeep_singh/32/25485_2.png) [@Gundeep\_Singh](https://discourse.threejs.org/u/Gundeep_Singh)\
**Post date:** [January 10, 2023, 1:20pm UTC](https://discourse.threejs.org/t/how-to-add-both-ktx2loader-and-dracoloader-for-compressed-glb/46726/3 "2023-01-10T13:20:00Z")

</div>

Again facing error by changing like that -

 ![Capture2](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/2/c/2c6e97ae44004d10cb075985598c283c6cecf742.jpeg)

and code is -

 ![Capture3](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/6/2/6290ef71b92a0dcfed08ed5a983656d30295811e.jpeg)

---

<div class="post-metadata">

**Author:** ![Gundeep\_Singh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gundeep_singh/32/25485_2.png) [@Gundeep\_Singh](https://discourse.threejs.org/u/Gundeep_Singh)\
**Post date:** [January 10, 2023, 1:23pm UTC](https://discourse.threejs.org/t/how-to-add-both-ktx2loader-and-dracoloader-for-compressed-glb/46726/4 "2023-01-10T13:23:03Z")

</div>

Are setDecoderPath and setTranscoderPath are correct?

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [January 10, 2023, 1:59pm UTC](https://discourse.threejs.org/t/how-to-add-both-ktx2loader-and-dracoloader-for-compressed-glb/46726/5 "2023-01-10T13:59:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gundeep\_Singh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gundeep_singh/32/25485_2.png) [@Gundeep\_Singh](https://discourse.threejs.org/u/Gundeep_Singh)\
**Post date:** [January 10, 2023, 2:06pm UTC](https://discourse.threejs.org/t/how-to-add-both-ktx2loader-and-dracoloader-for-compressed-glb/46726/6 "2023-01-10T14:06:47Z")

</div>

JSM folder structure there is no draco and ktx2 present -

 ![5](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/9/c/9c4796a6bd53f5c406ab4eba2c4408de10f2afab.jpeg)  
JS folder structure there is draco and ktx2 present -  
 ![6](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/f/d/fd6306758590c5b91944304d1084362a41cd1c88.jpeg)

and three js version is - “^0.139.2”

---

<div class="post-metadata">

**Author:** ![donmccurdy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/donmccurdy/32/33209_2.png) [@donmccurdy](https://discourse.threejs.org/u/donmccurdy)\
**Post date:** [January 10, 2023, 2:45pm UTC](https://discourse.threejs.org/t/how-to-add-both-ktx2loader-and-dracoloader-for-compressed-glb/46726/7 "2023-01-10T14:45:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Gundeep\_Singh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gundeep_singh/32/25485_2.png) [@Gundeep\_Singh](https://discourse.threejs.org/u/Gundeep_Singh)\
**Post date:** [January 11, 2023, 4:08am UTC](https://discourse.threejs.org/t/how-to-add-both-ktx2loader-and-dracoloader-for-compressed-glb/46726/8 "2023-01-11T04:08:27Z")

</div>

Thanks, it is working! 😁
