[SOLVED] How to get material texture map asset names? Only getting "placeholder"

Is there a way to get the asset names of the texture maps that make up a material? What I’m currently doing is on the asset ‘load’ event, I try to fetch the texture maps, ie materialAsset.resource.diffuseMap and despite these materials being “loaded” all that returns is this placeholder texture with the name “placeholder”. Adding a delay using setTimeout does fix this issue, but setTimeout is already unreliable and I know load times vary greatly so I’d really prefer not to rely on it.

This is the “placeholder” texture object that returns on materialAsset.resource.diffuseMap on the material asset ‘load’ event trigger:

_addressU: 0
_addressV: 0
_addressW: 0
_anisotropy: 1
_compareFunc: 1
_compareOnRead: false
_compressed: false
_cubemap: false
_depth: 1
_flipY: true
_format: 7
_glFormat: 6408
_glInternalFormat: 32856
_glPixelType: 5121
_glTarget: 3553
_glTexture: WebGLTexture { }
_gpuSize: 20
_height: 2
_invalid: false
_levels: Array [ Uint8Array(16) ]
_levelsUpdated: Array [ false ]
_lockedLevel: -1
_magFilter: 1
_minFilter: 5
_mipmaps: true
_mipmapsUploaded: true
_needsMipmapsUpload: false
_needsUpload: false
_parameterFlags: 0
_premultiplyAlpha: false
_volume: false
_width: 2
device: Object { _enableAutoInstancing: false, autoInstancingMaxObjects: 16384, attributesInvalidated: false, … }
fixCubemapSeams: false
name: “placeholder”
profilerHint: 0
​type: “default”

Hi @Chris,

Yes, that can be confusing. The reason it’s happening is because the engine is temporary assigning a placeholder texture on all used material slots while the texture maps get fetched and uploaded to the GPU.

Otherwise the shader will fail to run and the model can’t render at all.

You can get a reference to all assets used by another asset, in your case this material, using a private property available initially when the asset is first loaded.

Take a look at this thread for more info:

1 Like

Wow, thanks! That explanation makes sense. That is exactly what I’m looking for. I’m surprised I missed that thread.

1 Like