customProgramCacheKey property
In case onBeforeCompile is used, this callback can be used to identify values of settings used in onBeforeCompile, so three.js can reuse a cached shader or recompile the shader for this material as needed.
if(black){
shader.fragmentShader = shader.fragmentShader.replace('gl_FragColor = vec4(1)', 'gl_FragColor = vec4(0)');
}
material.customProgramCacheKey(){
return black ? '1' : '0';
}
Unlike properties, the callback is not supported by clone, copy and toJson.
Implementation
late Function customProgramCacheKey;