     requiredFeatures: useLayer?['layers']:[],
        }).then(onSessionStarted);
      }

      function onSessionStarted(session) {
        xrButton.setSession(session);

        session.addEventListener('end', onSessionEnded);

        gl = createWebGLContext({
          xrCompatible: true, webgl2: true
        });

        renderer = new Renderer(gl);

        scene.setRenderer(renderer);

        if (useLayer) {
            xrFramebuffer = gl.createFramebuffer();
            xrGLFactory = new XRWebGLBi