Updating colors programatically without using state?
ggomaeng opened this issue · comments
undefined commented
I am trying to update the colors programatically frame by frame without using state for performance reasons, and it seems like I can't access uniforms
of the material. It seems like I can't access the getters and setters of the shaderMaterial as well.
Any pointers would be greatly appreciated!
Here are my efforts below without any luck
three.current?.scene.traverse(function (object) {
if (
object instanceof Mesh &&
object.material instanceof MeshPhysicalMaterial
) {
object.material.userData.colors = ["#0000FF", "#00FF00", "#000000"];
object.material.needsUpdate = true;
const shaderMaterial =
object.material as unknown as ShaderMaterial & {
colors: Color[];
};
console.log(shaderMaterial);
console.log(shaderMaterial.colors); // this throws an error
console.log(shaderMaterial.uniforms); // this throws an error
}
});