sabomate / AR-video_viewer

0 stars 0 forks source link

nftマーカとの距離とか関係を調査 #55

Closed tagahei closed 7 months ago

tagahei commented 7 months ago

解決したい課題

表示位置が安定しない -> 認識した時点で座標軸が展開され,座標の幅が認識した位置によって異なるのでは?

やること

tagahei commented 7 months ago

イベント https://ar-js-org.github.io/AR.js-Docs/ui-events/

tagahei commented 7 months ago

マーカーから距離を得る

// import this on your HTML
window.addEventListener('load', () => {
    const camera = document.querySelector('[camera]');
    const marker = document.querySelector('a-marker');
    let check;

    marker.addEventListener('markerFound', () => {
        let cameraPosition = camera.object3D.position;
        let markerPosition = marker.object3D.position;
        let distance = cameraPosition.distanceTo(markerPosition)

        check = setInterval(() => {
            cameraPosition = camera.object3D.position;
            markerPosition = marker.object3D.position;
            distance = cameraPosition.distanceTo(markerPosition)

            // do what you want with the distance:
            console.log(distance);
        }, 100);
    });

    marker.addEventListener('markerLost', () => {
      clearInterval(check);
    })
})
tagahei commented 7 months ago

DPIが大事っぽい,これによって表示するコンテンツのサイズも変更されるっぽい

重要な要素は画像の DPI です。良好な dpi (300 以上) では非常に良好な安定化が得られますが、低い DPI (72 など) ではユーザーは非常に静止して画像の近くに留まる必要があり、そうしないと追跡が遅れます。 。

https://medium.com/@noemi__biro/exclusive-builds-of-tracking-image-based-tracking-ar-js-d92821cae83d

tagahei commented 7 months ago

この人のやつめっちゃきれいに場所でとるな,JS何も書いてないけど

https://www.jyuko49.com/entry/2021/01/04/210815

tagahei commented 7 months ago

この処理めっちゃポジションを真ん中にしている感ある -> THREE.jsっぽい https://discourse.threejs.org/t/way-to-raycast-webar-ar-js/55244

            window.addEventListener('arjs-nft-init-data', function(nft) {
              console.log(nft);
              var msg = nft.detail;
              model.position.y = (msg.height / msg.dpi * 2.54 * 10)/2.0; //y axis?
              model.position.x = (msg.width / msg.dpi * 2.54 * 10)/2.0; //x axis?
            })