import { AViewerPluginEventMap, AViewerPluginSync, ThreeViewer } from '../../viewer'; import { IObject3D } from '../../core'; import { ComponentJSON, Object3DComponent, TObject3DComponent } from './components'; export type FunctionPropertyNames = { [K in keyof T]: T[K] extends (((...args: any[]) => any) | undefined) ? K : never; }[keyof T] & string; export interface EntityComponentPluginEventMap extends AViewerPluginEventMap { registerComponent: { component: Object3DComponent; object: IObject3D; }; unregisterComponent: { component: Object3DComponent; object: IObject3D; }; addComponentType: { cls: TObject3DComponent; }; removeComponentType: { cls: TObject3DComponent; }; } /** * Entity Component Framework plugin for threepipe. * Allows attaching reusable components to IObject3D instances. * Components can have their own serializable/runtime state, lifecycle methods, and update logic. * Components are defined as classes extending Object3DComponent. * * This system is not documented at the moment. */ export declare class EntityComponentPlugin extends AViewerPluginSync { static readonly PluginType = "EntityComponentPlugin"; enabled: boolean; protected _running: boolean; get running(): boolean; start(): void; stop(): void; componentsDispatch>(type: T, ...args: Parameters>): any[][]; private readonly _components; private _typeToComponents; readonly componentTypes: Map; static readonly ObjectToComponents: WeakMap; static ObjectDispatch>(object: IObject3D, type: T, ...args: Parameters>): any[][]; static ComponentsDispatch>(comps: Object3DComponent[], type: T, args: Parameters>): any[][]; static UserDataKey: string; constructor(running?: boolean); addComponentType(type: TObject3DComponent): boolean; removeComponentType(type: TObject3DComponent): boolean; hasComponentType(type: TObject3DComponent | string): boolean; private _onRemove; onAdded(viewer: ThreeViewer): void; private _preFrame; onRemove(viewer: ThreeViewer): void; static GetObjectData(obj: IObject3D): Record | null; /** * Add a component to an object * @param obj - Target object * @param stateOrType - Component state json or type string or component class * @param id - Optional component id, if not provided a random uuid will be generated * @returns Undo/redo action, added component is in action.component */ addComponent(obj: IObject3D, stateOrType: ComponentJSON | string | T, id?: string): { undo: () => void; redo: () => void; component: InstanceType; }; /** * Remove a component from an object * @param obj * @param id */ removeComponent(obj: IObject3D, id: string): { state: Record | null | undefined; undo: () => void; redo: () => void; } | undefined; static GetComponentData(obj: IObject3D, type: string | T): ({ id: string; } & ComponentJSON) | null; static GetComponents(obj: IObject3D, type?: string | T): InstanceType[]; static GetComponent(obj: IObject3D, type: string | T): InstanceType | null; static GetComponentInParent(object: IObject3D, type: string | T): InstanceType | null; static GetComponentsInParent(object: IObject3D, type: string | T): InstanceType[]; /** * Get all components of a specific type from the plugin instance * @param type - The component type (string or class) * @returns Array of components matching the specified type */ getComponentsOfType(type: string | T): InstanceType[]; /** * Get the first component of a specific type from the plugin instance * @param type - The component type (string or class) * @returns The first component matching the specified type, or null if not found */ getComponentOfType(type: string | T): InstanceType | null; registerComponent(obj: IObject3D, state: ComponentJSON, id?: string): Object3DComponent | null; unregisterComponent(comp: Object3DComponent): Record | null | undefined; static AddObjectUiConfig: boolean; private _objectAdd; private _objectRemove; private _objectUpdate; } export declare const ECS: typeof EntityComponentPlugin; declare module '../../core/IObject' { interface IObject3D { /** * Get a component attached to this object or in its parent hierarchy, or get a component of the specified type from the global registry. * This method is added by EntityComponentPlugin when the object is added to the scene. * @param type - The component type (string or class) * @param self - If true, only search this object; if false, search parents and global registry * @returns The component instance if found, or null */ getComponent?(type: T | string, self?: boolean): InstanceType | null; } } //# sourceMappingURL=../../src/plugins/extras/EntityComponentPlugin.d.ts.map