Animate color of standardMaterial


I want to animate color of standardMaterial but it doesn’t work.

An idea ?
Thanks for your answer

Hi F! Line 23… needed to change ‘diffuseColor’… to ‘material.diffuseColor’.

Party on… mark as solved if your happy… thx.


Thanks a lot !!

1 Like

My pleasure. Just for fun…

I changed the light… hemisphericLight is better for general playing, cuz it lights all sides of mesh, and with it’s groundColor option, it lets you set belly-color differently than hemi.diffuse (light.diffuse).

I temporarily turned off your previous animation (by disabling line 57)… and then installed a “shortcut” animation method… in lines 60-76.

Then in line 79, I showed how to make it even shorter, but I left that line disabled.

And then in lines 82-83, I used that shortcut method… to animate the y-axis rotation (using the same speed and totalFrames as the color animation uses).

Notice that when using CreateAndStartAnimation() method… we don’t need to tell the animation system that we are animating a BABYLON.Animation.ANIMATIONTYPE_COLOR3 data-type. CreateAndStartAnimation() automatically “senses” the animated dataType FOR US! Cool, huh?

In line 83, where we animate a vector3 instead of a color3, we didn’t need to specify that. It sensed it.

I’m just showing you some other fun ways to animate. I hope I’ve been helpful. Be well.

1 Like

Good to know, thanks :slight_smile:

1 Like

Thank you!! :grinning:

1 Like