Tween multiple objects at same time

Is it possible to apply a tween (alpha tween) to a large number of objects at the same time?

(I have tried with scripts and arrays but I’m new to scripting.)

Many thanks for any pointers


Here’s a quick example that animates the metallic property on a PBR material. You can do the same with opacity as long as that parameter exists on the material (it doesn’t on simple PBR).

You can put this in a tap event or make a function for a behavior. It iterates over all the material and dynamically creates tweens for each of the materials.

//@input Asset.Material[] mats

script.mats.forEach(function(mat, i){
    var startValue = {val: 0}
    var endValue = {val: 1}
    var duration = 1000
    var tween = new TWEEN.Tween( startValue )
        .to( endValue, duration )
        .delay(i*200) // stagger
        .onUpdate( function(v){
            mat.mainPass.metallic = v.val
        } ).start()
}) (3.2 MB)

1 Like

Thank you so much. I’m going to try it out but it looks very hopeful. I really appreciate your help.

So grateful, it works perfectly. Thank you for your generosity in encouraging and helping people.

1 Like