I saw this tutorial. However, the effects keeps looping. How can I control it to fade in then stop and show the full model. Or fade out then stop and show the full model. And not just loop.
I know it has to do with the time variable. Here’s what I tried but couldn’t get it to work
CustomShader.prototype.update = function(dt) {
this.time += dt;
// Bounce value of t 0->1->0
var t = (this.time % 2);
if (t > 1) {
t = 1 - (t - 1);
}
if (t < 0.01) {//when t is less than this, it's close to showing the full model
console.log("faded in");
//now stop shader and show full model
this.enabled = false;//doing this doesn't work, the effect is still there, close to finish but not finished yet.
}
// Update the time value in the material
this.material.setParameter('uTime', t);
};