前提・実現したいこと
AR.jsを使ってある画像にスマホのカメラをかざすと映像が出る仕組みを作りました。
そこで、その映像を触ると指定したサイトに飛ぶようにしたいのですが、
下記のように記述しても飛びません。
どうすれば飛ぶようになるでしょうか?
iOS用にタップすすると動画が再生するようにしたので、
ダブルタップでリンクへ飛ぶようにしたいです。
該当のソースコード
<!doctype HTML> <html> <head> <meta charset="utf-8"> <!-- A-Frame ライブラリの読み込み --> <script src="aframe-master.min.js"></script> <!-- AR.js ライブラリの読み込み --> <script src="aframe-ar.js"></script> </head> <body style='margin:0px; overflow:hidden;'> <a-assets> <video id="ar-video" autoplay loop="true" muted="true" src="test.mp4"></video> </a-assets> <!-- デバッグ用の画面表示、VR用のボタンをそれぞれ非表示に --> <a-scene embedded arjs="debugUIEnabled:false;" vr-mode-ui="enabled: false"> <!-- 今回作成した『.patt』ファイルを読み込む --> <a-marker type='pattern' url='pattern-test.patt'> <a-video src="#ar-video" width="2.6" height="1.4" position="0 0 0" rotation="270 0 0" play="true"></a-video> </a-marker> <a-entity camera link="href: https://www.google.com/; title: test; image: #ar-video"></a-entity> </a-scene> <script> window.addEventListener('click', function () { var v = document.querySelector('#ar-video'); v.play(); }); </script> <script> // ビデオ格納用の変数定義を追加 var video = null; AFRAME.registerComponent('registerevents', { init: function () { var marker = this.el; // マーカーを検出したイベントの登録 marker.addEventListener('markerFound', function () { // マーカー認識したら、ビデオ再生 if (video == null) { video = document.querySelector('#ar-video'); } video.play(); }); // マーカーを見失ったイベントの登録 marker.addEventListener('markerLost', function () { // マーカー認識が外れたら、、ビデオ停止 video.pause(); }); } }); window.addEventListener('click', function () { video = document.querySelector('#ar-video'); video.play(); }); </script> <script> AFRAME.registerComponent('change-url',{ schema : {}, init : function(){ this.el.addEventListener('click',function(e){ window.location.href = "https://www.rokkado.jp/"; }) } }) </script> </body> </html>

あなたの回答
tips
プレビュー