Three.js: Is there any reason why Object3D.traverseAncestors is not called on this, unlike Object3D.traverse ?

Created on 1 Jun 2020  路  7Comments  路  Source: mrdoob/three.js

I expected Object3D.traverseAncestors to behave like Object3D.traverse in this regard. Has it been done like this intentionally for some reason ?

If you want I can add callback( this ); here :
https://github.com/mrdoob/three.js/blob/6400f2c9b6ee58e01c005a66f00c7cd1113752aa/src/core/Object3D.js#L494

Although it could potentially break a lot of things for such a trivial benefit...

Question

All 7 comments

I guess this was done intentional. As the name implies, Object3D.traverseAncestors() only executes the callback on all ancestors. Object3D.traverse() for the object itself and all descendants. This assumption seems logical to me (otherwise Object3D.traverse() should be renamed to Object3D.traverseDescendants()).

Your interpretation of the method is of course valid, too. But I would not change the semantics of this method now.

Your interpretation of the method is of course valid, too.

I do not think it is. An object is not an ancestor of itself.

That is the reason why it is not traversed.

Yes is does make sense according to the semantic of "ancestors". I just expected the two methods to have mirror behaviours, independently of their semantics. Anyway it was just a question, you can close the issue if you want.

Okay 馃槆 .

Yes is does make sense according to the semantic of "ancestors".

Sorry, it does not. An object is not an ancestor of itself. The method is correct as written.

See https://en.wikipedia.org/wiki/Tree_structure.

Yes is does make sense according to the semantic of "ancestors".

This sentence actually meant that I agree that the current behaviour does make sense according the semantic of "ancestors".

@felixmariotto I've made the experience that other users were confused by traverseAncestors(), too 馃槄 . They thought the method just changes the direction of the traversal but apart from that behaves identical.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Horray picture Horray  路  3Comments

boyravikumar picture boyravikumar  路  3Comments

danieljack picture danieljack  路  3Comments

fuzihaofzh picture fuzihaofzh  路  3Comments

yqrashawn picture yqrashawn  路  3Comments