How to load glslang.js locally instead of cdn?

Hi everyone!

During the azure being down I noticed that I have this one dependency https://cdn.babylonjs.com/glslang/glslang.js being loaded from the cdn. I guess this is needed because of webgpu, but how can I load it locally instead of cdn?

Thanks in advance :smiley:

You can pass in your own path to glslang.js when constructing the engine. Something like…

const engine = CreateAsync(canvas, {
   glslangOptions: {
      jsPath: `${basePath}/glslang.js`
      wasmPath: `${basePath}/glslang.wasm`
   }
});

See Babylon.js/packages/dev/core/src/Engines/webgpuEngine.ts at ff1b476f06d6e5d357fdd82467e8809788327faa · BabylonJS/Babylon.js · GitHub for reference.

3 Likes

JS download: https://raw.githubusercontent.com/BabylonJS/Babylon.js/ff1b476f06d6e5d357fdd82467e8809788327faa/packages/tools/babylonServer/public/glslang/glslang.js

WASM download: https://github.com/BabylonJS/Babylon.js/raw/refs/heads/master/packages/tools/babylonServer/public/glslang/glslang.wasm

2 Likes

Managed to get that handled, thank you! Now I have a next issue with `twgsl` :smiley: I managed to get copies of it from the github, but now I need to find how to point those locally as well…

      twgslOptions: {
        jsPath: `${assetPath}/babylonjs/twgsl.js`,
        wasmPath: `${assetPath}/babylonjs/twgsl.wasm`,
      },
      glslangOptions: {
        jsPath: `${assetPath}/babylonjs/glslang.js`,
        wasmPath: `${assetPath}/babylonjs/glslang.wasm`,
      },

This seemed to finally do the trick :slight_smile:

1 Like

It seems I celebrated a bit too early, when doing a production build I get webassemby errors :melting_face: :

Edit: It was just 404 not found error, I didn’t include the wasm files to production since they were git ignored :man_facepalming:

1 Like

Ok azure is back online folks. We should be good

1 Like