/** * AR Anchors and Persistent AR Experiences * * This module enables anchoring AR content to real-world positions that can * persist across app sessions and be shared between devices. */ /** * Types of anchors that can be created */ export declare enum ARAnchorType { /** * Basic anchor attached to a point in 3D space */ POINT = "point", /** * Anchor attached to a detected plane */ PLANE = "plane", /** * Anchor attached to a detected image */ IMAGE = "image", /** * Anchor attached to a geographic location (requires GPS) */ GEO = "geo", /** * Anchor that can be shared with other devices */ CLOUD = "cloud" } /** * Persistence level for anchors */ export declare enum ARPersistenceLevel { /** * Anchor only exists in the current AR session */ SESSION = "session", /** * Anchor persists across app restarts on this device */ DEVICE = "device", /** * Anchor can be shared with other devices and persists in the cloud */ CLOUD = "cloud" } /** * Base interface for all anchor types */ export interface ARAnchorBase { /** * Unique identifier for the anchor */ id: string; /** * The type of anchor */ type: ARAnchorType; /** * Persistence level of the anchor */ persistenceLevel: ARPersistenceLevel; /** * Position of the anchor in world space */ position: { x: number; y: number; z: number; }; /** * Rotation of the anchor in radians */ rotation: { x: number; y: number; z: number; }; /** * When the anchor was created */ createdAt: number; /** * Last time the anchor was updated */ updatedAt: number; /** * User-defined metadata for this anchor */ metadata?: Record; } /** * Point anchor, attached to a specific point in 3D space */ export interface ARPointAnchor extends ARAnchorBase { type: ARAnchorType.POINT; } /** * Plane anchor, attached to a detected plane */ export interface ARPlaneAnchor extends ARAnchorBase { type: ARAnchorType.PLANE; /** * Dimensions of the detected plane */ dimensions: { width: number; height: number; }; /** * Normal vector of the plane */ normal: { x: number; y: number; z: number; }; } /** * Image anchor, attached to a detected reference image */ export interface ARImageAnchor extends ARAnchorBase { type: ARAnchorType.IMAGE; /** * Name of the reference image */ imageName: string; /** * Physical size of the image in meters */ physicalSize: { width: number; height: number; }; } /** * Geographic anchor, attached to a real-world location */ export interface ARGeoAnchor extends ARAnchorBase { type: ARAnchorType.GEO; /** * Coordinates of the anchor */ coordinate: { latitude: number; longitude: number; altitude?: number; }; /** * Accuracy of the geo location in meters */ accuracy?: number; } /** * Cloud anchor that can be shared with other devices */ export interface ARCloudAnchor extends ARAnchorBase { type: ARAnchorType.CLOUD; /** * Cloud identifier for the anchor */ cloudIdentifier: string; /** * Whether the cloud anchor is currently being hosted */ isHosting: boolean; /** * Anchor hosting/resolving state */ cloudState: ARCloudAnchorState; /** * Time-to-live for the cloud anchor in seconds * Default: 24 hours */ ttlSeconds?: number; } /** * State of a cloud anchor */ export declare enum ARCloudAnchorState { NONE = "none", TASK_IN_PROGRESS = "taskInProgress", HOSTING_SUCCESS = "hostingSuccess", HOSTING_ERROR = "hostingError", RESOLVING_SUCCESS = "resolvingSuccess", RESOLVING_ERROR = "resolvingError" } /** * Options for creating a new anchor */ export interface ARCreateAnchorOptions { /** * Position for the anchor in world space */ position: { x: number; y: number; z: number; }; /** * Rotation for the anchor in radians */ rotation?: { x: number; y: number; z: number; }; /** * Persistence level for the anchor * @default ARPersistenceLevel.SESSION */ persistenceLevel?: ARPersistenceLevel; /** * Custom metadata to attach to the anchor */ metadata?: Record; } /** * Options for creating a new plane anchor */ export interface ARCreatePlaneAnchorOptions extends ARCreateAnchorOptions { /** * Dimensions of the plane */ dimensions: { width: number; height: number; }; /** * Normal vector of the plane */ normal: { x: number; y: number; z: number; }; } /** * Options for creating a new geo anchor */ export interface ARCreateGeoAnchorOptions extends ARCreateAnchorOptions { /** * Coordinates for the anchor */ coordinate: { latitude: number; longitude: number; altitude?: number; }; } /** * Options for creating a cloud anchor */ export interface ARCreateCloudAnchorOptions extends ARCreateAnchorOptions { /** * Time-to-live for the cloud anchor in seconds * @default 86400 (24 hours) */ ttlSeconds?: number; } /** * Options for hosting a cloud anchor */ export interface ARHostCloudAnchorOptions { /** * ID of the anchor to host in the cloud */ anchorId: string; /** * Time-to-live for the cloud anchor in seconds * @default 86400 (24 hours) */ ttlSeconds?: number; /** * Custom metadata to attach to the cloud anchor */ metadata?: Record; } /** * Options for resolving a cloud anchor */ export interface ARResolveCloudAnchorOptions { /** * Cloud identifier of the anchor to resolve */ cloudIdentifier: string; } /** * Event for anchor updates */ export interface ARAnchorUpdateEvent { /** * The anchor that was updated */ anchor: ARAnchorBase; /** * Type of update that occurred */ updateType: 'added' | 'updated' | 'removed'; } /** * Event for cloud anchor state changes */ export interface ARCloudAnchorEvent { /** * Cloud anchor that changed */ anchor: ARCloudAnchor; /** * The new state of the cloud anchor */ state: ARCloudAnchorState; /** * Error message if hosting/resolving failed */ errorMessage?: string; } /** * Options for anchor finding */ export interface ARFindAnchorsOptions { /** * Types of anchors to find */ types?: ARAnchorType[]; /** * Maximum distance in meters from the specified position */ maxDistance?: number; /** * Only return anchors with this persistence level */ persistenceLevel?: ARPersistenceLevel; } /** * Class that handles AR anchors for persistent experiences */ export declare class ARAnchorManager { /** * Creates a new point anchor at the given position * @param options Options for creating the anchor * @returns Promise that resolves to the created anchor's ID */ static createAnchor(options: ARCreateAnchorOptions): Promise; /** * Creates a new plane anchor * @param options Options for creating the plane anchor * @returns Promise that resolves to the created anchor's ID */ static createPlaneAnchor(options: ARCreatePlaneAnchorOptions): Promise; /** * Creates a new geo anchor * @param options Options for creating the geo anchor * @returns Promise that resolves to the created anchor's ID */ static createGeoAnchor(options: ARCreateGeoAnchorOptions): Promise; /** * Creates a new cloud anchor * @param options Options for creating the cloud anchor * @returns Promise that resolves to the created anchor's ID */ static createCloudAnchor(options: ARCreateCloudAnchorOptions): Promise; /** * Hosts an existing anchor in the cloud so it can be shared * @param options Options for hosting the cloud anchor * @returns Promise that resolves to the cloud identifier once hosting is successful */ static hostCloudAnchor(options: ARHostCloudAnchorOptions): Promise; /** * Resolves a cloud anchor from its cloud identifier * @param options Options for resolving the cloud anchor * @returns Promise that resolves to the anchor ID once resolving is successful */ static resolveCloudAnchor(options: ARResolveCloudAnchorOptions): Promise; /** * Gets an anchor by its ID * @param anchorId ID of the anchor to get * @returns Promise that resolves to the anchor */ static getAnchor(anchorId: string): Promise; /** * Updates an existing anchor * @param anchorId ID of the anchor to update * @param properties Properties to update * @returns Promise that resolves when the update is complete */ static updateAnchor(anchorId: string, properties: Partial<{ position: { x: number; y: number; z: number; }; rotation: { x: number; y: number; z: number; }; metadata: Record; }>): Promise; /** * Removes an anchor * @param anchorId ID of the anchor to remove * @returns Promise that resolves when the anchor is removed */ static removeAnchor(anchorId: string): Promise; /** * Gets all anchors with optional filtering * @param options Options for filtering anchors * @returns Promise that resolves to an array of anchors */ static getAllAnchors(options?: { types?: ARAnchorType[]; persistenceLevel?: ARPersistenceLevel; }): Promise; /** * Finds anchors near a specified position * @param position Position to search around * @param options Options for finding anchors * @returns Promise that resolves to an array of anchors sorted by distance */ static findAnchorsNearPosition(position: { x: number; y: number; z: number; }, options?: ARFindAnchorsOptions): Promise; /** * Attaches an object to an anchor * @param objectId ID of the object to attach * @param anchorId ID of the anchor to attach to * @param offsetPosition Optional position offset relative to anchor * @param offsetRotation Optional rotation offset relative to anchor * @returns Promise that resolves when the object is attached */ static attachObjectToAnchor(objectId: string, anchorId: string, offsetPosition?: { x: number; y: number; z: number; }, offsetRotation?: { x: number; y: number; z: number; }): Promise; /** * Detaches an object from its anchor * @param objectId ID of the object to detach * @returns Promise that resolves when the object is detached */ static detachObjectFromAnchor(objectId: string): Promise; /** * Gets the anchor ID attached to an object * @param objectId ID of the object * @returns Promise that resolves to the anchor ID or null if not attached */ static getObjectAnchorId(objectId: string): Promise; /** * Gets all objects attached to an anchor * @param anchorId ID of the anchor * @returns Promise that resolves to an array of object IDs */ static getAnchorAttachedObjects(anchorId: string): Promise; /** * Shares an AR experience with another device * This creates a shareable data package containing anchors and object placements * @param options Options for sharing the experience * @returns Promise that resolves to a sharing code that can be used by another device */ static shareExperience(options: { anchorIds?: string[]; includeAllCloudAnchors?: boolean; includeAllLocalAnchors?: boolean; includeAttachedObjects?: boolean; metadata?: Record; ttlSeconds?: number; }): Promise; /** * Restores a shared AR experience * @param sharingCode Code obtained from shareExperience * @returns Promise that resolves to an array of restored anchor IDs */ static restoreSharedExperience(sharingCode: string): Promise<{ anchorIds: string[]; metadata?: Record; }>; /** * Imports a serialized AR experience * @param serializedData Serialized data containing anchors and objects * @returns Promise that resolves to an array of imported anchor IDs */ static importExperience(serializedData: string): Promise<{ anchorIds: string[]; metadata?: Record; }>; /** * Exports an AR experience to serialized data * @param options Options for exporting the experience * @returns Promise that resolves to serialized data */ static exportExperience(options: { anchorIds?: string[]; includeAllAnchors?: boolean; includeAttachedObjects?: boolean; metadata?: Record; }): Promise; /** * Saves all persistent anchors to storage * @returns Promise that resolves when anchors are saved */ static saveAnchors(): Promise; /** * Loads persistent anchors from storage * @returns Promise that resolves to an array of loaded anchor IDs */ static loadAnchors(): Promise; /** * Clears all persistent anchors from storage * @returns Promise that resolves when anchors are cleared */ static clearSavedAnchors(): Promise; /** * Helper method to convert raw anchor data from native module to typed anchor objects * @param data Raw anchor data * @returns Typed anchor object */ private static parseAnchorData; } //# sourceMappingURL=ARAnchors.d.ts.map