首页 > 解决方案 > 如何使用 Lottie web 访问预合成中的文本数据

问题描述

我正在尝试控制使用 bodymovin 导出的 .json 文件的文本值。

此刻,我成功地创建了一个从 bodymovin 导出的平面“模板”,并使用函数 updateDocumentData 更改了 bodymovin .json 文件中的值。

但我唯一可以更改的元素是 After Effects 主要组成中的元素。现在我想尝试制作一个更难的模板,在 After Effects 中使用预合成。我如何使用 updateDocumentData (或其他函数?)来更改更深层组合中的文本值。

function functionUpdate() {
        anim.playSegments([450, 460], true);
        const animElement = anim.renderer.elements[1];
        console.log(anim.renderer.elements[1])
        animElement.updateDocumentData({t: 'Test Text'});
    }

    const animData = 'js/data_test.json';
    const animContainer = document.getElementById('lottie-container');
    const anim = lottie.loadAnimation({
        container: animContainer, // The dom element that will contain the animation
        renderer: 'svg',
        loop: false,
        autoplay: false,
        path: animData // Path to the animation json
    });

标签: javascriptjsonlottiebodymovin

解决方案


推荐阅读