Skip to content

Instantly share code, notes, and snippets.

@JacobMuchow
Created June 27, 2022 22:02
Show Gist options
  • Save JacobMuchow/8d3260247fc14e77c0e355bbeafe6474 to your computer and use it in GitHub Desktop.
Save JacobMuchow/8d3260247fc14e77c0e355bbeafe6474 to your computer and use it in GitHub Desktop.
three.js morph target utility
const object3DChildNamed = (object, name, { recursive = false } = {})
if (!recursive) {
return object.children.find(child => child.name === name)
}
for (const child of object.children) {
if (child.name === name) return child
if (child.children.length > 0) {
const found = object3DChildNamed(child, name, { recursive })
if (found) return found
}
}
return undefined
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment