Skip to main content

Function: objectIsDescendantOf()

objectIsDescendantOf(child?, parent?): boolean

Defined in: src/utils/SceneGraphUtils.ts:16

Checks if a given object is a descendant of another object in the scene graph. This function is useful for determining if an interaction (like a raycast hit) has occurred on a component that is part of a larger, complex entity.

It uses an iterative approach to traverse up the hierarchy from the child.

Parameters

child?

The potential descendant object.

null | Readonly<Object3D<Object3DEventMap>>

parent?

The potential ancestor object.

null | Readonly<Object3D<Object3DEventMap>>

Returns

boolean

True if child is the same as parent or is a descendant of parent.