Non-CDN ShadowOnly Material?

Hi there,

I hope you all are well.

I have a website that uses ShadowOnly Material from CDN:

https://cdn.babylonjs.com/materialsLibrary/babylon.shadowOnlyMaterial.js

But sometimes, when I open my site, it has problems loading this material. Most of the time, it works, but sometimes it does not, and I need to reload the page to load it correctly.

Today, it happened with many users of my website (the problem was 504 gateway timeout). I needed to turn off shadow only on my website so that the users could keep using it.

So my question is… is there any recommended way to bring the shadowOnlyMaterial to my application instead of loading it from the CDN?

Thank you for your attention.

Just download this file and place it on your server(+ you need to change url in your code). I’d recommend to use CDN like Cloudflare to decrease downloading time.

Thanks, @Alexander_Sosnovskiy , I already tried it. But it seems that the problem is that the file in the CDN is not the material. It is a Webpack compiled file that includes another file from Babylon’s server (and it seems the gateway timeout is occurring when trying to load this internal file, as the CDN javascript is always loaded correctly)

EDIT: I was very dumb here. I don’t know how I came to that conclusion, it really has nothing to do with it.

cc @RaananW

Those are webpack require statement not require statement and the dependencies should be bundled within the file itself but the babylon once which come from babylon.js

1 Like

@sebavan @Alexander_Sosnovskiy I can’t believe I made that mistake, thank you very much. I thought the problem was in this line, and I didn’t notice the rest of the file below. It was probably some other problem.

Thank you very much!

This is just webpack setting the keys to the internal dependencies. Nothing to do on our end. This is also the non-minified version. The minified version has no reference to any of those:

https://cdn.babylonjs.com/materialsLibrary/babylon.shadowOnlyMaterial.min.js

1 Like

and and an extra small note - if you use the es6 version of our packages and load the material directly from the corresponding file in the package, the rest of the materials library will be tree-shaken out. This is the best (only only) way to get only this material not using CDN.

1 Like