UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in

77 lines (76 loc) 2.91 kB
import { type LifecycleMethod, LifecycleMethodOptions } from "./engine_lifecycle_functions_internal.js"; /** * Register a callback in the engine context created event. * This happens once per context (after the context has been created and the first content has been loaded) * @param cb The callback to be called * @returns A function that can be called to unregister the callback * @example * ```ts * onInitialized((ctx : Context) => { * // do something * } * ``` * */ export declare function onInitialized(cb: LifecycleMethod, opts?: LifecycleMethodOptions): () => void; /** * Register a callback before the engine context is cleared. * This happens if e.g. `<needle-engine src>` changes */ export declare function onClear(cb: LifecycleMethod, opts?: LifecycleMethodOptions): () => void; /** * Register a callback in the engine before the context is destroyed * This happens once per context (before the context is destroyed) */ export declare function onDestroy(cb: LifecycleMethod, opts?: LifecycleMethodOptions): () => void; /** Register a callback in the engine start event. * This happens at the beginning of each frame * @param cb The callback to be called * @returns A function that can be called to unregister the callback * @example * ```ts * onStart((ctx : Context) => { * // do something * } * ``` * */ export declare function onStart(cb: LifecycleMethod, opts?: LifecycleMethodOptions): () => void; /** Register a callback in the engine update event * This is called every frame * @param cb The callback to be called * @returns A function that can be called to unregister the callback * @example * ```ts * onUpdate((ctx : Context) => { * // do something * } * ``` * */ export declare function onUpdate(cb: LifecycleMethod, opts?: LifecycleMethodOptions): () => void; /** Register a callback in the engine onBeforeRender event * This is called every frame before the main camera renders * @param cb The callback to be called * @returns A function that can be called to unregister the callback * @example * ```ts * onBeforeRender((ctx : Context) => { * // do something * } * ``` * */ export declare function onBeforeRender(cb: LifecycleMethod, opts?: LifecycleMethodOptions): () => void; /** * Register a callback in the engine onAfterRender event * This is called every frame after the main camera has rendered * @param cb The callback to be called * @returns A function that can be called to unregister the callback * @example * ```ts * const unsubscribe = onAfterRender((ctx : Context) => { * // do something... * console.log("After render"); * // if you want to unsubscribe after the first call: * unsubscribe(); * }); * ``` */ export declare function onAfterRender(cb: LifecycleMethod, opts?: LifecycleMethodOptions): () => void;