Find all materials in the scene that reference texture A
There is no direct relation between texture and material. You can create a texture independent of a material. If you want to check the references you will need to do it on your own when setting the materialâs texture. Otherwise you can iterate over all materials, and check if one of the materialâs textures in a specific texture. The material itself has a function called âhasTextureâ with which you can check if a specific texture is referenced by it.
Correct. I could add that I like to make use of the property ânameâ when creating such texture.
I can next pick from all of its ânameâ. By creating this name including some sort of identifier in the name, I can next pick from all textures that include this identifier (searching through âincludesâ).
So, something like this:
var picttex= new BABYLON.Texture(âtextures/mypicttex.jpgâ, scene);
picttex.name = âmytex0_pict_customâ;
and then access through:
scene.textures.forEach((texture)=>{
if (texture.name && texture.name.includes(âpictâ)){
texture.level = 2;}
});
or of course, through mesh or material (or a combination of all).
Else, you can also use âuniqueIdâ on texture. Except of course in this case the ID isâŚwell, unique ![]()
scene.materials.forEach(m => m.hasTexture(textureA));
this should do it but it can be slow has it iterates over everything. I would recommend to avoid using this every frame.