import type { IWebXRFeature } from "../webXRFeaturesManager"; import type { EventState } from "../../Misc/observable"; import { Observable } from "../../Misc/observable"; import type { WebXRSessionManager } from "../webXRSessionManager"; /** * This is the base class for all WebXR features. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class */ export declare abstract class WebXRAbstractFeature implements IWebXRFeature { protected _xrSessionManager: WebXRSessionManager; private _attached; private _removeOnDetach; /** * Is this feature disposed? */ isDisposed: boolean; /** * Should auto-attach be disabled? */ disableAutoAttach: boolean; protected _xrNativeFeatureName: string; /** * The name of the native xr feature name (like anchor, hit-test, or hand-tracking) */ get xrNativeFeatureName(): string; set xrNativeFeatureName(name: string); /** * Observers registered here will be executed when the feature is attached */ onFeatureAttachObservable: Observable; /** * Observers registered here will be executed when the feature is detached */ onFeatureDetachObservable: Observable; /** * The dependencies of this feature, if any */ dependsOn?: string[]; /** * Construct a new (abstract) WebXR feature * @param _xrSessionManager the xr session manager for this feature */ constructor(_xrSessionManager: WebXRSessionManager); /** * Is this feature attached */ get attached(): boolean; /** * attach this feature * * @param force should attachment be forced (even when already attached) * @returns true if successful, false is failed or already attached */ attach(force?: boolean): boolean; /** * detach this feature. * * @returns true if successful, false if failed or already detached */ detach(): boolean; /** * Dispose this feature and all of the resources attached */ dispose(): void; /** * This function will be executed during before enabling the feature and can be used to not-allow enabling it. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it * * @returns whether or not the feature is compatible in this environment */ isCompatible(): boolean; /** * This is used to register callbacks that will automatically be removed when detach is called. * @param observable the observable to which the observer will be attached * @param callback the callback to register * @param insertFirst should the callback be executed as soon as it is registered */ protected _addNewAttachObserver(observable: Observable, callback: (eventData: T, eventState: EventState) => void, insertFirst?: boolean): void; /** * Code in this function will be executed on each xrFrame received from the browser. * This function will not execute after the feature is detached. * @param _xrFrame the current frame */ protected abstract _onXRFrame(_xrFrame: XRFrame): void; }