@playcanvas/react
Version:
A React renderer for PlayCanvas – build interactive 3D applications using React's declarative paradigm.
59 lines (58 loc) • 1.84 kB
TypeScript
import { Entity } from 'playcanvas';
/**
* PathMatcher utility for matching entity paths in the GLTF hierarchy.
* Supports:
* - Exact paths: "head.arm.hand"
* - Single-level wildcards: "head.arm.*"
* - Multi-level wildcards: "head.arm.**"
* - Component filters: "[light]"
* - Combined queries: "head.*[light]"
*/
export interface PathMatcherOptions {
caseSensitive?: boolean;
}
export interface EntityMetadata {
entity: Entity;
path: string;
guid: string;
name: string;
originalChildGUIDs: string[];
}
export type PathPredicate = (entity: Entity, metadata: EntityMetadata) => boolean;
export declare class PathMatcher {
private caseSensitive;
constructor(options?: PathMatcherOptions);
/**
* Normalizes a path for comparison
*/
private normalizePath;
/**
* Checks if a path matches a pattern
*/
match(pattern: string, entityPath: string, entity: Entity): boolean;
/**
* Matches a path against a pattern with wildcards
* Handles exact paths, single-level wildcards (*), and multi-level wildcards (**)
*/
private matchPath;
/**
* Calculates specificity score for a pattern (used for conflict resolution)
*/
getSpecificity(pattern: string | PathPredicate): number;
/**
* Finds all entities matching a pattern in a hierarchy
*/
findMatching(pattern: string | PathPredicate, hierarchyCache: Map<string, EntityMetadata>): EntityMetadata[];
/**
* Checks if a pattern matches an entity
*/
matches(pattern: string | PathPredicate, metadata: EntityMetadata): boolean;
/**
* Resolves a path relative to a parent path
*/
resolvePath(parentPath: string, relativePath: string): string;
}
/**
* Default path matcher instance
*/
export declare const defaultPathMatcher: PathMatcher;