@osobh/reactar
Version:
AR Library for React Native and Expo
90 lines (89 loc) • 2.45 kB
TypeScript
import { EventEmitter } from 'events';
import { Anchor } from '../sensors/EnvironmentalDetection';
export interface CloudAnchor extends Anchor {
cloudId: string;
hostDeviceId: string;
timestamp: number;
}
export interface CloudAnchorOptions {
serverUrl?: string;
resolveTimeoutSeconds?: number;
}
export declare enum CloudAnchorState {
NONE = "NONE",
HOSTING = "HOSTING",
HOSTED = "HOSTED",
RESOLVING = "RESOLVING",
RESOLVED = "RESOLVED",
FAILED = "FAILED"
}
export declare class CloudAnchorManager extends EventEmitter {
private options;
private deviceId;
private hostedAnchors;
private resolvedAnchors;
private anchorStates;
constructor(options?: CloudAnchorOptions);
private generateDeviceId;
/**
* Returns the unique device identifier used for cloud anchor operations
*/
getDeviceId(): string;
/**
* Hosts a local anchor to the cloud, making it available for other devices
*/
hostAnchor(anchor: Anchor): Promise<CloudAnchor>;
/**
* Resolves a cloud anchor using its cloud ID
*/
resolveAnchor(cloudId: string): Promise<CloudAnchor>;
/**
* Updates an existing cloud anchor's position
*/
updateAnchor(cloudId: string, newPosition: {
x: number;
y: number;
z: number;
}): Promise<CloudAnchor>;
/**
* Removes a cloud anchor
*/
removeAnchor(cloudId: string): Promise<void>;
/**
* Gets all hosted anchors for the current device
*/
getHostedAnchors(): CloudAnchor[];
/**
* Gets all resolved anchors for the current device
*/
getResolvedAnchors(): CloudAnchor[];
/**
* Creates a new anchor with the specified position and rotation
*/
createAnchor(position: {
x: number;
y: number;
z: number;
}, rotation: {
x: number;
y: number;
z: number;
w: number;
}): Promise<Anchor>;
/**
* Hosts an anchor to the cloud service
*/
hostCloudAnchor(anchor: Anchor): Promise<string>;
/**
* Resolves a cloud anchor by its cloud identifier
*/
resolveCloudAnchor(cloudId: string): Promise<CloudAnchor>;
/**
* Deletes a cloud anchor
*/
deleteCloudAnchor(cloudId: string): Promise<boolean>;
/**
* Gets the current state of a cloud anchor
*/
getCloudAnchorState(cloudId: string): Promise<string>;
}