For example: meshInstance.material will access the first material, but what if the meshinstance (render component) has many materials? How can I access them?
I tried the folowing but it doesnt seem to work:
meshInstance.material[1]
For example: meshInstance.material will access the first material, but what if the meshinstance (render component) has many materials? How can I access them?
I tried the folowing but it doesnt seem to work:
meshInstance.material[1]
Thanks, but I cant find anything there that hints at how to access multiple materials.
The only thing I found there that seemed relevant is materialAssets but there is no explanation so I tried to use it in different ways but none of them worked.
You need to iterate through the render component mesh instances to access each material:
this.entity.render.meshInstances.forEach(meshInstance => {
const material = meshInstance.material;
});
Okay Thanks. So actually ‘MeshInstance’ really means ‘Material Instance’?
It’s something more, a mesh instance is the combination of three things:
These get submitted on each frame on each layer that’s to be rendered, as draw calls.
Good to know. Thanks!!