[WebGL2.0][Basic]scene graph
Reene

Reene @reene44444

About: 🎯

Joined:
Jul 10, 2024

[WebGL2.0][Basic]scene graph

Publish Date: Nov 4 '24
2 1

Transition Matrix: localMatrix and worldMatrix

In 3D graphics rendering, both localMatrix and worldMatrix are transformation matrices used to describe the position, rotation, and scaling of an object in different spaces. Multiplying these matrices is necessary to progressively apply the transformations of each object in the hierarchy to the overall scene’s world coordinate system. Here’s a deeper explanation of why these matrices are multiplied and their specific roles.

1. localMatrix and worldMatrix

  • localMatrix: Represents the transformation of the current node (object) in its local coordinate space. This space is relative to its parent node, meaning the object’s position, rotation, and scaling are all described relative to its parent. Any child nodes will inherit this transformation.

  • localMatrix describe itself information rather than a single coordinate system, same as worldMatrix.

  • worldMatrix: Represents the transformation of the current node in the world (or scene) coordinate space. This matrix transforms the node from its local coordinate space all the way up to the root node of the scene graph, effectively placing it in world space.

2. Why Multiply the Matrices?

Matrix multiplication is used to apply transformations from one space to another. For instance:

  • The parent node’s worldMatrix represents its position and orientation in the world space.
  • The current node’s localMatrix represents its position and orientation relative to the parent node.

To compute the position and orientation of the current node in world space, we multiply the parent node’s worldMatrix by the current node’s localMatrix. This multiplication effectively applies the parent’s transformation, followed by the current node’s transformation, resulting in the current node’s worldMatrix.

3. Example: Earth and Moon

Consider a scenario where the Earth orbits the Sun, and the Moon orbits the Earth. Using matrices, we can represent these transformations:

  • Earth’s worldMatrix describes its position and rotation around the Sun in the world (solar system) space.
  • Moon’s localMatrix describes its position and rotation around the Earth, in Earth’s local space.

To compute the Moon’s position in the world space, we multiply Earth’s worldMatrix by Moon’s localMatrix, resulting in Moon’s worldMatrix. This way, the Moon orbits Earth, which in turn orbits the Sun, capturing the hierarchical transformation relationship.

4. Conclusion

By multiplying matrices, we can apply each level’s transformation within a hierarchy (like a scene graph), obtaining the final position and orientation of each node in world coordinates. This method is fundamental in 3D scenes, especially for complex parent-child transformation relationships.

Comments 1 total

  • V_Systems
    V_SystemsApr 30, 2025

    Hey there, would you be interested in joining our WebGL Shader Hackathon?

    Until 8 May, create your original shader and publish it on our blockchain to compete for prizes ranging between $500 and $1000!

Add comment