Home > Software engineering >  Relation between entries in node and children in glTF 2.0
Relation between entries in node and children in glTF 2.0

Time:10-10

I'm writing a reader for glTF/GLB files in R. Reading through the spec at https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html, the relation between nodes and their children is unclear to me.

A node may have properties defining the transform (matrix, rotation, scale, translation). Do its children inherit this transform? If they specify their own transform, does it replace the parent one, or is it composed with it?

It also may have a camera spec. If the child has one as well, does it replace the parent one, or are they combined somehow?

CodePudding user response:

The child node's transformation is always composed with the parent one. For example, if the parent had a 5 X translation, and the child had a 90deg Y rotation, the resulting child mesh would be positioned at 5 X with the rotated orientation.

Note that matrix is mutually exclusive with the other three (translation, rotation, scale), so a given node must not mix matrix with any of the other forms of transformation. However, a parent could use matrix with children that use the other 3 transforms, or vice versa.

Typically camera appears on a leaf node, although that's not required. If a parent and child both have camera objects, they are considered two separate cameras, although the child's camera will move when the parent is repositioned.

If you get glTF working in R, please let us know with a comment at the bottom of issue #1058, thanks!

  • Related