Hi there,
I’m trying to add support for AR to a project. I’ve tried this hit test example on my devices, and it was working fine.
I then pretty much copied the code from the above example but I’m getting the following error
Uncaught (in promise) DOMException: Failed to execute ‘requestHitTestSource’ on ‘XRSession’: Hit test feature is not supported.
below is the function in typescript.
private render(timestamp:any, frame:any){
if (this.allAssets && frame) {
var referenceSpace:any = this.renderer.xr.getReferenceSpace();
var session:any = this.renderer.xr.getSession();
if ( this.hitTestSourceRequested === false ) {
session.requestReferenceSpace( 'viewer' ).then( ( referenceSpace: any ) => {
session.requestHitTestSource( { space: referenceSpace } ).then( ( source: any ) => {
this.hitTestSource = source;
});
session.addEventListener( 'end', () => {
this.hitTestSourceRequested = false;
this.hitTestSource = null;
});
this.hitTestSourceRequested = true;
});
}
if ( this.hitTestSource ) {
var hitTestResults = frame.getHitTestResults( this.hitTestSource );
if ( hitTestResults.length ) {
var hit = hitTestResults[ 0 ];
this.reticle.visible = true;
this.reticle.matrix.fromArray( hit.getPose( referenceSpace ).transform.matrix );
}
else {
this.reticle.visible = false;
}
}
}
this.renderer.render( this.scene, this.camera );
}
Any ideas?