babbleon

ultimate parent of mesh

Recommended Posts

Hello,

Say I have ParentName > ChildName1 > ChildName2 > ChildName3, is there a quick way to have Babylon tell me the name of the ultimate parent, no matter which child I choose?

I can get immediate parent using...

scene.meshes[i].parent

... but I need to go right to the top.

Cheers,

Share this post


Link to post
Share on other sites

Cheers buddy!

This sorted it with a small tweak:

function getLastParent(target) {
	if (typeof target.parent != 'undefined') {
		if (target.parent.parent) {
			return getLastParent(target.parent);
		} else {
			return target.parent.name;
		}
	}
};

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.