DarcoLoader
extends the Loader class. When dealing with URL.createObjectURL(blob)
, you need to use a LoadingManager. With manager.setURLModifier, you can intercept any URL that should point to a blob URL and replace it with the actual blob URL generated by URL.createObjectURL(blob)
.
It should look like the following:
const manager = new THREE.LoadingManager();
// Intercept requests for Draco files and replace with Blob URLs
manager.setURLModifier((url) => {
if (url.includes('draco_decoder.wasm'))
return wasmBlobURL;
if (url.includes('draco_wasm_wrapper.js'))
return jsBlobUrl;
return url;
});
// Set up DRACOLoader with the custom manager
const dracoLoader = new DRACOLoader(manager);
dracoLoader.setDecoderPath('draco/'); // Use a virtual path, intercepted by LoadingManager
As an alternative, use a CDN to load the Darco files. Instead of storing the base64 data, you can try the following approach (though I’m not entirely sure about this, a feedback would be appreciated)
const CDNPath = 'https://unpkg.com/browse/three@0.169.0/examples/jsm/libs/draco/';
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath(CDNPath);