google-ar / codelab-webxr

Building an augmented reality application with the WebXR Device API
https://codelabs.developers.google.com/codelabs/ar-with-webxr/
Apache License 2.0
171 stars 85 forks source link

Only head-model hit testing is supported #23

Closed Fehler40 closed 5 years ago

Fehler40 commented 5 years ago

Hey, I'm trying to implement hit-testing like it's showing here. In the onSessionStarted function I set the frame of reference, but I'm forced to do this in 'head-model'. When I try to set it to 'eye-level' I get this error: Unhandled Promise Rejection: Only head-model hit testing is supported

This is my onSessionStarted function:

onSessionStarted = async () => {
        this.setState({ isARSessionStarted: true, arMessage: 'session started' });
    this.renderer = new THREE.WebGLRenderer({
        alpha: true,
        preserveDrawingBuffer: true,
    });
    this.scene = new THREE.Scene();

    this.renderer.autoClear = false;
    this.renderer.shadowMap.enabled = true;
    this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;

    this.gl = this.renderer.getContext();

    await this.gl.setCompatibleXRDevice(this.session.device);

    this.session.baseLayer = new window.XRWebGLLayer(this.session, this.gl);

    const framebuffer = this.session.baseLayer.framebuffer;
    this.renderer.setFramebuffer(framebuffer);       

     // this.camera.matrixAutoUpdate = false;
    //  this.camera.position.z = 100;
    this.camera = new THREE.PerspectiveCamera();

    this.frameOfRef = await this.session.requestFrameOfReference('eye-level');
    this.session.requestAnimationFrame(this.onXRFrame);

};`

So the behavior of my app is strange. When I want to add an object on the surface, it instead "sticks on the display" and moves with the camera. Is this caused by 'head-model'? Is there a way to fix this? I am on iOS in the XRViewer Browser. Thanks!

Fehler40 commented 5 years ago

Sorry my fault. This belongs to https://github.com/mozilla-mobile/webxr-ios.