@playcanvas/react
Version:
A React renderer for PlayCanvas – build interactive 3D applications using React's declarative paradigm.
21 lines (20 loc) • 828 B
TypeScript
import { Entity } from 'playcanvas';
import { PathPredicate } from '../utils/path-matcher.ts';
/**
* Hook to find entities by path relative to the current parent context
* Uses the unified PathMatcher for consistent syntax with Modify.Node
* @param path - String path or predicate function to match entities
* @returns The matched entity, array of entities (for wildcards), or null if not found
* @example
* ```tsx
* // Find by path
* const handEntity = useEntity('arm.hand');
* // Find by predicate
* const lightsEntity = useEntity((entity) => entity.c?.light !== undefined);
* // Find with wildcard
* const allChildren = useEntity('*');
* // Find with component filter
* const lights = useEntity('**[light]');
* ```
*/
export declare function useEntity(path: string | PathPredicate): Entity | Entity[] | null;