import { Matrix } from "@galacean/engine-math"; import { BoolUpdateFlag } from "./BoolUpdateFlag"; import { Component } from "./Component"; import { Engine } from "./Engine"; import { Layer } from "./Layer"; import { Scene } from "./Scene"; import { Transform } from "./Transform"; import { EngineObject } from "./base"; /** * Entity, be used as components container. */ export declare class Entity extends EngineObject { /** The name of entity. */ name: string; /** The layer the entity belongs to. */ layer: Layer; private _transform; private _templateResource; private _parent; private _activeChangedComponents; private _modifyFlagManager; /** * The transform of this entity. */ get transform(): Transform; /** * Whether to activate locally. */ get isActive(): boolean; set isActive(value: boolean); /** * Whether it is active in the hierarchy. */ get isActiveInHierarchy(): boolean; /** * The parent entity. */ get parent(): Entity; set parent(value: Entity); /** * The children entities */ get children(): Readonly; /** * @deprecated Please use `children.length` property instead. * Number of the children entities */ get childCount(): number; /** * The scene the entity belongs to. */ get scene(): Scene; /** * The sibling index. */ get siblingIndex(): number; set siblingIndex(value: number); /** * Create a entity. * @param engine - The engine the entity belongs to * @param name - The name of the entity * @param components - The types of components you wish to add */ constructor(engine: Engine, name?: string, ...components: ComponentConstructor[]); /** * Add component based on the component type. * @param type - The type of the component * @param args - The arguments of the component * @returns The component which has been added */ addComponent(type: T, ...args: ComponentArguments): InstanceType; /** * Get component which match the type. * @param type - The type of the component * @returns The first component which match type */ getComponent(type: ComponentConstructor): T | null; /** * Get components which match the type. * @param type - The type of the component * @param results - The components which match type * @returns The components which match type */ getComponents(type: ComponentConstructor, results: T[]): T[]; /** * Get the components which match the type of the entity and it's children. * @param type - The component type * @param results - The components collection * @returns The components collection which match the type */ getComponentsIncludeChildren(type: ComponentConstructor, results: T[]): T[]; /** * Add child entity. * @param child - The child entity which want to be added */ addChild(child: Entity): void; /** * Add child entity at specified index. * @param index - specified index * @param child - The child entity which want to be added */ addChild(index: number, child: Entity): void; /** * Remove child entity. * @param child - The child entity which want to be removed */ removeChild(child: Entity): void; /** * @deprecated Please use `children` property instead. * Find child entity by index. * @param index - The index of the child entity * @returns The component which be found */ getChild(index: number): Entity; /** * Find entity by name. * @param name - The name of the entity which want to be found * @returns The component which be found */ findByName(name: string): Entity; /** * Find the entity by path. * @param path - The path of the entity eg: /entity * @returns The component which be found */ findByPath(path: string): Entity; /** * Create child entity. * @param name - The child entity's name * @returns The child entity */ createChild(name?: string): Entity; /** * Clear children entities. */ clearChildren(): void; /** * Clone this entity include children and components. * @returns Cloned entity */ clone(): Entity; /** * Listen for changes in the world pose of this `Entity`. * @returns Change flag */ registerWorldChangeFlag(): BoolUpdateFlag; private _createCloneEntity; private _parseCloneEntity; /** * Destroy self. */ destroy(): void; private _dispatchModify; private _addToChildrenList; private _setParent; private _getComponentsInChildren; private _setActiveComponents; private _setActiveInHierarchy; private _setInActiveInHierarchy; private _setSiblingIndex; private _setTransform; private _invModelMatrix; private _inverseWorldMatFlag; /** * @deprecated */ getInvModelMatrix(): Matrix; } export type ComponentArguments Component> = T extends new (entity: Entity, ...args: infer P) => Component ? P : never; export type ComponentConstructor = new (entity: Entity, ...args: any[]) => T;