DracoCompression.Configuration not working in 5.0.0-alpha.37?


I have just switched from “latest” to “preview” in my project and Draco decompression has broken. I have a situation where I need to run disconnected from the web so I have a local copy of the draco scripts and set the configuration like this

        DracoCompression.Configuration = {
            decoder: {
              wasmUrl: process.env.PUBLIC_URL + '/assets/draco/draco_wasm_wrapper_gltf.js',
              wasmBinaryUrl: process.env.PUBLIC_URL + '/assets/draco/draco_decoder_gltf.wasm',
              fallbackUrl: process.env.PUBLIC_URL + '/assets/draco/draco_decoder_gltf.js',

where process.env.PUBLIC_URL equates to the root on my dev server (it is a React app). This all worked until I updated to 5.0 (I also downloaded “fresh” versions of the draco scripts from preview). Now I get this message…

Failed to execute ‘importScripts’ on ‘WorkerGlobalScope’: The URL ‘/assets/draco/draco_wasm_wrapper_gltf.js’ is invalid.

If I append that path to the browser address I do see the file. Has anything changed with the way DracoCompression.Configuration is handled? If I comment out my configuration block and use the default then it works, however this requires that I am connected to the web but for my solution I need it to work when not connected to the web.

Adding @bghgary.

Are you sure that locally the .js and .wasm files do match (meaning, they are from the same version of the decoder)?

I don’t think this has changed recently. Are you sure process.env.PUBLIC_URL is set correctly? From the error you are seeing, it looks like this variable might be an empty string.

1 Like

Yes, I am using the correct version. I got them from here and made sure I cleared cache etc.
fallbackUrl: “https://preview.babylonjs.com/draco_decoder_gltf.js
wasmBinaryUrl: “https://preview.babylonjs.com/draco_decoder_gltf.wasm
wasmUrl: “https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js

It seems that DracoCompression.Configuration cannot use relative paths. The process.env.PUBLIC_URL does return a blank when in my dev environment which used to work. If I change that to window.location.href then it works so it seems to need a fully qualified path. Maybe it was just luck that it worked in 4.20.

Looks like you are right. This is a regression from this PR: meshopt fixes and misc cleanup · BabylonJS/Babylon.js@95db4c8 (github.com)

Do you mind filing a bug for this?

Yep, will do. Thanks.

1 Like

This has been addressed in this PR: Factor out meshopt into its own class by bghgary · Pull Request #10830 · BabylonJS/Babylon.js (github.com).