Skottie - dealing with expressions

74 views
Skip to first unread message

Felix Don

unread,
Jan 4, 2023, 6:51:45 AM1/4/23
to skia-discuss
I have the following block inside a bodymovin json file

{
                "ty": "tr",
                "p": { "a": 0, "k": [0, 0], "ix": 2 },
                "a": { "a": 0, "k": [0, 0], "ix": 1 },
                "s": { "a": 0, "k": [100, 100], "ix": 3 },
                "r": { "a": 0, "k": 0, "ix": 6 },
                "o": {
                  "a": 1,
                  "k": [
                    {
                      "i": { "x": [0.833], "y": [0.833] },
                      "o": { "x": [0.167], "y": [0.167] },
                      "t": 0,
                      "s": [100],
                      "__fnct": [null]
                    },
                    { "t": 15, "s": [0] }
                  ],
                  "ix": 7,
                  "x": "var $bm_rt;\nvar dur, outDur;\ndur = 5;\noutDur = 0.5;\n$bm_rt = valueAtTime($bm_sum($bm_sub(time, dur), outDur));"
                },
                "sk": { "a": 0, "k": 0, "ix": 4 },
                "sa": { "a": 0, "k": 0, "ix": 5 },
                "nm": "Transform",
                "_render": true
              }

the opacity property contains an expression and specifically the "valueAtTime" expression. This valueAtTime operates on two keyframes inside this block. {0, 100} and {15,0}. 
Inside the Animator.cpp, the function AnimatablePropertyContainer::bindImpl disregards and never parses the keyframes (it just handles expressions on the property) so they are left untracked.

Is there an elegant way to track those abandoned keyframes and retrieve them back in user code so that when I'm using  expression manager I could pass them to my implementation of 'valueAtTime' ?



Florin Malita

unread,
Jan 4, 2023, 9:45:26 AM1/4/23
to skia-d...@googlegroups.com
This is currently not supported in Skottie: animated properties can be keyframed or expression-driven, but not both.

I think it's something that could be added -- although it would require some public API changes.  The way it would work is we'd have to always instantiate a property animator and pass it to the expression evaluator factory.  Feel free to open a feature request.

Do you know how the expression was authored, by hand or some plugin?  There are probably some workarounds on the authoring side (time remapping or just updating the actual keyframes) to avoid valueAtTime().

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/df157acb-5dfa-4339-a2bd-4a4133b6aa55n%40googlegroups.com.

Felix Don

unread,
Jan 5, 2023, 3:39:27 AM1/5/23
to skia-discuss
Hey,
The expression was authored by hand and we're looking for workarounds as you said.
Thanks for the quick response :-)
Reply all
Reply to author
Forward
0 new messages