Hiya, is it possible to animate the intensity on the emissive part of a material in play canvas?
thanks!
Hiya, is it possible to animate the intensity on the emissive part of a material in play canvas?
thanks!
Hi @davidj2022,
Yes, one way to do it is using the tween library. Check at the bottom of this page on how you can animate the colour of a material.
In a similar way you can animate any numeric material property.
thanks for this… I’m having some trouble getting it to work with the emissive intensity however.
This is the project:
https://playcanvas.com/editor/scene/1357123
this is the error message I get:
this.fromemissiveintensity.clone is not a function
many thanks
So this code won’t work:
this.tween = this.app.tween(this.tweenedProperties.emissiveintensity)
.to(this.toemissiveintensity, this.duration, pc[this.easing])
.delay(this.delay);
If you check the link I posted, the way to tween a material property is different:
To that regard, tweening emission intensity will be something like this:
const material = this.entity.render.material;
const data = {
intensity: material.emissiveIntensity
};
this.app
.tween(data)
.to({intensity: 1.0}, 1.0, pc.Linear)
.loop(true)
.yoyo(true)
.on('update', function () {
material.emissiveIntensity = data.intensity;
material.update();
})
.start();
For other who arrive here and try to cut/paste this code…it should be…
emissiveIntensity
…and not…
emissiveintensity
Thanks @Grimmy, I’ve updated the code.