@onirix/ar-engine-sdk 1.6.3 → 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  !("requestVideoFrameCallback"in HTMLVideoElement.prototype)&&"getVideoPlaybackQuality"in HTMLVideoElement.prototype&&(HTMLVideoElement.prototype._rvfcpolyfillmap={},HTMLVideoElement.prototype.requestVideoFrameCallback=function(e){const t=performance.now(),i=this.getVideoPlaybackQuality(),a=this.mozPresentedFrames||this.mozPaintedFrames||i.totalVideoFrames-i.droppedVideoFrames,o=(l,r)=>{const m=this.getVideoPlaybackQuality(),s=this.mozPresentedFrames||this.mozPaintedFrames||m.totalVideoFrames-m.droppedVideoFrames;if(s>a){const a=this.mozFrameDelay||m.totalFrameDelay-i.totalFrameDelay||0,o=r-l;e(r,{presentationTime:r+1e3*a,expectedDisplayTime:r+o,width:this.videoWidth,height:this.videoHeight,mediaTime:Math.max(0,this.currentTime||0)+o/1e3,presentedFrames:s,processingDuration:a}),delete this._rvfcpolyfillmap[t];}else this._rvfcpolyfillmap[t]=requestAnimationFrame((e=>o(r,e)));};return this._rvfcpolyfillmap[t]=requestAnimationFrame((e=>o(t,e))),t},HTMLVideoElement.prototype.cancelVideoFrameCallback=function(e){cancelAnimationFrame(this._rvfcpolyfillmap[e]),delete this._rvfcpolyfillmap[e];});
2
2
 
3
- const TrackingMode={Image:1,QRCode:2,Surface:3,Spatial:4},SurfaceMode={WebXR:1,SLAM:2,Gyroscope:3},Events={OnDetected:1,OnPose:2,OnLost:3,OnResize:4,OnTouch:5,OnHitTestResult:6,OnKeyFrame:7,OnStatusChange:8,OnSessionEnd:9,OnFrame:10},DefaultConfig={useVocabulary:!1,forceCompatWorldTracking:!1,forceRotationOnlyTracking:!1,debug:!1,cameraAccess:!1};
3
+ const TrackingMode={Image:1,QRCode:2,Surface:3,Spatial:4},SurfaceMode={WebXR:1,SLAM:2,Gyroscope:3},Events={OnDetected:1,OnPose:2,OnLost:3,OnResize:4,OnTouch:5,OnHitTestResult:6,OnKeyFrame:7,OnStatusChange:8,OnSessionEnd:9,OnFrame:10},DefaultConfig={useVocabulary:!1,forceCompatWorldTracking:!1,forceRotationOnlyTracking:!1,debug:!1,cameraAccess:!1,highResolutionCamera:!1};
4
4
 
5
5
  class InternalError extends Error{constructor(r){super(r),this.name="INTERNAL_ERROR";}}class LicenseError extends Error{constructor(r){super(r),this.name="LICENSE_ERROR";}}class CameraError extends Error{constructor(r){super(r),this.name="CAMERA_ERROR";}}class SensorsError extends Error{constructor(r){super(r),this.name="SENSORS_ERROR";}}class ReconstructionPendingError extends Error{constructor(r){super(r),this.name="RECONSTRUCTION_PENDING_ERROR";}}
6
6
 
@@ -38,11 +38,11 @@ class Quaternion{constructor(t=0,s=0,i=0,h=1){this.x=t,this.y=s,this.z=i,this.w=
38
38
 
39
39
  const mat4RotationZ90CCW=(new Matrix4).set(0,1,0,0,-1,0,0,0,0,0,1,0,0,0,0,1),mat4RotationZ90CW=(new Matrix4).set(0,-1,0,0,1,0,0,0,0,0,1,0,0,0,0,1),mat4RotationX90CW=(new Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),mat3RotationX90CCW=(new Matrix3).set(1,0,0,0,0,1,0,-1,0),mat3RotationZ90CW=(new Matrix3).set(0,-1,0,1,0,0,0,0,1);
40
40
 
41
- class NativeManager{constructor(t,i,e,a){this.uiManager=t,this.deviceManager=i,this.workerManager=e,this.indexedDBManager=a;}async init(t,i){try{let e;try{e=await getFileFromIndexedDB("SDK_1.6.3");}catch(t){let i=await fetch(new URL("./onirix_native_sdk.js",import.meta.url).href);e=await i.text(),await this.indexedDBManager.saveFileToIndexedDB("SDK_1.6.3",e);}let a=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));const{default:r}=await import(/* webpackIgnore: true, webpackMode: "lazy" */a);let s,n,o;if(this.useVocabulary=i.useVocabulary,this.host=i.host??"https://studio.onirix.com",this.useVocabulary&&(s=await this.indexedDBManager.getFromCacheOrFetch("orb.fbow","https://sdk.onirix.com/common/orb.fbow")),i.mode===TrackingMode.Spatial){if(n=await fetch(`${this.host}/api/projects/self/targets/${i.sceneOid}/osf?token=${t}`),!n.ok)throw new ReconstructionPendingError(`Could not get Onirix Spatial File. Server responded with ${n.status}`);const e=await n.arrayBuffer();o=new Uint8Array(e),await this.workerManager.createWorkers();}this.nativeSDK=await r({preRun:e=>{i.mode==TrackingMode.Spatial?e.FS_createDataFile("/","scene.osf",o,!0,!0,!0):i.mode===TrackingMode.Image?(this.useVocabulary&&e.FS_createDataFile("/","orb.fbow",s,!0,!0,!0),e.FS_createPreloadedFile("/","classifier.otf",`${this.host}/api/projects/self/targets/otf?token=${t}`,!0,!1)):i.mode===TrackingMode.Surface&&this.useVocabulary&&e.FS_createDataFile("/","orb.fbow",s,!0,!0,!0);}}),this.buffer=this.nativeSDK._malloc(1228800),this.imageBuffer=this.nativeSDK._malloc(1228800),this.imuAccData=this.nativeSDK._malloc(32),this.imuRotData=this.nativeSDK._malloc(72),this.cameraParamsStruct=this.nativeSDK._malloc(40),this.frameLayoutStruct=this.nativeSDK._malloc(28),this.nativeSDK.HEAPU32[this.cameraParamsStruct/4+0]=640,this.nativeSDK.HEAPU32[this.cameraParamsStruct/4+1]=480,this.nativeSDK.HEAPF64[this.cameraParamsStruct/8+1]=468,this.nativeSDK.HEAPF64[this.cameraParamsStruct/8+2]=468,this.nativeSDK.HEAPF64[this.cameraParamsStruct/8+3]=320,this.nativeSDK.HEAPF64[this.cameraParamsStruct/8+4]=240,i.debug&&this.nativeSDK._OX_SetLogCallback(this.nativeSDK.addFunction((t=>{console.log(this.nativeSDK.UTF8ToString(t));}),"vi"));}catch(t){throw t instanceof ReconstructionPendingError?t:new InternalError(t)}await this.checkLicense(t);}async checkLicense(t){try{const i=this.getStringBuffer(this.host),e=this.getStringBuffer(t),a=this.getStringBuffer(window.location.hostname),r=this.getStringBuffer(this.deviceManager.platform),s=this.getStringBuffer(this.deviceManager.device),n=await new Promise(((t,n)=>{this.nativeSDK._OX_SetLicense([i],[e],[a],[r],[s],this.nativeSDK.addFunction((i=>t(i)),"vi"));}));if(this.releaseStringBuffer(i),this.releaseStringBuffer(e),this.releaseStringBuffer(a),this.releaseStringBuffer(r),this.releaseStringBuffer(s),!n)throw new LicenseError("Invalid license")}catch(t){throw new LicenseError(t)}}startImageTracking(t,i,e){if(this.onDetected=t,this.onPose=i,this.onLost=e,this.useVocabulary){const t=this.getStringBuffer("orb.fbow");this.nativeSDK._OX_Initialize(this.cameraParamsStruct,[t]),this.releaseStringBuffer(t);}else this.nativeSDK._OX_Initialize(this.cameraParamsStruct,"");let a=this.getStringBuffer("classifier.otf");this.nativeSDK._OX_LoadImageClassifier([a]),this.releaseStringBuffer(a),this.nativeSDK._OX_StartImageDetection(2,this.nativeSDK.addFunction((t=>this.onDetected(this.nativeSDK.UTF8ToString(t))),"vi"),this.nativeSDK.addFunction((t=>{const i=this.nativeSDK.HEAPF64.subarray(t/8,t/8+16);let e=(new Matrix4).fromArray(i);e.multiply(mat4RotationX90CW),e.invert(),this.uiManager.isPortrait()?(e.multiply(mat4RotationZ90CCW),this.onPose(e.toArray())):this.onPose(e.toArray());}),"vi"),this.nativeSDK.addFunction((t=>this.onLost(this.nativeSDK.UTF8ToString(t))),"vi"));}startQRCodeTracking(t,i,e){this.onDetected=t,this.onPose=i,this.onLost=e,this.nativeSDK._OX_Initialize(this.cameraParamsStruct,""),this.nativeSDK._OX_StartQRCodeDetection(2,this.nativeSDK.addFunction((t=>this.onDetected(this.nativeSDK.UTF8ToString(t))),"vi"),this.nativeSDK.addFunction((t=>{const i=this.nativeSDK.HEAPF64.subarray(t/8,t/8+16);let e=(new Matrix4).fromArray(i);e.multiply(mat4RotationX90CW),e.invert(),this.uiManager.isPortrait()?(e.multiply(mat4RotationZ90CCW),this.onPose(e.toArray())):this.onPose(e.toArray());}),"vi"),this.nativeSDK.addFunction((t=>this.onLost(this.nativeSDK.UTF8ToString(t))),"vi"));}startSLAM(t,i,e){if(this.onPose=t,this.onKeyFrame=i,this.onStatusChange=e,this.useVocabulary){const t=this.getStringBuffer("orb.fbow");this.nativeSDK._OX_Initialize(this.cameraParamsStruct,[t]),this.releaseStringBuffer(t);}else this.nativeSDK._OX_Initialize(this.cameraParamsStruct,"");this.nativeSDK._OX_StartSLAM(this.nativeSDK.addFunction((t=>{const i=this.nativeSDK.HEAPF64.subarray(t/8,t/8+16);let e=(new Matrix4).fromArray(i);e.invert(),this.uiManager.isPortrait()?(e.multiply(mat4RotationZ90CCW),this.onPose(e.toArray())):this.onPose(e.toArray());}),"vi"),null!=this.onKeyFrame?this.nativeSDK.addFunction((()=>this.onKeyFrame()),"v"):null,this.nativeSDK.addFunction(((t,i)=>{this.onStatusChange([this.nativeSDK.UTF8ToString(t),this.nativeSDK.UTF8ToString(i)]);}),"vii"));}xrRelocation(t){if(this.lastXrPose){let i=(new Matrix4).fromArray(this.lastXrPose),e=(new Matrix4).fromArray(t.elements);this.xrTransform=e.multiply(i.invert());}}slamRelocation(t){if(this.lastSlamPose){let i=(new Matrix4).fromArray(this.lastSlamPose),e=(new Matrix4).fromArray(t.elements);this.slamTransform=e.multiply(i.invert());}}startSpatialTracking(t,i,e){this.onDetected=t,e||(this.onPose=i),this.nativeSDK._OX_Initialize(this.cameraParamsStruct,""),this.nativeSDK._OX_StartSpatialTracking(this.nativeSDK.addFunction((t=>{e||(this.spatialLocated=!0),this.onDetected("");}),"vi"),this.nativeSDK.addFunction((t=>{const i=this.nativeSDK.HEAPF64.subarray(t/8,t/8+16);let a=(new Matrix4).fromArray(i);a.invert(),this.uiManager.isPortrait()&&a.multiply(e?mat4RotationZ90CW:mat4RotationZ90CCW),e?(this.xrRelocation(a),this.onDetected("")):this.onPose(a.toArray());}),"vi"),!e);let a=this.getStringBuffer("scene.osf");this.nativeSDK._OX_LoadOSF(a),this.releaseStringBuffer(a);}processFrame(t,i=null,e=480,a=640,r=0,s=0){let n=i||this.buffer;this.nativeSDK.HEAPU8.set(t,n),this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+0]=a,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+1]=e,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+2]=4*a,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+3]=!1,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+4]=5,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+5]=s,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+6]=r,this.nativeSDK._OX_ProcessFrame(n,this.frameLayoutStruct);}loadExtractionData(t,i=-1){return this.siftBuffer&&this.netvladBuffer?(this.nativeSDK.HEAPF32.set(t.extraction,this.siftBuffer/4),this.nativeSDK.HEAPF32.set(t.descriptor,this.netvladBuffer/4),this.nativeSDK._OX_LoadExtractionData(this.siftBuffer,this.netvladBuffer,i)):0}getCandidateData(t){let i=this.nativeSDK._OX_GetCandidateData(t),e=[];for(let t=0;t<55e4;t++)e.push(this.nativeSDK.HEAPF32[i/4+t]);return new Float32Array(e)}loadMatch(t){this.matchBuffer&&(this.nativeSDK.HEAPF32.set(t,this.matchBuffer/4),this.nativeSDK._OX_LoadMatch(this.matchBuffer));}spatialLocate(){this.nativeSDK._OX_SpatialLocate();}loadKeyframePose(t){this.nativeSDK._OX_LoadKfPose(t);}numSLAMKeyframes(){return this.nativeSDK._OX_GetSLAMNumKfs()}getSLAMKeyframe(t){let i=this.nativeSDK._OX_GetSLAMKf(t),e=[];for(let t=0;t<1228800;t++)e.push(this.nativeSDK.HEAPU8[i+t]);return new Uint8Array(e)}stopImageTracking(){this.nativeSDK._OX_StopImageDetection();}stopQRCodeTracking(){this.nativeSDK._OX_StopQRCodeDetection();}stopSLAM(){this.nativeSDK._OX_StopSLAM();}stopSLAM(){this.nativeSDK._OX_StopSLAM();}addImage(t,i){this.nativeSDK.HEAPU8.set(i,this.imageBuffer),this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+0]=640,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+1]=480,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+2]=2560,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+3]=!1,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+4]=5,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+5]=0,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+6]=0;const e=this.getStringBuffer(t);this.nativeSDK._OX_AddImage([e],this.imageBuffer,this.frameLayoutStruct),this.releaseStringBuffer(e);}destroy(){this.nativeSDK._OX_Destroy();}extractionType(){return this.nativeSDK._OX_ExtractionType()}getStringBuffer(t){const i=this.nativeSDK.lengthBytesUTF8(t)+1;let e=this.nativeSDK._malloc(i);return this.nativeSDK.stringToUTF8(t,e,i),e}releaseStringBuffer(t){this.nativeSDK._free(t);}getSLAMMap(){const t=this.nativeSDK.UTF8ToString(this.nativeSDK._OX_GetSLAMMap());let i;try{i=JSON.parse(t);}catch(i){console.error(`Could not parse ${t}`);}return i}getSLAMTrackingPoints(){const t=this.nativeSDK.UTF8ToString(this.nativeSDK._OX_GetSLAMTrackingPoints());let i;try{i=JSON.parse(t);}catch(i){console.error(`Could not parse ${t}`);}return i}raycast(t,i,e,a,r,s){const n=this.nativeSDK.UTF8ToString(this.nativeSDK._OX_Raycast(t,i,e,a,r,s));let o;try{o=JSON.parse(n);}catch(t){console.error(`Could not parse ${n}`);}return o}}
41
+ class NativeManager{constructor(t,i,e,a){this.uiManager=t,this.deviceManager=i,this.workerManager=e,this.indexedDBManager=a;}async init(t,i){try{let e;try{e=await getFileFromIndexedDB("SDK_1.6.4");}catch(t){let i=await fetch(new URL("./onirix_native_sdk.js",import.meta.url).href);e=await i.text(),await this.indexedDBManager.saveFileToIndexedDB("SDK_1.6.4",e);}let a=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));const{default:r}=await import(/* webpackIgnore: true, webpackMode: "lazy" */a);let s,n,o;if(this.useVocabulary=i.useVocabulary,this.host=i.host??"https://studio.onirix.com",this.useVocabulary&&(s=await this.indexedDBManager.getFromCacheOrFetch("orb.fbow","https://sdk.onirix.com/common/orb.fbow")),i.mode===TrackingMode.Spatial){if(n=await fetch(`${this.host}/api/projects/self/targets/${i.sceneOid}/osf?token=${t}`),!n.ok)throw new ReconstructionPendingError(`Could not get Onirix Spatial File. Server responded with ${n.status}`);const e=await n.arrayBuffer();o=new Uint8Array(e),await this.workerManager.createWorkers();}this.nativeSDK=await r({preRun:e=>{i.mode==TrackingMode.Spatial?e.FS_createDataFile("/","scene.osf",o,!0,!0,!0):i.mode===TrackingMode.Image?(this.useVocabulary&&e.FS_createDataFile("/","orb.fbow",s,!0,!0,!0),e.FS_createPreloadedFile("/","classifier.otf",`${this.host}/api/projects/self/targets/otf?token=${t}`,!0,!1)):i.mode===TrackingMode.Surface&&this.useVocabulary&&e.FS_createDataFile("/","orb.fbow",s,!0,!0,!0);}}),this.buffer=this.nativeSDK._malloc(1228800),this.imageBuffer=this.nativeSDK._malloc(1228800),this.imuAccData=this.nativeSDK._malloc(32),this.imuRotData=this.nativeSDK._malloc(72),this.cameraParamsStruct=this.nativeSDK._malloc(40),this.frameLayoutStruct=this.nativeSDK._malloc(28),this.nativeSDK.HEAPU32[this.cameraParamsStruct/4+0]=640,this.nativeSDK.HEAPU32[this.cameraParamsStruct/4+1]=480,this.nativeSDK.HEAPF64[this.cameraParamsStruct/8+1]=468,this.nativeSDK.HEAPF64[this.cameraParamsStruct/8+2]=468,this.nativeSDK.HEAPF64[this.cameraParamsStruct/8+3]=320,this.nativeSDK.HEAPF64[this.cameraParamsStruct/8+4]=240,i.debug&&this.nativeSDK._OX_SetLogCallback(this.nativeSDK.addFunction((t=>{console.log(this.nativeSDK.UTF8ToString(t));}),"vi"));}catch(t){throw t instanceof ReconstructionPendingError?t:new InternalError(t)}await this.checkLicense(t);}async checkLicense(t){try{const i=this.getStringBuffer(this.host),e=this.getStringBuffer(t),a=this.getStringBuffer(window.location.hostname),r=this.getStringBuffer(this.deviceManager.platform),s=this.getStringBuffer(this.deviceManager.device),n=await new Promise(((t,n)=>{this.nativeSDK._OX_SetLicense([i],[e],[a],[r],[s],this.nativeSDK.addFunction((i=>t(i)),"vi"));}));if(this.releaseStringBuffer(i),this.releaseStringBuffer(e),this.releaseStringBuffer(a),this.releaseStringBuffer(r),this.releaseStringBuffer(s),!n)throw new LicenseError("Invalid license")}catch(t){throw new LicenseError(t)}}startImageTracking(t,i,e){if(this.onDetected=t,this.onPose=i,this.onLost=e,this.useVocabulary){const t=this.getStringBuffer("orb.fbow");this.nativeSDK._OX_Initialize(this.cameraParamsStruct,[t]),this.releaseStringBuffer(t);}else this.nativeSDK._OX_Initialize(this.cameraParamsStruct,"");let a=this.getStringBuffer("classifier.otf");this.nativeSDK._OX_LoadImageClassifier([a]),this.releaseStringBuffer(a),this.nativeSDK._OX_StartImageDetection(2,this.nativeSDK.addFunction((t=>this.onDetected(this.nativeSDK.UTF8ToString(t))),"vi"),this.nativeSDK.addFunction((t=>{const i=this.nativeSDK.HEAPF64.subarray(t/8,t/8+16);let e=(new Matrix4).fromArray(i);e.multiply(mat4RotationX90CW),e.invert(),this.uiManager.isPortrait()?(e.multiply(mat4RotationZ90CCW),this.onPose(e.toArray())):this.onPose(e.toArray());}),"vi"),this.nativeSDK.addFunction((t=>this.onLost(this.nativeSDK.UTF8ToString(t))),"vi"));}startQRCodeTracking(t,i,e){this.onDetected=t,this.onPose=i,this.onLost=e,this.nativeSDK._OX_Initialize(this.cameraParamsStruct,""),this.nativeSDK._OX_StartQRCodeDetection(2,this.nativeSDK.addFunction((t=>this.onDetected(this.nativeSDK.UTF8ToString(t))),"vi"),this.nativeSDK.addFunction((t=>{const i=this.nativeSDK.HEAPF64.subarray(t/8,t/8+16);let e=(new Matrix4).fromArray(i);e.multiply(mat4RotationX90CW),e.invert(),this.uiManager.isPortrait()?(e.multiply(mat4RotationZ90CCW),this.onPose(e.toArray())):this.onPose(e.toArray());}),"vi"),this.nativeSDK.addFunction((t=>this.onLost(this.nativeSDK.UTF8ToString(t))),"vi"));}startSLAM(t,i,e){if(this.onPose=t,this.onKeyFrame=i,this.onStatusChange=e,this.useVocabulary){const t=this.getStringBuffer("orb.fbow");this.nativeSDK._OX_Initialize(this.cameraParamsStruct,[t]),this.releaseStringBuffer(t);}else this.nativeSDK._OX_Initialize(this.cameraParamsStruct,"");this.nativeSDK._OX_StartSLAM(this.nativeSDK.addFunction((t=>{const i=this.nativeSDK.HEAPF64.subarray(t/8,t/8+16);let e=(new Matrix4).fromArray(i);e.invert(),this.uiManager.isPortrait()?(e.multiply(mat4RotationZ90CCW),this.onPose(e.toArray())):this.onPose(e.toArray());}),"vi"),null!=this.onKeyFrame?this.nativeSDK.addFunction((()=>this.onKeyFrame()),"v"):null,this.nativeSDK.addFunction(((t,i)=>{this.onStatusChange([this.nativeSDK.UTF8ToString(t),this.nativeSDK.UTF8ToString(i)]);}),"vii"));}xrRelocation(t){if(this.lastXrPose){let i=(new Matrix4).fromArray(this.lastXrPose),e=(new Matrix4).fromArray(t.elements);this.xrTransform=e.multiply(i.invert());}}slamRelocation(t){if(this.lastSlamPose){let i=(new Matrix4).fromArray(this.lastSlamPose),e=(new Matrix4).fromArray(t.elements);this.slamTransform=e.multiply(i.invert());}}startSpatialTracking(t,i,e){this.onDetected=t,e||(this.onPose=i),this.nativeSDK._OX_Initialize(this.cameraParamsStruct,""),this.nativeSDK._OX_StartSpatialTracking(this.nativeSDK.addFunction((t=>{e||(this.spatialLocated=!0),this.onDetected("");}),"vi"),this.nativeSDK.addFunction((t=>{const i=this.nativeSDK.HEAPF64.subarray(t/8,t/8+16);let a=(new Matrix4).fromArray(i);a.invert(),this.uiManager.isPortrait()&&a.multiply(e?mat4RotationZ90CW:mat4RotationZ90CCW),e?(this.xrRelocation(a),this.onDetected("")):this.onPose(a.toArray());}),"vi"),!e);let a=this.getStringBuffer("scene.osf");this.nativeSDK._OX_LoadOSF(a),this.releaseStringBuffer(a);}processFrame(t,i=null,e=480,a=640,r=0,s=0){let n=i||this.buffer;this.nativeSDK.HEAPU8.set(t,n),this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+0]=a,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+1]=e,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+2]=4*a,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+3]=!1,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+4]=5,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+5]=s,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+6]=r,this.nativeSDK._OX_ProcessFrame(n,this.frameLayoutStruct);}loadExtractionData(t,i=-1){return this.siftBuffer&&this.netvladBuffer?(this.nativeSDK.HEAPF32.set(t.extraction,this.siftBuffer/4),this.nativeSDK.HEAPF32.set(t.descriptor,this.netvladBuffer/4),this.nativeSDK._OX_LoadExtractionData(this.siftBuffer,this.netvladBuffer,i)):0}getCandidateData(t){let i=this.nativeSDK._OX_GetCandidateData(t),e=[];for(let t=0;t<55e4;t++)e.push(this.nativeSDK.HEAPF32[i/4+t]);return new Float32Array(e)}loadMatch(t){this.matchBuffer&&(this.nativeSDK.HEAPF32.set(t,this.matchBuffer/4),this.nativeSDK._OX_LoadMatch(this.matchBuffer));}spatialLocate(){this.nativeSDK._OX_SpatialLocate();}loadKeyframePose(t){this.nativeSDK._OX_LoadKfPose(t);}numSLAMKeyframes(){return this.nativeSDK._OX_GetSLAMNumKfs()}getSLAMKeyframe(t){let i=this.nativeSDK._OX_GetSLAMKf(t),e=[];for(let t=0;t<1228800;t++)e.push(this.nativeSDK.HEAPU8[i+t]);return new Uint8Array(e)}stopImageTracking(){this.nativeSDK._OX_StopImageDetection();}stopQRCodeTracking(){this.nativeSDK._OX_StopQRCodeDetection();}stopSLAM(){this.nativeSDK._OX_StopSLAM();}stopSLAM(){this.nativeSDK._OX_StopSLAM();}addImage(t,i){this.nativeSDK.HEAPU8.set(i,this.imageBuffer),this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+0]=640,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+1]=480,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+2]=2560,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+3]=!1,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+4]=5,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+5]=0,this.nativeSDK.HEAPU32[this.frameLayoutStruct/4+6]=0;const e=this.getStringBuffer(t);this.nativeSDK._OX_AddImage([e],this.imageBuffer,this.frameLayoutStruct),this.releaseStringBuffer(e);}destroy(){this.nativeSDK._OX_Destroy();}extractionType(){return this.nativeSDK._OX_ExtractionType()}getStringBuffer(t){const i=this.nativeSDK.lengthBytesUTF8(t)+1;let e=this.nativeSDK._malloc(i);return this.nativeSDK.stringToUTF8(t,e,i),e}releaseStringBuffer(t){this.nativeSDK._free(t);}getSLAMMap(){const t=this.nativeSDK.UTF8ToString(this.nativeSDK._OX_GetSLAMMap());let i;try{i=JSON.parse(t);}catch(i){console.error(`Could not parse ${t}`);}return i}getSLAMTrackingPoints(){const t=this.nativeSDK.UTF8ToString(this.nativeSDK._OX_GetSLAMTrackingPoints());let i;try{i=JSON.parse(t);}catch(i){console.error(`Could not parse ${t}`);}return i}raycast(t,i,e,a,r,s){const n=this.nativeSDK.UTF8ToString(this.nativeSDK._OX_Raycast(t,i,e,a,r,s));let o;try{o=JSON.parse(n);}catch(t){console.error(`Could not parse ${n}`);}return o}}
42
42
 
43
- class UIManager{constructor(){this.onFocus=this.onFocus.bind(this);}createRenderCanvas(){this.renderCanvas=document.createElement("canvas"),this.renderCanvas.id="renderer",this.renderCanvas.style.position="absolute",document.body.prepend(this.renderCanvas),this.addTouchListeners();}setRenderCanvas(e){this.renderCanvas=e,this.addTouchListeners();}addTouchListeners(){this.renderCanvas.addEventListener("click",(e=>{this.onCanvasTouch(e);})),this.renderCanvas.addEventListener("touchstart",(e=>{this.onCanvasTouchStart(e);})),this.renderCanvas.addEventListener("touchmove",(e=>{this.onCanvasTouchMove(e);})),this.renderCanvas.addEventListener("touchend",(e=>{this.onCanvasTouchEnd(e);}));}removeRenderCanvas(){this.renderCanvas&&(this.renderCanvas.remove(),this.renderCanvas=null);}createVideoElement(e){let t=document.createElement("video");t.setAttribute("playsinline","true"),t.setAttribute("autoplay","true"),t.setAttribute("muted",""),this.videoCanvas=document.createElement("canvas"),this.videoCanvas.width=640,this.videoCanvas.height=480,this.videoContext=this.videoCanvas.getContext("2d"),t.srcObject=e,document.body.appendChild(t),this.videoElement=t;const i=this.videoElement.srcObject.getVideoTracks()[0].getSettings();this.videoSizeHorizontal=[Math.max(i.width,i.height),Math.min(i.width,i.height)],this.videoSizeVertical=[Math.min(i.width,i.height),Math.max(i.width,i.height)],window.addEventListener("focus",this.onFocus);}onFocus(){this.videoElement.play();}removeVideoElement(){this.videoElement&&(window.removeEventListener("focus",this.onFocus),this.videoElement.remove(),this.videoElement=null);}fitVideoToScreen(){this.videoSize=window.innerWidth>window.innerHeight?this.videoSizeHorizontal:this.videoSizeVertical;let e=[],t=[];this.videoSize[0]/this.videoSize[1]>window.innerWidth/window.innerHeight?(t=[Math.floor(this.videoSize[0]*(window.innerHeight/this.videoSize[1])),window.innerHeight],e=[-(t[0]-window.innerWidth)/2,0]):(t=[window.innerWidth,Math.floor(this.videoSize[1]*(window.innerWidth/this.videoSize[0]))],e=[0,-(t[1]-window.innerHeight)/2]),document.body.style.setProperty("overflow","hidden"),this.videoElement.width=t[0],this.videoElement.height=t[1],this.videoElement.style.setProperty("position","absolute"),this.videoElement.style.setProperty("z-index","-1"),this.videoElement.style.setProperty("width",`${t[0]}px`),this.videoElement.style.setProperty("height",`${t[1]}px`),this.videoElement.style.setProperty("left",`${e[0]}px`),this.videoElement.style.setProperty("top",`${e[1]}px`),this.videoElement.style.setProperty("touch-action","none"),this.renderCanvas.width=t[0],this.renderCanvas.height=t[1],this.renderCanvas.style.setProperty("position","absolute","important"),this.renderCanvas.style.setProperty("width",`${t[0]}px`,"important"),this.renderCanvas.style.setProperty("height",`${t[1]}px`,"important"),this.renderCanvas.style.setProperty("left",`${e[0]}px`,"important"),this.renderCanvas.style.setProperty("top",`${e[1]}px`,"important"),this.renderCanvas.style.setProperty("touch-action","none","important");}async displayPermissionsDialog(e){return new Promise(((t,i)=>{let o,s,n,r;o=document.createElement("div"),o.id="ox-permissions-dialog",o.style.setProperty("position","fixed"),o.style.setProperty("z-index","999999"),o.style.setProperty("max-width","360px"),o.style.setProperty("width","calc(100% - 140px"),o.style.setProperty("left","50vw"),o.style.setProperty("top","50vh"),o.style.setProperty("transform","translate(-50%, -50%)"),o.style.setProperty("background-color","#FFFFFF"),o.style.setProperty("border-radius","10px"),o.style.setProperty("font-family","'Open Sans', Arial, sans-serif"),o.style.setProperty("text-align","center"),o.style.setProperty("padding","30px"),document.body.appendChild(o),s=document.createElement("h1"),s.id="ox-permissions-dialog-title",s.innerText="Access to motion sensors required",s.style.setProperty("font-size","20px"),o.appendChild(s),n=document.createElement("span"),n.id="ox-permissions-dialog-message",n.innerText="This augmented reality experience requires access to your phone motion sensors. The browser may ask you for permissions.",n.style.setProperty("display","block"),n.style.setProperty("padding","10px 0"),o.appendChild(n),r=document.createElement("button"),r.id="ox-permissions-dialog-ok-button",r.innerText="Okay!",r.style.setProperty("display","block"),r.style.setProperty("margin","auto"),r.style.setProperty("background","#000000"),r.style.setProperty("color","#FFFFFF"),r.style.setProperty("border","none"),r.style.setProperty("border-radius","12px"),r.style.setProperty("padding","20px 0"),r.style.setProperty("width","100%"),r.style.setProperty("font-size","18px"),r.style.setProperty("font-weight","bold"),r.style.setProperty("margin-top","20px"),r.style.setProperty("background-image","linear-gradient(to left, #f6414b, #ee0979)"),o.appendChild(r),r.addEventListener("click",(async s=>{s.stopPropagation(),o.remove();try{await e(),t();}catch(e){i(e);}}));}))}getVideoData(){let e;if(this.videoElement){if(this.isPortrait()){let e=320,i=240,o=480,s=640;var t=Math.PI/2;this.videoContext.translate(e,i),this.videoContext.rotate(t),this.videoContext.drawImage(this.videoElement,-i,-e,o,s),this.videoContext.rotate(-t),this.videoContext.translate(-e,-i);}else this.videoContext.drawImage(this.videoElement,0,0,640,480);e=this.videoContext.getImageData(0,0,640,480).data;}return e}getVideoElement(){return this.videoElement}getCameraParameters(){return {fov:radToDeg(2*Math.atan(this.videoSize[1]/936)),aspect:this.videoSize[0]/this.videoSize[1]}}isPortrait(){return window.innerWidth<window.innerHeight}setTouchListener(e){this.onTouch=e;}setTouchStartListener(e){this.onTouchStart=e;}setTouchMoveListener(e){this.onTouchMove=e;}setTouchEndListener(e){this.onTouchEnd=e;}getNormalizedTouchCoords(e){const t=new Vector2,i=this.renderCanvas.getBoundingClientRect();return null!=e.clientX?(t.x=(e.clientX-i.left)/i.width*2-1,t.y=-(e.clientY-i.top)/i.height*2+1):e.touches[0]?(t.x=e.touches[0].clientX/window.innerWidth*2-1,t.y=-e.touches[0].clientY/window.innerHeight*2+1):(t.x=e.changedTouches[0].clientX/window.innerWidth*2-1,t.y=-e.changedTouches[0].clientY/window.innerHeight*2+1),t}onCanvasTouch(e){const t=this.getNormalizedTouchCoords(e);this.onTouch&&this.onTouch(t);}onCanvasTouchStart(e){const t=this.getNormalizedTouchCoords(e);this.onTouchStart&&this.onTouchStart(t);}onCanvasTouchMove(e){const t=this.getNormalizedTouchCoords(e);this.onTouchMove&&this.onTouchMove(t);}onCanvasTouchEnd(e){const t=this.getNormalizedTouchCoords(e);this.onTouchEnd&&this.onTouchEnd(t);}}
43
+ class UIManager{constructor(){this.onFocus=this.onFocus.bind(this);}createRenderCanvas(){this.renderCanvas=document.createElement("canvas"),this.renderCanvas.id="renderer",this.renderCanvas.style.position="absolute",document.body.prepend(this.renderCanvas),this.addTouchListeners();}setRenderCanvas(e){this.renderCanvas=e,this.addTouchListeners();}addTouchListeners(){this.renderCanvas.addEventListener("click",(e=>{this.onCanvasTouch(e);})),this.renderCanvas.addEventListener("touchstart",(e=>{this.onCanvasTouchStart(e);})),this.renderCanvas.addEventListener("touchmove",(e=>{this.onCanvasTouchMove(e);})),this.renderCanvas.addEventListener("touchend",(e=>{this.onCanvasTouchEnd(e);}));}removeRenderCanvas(){this.renderCanvas&&(this.renderCanvas.remove(),this.renderCanvas=null);}createVideoElement(e,t,i){let o=document.createElement("video");o.setAttribute("playsinline","true"),o.setAttribute("autoplay","true"),o.setAttribute("muted",""),this.videoCanvas=document.createElement("canvas"),this.videoCanvas.width=t,this.videoCanvas.height=i,this.videoContext=this.videoCanvas.getContext("2d"),o.srcObject=e,document.body.appendChild(o),this.videoElement=o;const s=this.videoElement.srcObject.getVideoTracks()[0].getSettings();this.videoSizeHorizontal=[Math.max(s.width,s.height),Math.min(s.width,s.height)],this.videoSizeVertical=[Math.min(s.width,s.height),Math.max(s.width,s.height)],window.addEventListener("focus",this.onFocus);}onFocus(){this.videoElement.play();}removeVideoElement(){this.videoElement&&(window.removeEventListener("focus",this.onFocus),this.videoElement.remove(),this.videoElement=null);}fitVideoToScreen(){this.videoSize=window.innerWidth>window.innerHeight?this.videoSizeHorizontal:this.videoSizeVertical;let e=[],t=[];this.videoSize[0]/this.videoSize[1]>window.innerWidth/window.innerHeight?(t=[Math.floor(this.videoSize[0]*(window.innerHeight/this.videoSize[1])),window.innerHeight],e=[-(t[0]-window.innerWidth)/2,0]):(t=[window.innerWidth,Math.floor(this.videoSize[1]*(window.innerWidth/this.videoSize[0]))],e=[0,-(t[1]-window.innerHeight)/2]),document.body.style.setProperty("overflow","hidden"),this.videoElement.width=t[0],this.videoElement.height=t[1],this.videoElement.style.setProperty("position","absolute"),this.videoElement.style.setProperty("z-index","-1"),this.videoElement.style.setProperty("width",`${t[0]}px`),this.videoElement.style.setProperty("height",`${t[1]}px`),this.videoElement.style.setProperty("left",`${e[0]}px`),this.videoElement.style.setProperty("top",`${e[1]}px`),this.videoElement.style.setProperty("touch-action","none"),this.renderCanvas.width=t[0],this.renderCanvas.height=t[1],this.renderCanvas.style.setProperty("position","absolute","important"),this.renderCanvas.style.setProperty("width",`${t[0]}px`,"important"),this.renderCanvas.style.setProperty("height",`${t[1]}px`,"important"),this.renderCanvas.style.setProperty("left",`${e[0]}px`,"important"),this.renderCanvas.style.setProperty("top",`${e[1]}px`,"important"),this.renderCanvas.style.setProperty("touch-action","none","important");}async displayPermissionsDialog(e){return new Promise(((t,i)=>{let o,s,n,r;o=document.createElement("div"),o.id="ox-permissions-dialog",o.style.setProperty("position","fixed"),o.style.setProperty("z-index","999999"),o.style.setProperty("max-width","360px"),o.style.setProperty("width","calc(100% - 140px"),o.style.setProperty("left","50vw"),o.style.setProperty("top","50vh"),o.style.setProperty("transform","translate(-50%, -50%)"),o.style.setProperty("background-color","#FFFFFF"),o.style.setProperty("border-radius","10px"),o.style.setProperty("font-family","'Open Sans', Arial, sans-serif"),o.style.setProperty("text-align","center"),o.style.setProperty("padding","30px"),document.body.appendChild(o),s=document.createElement("h1"),s.id="ox-permissions-dialog-title",s.innerText="Access to motion sensors required",s.style.setProperty("font-size","20px"),o.appendChild(s),n=document.createElement("span"),n.id="ox-permissions-dialog-message",n.innerText="This augmented reality experience requires access to your phone motion sensors. The browser may ask you for permissions.",n.style.setProperty("display","block"),n.style.setProperty("padding","10px 0"),o.appendChild(n),r=document.createElement("button"),r.id="ox-permissions-dialog-ok-button",r.innerText="Okay!",r.style.setProperty("display","block"),r.style.setProperty("margin","auto"),r.style.setProperty("background","#000000"),r.style.setProperty("color","#FFFFFF"),r.style.setProperty("border","none"),r.style.setProperty("border-radius","12px"),r.style.setProperty("padding","20px 0"),r.style.setProperty("width","100%"),r.style.setProperty("font-size","18px"),r.style.setProperty("font-weight","bold"),r.style.setProperty("margin-top","20px"),r.style.setProperty("background-image","linear-gradient(to left, #f6414b, #ee0979)"),o.appendChild(r),r.addEventListener("click",(async s=>{s.stopPropagation(),o.remove();try{await e(),t();}catch(e){i(e);}}));}))}getVideoData(){let e;if(this.videoElement){if(this.isPortrait()){let[e,i]=this.videoSizeVertical;var t=Math.PI/2;this.videoContext.translate(480,0),this.videoContext.rotate(t),this.videoContext.drawImage(this.videoElement,0,0,i,i,0,-160,640,640),this.videoContext.rotate(-t),this.videoContext.translate(-480,0);}else this.videoContext.drawImage(this.videoElement,0,0,640,480);e=this.videoContext.getImageData(0,0,640,480).data;}return e}getVideoElement(){return this.videoElement}getCameraParameters(){let e=640,t=480;return this.isPortrait()||([e,t]=[t,e]),{fov:radToDeg(2*Math.atan(e/936)),aspect:t/e}}isPortrait(){return window.innerWidth<window.innerHeight}setTouchListener(e){this.onTouch=e;}setTouchStartListener(e){this.onTouchStart=e;}setTouchMoveListener(e){this.onTouchMove=e;}setTouchEndListener(e){this.onTouchEnd=e;}getNormalizedTouchCoords(e){const t=new Vector2,i=this.renderCanvas.getBoundingClientRect();return null!=e.clientX?(t.x=(e.clientX-i.left)/i.width*2-1,t.y=-(e.clientY-i.top)/i.height*2+1):e.touches[0]?(t.x=e.touches[0].clientX/window.innerWidth*2-1,t.y=-e.touches[0].clientY/window.innerHeight*2+1):(t.x=e.changedTouches[0].clientX/window.innerWidth*2-1,t.y=-e.changedTouches[0].clientY/window.innerHeight*2+1),t}onCanvasTouch(e){const t=this.getNormalizedTouchCoords(e);this.onTouch&&this.onTouch(t);}onCanvasTouchStart(e){const t=this.getNormalizedTouchCoords(e);this.onTouchStart&&this.onTouchStart(t);}onCanvasTouchMove(e){const t=this.getNormalizedTouchCoords(e);this.onTouchMove&&this.onTouchMove(t);}onCanvasTouchEnd(e){const t=this.getNormalizedTouchCoords(e);this.onTouchEnd&&this.onTouchEnd(t);}}
44
44
 
45
- class CameraManager{constructor(e){this.uiManager=e;}async startCamera(){try{let e=await navigator.mediaDevices.enumerateDevices();e=e.filter((e=>!e.label.includes("Telephoto"))),e=e.filter((e=>!e.label.includes("Wide")));let a=e[e.length-1];e.forEach((e=>{"videoinput"===e.kind&&(a=e);}));const t={facingMode:"environment",width:640,height:480};a&&a.deviceId&&""!==a.deviceId&&(t.deviceId={exact:a.deviceId});const r=await navigator.mediaDevices.getUserMedia({video:t,audio:!1});this.stream=r,this.uiManager.createVideoElement(this.stream);}catch(e){throw new CameraError(e)}}stopCamera(){this.stream&&(this.stream.getTracks().forEach((e=>{e.stop();})),this.uiManager.removeVideoElement());}}
45
+ class CameraManager{constructor(e){this.uiManager=e;}async startCamera(e){try{let a=await navigator.mediaDevices.enumerateDevices();a=a.filter((e=>!e.label.includes("Telephoto"))),a=a.filter((e=>!e.label.includes("Wide")));let t,i=a[a.length-1];a.forEach((e=>{"videoinput"===e.kind&&(i=e);})),t=e?{facingMode:{exact:"environment"},width:{min:640,ideal:1280,max:1280},height:{min:480,ideal:960,max:960},aspectRatio:{exact:640/480}}:{facingMode:"environment",width:640,height:480},i&&i.deviceId&&""!==i.deviceId&&(t.deviceId={exact:i.deviceId});const r=await navigator.mediaDevices.getUserMedia({video:t,audio:!1});let{width:n,height:s}=r.getTracks()[0].getSettings();this.stream=r,this.uiManager.createVideoElement(this.stream,n,s);}catch(e){throw new CameraError(e)}}stopCamera(){this.stream&&(this.stream.getTracks().forEach((e=>{e.stop();})),this.uiManager.removeVideoElement());}}
46
46
 
47
47
  class IMUManager{constructor(e,t){this.uiManager=e,this.deviceManager=t,this.started=!1;}async init(e,t,i){this.onRotation=e,this.onAcceleration=t,this.onEmulatedHitTest=i;const n=async()=>{if(this.onDeviceOrientationChange=this.onDeviceOrientationChange.bind(this),this.onDeviceMotionChange=this.onDeviceMotionChange.bind(this),void 0!==window.DeviceOrientationEvent&&"function"==typeof window.DeviceOrientationEvent.requestPermission){let e;try{e=await window.DeviceOrientationEvent.requestPermission();}catch(e){throw new SensorsError("DeviceOrientation API is not supported")}if("granted"!=e)throw new SensorsError("DeviceOrientation permissions were rejected");try{e=await window.DeviceMotionEvent.requestPermission();}catch(e){throw new SensorsError("DeviceMotion API is not supported")}if("granted"!=e)throw new SensorsError("DeviceMotion permissions were rejected");window.addEventListener("deviceorientation",this.onDeviceOrientationChange),window.addEventListener("devicemotion",this.onDeviceMotionChange);}else window.addEventListener("deviceorientation",this.onDeviceOrientationChange),window.addEventListener("devicemotion",this.onDeviceMotionChange);};this.deviceManager.os===DeviceManager.OS.iOS?await this.uiManager.displayPermissionsDialog(n):await n();}start(){this.started=!0;}stop(){this.started=!1;}destroy(){this.stop(),window.removeEventListener("deviceorientation",this.onDeviceOrientationChange),window.removeEventListener("devicemotion",this.onDeviceMotionChange);}onDeviceMotionChange(e){this.started&&e.acceleration&&e.acceleration.x&&e.acceleration.y&&e.acceleration.z&&(this.acceleration=new Vector3(e.acceleration.x,e.acceleration.y,e.acceleration.z),this.onAcceleration(this.acceleration));}onDeviceOrientationChange(e){if(this.started&&e.alpha&&e.beta&&e.gamma){const t=degToRad(e.alpha),i=degToRad(e.beta),n=degToRad(e.gamma);let o=new Euler(i,t,-n,"YXZ"),a=(new Matrix3).makeRotationFromEuler(o);a.multiply(mat3RotationX90CCW);const r=degToRad(window.orientation||0);if(0!==r&&a.multiply((new Matrix3).makeRotationFromQuaternion((new Quaternion).setFromAxisAngle(new Vector3(0,0,1),-r))),this.rotation=a,this.onRotation(this.rotation),this.onEmulatedHitTest){const e=this.emulatedHitTest();this.onEmulatedHitTest(e);}}}emulatedHitTest(){const e=new Vector3(0,0,0),t=new Vector3(-this.rotation.elements[6],-this.rotation.elements[7],-this.rotation.elements[8]),i=new Vector3(0,1,0),n=new Vector3(0,-1,0),o=t.dot(i);if(Math.abs(o)>1e-6){const a=n.sub(e).dot(i)/o,r=e.add(t.multiplyScalar(a)),s=(new Matrix4).lookAt(new Vector3(0,-1,0),r,new Vector3(0,1,0));return {position:r,rotation:(new Quaternion).setFromRotationMatrix(s)}}return null}}
48
48
 
@@ -54,6 +54,6 @@ class EventManager{constructor(){this.eventListeners={},this.eventListenerCount=
54
54
 
55
55
  class IndexedDBManager{constructor(e,r){this.dbName=e,this.storeName=r;}async getFromCacheOrFetch(e,r){let t=null;try{t=await this.getFileFromIndexedDB(e);}catch(e){console.log("An error occurred while trying to get element from indexedDB.");}return t||(t=await this.fetchAndCacheFile(r,e)),new Uint8Array(t)}async getFileFromIndexedDB(e){return new Promise(((r,t)=>{const o=indexedDB.open(this.dbName);o.onerror=()=>t(o.error),o.onsuccess=()=>{const s=o.result.transaction(this.storeName,"readonly").objectStore(this.storeName).get(e);s.onsuccess=()=>r(s.result),s.onerror=()=>t(s.error);},o.onupgradeneeded=e=>{e.target.result.createObjectStore(this.storeName);};}))}async saveFileToIndexedDB(e,r){return new Promise(((t,o)=>{const s=indexedDB.open(this.dbName);s.onerror=()=>o(s.error),s.onupgradeneeded=e=>{e.target.result.createObjectStore(this.storeName);},s.onsuccess=()=>{try{const n=s.result.transaction(this.storeName,"readwrite"),a=n.objectStore(this.storeName).put(r,e);a.onsuccess=()=>t(a.result),a.onerror=()=>o(a.error);}catch(e){o(e);}};}))}async fetchAndCacheFile(e,r){const t=await fetch(e),o=await t.arrayBuffer();return await this.saveFileToIndexedDB(r,o),o}}
56
56
 
57
- class OnirixSDK{constructor(e){this.authToken=e,this.deviceManager=new DeviceManager,this.indexedDBManager=new IndexedDBManager("onirix-sdk","files"),this.uiManager=new UIManager,this.workerManager=new WorkerManager,this.nativeManager=new NativeManager(this.uiManager,this.deviceManager,this.workerManager,this.indexedDBManager),this.cameraManager=new CameraManager(this.uiManager),this.webXRManager=new WebXRManager(this.uiManager,this.nativeManager,this.deviceManager,this.workerManager),this.imuManager=new IMUManager(this.uiManager,this.deviceManager),this.eventManager=new EventManager;}async init(e){this.started=!1;const t=this.readConfig(e);this.mode=t.mode,this.debug=t.debug;const a=this.mode==TrackingMode.Spatial||t.cameraAccess;switch(await this.nativeManager.init(this.authToken,t),t.renderCanvas?(this.uiManager.setRenderCanvas(t.renderCanvas),this.usingProvidedCanvas=!0):(this.uiManager.createRenderCanvas(),this.usingProvidedCanvas=!1),this.mode){case TrackingMode.Surface:const e=await this.webXRManager.isWebXRSupported();t.disableWorldTracking||!e&&!t.disableWebXR&&t.disableSLAM?(this.surfaceMode=SurfaceMode.Gyroscope,await this.imuManager.init(this.onRotation.bind(this),this.onAcceleration.bind(this),this.onHitTestResult.bind(this)),this.imuManager.start()):t.disableWebXR||!e?(this.surfaceMode=SurfaceMode.SLAM,await this.imuManager.init(this.onRotation.bind(this),this.onAcceleration.bind(this),this.onHitTestResult.bind(this)),this.imuManager.start()):(this.surfaceMode=SurfaceMode.WebXR,await this.webXRManager.init(a,this.onPose.bind(this),(()=>this.stop())),this.webXRManager.setTouchListener(this.onTouch.bind(this)),this.webXRManager.setTouchStartListener(this.onTouchStart.bind(this)),this.webXRManager.setTouchMoveListener(this.onTouchMove.bind(this)),this.webXRManager.setTouchEndListener(this.onTouchEnd.bind(this)),this.webXRManager.setSessionEndListener(this.onSessionEnd.bind(this)),this.webXRManager.setHitTestListener(this.onHitTestResult.bind(this)),this.webXRManager.setResizeListener(this.onResize.bind(this)),this.webXRManager.setFrameListener(this.onFrame.bind(this)),this.webXRManager.start(),this.usingWebXR=!0);break;case TrackingMode.Image:case TrackingMode.QRCode:break;case TrackingMode.Spatial:{const e=await this.webXRManager.isWebXRSupported();t.disableWebXR||!e?(this.surfaceMode=SurfaceMode.SLAM,await this.imuManager.init(this.onRotation.bind(this),this.onAcceleration.bind(this),this.onHitTestResult.bind(this)),this.imuManager.start(),this.nativeManager.siftBuffer=this.nativeManager.nativeSDK._malloc(22e5),this.nativeManager.matchBuffer=this.nativeManager.nativeSDK._malloc(14e3),this.nativeManager.netvladBuffer=this.nativeManager.nativeSDK._malloc(32768),this.extractingIdx=1,this.workerManager.replaceCallback("extraction",(e=>{let t=this.nativeManager.loadExtractionData(e,this.extractingIdx);this.candidates=Array.from(Array(t).keys()).reverse(),this.siftData=e.extraction,this.matchKeyframes();})),this.workerManager.replaceCallback("matching",(e=>{this.nativeManager.loadMatch(e),this.matchKeyframes();}))):(this.surfaceMode=SurfaceMode.WebXR,this.usingWebXR=!0,this.webXRManager.usingSpatial=!0,await this.webXRManager.init(a,this.onPose.bind(this),(()=>this.stop())),this.webXRManager.setTouchListener(this.onTouch.bind(this)),this.webXRManager.setTouchStartListener(this.onTouchStart.bind(this)),this.webXRManager.setTouchMoveListener(this.onTouchMove.bind(this)),this.webXRManager.setTouchEndListener(this.onTouchEnd.bind(this)),this.webXRManager.setSessionEndListener(this.onSessionEnd.bind(this)),this.webXRManager.setHitTestListener(this.onHitTestResult.bind(this)),this.webXRManager.setResizeListener(this.onResize.bind(this)),this.webXRManager.setFrameListener(this.onFrame.bind(this)),this.webXRManager.start(),this.webXRManager.startRelocationTimer());}}if(this.surfaceMode!==SurfaceMode.WebXR){await this.cameraManager.startCamera(),this.uiManager.setTouchListener(this.onTouch.bind(this)),this.uiManager.setTouchStartListener(this.onTouchStart.bind(this)),this.uiManager.setTouchMoveListener(this.onTouchMove.bind(this)),this.uiManager.setTouchEndListener(this.onTouchEnd.bind(this)),this.frameLoop=!0;const e=()=>{this.frameLoop&&(this.onFrame(null),requestAnimationFrame(e));};requestAnimationFrame(e);}return this.onResize(),window.addEventListener("resize",(e=>this.onResize())),this.uiManager.renderCanvas}async start(){switch(this.started=!0,this.mode){case TrackingMode.Surface:switch(this.surfaceMode){case SurfaceMode.Gyroscope:this.imuManager.start();break;case SurfaceMode.SLAM:this.nativeManager.startSLAM((e=>{this.onPose(e);}),this.debug?this.onKeyFrame.bind(this):null,this.onStatusChange.bind(this)),this.processLoop();break;case SurfaceMode.WebXR:this.webXRManager.start();}break;case TrackingMode.Image:this.nativeManager.startImageTracking(this.onDetected.bind(this),this.onPose.bind(this),this.onLost.bind(this)),this.processLoop();break;case TrackingMode.QRCode:this.nativeManager.startQRCodeTracking(this.onDetected.bind(this),this.onPose.bind(this),this.onLost.bind(this)),this.processLoop();break;case TrackingMode.Spatial:this.nativeManager.startSpatialTracking(this.onDetected.bind(this),this.onPose.bind(this),this.usingWebXR),this.processLoop();}}async stop(){switch(this.mode){case TrackingMode.Surface:switch(this.surfaceMode){case SurfaceMode.Gyroscope:this.imuManager.stop();break;case SurfaceMode.SLAM:this.nativeManager.stopSLAM();}break;case TrackingMode.Image:this.nativeManager.stopImageTracking();break;case TrackingMode.QRCode:this.nativeManager.stopQRCodeTracking();break;case TrackingMode.Spatial:this.nativeManager.stopSpatialTracking();}this.started=!1;}matchKeyframes(){if(this.candidates.length>0){let e=this.candidates.pop();this.workerManager.sendDataToWorker("matching",new WorkerMatchingData(e,this.siftData,this.nativeManager.getCandidateData(e),this.nativeManager.extractionType()));}else this.nativeManager.loadKeyframePose(this.extractingIdx),this.extractingIdx++,this.locating=!1;}async destroy(){this.eventManager.stop(),this.nativeManager.destroy(),this.surfaceMode!==SurfaceMode.WebXR?this.cameraManager.stopCamera():this.webXRManager.destroy(),this.usingProvidedCanvas||this.uiManager.renderCanvas.remove(),this.frameLoop=!1;}readConfig(e){if(!e)throw new InternalError("A config object must be provided.");if(!e.mode)throw new InternalError("'mode' is a required parameter.");if(e.mode<=0||e.mode>4)throw new InternalError("Selected mode is not a valid tracking mode.");return 4==e.mode&&e.sceneOid,Object.assign(DefaultConfig,e)}onCameraFrame(){if(this.started){const e=this.uiManager.getVideoData();if(e){if(this.mode===TrackingMode.Spatial&&!this.locating){if(this.nativeManager.numSLAMKeyframes()>this.extractingIdx&&!this.nativeManager.spatialLocated){this.locating=!0;let e=this.nativeManager.getSLAMKeyframe(this.extractingIdx);this.workerManager.sendDataToWorker("extraction",new WorkerExtractionData(e,640,480,0,0,this.nativeManager.extractionType()));}}this.nativeManager.processFrame(e);}const t=this.uiManager.getVideoElement();t&&t.requestVideoFrameCallback(this.onCameraFrame.bind(this));}}processLoop(){this.onCameraFrame();}getCameraParameters(){return this.usingWebXR?this.webXRManager.getCameraParameters():this.uiManager.getCameraParameters()}getXRLayer(){return this.usingWebXR?this.webXRManager.getXRLayer():null}getXRParams(){return this.usingWebXR?{xrSession:this.webXRManager.xrSession,xrLocalRefSpace:this.webXRManager.xrLocalRefSpace,xrViewerRefSpace:this.webXRManager.xrViewerRefSpace}:null}getCameraFeed(){return this.uiManager.getVideoElement()}getSurfaceMode(){return this.surfaceMode}async addImage(e,t){const a=await(i=e,new Promise(((e,t)=>{const a=new Image;a.crossOrigin="Anonymous",a.addEventListener("load",(()=>e(a))),a.addEventListener("error",(e=>t(e))),a.src=i;})));var i;const n=document.createElement("canvas");n.width=640,n.height=480;const s=n.getContext("2d");s.drawImage(a,0,0);const r=s.getImageData(0,0,640,480).data;this.nativeManager.addImage(t,r);}onPose(e){this.eventManager.triggerEvent(Events.OnPose,e);}onKeyFrame(){this.eventManager.triggerEvent(Events.OnKeyFrame);}onStatusChange(e){this.eventManager.triggerEvent(Events.OnStatusChange,e);}onDetected(e){this.eventManager.triggerEvent(Events.OnDetected,e);}onLost(e){this.eventManager.triggerEvent(Events.OnLost,e);}onResize(){this.surfaceMode===SurfaceMode.WebXR?this.webXRManager.fitCanvasToXRViewport():this.uiManager.fitVideoToScreen(),this.eventManager.triggerEvent(Events.OnResize);}onTouch(e){this.eventManager.triggerEvent(Events.OnTouch,e);}onTouchStart(e){this.eventManager.triggerEvent(Events.OnTouchStart,e);}onTouchEnd(e){this.eventManager.triggerEvent(Events.OnTouchEnd,e);}onTouchMove(e){this.eventManager.triggerEvent(Events.OnTouchMove,e);}onSessionEnd(){this.eventManager.triggerEvent(Events.OnSessionEnd);}onHitTestResult(e){this.eventManager.triggerEvent(Events.OnHitTestResult,e);}onAcceleration(e){if((this.mode===TrackingMode.Spatial||this.surfaceMode===SurfaceMode.SLAM)&&this.started){let t=e;this.uiManager.isPortrait()||(t.x*=-1,t.y*=-1),t.z*=-1;const a=t.toArray().concat(0);this.nativeManager.nativeSDK.HEAPF64.set(a,this.nativeManager.nativeSDK.imuAccData/8),this.nativeManager.nativeSDK._OX_ProcessIMUAcceleration(this.nativeManager.nativeSDK.imuAccData);}}onRotation(e){if(this.surfaceMode===SurfaceMode.Gyroscope||this.surfaceMode===SurfaceMode.SLAM&&!this.started){let t=new Matrix4;t.setRotation(e),this.onPose(t.toArray());}else if(this.mode===TrackingMode.Spatial||this.surfaceMode===SurfaceMode.SLAM){let t=e;this.uiManager.isPortrait()&&t.multiply(mat3RotationZ90CW),this.nativeManager.nativeSDK.HEAPF64.set(t.toArray(),this.nativeManager.nativeSDK.imuRotData/8),this.nativeManager.nativeSDK._OX_ProcessIMURotation(this.nativeManager.nativeSDK.imuRotData);}}onFrame(e){this.eventManager.triggerEvent(Events.OnFrame,e);}subscribe(e,t){return this.eventManager.addEventListener(e,t)}unsubscribe(e){this.eventManager.removeEventListener(e);}getSLAMMap(){return this.nativeManager.getSLAMMap()}getSLAMTrackingPoints(){return this.nativeManager.getSLAMTrackingPoints()}raycast(e,t,a,i,n,s){return this.nativeManager.raycast(e,t,a,i,n,s)}}OnirixSDK.TrackingMode=TrackingMode,OnirixSDK.Events=Events;
57
+ class OnirixSDK{constructor(e){this.authToken=e,this.deviceManager=new DeviceManager,this.indexedDBManager=new IndexedDBManager("onirix-sdk","files"),this.uiManager=new UIManager,this.workerManager=new WorkerManager,this.nativeManager=new NativeManager(this.uiManager,this.deviceManager,this.workerManager,this.indexedDBManager),this.cameraManager=new CameraManager(this.uiManager),this.webXRManager=new WebXRManager(this.uiManager,this.nativeManager,this.deviceManager,this.workerManager),this.imuManager=new IMUManager(this.uiManager,this.deviceManager),this.eventManager=new EventManager;}async init(e){this.started=!1;const t=this.readConfig(e);this.mode=t.mode,this.debug=t.debug;const a=this.mode==TrackingMode.Spatial||t.cameraAccess;switch(await this.nativeManager.init(this.authToken,t),t.renderCanvas?(this.uiManager.setRenderCanvas(t.renderCanvas),this.usingProvidedCanvas=!0):(this.uiManager.createRenderCanvas(),this.usingProvidedCanvas=!1),this.mode){case TrackingMode.Surface:const e=await this.webXRManager.isWebXRSupported();t.disableWorldTracking||!e&&!t.disableWebXR&&t.disableSLAM?(this.surfaceMode=SurfaceMode.Gyroscope,await this.imuManager.init(this.onRotation.bind(this),this.onAcceleration.bind(this),this.onHitTestResult.bind(this)),this.imuManager.start()):t.disableWebXR||!e?(this.surfaceMode=SurfaceMode.SLAM,await this.imuManager.init(this.onRotation.bind(this),this.onAcceleration.bind(this),this.onHitTestResult.bind(this)),this.imuManager.start()):(this.surfaceMode=SurfaceMode.WebXR,await this.webXRManager.init(a,this.onPose.bind(this),(()=>this.stop())),this.webXRManager.setTouchListener(this.onTouch.bind(this)),this.webXRManager.setTouchStartListener(this.onTouchStart.bind(this)),this.webXRManager.setTouchMoveListener(this.onTouchMove.bind(this)),this.webXRManager.setTouchEndListener(this.onTouchEnd.bind(this)),this.webXRManager.setSessionEndListener(this.onSessionEnd.bind(this)),this.webXRManager.setHitTestListener(this.onHitTestResult.bind(this)),this.webXRManager.setResizeListener(this.onResize.bind(this)),this.webXRManager.setFrameListener(this.onFrame.bind(this)),this.webXRManager.start(),this.usingWebXR=!0);break;case TrackingMode.Image:case TrackingMode.QRCode:break;case TrackingMode.Spatial:{const e=await this.webXRManager.isWebXRSupported();t.disableWebXR||!e?(this.surfaceMode=SurfaceMode.SLAM,await this.imuManager.init(this.onRotation.bind(this),this.onAcceleration.bind(this),this.onHitTestResult.bind(this)),this.imuManager.start(),this.nativeManager.siftBuffer=this.nativeManager.nativeSDK._malloc(22e5),this.nativeManager.matchBuffer=this.nativeManager.nativeSDK._malloc(14e3),this.nativeManager.netvladBuffer=this.nativeManager.nativeSDK._malloc(32768),this.extractingIdx=1,this.workerManager.replaceCallback("extraction",(e=>{let t=this.nativeManager.loadExtractionData(e,this.extractingIdx);this.candidates=Array.from(Array(t).keys()).reverse(),this.siftData=e.extraction,this.matchKeyframes();})),this.workerManager.replaceCallback("matching",(e=>{this.nativeManager.loadMatch(e),this.matchKeyframes();}))):(this.surfaceMode=SurfaceMode.WebXR,this.usingWebXR=!0,this.webXRManager.usingSpatial=!0,await this.webXRManager.init(a,this.onPose.bind(this),(()=>this.stop())),this.webXRManager.setTouchListener(this.onTouch.bind(this)),this.webXRManager.setTouchStartListener(this.onTouchStart.bind(this)),this.webXRManager.setTouchMoveListener(this.onTouchMove.bind(this)),this.webXRManager.setTouchEndListener(this.onTouchEnd.bind(this)),this.webXRManager.setSessionEndListener(this.onSessionEnd.bind(this)),this.webXRManager.setHitTestListener(this.onHitTestResult.bind(this)),this.webXRManager.setResizeListener(this.onResize.bind(this)),this.webXRManager.setFrameListener(this.onFrame.bind(this)),this.webXRManager.start(),this.webXRManager.startRelocationTimer());}}if(this.surfaceMode!==SurfaceMode.WebXR){await this.cameraManager.startCamera(t.highResolutionCamera),this.uiManager.setTouchListener(this.onTouch.bind(this)),this.uiManager.setTouchStartListener(this.onTouchStart.bind(this)),this.uiManager.setTouchMoveListener(this.onTouchMove.bind(this)),this.uiManager.setTouchEndListener(this.onTouchEnd.bind(this)),this.frameLoop=!0;const e=()=>{this.frameLoop&&(this.onFrame(null),requestAnimationFrame(e));};requestAnimationFrame(e);}return this.onResize(),window.addEventListener("resize",(e=>this.onResize())),this.uiManager.renderCanvas}async start(){switch(this.started=!0,this.mode){case TrackingMode.Surface:switch(this.surfaceMode){case SurfaceMode.Gyroscope:this.imuManager.start();break;case SurfaceMode.SLAM:this.nativeManager.startSLAM((e=>{this.onPose(e);}),this.debug?this.onKeyFrame.bind(this):null,this.onStatusChange.bind(this)),this.processLoop();break;case SurfaceMode.WebXR:this.webXRManager.start();}break;case TrackingMode.Image:this.nativeManager.startImageTracking(this.onDetected.bind(this),this.onPose.bind(this),this.onLost.bind(this)),this.processLoop();break;case TrackingMode.QRCode:this.nativeManager.startQRCodeTracking(this.onDetected.bind(this),this.onPose.bind(this),this.onLost.bind(this)),this.processLoop();break;case TrackingMode.Spatial:this.nativeManager.startSpatialTracking(this.onDetected.bind(this),this.onPose.bind(this),this.usingWebXR),this.processLoop();}}async stop(){switch(this.mode){case TrackingMode.Surface:switch(this.surfaceMode){case SurfaceMode.Gyroscope:this.imuManager.stop();break;case SurfaceMode.SLAM:this.nativeManager.stopSLAM();}break;case TrackingMode.Image:this.nativeManager.stopImageTracking();break;case TrackingMode.QRCode:this.nativeManager.stopQRCodeTracking();break;case TrackingMode.Spatial:this.nativeManager.stopSpatialTracking();}this.started=!1;}matchKeyframes(){if(this.candidates.length>0){let e=this.candidates.pop();this.workerManager.sendDataToWorker("matching",new WorkerMatchingData(e,this.siftData,this.nativeManager.getCandidateData(e),this.nativeManager.extractionType()));}else this.nativeManager.loadKeyframePose(this.extractingIdx),this.extractingIdx++,this.locating=!1;}async destroy(){this.eventManager.stop(),this.nativeManager.destroy(),this.surfaceMode!==SurfaceMode.WebXR?this.cameraManager.stopCamera():this.webXRManager.destroy(),this.usingProvidedCanvas||this.uiManager.renderCanvas.remove(),this.frameLoop=!1;}readConfig(e){if(!e)throw new InternalError("A config object must be provided.");if(!e.mode)throw new InternalError("'mode' is a required parameter.");if(e.mode<=0||e.mode>4)throw new InternalError("Selected mode is not a valid tracking mode.");return 4==e.mode&&e.sceneOid,Object.assign(DefaultConfig,e)}onCameraFrame(){if(this.started){const e=this.uiManager.getVideoData();if(e){if(this.mode===TrackingMode.Spatial&&!this.locating){if(this.nativeManager.numSLAMKeyframes()>this.extractingIdx&&!this.nativeManager.spatialLocated){this.locating=!0;let e=this.nativeManager.getSLAMKeyframe(this.extractingIdx);this.workerManager.sendDataToWorker("extraction",new WorkerExtractionData(e,640,480,0,0,this.nativeManager.extractionType()));}}this.nativeManager.processFrame(e);}const t=this.uiManager.getVideoElement();t&&t.requestVideoFrameCallback(this.onCameraFrame.bind(this));}}processLoop(){this.onCameraFrame();}getCameraParameters(){return this.usingWebXR?this.webXRManager.getCameraParameters():this.uiManager.getCameraParameters()}getXRLayer(){return this.usingWebXR?this.webXRManager.getXRLayer():null}getXRParams(){return this.usingWebXR?{xrSession:this.webXRManager.xrSession,xrLocalRefSpace:this.webXRManager.xrLocalRefSpace,xrViewerRefSpace:this.webXRManager.xrViewerRefSpace}:null}getCameraFeed(){return this.uiManager.getVideoElement()}getSurfaceMode(){return this.surfaceMode}async addImage(e,t){const a=await(i=e,new Promise(((e,t)=>{const a=new Image;a.crossOrigin="Anonymous",a.addEventListener("load",(()=>e(a))),a.addEventListener("error",(e=>t(e))),a.src=i;})));var i;const n=document.createElement("canvas");n.width=640,n.height=480;const s=n.getContext("2d");s.drawImage(a,0,0);const r=s.getImageData(0,0,640,480).data;this.nativeManager.addImage(t,r);}onPose(e){this.eventManager.triggerEvent(Events.OnPose,e);}onKeyFrame(){this.eventManager.triggerEvent(Events.OnKeyFrame);}onStatusChange(e){this.eventManager.triggerEvent(Events.OnStatusChange,e);}onDetected(e){this.eventManager.triggerEvent(Events.OnDetected,e);}onLost(e){this.eventManager.triggerEvent(Events.OnLost,e);}onResize(){this.surfaceMode===SurfaceMode.WebXR?this.webXRManager.fitCanvasToXRViewport():this.uiManager.fitVideoToScreen(),this.eventManager.triggerEvent(Events.OnResize);}onTouch(e){this.eventManager.triggerEvent(Events.OnTouch,e);}onTouchStart(e){this.eventManager.triggerEvent(Events.OnTouchStart,e);}onTouchEnd(e){this.eventManager.triggerEvent(Events.OnTouchEnd,e);}onTouchMove(e){this.eventManager.triggerEvent(Events.OnTouchMove,e);}onSessionEnd(){this.eventManager.triggerEvent(Events.OnSessionEnd);}onHitTestResult(e){this.eventManager.triggerEvent(Events.OnHitTestResult,e);}onAcceleration(e){if((this.mode===TrackingMode.Spatial||this.surfaceMode===SurfaceMode.SLAM)&&this.started){let t=e;this.uiManager.isPortrait()||(t.x*=-1,t.y*=-1),t.z*=-1;const a=t.toArray().concat(0);this.nativeManager.nativeSDK.HEAPF64.set(a,this.nativeManager.nativeSDK.imuAccData/8),this.nativeManager.nativeSDK._OX_ProcessIMUAcceleration(this.nativeManager.nativeSDK.imuAccData);}}onRotation(e){if(this.surfaceMode===SurfaceMode.Gyroscope||this.surfaceMode===SurfaceMode.SLAM&&!this.started){let t=new Matrix4;t.setRotation(e),this.onPose(t.toArray());}else if(this.mode===TrackingMode.Spatial||this.surfaceMode===SurfaceMode.SLAM){let t=e;this.uiManager.isPortrait()&&t.multiply(mat3RotationZ90CW),this.nativeManager.nativeSDK.HEAPF64.set(t.toArray(),this.nativeManager.nativeSDK.imuRotData/8),this.nativeManager.nativeSDK._OX_ProcessIMURotation(this.nativeManager.nativeSDK.imuRotData);}}onFrame(e){this.eventManager.triggerEvent(Events.OnFrame,e);}subscribe(e,t){return this.eventManager.addEventListener(e,t)}unsubscribe(e){this.eventManager.removeEventListener(e);}getSLAMMap(){return this.nativeManager.getSLAMMap()}getSLAMTrackingPoints(){return this.nativeManager.getSLAMTrackingPoints()}raycast(e,t,a,i,n,s){return this.nativeManager.raycast(e,t,a,i,n,s)}}OnirixSDK.TrackingMode=TrackingMode,OnirixSDK.Events=Events;
58
58
 
59
59
  export { OnirixSDK as default };