Pixi.js Container Scale and Rotation Effects on Children

In Pixi.js, the display hierarchy operates as a tree structure where transformations applied to a parent Container automatically propagate down to all of its child elements. This article explains how scaling and rotating a parent container affects the visual output, spatial positioning, and coordinate systems of its children, and how you can work with these inherited transformations in your projects.

How Transformation Inheritance Works

Pixi.js uses a hierarchical scene graph. Every Container has a local transform matrix and a world transform matrix. When you modify the scale or rotation of a parent container, Pixi.js updates the parent’s local transform. During the rendering loop, Pixi.js multiplies this parent transform by each child’s local transform to calculate the child’s worldTransform. This means any change to the parent is mathematically applied to the children, even though the children’s local property values remain unchanged.

What Happens When You Scale the Parent Container?

When you change a parent’s scale (e.g., parent.scale.set(2)):

What Happens When You Rotate the Parent Container?

When you rotate a parent container (e.g., parent.rotation = 0.5):

Non-Uniform Scaling and Rotation (Skewing)

If you apply non-uniform scaling to a parent container (scaling X and Y by different factors, such as parent.scale.set(2, 1)) and then rotate either the parent or the child, the child elements will experience a visual distortion known as skewing or shearing. This is a natural mathematical consequence of matrix multiplication and is important to keep in mind when designing complex animations.

How to Calculate Global Coordinates

Because local coordinates do not change when a parent is scaled or rotated, you cannot rely on child.x or child.y to find where a child is on the screen. To get the true, transformed position, scale, or rotation of a child, you must use Pixi’s coordinate conversion methods: