KITASENJU DESIGN BLOG

memo, html, javascript, unity

playing AR Quick Look automatically

I checked inside of mode-viewer.js. The AR Quick Look code was inside it.

<model-viewer>

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>test</title>
       <script>
           window.onload=()=>{
               const modelUrl = new URL("g5.usdz", self.location.toString());
               /*
               if (this.arScale === 'fixed') {
                   if (modelUrl.hash) {
                       modelUrl.hash += '&';
                   }
                   modelUrl.hash += 'allowsContentScaling=0';
               }*/

               const anchor = document.getElementById("hoge");
               anchor.setAttribute('rel', 'ar');
               const img = document.createElement('img');
               anchor.appendChild(img);
               anchor.setAttribute('href', modelUrl.toString());
               // attach anchor to shadow DOM to ensure iOS16 ARQL banner click message event propagation 
               anchor.style.display = 'none';
               if (!anchor.isConnected)
                   this.shadowRoot.appendChild(anchor);
               console.log('Attempting to present in AR with Quick Look...');
               anchor.click();
               anchor.removeChild(img);
           }
       </script>
    </head>
    <body>
        
        <a id="hoge"></a>
    </body>
</html>
"FOOTER"