type MapType = 'map' | 'map-set' | 'object-tracking'; interface IPosition { x: number; y: number; z: number; } interface IRotation { x: number; y: number; z: number; w: number; } interface ILocalizeResponse { poseFound: boolean; position: IPosition; rotation: IRotation; confidence: number; mapIds: string[]; mapCodes: string[]; responseTime: number; } interface IMapLocation { type: string; coordinates: [number, number, number]; _id: string; } interface ICameraIntrinsicsResponse { fx: number; fy: number; px: number; py: number; } interface IMeshInfo { type: string; meshLink: string; } interface IMapMesh { rawMesh: IMeshInfo; texturedMesh: IMeshInfo; } interface IResolution { width: number; height: number; } interface IMapSource { provider: string; fileType: string; coordinateSystem: string; } interface IGetMapsDetailsResponse { _id: string; accountId: string; mapName: string; location: IMapLocation; status: string; storage: number; createdAt: string; updatedAt: string; cameraIntrinsics: ICameraIntrinsicsResponse; mapMesh: IMapMesh; resolution: IResolution; globalFeature: string; mapCode: string; source: IMapSource; } interface IMapSetMapData { _id: string; order: number; relativePose: { position: { x: number; y: number; z: number; }; rotation: { qx: number; qy: number; qz: number; qw: number; }; }; createdAt: string; updatedAt: string; map: { _id: string; accountId: string; mapName: string; status: string; mapCode: string; thumbnail: string; storage: number; createdAt: string; updatedAt: string; mapMesh: { rawMesh: { type: string; meshLink: string; }; texturedMesh: { type: string; meshLink: string; }; }; coordinates: { latitude: number; longitude: number; altitude: number; }; offlineBundleStatus?: string; offlineBundle?: string; }; } interface IMapSetMapsResponse { mapSet: { _id: string; name: string; accountId: string; createdAt: string; updatedAt: string; status: string; mapSetData: IMapSetMapData[]; }; } interface ILocalizeAndMapDetails { localizeData: ILocalizeResponse; mapDetails?: IGetMapsDetailsResponse; } interface IObjectTrackingResponse { poseFound: boolean; position: IPosition; rotation: IRotation; confidence: number; objectCodes: string[]; } interface IMultisetClientConfigBase { clientId: string; clientSecret: string; endpoints?: Partial; /** Override handedness flag sent to the query endpoint. Defaults to true. */ isRightHanded?: boolean; } /** * Keeps passGeoPose and use2DFiltering in sync: use2DFiltering is only * valid when passGeoPose is true (it requires a geoHint to have any effect). */ type IGeoFilterConfig = { passGeoPose?: false; use2DFiltering?: never; } | { passGeoPose: true; use2DFiltering?: boolean; }; /** Config when targeting a single map. */ type IMultisetClientMapConfig = IMultisetClientConfigBase & IGeoFilterConfig & { mapType: 'map'; /** Map code used for localization. */ code: string; /** Convert localization result to geographic coordinates. */ convertToGeoCoordinates?: boolean; /** Optional position hint in local coordinates "x,y,z". */ hintPosition?: string; /** Optional spatial filter radius in metres (1–100). */ hintRadius?: number | string; hintMapCodes?: never; }; /** Config when targeting a map set. */ type IMultisetClientMapSetConfig = IMultisetClientConfigBase & IGeoFilterConfig & { mapType: 'map-set'; /** Map-set code used for localization. */ code: string; /** Convert localization result to geographic coordinates. */ convertToGeoCoordinates?: boolean; /** Optional position hint in local coordinates "x,y,z". */ hintPosition?: string; /** Optional spatial filter radius in metres (1–100). */ hintRadius?: number | string; /** Narrow candidate maps within the set by map code. */ hintMapCodes?: string[]; }; /** Config when running in object-tracking mode. No map code is required. */ type IMultisetClientObjectTrackingConfig = IMultisetClientConfigBase & { mapType: 'object-tracking'; /** Object codes to detect and track. */ code: string[]; }; type IMultisetClientConfig = IMultisetClientMapConfig | IMultisetClientMapSetConfig | IMultisetClientObjectTrackingConfig; interface IMultisetSdkEndpoints { authUrl: string; queryUrl: string; mapDetailsUrl: string; fileDownloadUrl: string; mapSetDetailsUrl: string; objectQueryUrl: string; objectDetailsUrl: string; } interface IFrameCaptureEvent { blob: Blob; width: number; height: number; } interface ICameraIntrinsicsEvent { fx: number; fy: number; px: number; py: number; width: number; height: number; } interface IPoseResultEvent { poseFound: boolean; position: { x: number; y: number; z: number; }; rotation: { x: number; y: number; z: number; w: number; }; mapIds: string[]; confidence?: number; } interface ILocalizeResultEvent { frame: IFrameCaptureEvent; intrinsics: ICameraIntrinsicsEvent; response: ILocalizeAndMapDetails | null; } declare const DEFAULT_ENDPOINTS: IMultisetSdkEndpoints; declare class MultisetClient { private readonly credentials; private readonly config; private readonly endpoints; private accessToken; private readonly mapDetailsCache; constructor(input: IMultisetClientConfig); get token(): string | null; get mapType(): IMultisetClientConfig['mapType']; get objectCodes(): string[]; authorize(): Promise; downloadFile(key: string): Promise; localizeWithFrame(frame: IFrameCaptureEvent, intrinsics: ICameraIntrinsicsEvent, options?: { fetchMapDetails?: boolean; }): Promise; trackObject(frame: IFrameCaptureEvent, intrinsics: ICameraIntrinsicsEvent): Promise; downloadObjectMesh(objectCode: string): Promise; private fetchObjectMeshKey; fetchMapDetails(mapCode: string): Promise; private apiFetch; private getGeoPoseComponents; private queryLocalization; } /** Column-major 4×4 matrix — same memory layout as WebXR and OpenGL. */ type Mat4 = Float32Array; interface IXRFrameEvent { time: number; frame: XRFrame; pose: XRViewerPose; view: XRView; viewport: XRViewport; baseLayer: XRWebGLLayer; referenceSpace: XRReferenceSpace; deltaSeconds: number; } interface IXRSessionOptions { client: MultisetClient; overlayRoot?: HTMLElement; /** Trigger one localization run automatically when the AR session starts. */ autoLocalize?: boolean; /** Re-localize whenever tracking is lost and then recovered. */ relocalization?: boolean; /** * Periodically send localization requests in the background to maintain or * improve the device's pose over time. Only active during an AR session. */ backgroundLocalization?: boolean; /** * Interval in seconds between background localization attempts. * Clamped to 10–180 s. Default `30` for VPS modes, `10` for object tracking. */ bgLocalizationInterval?: number; /** Only accept a result if confidence >= confidenceThreshold. */ confidenceCheck?: boolean; /** Minimum confidence (0.2–0.8). Default 0.5. */ confidenceThreshold?: number; /** Max ms to wait for a valid viewer pose before failing. Default 10000. */ poseTimeoutMs?: number; /** * @deprecated Use `poseTimeoutMs` instead. Will be removed in v3. */ localizationTrackingTimeoutMs?: number; /** Automatically call trackObjects() once when the AR session starts. */ autoTracking?: boolean; /** Re-attempt tracking whenever XR tracking is lost and then recovered. */ restartTracking?: boolean; /** Milliseconds to wait before capturing a frame when trackObjects() is called. Useful for camera stabilisation. Default 0. */ trackingCaptureDelayMs?: number; /** * XR reference space type. Default 'local' (always supported for immersive-ar). * Use 'local-floor' for floor-relative tracking if the device supports it. */ referenceSpaceType?: XRReferenceSpaceType; /** * Scale factor applied to the XR framebuffer relative to the device's native * resolution. Values < 1 reduce GPU load; values > 1 supersample. * Passed directly to XRWebGLLayer as framebufferScaleFactor. */ framebufferScaleFactor?: number; onSessionStart?: () => void; onSessionEnd?: () => void; onLocalizationInit?: () => void; /** Called after a successful localization. */ onLocalizationResult?: (result: ILocalizeAndMapDetails) => void; /** * @deprecated Use `onLocalizationResult` instead. If you are using `ThreeAdapter`, * use its `onLocalizationSuccess` which also provides the `worldFromMap` matrix. * Will be removed in v3. */ onLocalizationSuccess?: (result: ILocalizeAndMapDetails) => void; onLocalizationFailure?: (reason?: string) => void; onFrameCaptured?: (frame: IFrameCaptureEvent) => void; onCameraIntrinsics?: (intrinsics: ICameraIntrinsicsEvent) => void; onPoseResult?: (pose: IPoseResultEvent) => void; onObjectTrackingInit?: () => void; onObjectTrackingRequested?: (frame: IFrameCaptureEvent, intrinsics: ICameraIntrinsicsEvent) => void; onObjectTrackingSuccess?: (result: IObjectTrackingResponse) => void; onObjectTrackingFailure?: (reason?: string) => void; onError?: (error: unknown) => void; /** Called when the WebGL context is lost. The active session is ended automatically. */ onContextLost?: () => void; /** Called when the WebGL context is restored. The user may restart the session. */ onContextRestored?: () => void; } declare class XRSessionManager { private readonly gl; private readonly options; private session; private referenceSpace; private baseLayer; private xrBinding; private lastFrameTime; private trackingLossFrames; private hadTrackingLoss; private _isLocalizing; private trackerSpace; private bgLocalizationTimer; private arButton; private xrFrameHandler; private adapterResultHandler; private adapterObjectTrackingHandler; private adapterSessionStartHandler; private adapterSessionEndHandler; constructor(gl: WebGL2RenderingContext, options: IXRSessionOptions); /** Returns true if the browser supports immersive-ar WebXR sessions. */ static isSupported(): Promise; setXRFrameHandler(handler: (event: IXRFrameEvent) => void): void; setAdapterResultHandler(handler: (result: ILocalizeAndMapDetails, trackerSpace: Mat4) => void): void; setAdapterObjectTrackingHandler(handler: (result: IObjectTrackingResponse, trackerSpace: Mat4) => void): void; setAdapterSessionHandlers(onStart: () => void, onEnd: () => void): void; getClient(): MultisetClient; getOverlayRoot(): HTMLElement | undefined; isActive(): boolean; get isLocalizing(): boolean; stopSession(): void; getBaseLayer(): XRWebGLLayer | null; createButton(): HTMLButtonElement; startSession(): Promise; private initSession; private startBackgroundLocalization; private handleSessionEnd; private readonly handleContextLost; private readonly handleContextRestored; private xrLoop; localizeFrame(): Promise; private captureFrame; trackObjects(): Promise; private captureFrameAndTrack; dispose(): void; } export { DEFAULT_ENDPOINTS, type ICameraIntrinsicsEvent, type IFrameCaptureEvent, type IGetMapsDetailsResponse, type ILocalizeAndMapDetails, type ILocalizeResponse, type ILocalizeResultEvent, type IMapSetMapsResponse, type IMultisetClientConfig, type IMultisetSdkEndpoints, type IObjectTrackingResponse, type IPoseResultEvent, type IXRFrameEvent, type IXRSessionOptions, type MapType, MultisetClient, XRSessionManager };