Material.Parse is using texture's name not the url

Hey, guys! I’m confused when i use material parse, the texture is getting from rootUrl and name but not the texture url. How can i parse material’s texture from its url?

Hello!
Let’s say you loaded the texture from textures/amiga.jpg. Then you have serialized your texture to JSON.

Load your JSON into the jsonMaterial variable and call:

Texture.Parse(jsonMaterial, scene, "https://playgrounds.babylonjs.xyz/")

BabylonJS will try to load the texture from https://playgrounds.babylonjs.xyz/textures/amiga.jpg

Example:

Hope this helps!

R. :vulcan_salute:

Thx for your reply!
If the name is amiga.jpg and the url is textures/amiga.jpg, the texture will missing.

Hey @JoeyKo !

BABYLON.Texture.Parse(json, scene, rootUrl)

The code above will load the texture from

rootUrl + json.name // not json.url

Your json has an incorrect value in the name property.


Results to the correct URL.

This is the texture json file serialized by the PG I’ve created. As you can see the name is correctly set. Your json seems to be manually changed.

:vulcan_salute:

1 Like

Okay, So the json.url is an unused property from BABYLON.Texture.Parse.
Thx bro! :smiley:

1 Like

It’s quite misleading :smiley:
You’ re welcome bro! :muscle:

Please mark as a solution if it helped you so the system can close your question. Thx!

1 Like