spark-ar-studio - 如何在脚本中获取循环动画进度(Spark AR)
问题描述
我需要获取循环动画进度(和循环)信息(如果它在补丁编辑器中,它就是输出)。但我在文档中找不到这些信息。我怎样才能获得所需的信息?
解决方案
对于“循环”,您可以在 TimeDriver 上使用 onAfterIteration 事件: https ://sparkar.facebook.com/ar-studio/learn/documentation/reference/classes/animationmodule.timedriver
对于进度,遗憾的是 TimeDriver 上没有可用的进度,但您可以在动画信号上使用 multiTrigger 事件侦听器。根据您要实现的具体目标,有几种不同的方法: https ://sparkar.facebook.com/ar-studio/learn/documentation/reference/classes/reactivemodule.scalarsignal
例如:
//setup your animation
const Animation = require('Animation');
let driver = Animation.timeDriver({durationMilliseconds:1000, loopCount:Infinity});
let sampler = Animation.samplers.linear(0,1);
let animation = Animation.animate(driver, sampler);
//add listener for "looped" to the driver
driver.onAfterIteration().subscribe(function(e){
//do stuff on here...
});
//add listener for progress to the animation signal
//this will trigger when the animation signal goes above .5
animation.multiTrigger(.5).subscribe(function(e){
//do stuff here...
})
推荐阅读
- laravel-8 - 如何在 laravel 中为采摘数组添加默认选项
- visual-studio - OpenCppCoverage 不在报告中显示我的源文件
- c - 是什么导致此 Linked List 节点添加代码中的无限迭代?
- python - 将文档列表设置为变量后的pymongo排序
- laravel - Laravel 分段上传到 AWS S3(错误 500)
- sql-server - 操作系统错误代码3(系统找不到指定的路径。) linux服务器上运行的MSSQL
- kubernetes - 如何在节点故障后自动强制删除卡在“终止”中的 pod?
- windows - 我无法在 Windows 10 中使用 Freeradius EAP TTLS/PAP 对 LDAP Google 进行身份验证
- design-patterns - 什么是“智能 UI 反模式”?
- load-balancing - 具有单个 ALB 和单个目标组的多域域