Dracoloader : uncaught (in promise) error


I am trying to import a compressed (using blender) .glb file using DRACOLoader but it is throwing some error.

         import { DRACOLoader } from './threejs/jsm/loaders/DRACOLoader.js'
         const dracoLoader = new DRACOLoader();
         dracoLoader.setDecoderPath( './threejs/js/libs/draco' );
         var loader = new GLTFLoader(manager).setPath(path);
         loader.setDRACOLoader( dracoLoader );
         loader.crossOrigin = "anonymous"; 
         loader.load(model+"."+modeltype, function(gltf) {
           // perform required actions 

Any help is appreciated.

Found that the below line is not loading draco_wasm_wrapper.js and draco_decoder.wasm from the specified path, rather it checks and loads from the root node.

          dracoLoader.setDecoderPath( './threejs/js/libs/draco/' );

Any suggestions?

I think there are decoders for standalone draco and gltf draco so maybe you need - './threejs/js/libs/draco/gltf/'

Otherwise they recommend using a cdn version - 'https://www.gstatic.com/draco/v1/decoders/'

1 Like

you cant fetch from a relative path, this is an xhr fetch request. you can import and require, but every fetch goes at the root. these binaries have to be inside “/public” and the path has to start with “/”. but import { DRACOLoader } from './threejs/jsm/loaders/DRACOLoader.js' looks also really odd. you don’t copy three inside your project folder, you npm install it, and then it’s just import ... from 'three/...'

1 Like