Skip to content

Parent-child transform problems #26

@nametable

Description

@nametable

Version: 0.9
Scenario: I have 2 svgs, one is the parent and has a child svg. Here is stripped down version below:

    commands
        .spawn(Svg3dBundle {
            svg: component_svg,
            origin: Origin::Center,
            transform: Transform {
                translation: translation,
                scale: Vec3::new(1.0, 1.0, 1.0),
                ..Default::default()
            },
            ..Default::default()
        })
        .with_children(|parent| {
                parent.spawn(Svg3dBundle {
                    svg: pin_svg,
                    origin: Origin::Center,
                    transform: Transform {
                        translation: Vec3::new(pin.position.x, pin.position.y, 1.0),
                        scale: Vec3::new(1.0, 1.0, 1.0),
                        ..Default::default()
                    },
                    ..Default::default()
                });
            }

The problems that I see are as follows:

  • The placement of the child seems to follow Origin::TopLeft of the child instead of Origin::Center of the child
  • When the child is translated by itself, it is placed relative to the Origin::TopLeft of the parent, and Origin::Center of the child.
    • When the parent is translated, the child is placed back according to the Origin::TopLeft of the child, offset from the (correct) Origin::Center of the parent.

I'm not sure if it matters, but I'm using bevy-inspector-egui to modify the transforms. A short recording of the issues can be seen below:

bevy_svg_parenting_problems.webm

If a more minimal reproduction or repo with example would be useful, I can make one up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions