1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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<IWebXRFeature>;
- /**
- * Observers registered here will be executed when the feature is detached
- */
- onFeatureDetachObservable: Observable<IWebXRFeature>;
- /**
- * 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<T>(observable: Observable<T>, 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;
- }
|