Proper method of loading custom particle systems from Json?

Hey Gang,

I made some particle effects in the babylon editor since this makes it a lot easier than typing it out in code. I then exported the json, but when trying to use the particle systems in my project there are multiple issues.
I eventually got it to work, but it feels like a really hacky way of doing it, so I’d like some feedback/advice on how to do it better :slight_smile:

1. When I export to json from the babylon editor the particle texture name won’t be the actual file name, but a really long string. (Not ‘skull.png’, but ‘data:image/png;base64,iVBORw0KGgoAAAANSUhE…’)

2. It will always try to pull the particle texture from a path on the babylon website even when the path for the json is set correctly (assets.babylonjs.com/particles/textures/xxxxx)

I found a thread talking about this issue Forum Post however the solution doesn’t work for me. BABYLON.Constants.PARTICLES_BaseAssetsUrl doesn’t even exist for me.

I worked around this by set.systems[0].particleTexture.updateURL("skull.png"); after the particle system has loaded in. However this way we still get a failed request to where it originally wants to find it.

Let me ping @julien-moreau

1 Like

Hey @Deltakosh
Thanks for the reply.
I’ve been playing around with this a bit more since I made this forum post, but I still can’t figure it out.

I guess you’re pinging julien since the editor is involved.
In my case the editor spitting out a really long string isn’t that huge of an issue since I can just manually delete and change it. So that only adds one extra step.

The bigger issue is that I cannot change the path where it wants to find the texture for the effect before it makes a request to the babylon server.
If I use set.systems[0].particleTexture.updateURL("skull.png"); it will load the correct image, but it will still do a failed request to the original path first which will lead the users to have an error message in the console and makes one unnecessary get request.

image
Do you have an idea why BABYLON.Constants.PARTICLES_BaseAssetsUrl doesn’t seem to exist for me? Was this changed over the last couple of updates?

Edit:
I just realized the long string in the particle json came from me clicking embed texture when exporting from the editor. So issue 1 is fixed by just selecting no when asked.
When trying to use an embedded texture the same issue happens though with it making a get request to some babylon server.

image

Greetings,
Stephen

WoW !! I have missed this post !!
so sorry !!

I have to check the code before giving you an answer but I’ll have a look ASAP

I understand urls can be a problem and I hope to find a solution!

2 Likes

I found a solution!

  1. Was just me pressing ‘embed texture’ without realizing it when exporting from the editor. When selecting NO the string is just the file name.
  2. Managed to change the path by changing the url for BABYLON.ParticleSystemSet.BaseAssetsUrl. The texture now loads offline from the project files.

This thread also goes into more detail about that.