flame icon indicating copy to clipboard operation
flame copied to clipboard

[flame_3d] Child components do not observe parent transformations

Open luanpotter opened this issue 3 months ago • 7 comments

What happened?

Child components have their transformations set with respect to global space. We need to pre-multiply the transform of parent components up the chain, ideally avoiding repeated calculations.

What do you expect?

A child 3d-object inside a parent 3d-object should have its coordinate system wrt to the parent's transform.

How can we reproduce this?

Just created a nested component within the flame_3d playground.

Affected platforms

All

luanpotter avatar Sep 19 '25 14:09 luanpotter

Hi @luanpotter I am interested in solving this bug !! could you assign this to me

harshithsaiv avatar Sep 19 '25 21:09 harshithsaiv

Hi @spydon , I was going through the codebase and I had a doubt the parent/child transform composition should happens in transform_3d.dart , component_3d.dart ? Is there any other file that I have to look into

harshithsaiv avatar Oct 10 '25 21:10 harshithsaiv

@harshithsaiv this is better to ask @luanpotter , I've barely been involved in flame_3d.

spydon avatar Oct 10 '25 21:10 spydon

@harshithsaiv I actually haven't taken a look at this and thought about how/where it should work; do you have thoughts / preferences / proposals?

luanpotter avatar Oct 12 '25 14:10 luanpotter

btw - thank you so much for tackling this! I love to see other people interested in expanding flame_3d :)

luanpotter avatar Oct 12 '25 14:10 luanpotter

Thank you @luanpotter , This is a very interesting task to work on

This is the current implementation :

final parent = MeshComponent(
  mesh: CubeMesh(),
  position: Vector3(10, 0, 0),  // Parent at x=10
);

final child = MeshComponent(
  mesh: CubeMesh(),
  position: Vector3(5, 0, 0),   // Child at x=5
);

parent.add(child);
world.add(parent);
  1. Planning to add a cached world that transforms that compose parent transforms automatically using lazy evaluation. When our transform changes → mark dirty → notify children When parent changes → we get notified → mark dirty → notify children Lazy evaluation: only recalculates when accessed AND dirty
  2. And also update the rendering to use this cached world transformation .
  3. Would also write test cases

harshithsaiv avatar Oct 13 '25 05:10 harshithsaiv

Amazing! Plan looks solid to me @harshithsaiv , thanks for taking this on! Would the cache live on the Component level? Because we would need one per component. Also need to make sure to include a test of deeply nested component hierarchies as well.

luanpotter avatar Oct 19 '25 02:10 luanpotter