Function getComponentEntityTree

  • Get an iterator of entities that follow a tree structure for a component

    Returns

    An iterator of an array as [entity, entity2, ...]

    Example:

    const TreeComponent = engine.defineComponent('custom::TreeComponent', {
    label: Schemas.String,
    parent: Schemas.Entity
    })

    for (const entity of getComponentEntityTree(engine, entity, TreeComponent)) {
    // entity in the tree
    }

    Type Parameters

    • T

    Parameters

    • engine: Pick<IEngine, "getEntitiesWith">

      the engine running the entities

    • entity: Entity

      the root entity of the tree

    • component: ComponentDefinition<T & {
          parent?: Entity;
      }>

      the parenting component to filter by

    Returns Generator<Entity>