0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AR Quick Lookを自動で再生させる

Last updated at Posted at 2023-09-09
  • model-viewer.jsを参考にした
  • .usdzへの直リンクでも自動で起動する。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>test</title>
       <script>
           window.onload=()=>{
               const modelUrl = new URL("test.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>

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?