Skip to content

Conversation

@yuripourre
Copy link
Contributor

Title

Preserve world transform on graph parenting

Summary

When assigning a node to another node, it's world transformation is not persisted, so the child node has it's position, rotation and scaled modified relatively to it's the parent, this is not desirable and sometimes you have no idea where the node went after assigning a parent.

Changes Made

Introduced _setParentPreservingWorldTransform

In the graph we added a new method that assigns a parent and preserves world transform.

Benefits

  • When assigning a child node to a parent node using the scene graph, the node remains exactly how it is when assigned to a parent.

@yuripourre
Copy link
Contributor Author

There are still edge-cases but it's a good start.

private _setParentPreservingWorldTransform(node: Node, newParent: Node | null): void {
if (!(node instanceof TransformNode)) {
// For non-transform nodes, just set the parent directly
node.parent = newParent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should manage for lights and cameras too, that they don't extend TransformNode

Copy link
Contributor Author

@yuripourre yuripourre Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good suggestion. I used Copilot, I will properly test is during the weekend

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.

2 participants