ParticleHelper.LoadASync loads textures from

I have a custom .json file saved locally that defines my particle system.

When I set ParticleHelper.BaseAssetsUrl to my local public folder the json loads fine but then the texture that is defined as “textureName”: “flare.png” in json file is trying to load from even tho BaseAssetsUrl is set to my local directory.

To the level I was able to understand the source code, static variable BaseAssetsUrl is only used in ParticleHelper class and when the json is loaded end sent to ParticleSystemSet parse method there is no reference to BaseAssetsUrl. The parse methods always takes Constants.PARTICLES_BaseAssetsUrl value. I think ParticleHelper.BaseAssetsUrl should be injected into Parse methods for ParticleSystemSet and ParticleSystem classes.

I was thinking to change Constants.PARTICLES_BaseAssetsUrl but this seems like to much of a hack…

Please help.

This is not a hack but the expected way actually :slight_smile:
Just call BABYLON.Constants.PARTICLES_BaseAssetsUrl = ...

1 Like

Yeah, it was so simple! I’m stupid, I went into babylon.min.js source and changed variable there did not even come to mind to just do this hahah.

No worries!

Actually, now I tried this solution but it seems it doesnt work. This is a read only property so you cant change it programatically. Any way around this?

My bad! I’ll remove the readonly property for next commit !

You can cast it to any in the meantime

Hey @Deltakosh I just tried this again in version 4.1.0. Was that constant removed?

nope still here: Babylon.js/particleHelper.ts at master · BabylonJS/Babylon.js · GitHub

interesting, I’ve got that line added to my code, however, it’s still using the remote assets as seen in the console on the left.

What am I missing oh mighty sith lord?


can you try with BABYLON.ParticleHelper.BaseAssetsUrl ?

interesting, when I switch to that property, it seems to be effective.
However, before I can find out babylon can no longer find (404) the following json file which normally does not show up in the source panel.

Alright, found that json file and added it to my local server as well.
Now I notice, it’s still defaulting to
(when i turn off my internet connection, the images are missing)
Is this the expected behavior?

sorry wrong image before.

I ll have a look shortly

I think I found a simple solution for this after looking at the source code snipped that @Deltakosh posted.

I’ve also been having a similar issue with not being able to change BABYLON.Constants.PARTICLES_BaseAssetsUrl:

When just changing the url for BABYLON.ParticleSystemSet.BaseAssetsUrl instead it works just fine and loads the textures offline from the project folder.

I hope this is a good approach and also works for you @craql

Thanks @Stephen I reread your solution and that was the ticket.
However, I had to use different strings as bbjs appends the two variables when creating the path to the textures for the particles.

1 Like