      session.addEventListener('end', onSessionEnded);

      initGL();

      xrFramebuffer = gl.createFramebuffer();
      xrGLFactory = new XRWebGLBinding(session, gl);

      session.requestReferenceSpace('local').then((refSpace) => {
        xrRefSpace = refSpace;
        projLayer = xrGLFactory.createProjectionLayer({ space: refSpace, stencil: false });
        session.updateRenderState({ layers: [projLayer] });

        // Loading texture is async, create layer and update render state when done
     