import { Node } from "@babylonjs/core/node"; import { Scene } from "@babylonjs/core/scene"; import { Observer } from "@babylonjs/core/Misc/observable"; import { PointerInfo } from "@babylonjs/core/Events/pointerEvents"; import { KeyboardInfo } from "@babylonjs/core/Events/keyboardEvents"; import { IParticleSystem } from "@babylonjs/core/Particles/IParticleSystem"; import { IScript } from "../../script"; import { ScriptMap } from "../loader"; /** * @internal */ export declare function _applyScriptsForObject(scene: Scene, object: any, scriptsMap: ScriptMap, rootUrl: string): void; /** * Applies the given script constructor on the given object on the fly. * @param object defines the reference to the object on which the script must be applied. * @param scriptConstructor defines the constructor of the script to apply on the object. * @param scene defines the reference to the scene. If not provided, will try to get it from object.getScene() * @example * import { applyScriptOnObject } from "babylonjs-editor-tools"; * ... * const instance = applyScriptOnObject(mesh, MyScriptClass); */ export declare function applyScriptOnObject(object: any, scriptConstructor: new (...args: any) => any, scene?: Scene): any; export interface IRegisteredScript { /** * Defines the key of the script. Refer to scriptMap. */ key: string; /** * Defines the instance of the script that was created while loading the scene. */ instance: IScript; /** * Defines the dictionary of all registered observers for this script. */ observers: IRegisteredScriptObservers; } export interface IRegisteredScriptObservers { onStartObserver?: Observer | null; onUpdateObserver?: Observer | null; pointerObserver?: Observer | null; keyboardObserver?: Observer | null; } export declare const scriptsDictionary: Map; /** * When a scene is being loaded, scripts that were attached to objects in the scene using the Editor are processed. * This function registers the instance of scripts per object in order to retrieve them later. * @internal */ export declare function _registerScriptInstance(object: any, scriptInstance: IScript, key: string, observers: IRegisteredScriptObservers): void; /** * When a node is disposed, or for hot reload purpose, the script should be unregistered and all observers removed. * @internal */ export declare function _removeRegisteredScriptInstance(object: any, registeredScript: IRegisteredScript): void; /** * Returns all the instances of the script attached to the given object that matches the given class type. * The same script can be attached multiple times to the same object. If you ensure that ONLY DISTINCT scripts * are attached to the object, you can use `getScriptByClassForObject` which will return the unique instance for the given object. * @param object defines the reference to the object where the script to retrieve is attached to. * @param classType defines the class of the type to retrieve * @example * import { IScript, getAllScriptsByClassForObject } from "babylonjs-editor-tools"; * * class ScriptClass implements IScript { * public onStart(): void { * const instances = getAllScriptsByClassForObject(mesh, OtherScriptClass); * instances.forEach((i) => { * i.doSomething(); * }); * } * } * * class OtherScriptClass implements IScript { * public doSomething(): void { * console.log("Doing something!"); * } * } */ export declare function getAllScriptsByClassForObject any>(object: any, classType: T): InstanceType[]; /** * Returns the instance of the script attached to the given object that matches the given class type. * @param object defines the reference to the object where the script to retrieve is attached to. * @param classType defines the class of the type to retrieve * @example * import { IScript, getScriptByClassForObject } from "babylonjs-editor-tools"; * * class ScriptClass implements IScript { * public onStart(): void { * const instance = getScriptByClassForObject(mesh, OtherScriptClass); * instance.doSomething(); * } * } * * class OtherScriptClass implements IScript { * public doSomething(): void { * console.log("Doing something!"); * } * } */ export declare function getScriptByClassForObject any>(object: any, classType: T): NonNullable> | null;