Offer alternative to Babylon.js CDN

I installed Babylon.js through npm, as in npm i @babylonjs/core. Then I imported it, and happily used it on a website.


However, when using the Babylon.js WebGPU backend, it makes a request to every time a user visits the website.
That is a potentially legal problem, which is never any fun. Essentially, it means that personal data is being sent to a 3rd party, which means that the GDPR applies in the EU.


Could we get an alternative for that, be it a note somewhere in the documentation, or something that’s done by default?

I absolutely do understand that Javascript’s story for loading WASM binaries, and distributing it in a proper package, is a tad irritating at the moment. Hopefully you’ll still find a decent solution for this.

The best option is for you to host it on your own server and then set the correct path with initAsync

const glslangOptions = {
  jsPath: baseUrl + "/glslang/glslang.js",
  wasmPath: baseUrl + "/glslang/glslang.wasm",

const twgslOptions = {
  jsPath: baseUrl + "/twgsl/twgsl.js",
  wasmPath: baseUrl + "/twgsl/twgsl.wasm",

const options = {
  // ... webgpu options

const engine = new BABYLON.WebGPUEngine(window.canvas, options);
await engine.initAsync(glslangOptions, twgslOptions);

You can also use Tools.ScriptBaseUrl = “absoluteUrlWhereYouPutAllYourBabylonThinggies” :slight_smile:


Lovely, thank you for the solutions!

I see that it is in the documentation after all, that’s nice. And here’s to hoping that at some point, Babylon.js will have an even cooler solution, like

  • no longer needing glslang and twgsl
  • shipping them by default on npm
1 Like

I noticed There seems to be omissions in the Doc file you mentioned that are coming from the CDN. I am thinking specifically about Havok. You are probably very busy right now, but as that has an asm file too it might be a good idea to include something about it.

Havok will not be automatically loaded from the CDN. If Havok is not available in the global namespace, it will simply not work.
But I agree, we can document that as well. I need to also document how to use the @babylonjs/ktx2decoder package (and the wasms in @babylonjs/core), i’ll add something about havok as well.