Finding transformNodes

Does an existing method exist to find a transformNode of a bunch of meshes / assets parented to it in the scenegraph that are nested up to x levels deep?

Or in general how do I instance up the hearchy searching for the nearest typeOf…mesh…transformnode… light, ext…, in hearchy?

just strait recursion or is there a better way or existing method?


+mesh <-- if here I can cheat by calling .parent
–mesh <-- if here, how do I navigate to tnode?
--------mesh <-- What if I don’t know how many level’s deep a mesh is in tree, and I just want to find the closest transformNode?


Recursion is the way :slightly_smiling_face:
Something like:

var getAscendantOfClass = function(className) {
        if (!this.parent) {
            return null;

        if (this.parent.getClassName() === className) {
            return this.parent;

        return this.parent.getAscendantOfClass(className);
1 Like