0

what would be the equivalent of a transition Patch in Reactive script? I would like to tween a color from say 0,0,0,1 to 1,1,1,1 in RGBA. I know ho to animate a single value as alpha, like this:

const timeDriver = Animation.timeDriver(timeDriverParameters);
const alphaSampler = Animation.samplers.linear(1, 0);
const alphaAnimation = Animation.animate(timeDriver, alphaSampler);
mymaterial.opacity = alphaAnimation;

Using visual patches you can use a Transform Patch to link a Vector3 to an animation progress. I cannot find something like this anywhere in the docs for reactive script. anyone can tell me?

Thank you!

Wolfgang Müller
  • 205
  • 1
  • 4
  • 16

1 Answers1

2

you need to look at ShaderModule. Find the material by name, and then you can use setTexture.


const R = require('Reactive');
const A = require('Animation');
const S = require('Shaders');
const Materials = require('Materials');


const material = Materials.get('matName');
const driver = A.timeDriver({ durationMilliseconds : 1000});
const sampler = A.samplers.linear(
    [1, 1, 1, 1],
    [0, 0, 0, 1]
);
const colorAnimation = A.animate(
    driver,
    sampler
);


material.setTexture(
    R.pack4(
        colorAnimation.get(0),
        colorAnimation.get(1),
        colorAnimation.get(2),
        colorAnimation.get(3)
    ), 
    {textureSlotName: S.DefaultMaterialTextures.DIFFUSE}
);  

Here i've used ArrayOfScalarSamplers, but it's not crucial.

lisichka ggg
  • 563
  • 3
  • 15
  • 1
    Ahh, thanks! Great. I failed to unpack the signal array. By the way, do you know an additional source of documentation for the scripting? i find the offical spark docs quite small. – Wolfgang Müller Jan 10 '20 at 15:57
  • There was an unofficial wiki page, but it looks like it is broken for now( – lisichka ggg Jan 11 '20 at 00:37