简体   繁体   中英

How can I access a assets (animation sequence) using scripting in Spark AR studio

I'm trying to change the current frame of an animation sequence using a script in JS and I can't find the equivalent of Scene.root.find.... of assets... I'm trying to create a "Which ____ are you?" and I make the code for the roll an image but I don't know how to access it using scripts?

If I get it right, this will help you.


const Materials = require('Materials');
const mat = Materials.get('matName');
// set your number here, or an animation
mat.diffuse.currentFrame = 1;

UPD 8 May 2021: Now you should use async methods:


const M = require("Materials"); 
const D = require("Diagnostics");
(async function () {
    const mat = await M.findFirst("material0");
    const diff = await mat.getDiffuse();
    diff.currentFrame = 1;
})(); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM