@osobh/reactar
Version:
AR Library for React Native and Expo
86 lines (85 loc) • 2.26 kB
TypeScript
import { EventEmitter } from 'events';
import { CloudAnchor } from './CloudAnchorManager';
export interface ARSessionOptions {
cameraType?: 'front' | 'back';
enablePlaneDetection?: boolean;
enableCloudAnchors?: boolean;
enableMultiUser?: boolean;
cloudAnchorOptions?: {
serverUrl?: string;
resolveTimeoutSeconds?: number;
};
userSessionOptions?: {
serverUrl?: string;
heartbeatInterval?: number;
inactivityTimeout?: number;
};
}
export declare enum ARSessionState {
UNINITIALIZED = "UNINITIALIZED",
INITIALIZED = "INITIALIZED",
RUNNING = "RUNNING",
PAUSED = "PAUSED",
STOPPED = "STOPPED"
}
export declare class ARSession extends EventEmitter {
private state;
private options;
private cloudAnchorManager;
private userSessionManager;
constructor(options?: ARSessionOptions);
/**
* Initializes the AR session:
* - Requests camera permissions.
* - Prepares configuration based on options.
*/
initialize(): Promise<void>;
/**
* Starts the AR session if it is properly initialized.
*/
start(): void;
/**
* Pauses the AR session, suspending rendering and sensor updates.
*/
pause(): void;
/**
* Resumes the AR session if it is paused.
*/
resume(): void;
/**
* Hosts a local anchor to the cloud
*/
hostCloudAnchor(anchor: any): Promise<CloudAnchor>;
/**
* Resolves a cloud anchor by its ID
*/
resolveCloudAnchor(cloudId: string): Promise<CloudAnchor>;
/**
* Updates a cloud anchor's position
*/
updateCloudAnchor(cloudId: string, newPosition: {
x: number;
y: number;
z: number;
}): Promise<CloudAnchor>;
/**
* Removes a cloud anchor
*/
removeCloudAnchor(cloudId: string): Promise<void>;
/**
* Gets all hosted cloud anchors
*/
getHostedCloudAnchors(): CloudAnchor[];
/**
* Gets all resolved cloud anchors
*/
getResolvedCloudAnchors(): CloudAnchor[];
/**
* Stops the AR session and cleans up resources.
*/
stop(): void;
/**
* Returns the current state of the AR session.
*/
getState(): ARSessionState;
}