I am using WebGPURenderer, and I want to know if there is a way to determine whether a material has been compiled.
I have a requirement to create an InstancedMesh where the count
value might change. For example, if the count
is initially 100 and then gets updated to 10, but the InstancedMesh has not yet been compiled, a buffer of size 10 will be created instead of the expected size of 100. If there is a way to determine when the material has been compiled before assigning the value, it would be very helpful.
To determine if a material has been compiled in WebGPURenderer, you can check the isMaterialDirty
property of the material. If this property is false
, the material has been compiled and is ready for use. Here’s a simple example:
if (!yourMaterial.isMaterialDirty) {
// Material has been compiled, proceed with assigning the value
yourInstancedMesh.count = newValue;
} else {
// Material is not compiled yet, handle accordingly
}
This way, you can ensure that the buffer size matches the updated count value only when the material is ready Learn more