Fix layer rotation ignored when "ddd" key is omitted (issue #581) - #597
Open
ZayanKhan-12 wants to merge 1 commit into
Open
Fix layer rotation ignored when "ddd" key is omitted (issue #581)#597ZayanKhan-12 wants to merge 1 commit into
ZayanKhan-12 wants to merge 1 commit into
Conversation
parseLayer() initialized the 3D flag to true, so any layer without an explicit "ddd": 0 was treated as 3D. In 3D mode the transform uses mExtra->m3DRz (which has no keyframes) instead of mRotation, so layer-level rotation keyframes rendered as static. Most Lottie files exported from After Effects omit "ddd" for 2D layers. Per the Lottie spec the "ddd" property defaults to 0 (2D), matching the default of parseTransformObject(bool ddd = false). Initialize ddd to false so omitted-ddd layers are parsed as 2D and their rotation is applied. Added a regression test that renders a 360-degree layer rotation at two frames and asserts the pixels differ; it fails before this change (frames are identical) and passes after. Fixes Samsung#581 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #581
Problem
parseLayer()insrc/lottie/lottieparser.cppinitialized the 3D flag withbool ddd = true;. Any layer that doesn't explicitly set"ddd": 0was therefore parsed as 3D. In 3D modeTransform::Data::matrix()takes rotation frommExtra->m3DRz— which has no keyframes — instead ofmRotation, so layer-level rotation keyframes (ks.r) render as static. After Effects omits the"ddd"key for 2D layers, so this affects most real Lottie files (they animate correctly in lottie-web).Per the Lottie spec,
"ddd"defaults to0(2D) — which is also the default of this file's ownparseTransformObject(bool ddd = false). Thetrueinitializer contradicts that.Fix
One line:
bool ddd = true;→bool ddd = false;, so a layer with no"ddd"key is treated as 2D and its rotation is applied.Verification
Built with
-DLOTTIE_TEST=ONand rendered the reproduction from the issue (a bar with a 360° rotation) at frame 0 and frame 15:Added a gtest regression test (
AnimationRotation.layerWithoutDddRotates) that asserts the two frames differ; it fails onmasterand passes with this change. The rest of the animation suite is unchanged by this commit (the two pre-existingloadFromFilefailures onmasterare an unrelatedtotalFrame()30-vs-31 expectation mismatch, present before this change).🤖 Generated with Claude Code