Issue with .setDecoderPath()

Hi ! I use gltf loader + draco loader to decompress my models. Its worked well in previous versions of three.js, but now i see this message in console:

THREE.DRACOLoader: The .setDecoderPath() method has been removed. Use instance methods.

Here my code:

 this.loader = new GLTFLoader();
    DRACOLoader.setDecoderPath('model/gltf/');
    this.loader.setDRACOLoader(new DRACOLoader());
    this.loader.load(Config.model.path, function(gltf) {

  gltf.scene.traverse(function(child) {
    if (!child.isMesh) return;

    scene.add(gltf.scene);
    console.log(gltf.scene.children[0].children);

    gltf.scene.children[0].children.forEach(function(e) {
      e.castShadow = true,
      e.receiveShadow = true
      e.material.needsUpdate = true;
    });


  });
});

Do it like in the official glTF extension example:

var gltfLoader = new GLTFLoader();
var dracoLoader = new DRACOLoader();

dracoLoader.setDecoderPath( 'js/libs/draco/gltf/' )
gltfLoader.setDRACOLoader( dracoLoader );

The migration guide now contains a hint about this change in R108:

2 Likes

The deprecated static .releaseDecoderModule() method is now an instance method, .dispose(). Currently there is no instance equivalent of .getDecoderModule(). You don’t need that to use the loader, the decoder module will load automatically. But there were reasons to use it, to request the decoder in parallel with other resources, so we could consider adding an instance method in the future. Perhaps named .preload() or something a bit clearer.

1 Like

Im sorry, i want to clarify the moment. That is, i can use gltf loader without draco loader with decoder path? Gltf loader decompress my models anyway? I use gltf-pipeline to encode

Most glTF models are not compressed, and you can (optionally) use glTF-Pipeline or other tools to compress them using Draco. If you have not compressed the model, then GLTFLoader can load it without any DRACOLoader or Draco-related configuration.

If you are loading models that use compression, you will need to create a DRACOLoader, configure it, and pass it to the GLTFLoader instance as documented on https://threejs.org/docs/#examples/en/loaders/GLTFLoader.

1 Like

Ok, thanks!