Babylonjs Offline Support

Hi,
I need to run a project developed using babylonjs in offline. In that project the draco compressed 3d models has been used as glb format. While run this with internet connection, it is running perfectly. But, while run this in offline, The 3d model doesn’t get loaded. It shows an error with the draco_decoder_gltf.wasm , Kindly have a look into the error message given below and help me on this.

https://preview.babylonjs.com/draco_decoder_gltf.wasm net::ERR_NAME_NOT_RESOLVED

By default the files used by the Draco decompressor are downloaded from preview.babylonjs.com. You will need to host them locally and change the urls to point to those files.

The urls can be found in DracoCompression.Configuration:

public static Configuration: IDracoCompressionConfiguration = {
    decoder: {
        wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
        wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
        fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
    }
};

So, do something like:

BABYLON.DracoCompression.Configuration.decoder.wasmUrl = "local url to draco_wasm_wrapper_gltf.js";
BABYLON.DracoCompression.Configuration.decoder.wasmBinaryUrl = "local url to draco_decoder_gltf.wasm";
BABYLON.DracoCompression.Configuration.decoder.fallbackUrl = "local url to draco_decoder_gltf.js";
4 Likes

@Evgeni_Popov Thanks for your reply. I am sorry to say that, I don’t know where I can see that DracoCompression.Configuration . Can you please share a live demo.

Look at the browser console in this PG:

3 Likes

Thanks a lot @Evgeni_Popov . It is working.

1 Like

Hi,
any way to do the same for ktx2Decoder ?
It is loaded from preview.babylonjs too. But I would like to import it locally.

I see the tooling here, but no wasm files: https://github.com/BabylonJS/Babylon.js/tree/master/packages/tools/ktx2Decoder
Having similar configuration like for dracocompression would be nice :slight_smile:

Best!

Edit: Found this:

import { KhronosTextureContainer2 } from '@babylonjs/core/Misc/khronosTextureContainer2'
KhronosTextureContainer2.URLConfig

and this: Load KTX2 de/transcoder from own server

I think you can adpat them through https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Misc/khronosTextureContainer2.ts#L236

2 Likes

nice you replied faster :slight_smile: guess i just have to download the files from preview server. couldnt find the builds in github yet.