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.
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.
Okay, So the json.url is an unused property from BABYLON.Texture.Parse.
Thx bro!
It’s quite misleading
You’ re welcome bro!
Please mark as a solution if it helped you so the system can close your question. Thx!