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.

94 lines (93 loc) 3.19 kB
import type { Context } from "../engine_context.js"; import { NeedleXRSession } from "./NeedleXRSession.js"; export declare type XRSessionEventArgs = { session: NeedleXRSession; }; /** * Add a listener for when an XR session starts * This event is triggered when the XR session is started, either by the user or by the application before all other XR start events * @param fn The function to call when the XR session starts * @example * ```js * onXRSessionStart((evt) => { * console.log("XR session started", evt); * }); * ``` * @returns A function to remove the listener */ export declare function onXRSessionStart(fn: (evt: XRSessionEventArgs) => void): () => void; /** * Remove a listener for when an XR session starts * @param fn The function to remove from the listeners * @example * ```js * const myFunction = (evt) => { * console.log("XR session started", evt); * }; * onXRSessionStart(myFunction); * offXRSessionStart(myFunction); * ``` */ export declare function offXRSessionStart(fn: (evt: XRSessionEventArgs) => void): void; /** * Add a listener for when an XR session ends * This event is triggered when the XR session is ended, either by the user or by the application before all other XR end events * @param fn The function to call when the XR session ends * @example * ```js * onXRSessionEnd((evt) => { * console.log("XR session ended", evt); * }); * ``` * @returns A function to remove the listener */ export declare function onXRSessionEnd(fn: (evt: XRSessionEventArgs) => void): () => void; /** * Remove a listener for when an XR session ends * @param fn The function to remove from the listeners * @example * ```js * const myFunction = (evt) => { * console.log("XR session ended", evt); * }; * onXRSessionEnd(myFunction); * offXRSessionEnd(myFunction); * ``` */ export declare function offXRSessionEnd(fn: (evt: XRSessionEventArgs) => void): void; export declare type XRSessionRequestEventArgs = { readonly mode: XRSessionMode; readonly init: XRSessionInit; readonly context: Context; }; /** * Add a listener that fires before an XR session is requested. * Use this to modify the session init options, e.g. to add optional features like `camera-access`. * @param fn The function to call before the XR session is requested * @example * ```js * onBeforeXRSession((args) => { * args.init.optionalFeatures ??= []; * args.init.optionalFeatures.push("camera-access"); * }); * ``` * @return A function to remove the listener */ export declare function onBeforeXRSession(fn: (args: XRSessionRequestEventArgs) => void): () => void; /** * Remove a listener for before an XR session is requested * @param fn The function to remove from the listeners */ export declare function offBeforeXRSession(fn: (args: XRSessionRequestEventArgs) => void): void; /** * @internal * Invoke the XRSessionStart event * @param evt The XRSession event arguments */ export declare function invokeXRSessionStart(evt: XRSessionEventArgs): void; /** * @internal * Invoke the XRSessionEnd event * @param evt The XRSession event arguments */ export declare function invokeXRSessionEnd(evt: XRSessionEventArgs): void;