Skip to content

Fix layer rotation ignored when "ddd" key is omitted (issue #581) - #597

Open
ZayanKhan-12 wants to merge 1 commit into
Samsung:masterfrom
ZayanKhan-12:fix-581-ddd-default-2d
Open

Fix layer rotation ignored when "ddd" key is omitted (issue #581)#597
ZayanKhan-12 wants to merge 1 commit into
Samsung:masterfrom
ZayanKhan-12:fix-581-ddd-default-2d

Conversation

@ZayanKhan-12

Copy link
Copy Markdown

Fixes #581

Problem

parseLayer() in src/lottie/lottieparser.cpp initialized the 3D flag with bool ddd = true;. Any layer that doesn't explicitly set "ddd": 0 was therefore parsed as 3D. In 3D mode Transform::Data::matrix() takes rotation from mExtra->m3DRz — which has no keyframes — instead of mRotation, 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 to 0 (2D) — which is also the default of this file's own parseTransformObject(bool ddd = false). The true initializer 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=ON and rendered the reproduction from the issue (a bar with a 360° rotation) at frame 0 and frame 15:

  • before: 0 pixels differ between the two frames (rotation ignored — bug reproduced)
  • after: 526 pixels differ (rotation applied)

Added a gtest regression test (AnimationRotation.layerWithoutDddRotates) that asserts the two frames differ; it fails on master and passes with this change. The rest of the animation suite is unchanged by this commit (the two pre-existing loadFromFile failures on master are an unrelated totalFrame() 30-vs-31 expectation mismatch, present before this change).

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Layer rotation broken: ddd flag defaults to true instead of false

1 participant