Core Usage
Use XRSessionManager with any WebGL2 renderer without Three.js
Setup
import { MultisetClient, XRSessionManager } from '@multisetai/vps/core';
const client = new MultisetClient({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
mapType: 'map',
code: 'MAP_XXXXXXXXXX',
});
await client.authorize();Create the Session Manager
const canvas = document.getElementById('canvas') as HTMLCanvasElement;
const gl = canvas.getContext('webgl2')!;
const session = new XRSessionManager(gl, {
client,
autoLocalize: true,
onSessionStart: () => {
console.log('AR session started');
},
onSessionEnd: () => {
console.log('AR session ended');
},
onLocalizationResult: (result) => {
const { position, rotation, confidence } = result.localizeData;
console.log('Pose found:', position, rotation, 'confidence:', confidence);
},
onLocalizationFailure: (reason) => {
console.warn('Localization failed:', reason);
},
onError: (error) => {
console.error('Session error:', error);
},
});Handle XR Frames
Mount the AR Button
Handle Localization Results
Manual Localization
Cleanup
Checking Support
Last updated
Was this helpful?

