Restricted parenting

As others already pointed out, it would be great to have some way to parent only a restricted set of properties. In my app, I have several places where this would be an extremely useful feature.
A possible work-around is registering a method agains the change of world-coordinates, as shown in this playground:

which “parents” only position, rotation or scaling.
However, I see several problems with this approach:

  1. Registering a function for such an action seems wasteful
  2. What happens if a child object gets destroyed? Will the function registered to the “parent” still try to perform its work? Supposedly yes. Thus one needs to also implement a way to detect this and remove the update function.
  3. Some of the computations needed may be quite wasteful and unnecessary. E.g. if you have to compute an inverse rotation matrix to just compensate the current rotation, this seems like a waste.

Therefore it would be great, if one could implement such functionality in a more proper and easy-to use way. the mesh could have a restrict tag for the inheritance, which would be the best way, but otherwise one could potentially provide functions within Babylon like the ones in the workspace above, ideally also accounting for the rotation, scale and position properties one may additionally want to set on the child instead of giving it as a separate vector.

For related posts see also:



… here is an updated workspace with appropriate Observable removal code:

I’m not sure it can be implemented in a performant way, that is without either having to recalculate all the parent matrices or decomposing/recomposing the direct parent matrix each time we need it in a calculation. Or we would have to store the parent matrix in the child (which would probably come with its own problems)…

I think we would be open to add this feature, if someone can come up with a non-breaking performant way to implement it.

cc @sebavan

That’s a good point. I would need to look into the code which implements the normal parenting to see if there is a way to implement this. Additionally also limiting the parenting to only X, only Y etc. may also be a cool feature.
How does one add to Babylon? Can I just fork it and then use the downloaded version locally for changing and testing and then make a pull request from my source?

… another option would be to implement such code as a behaviour. Maybe then the expectations on performance would be slightly less high :wink:

We have a section in the doc repository, if you want to contribute code or doc:

1 Like

Thanks for the link!