通过脚本在Spark AR上补间颜色 [英] Tweening Colors on Spark AR via Script

查看:163
本文介绍了通过脚本在Spark AR上补间颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是等效的Reactive Patch中的过渡补丁?我想在RGBA中将颜色从0,0,0,1更改为1,1,1,1,1.我知道ho可以将单个值设置为alpha动画,如下所示:

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;

使用视觉补丁,您可以使用变换补丁将Vector3链接到动画进度.我在反应脚本的文档中的任何地方都找不到这样的东西.有人可以告诉我吗?

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?

谢谢!

推荐答案

您需要查看ShaderModule.通过名称查找材料,然后可以使用setTexture.

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}
);  

我在这里使用了ArrayOfScalarSamplers,但这并不重要.

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

这篇关于通过脚本在Spark AR上补间颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆