14
7

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が飛び出してきたらカッコいい!
そう思って、AR名刺を作ってみました!

Screenshot_20230519-184547~2.png

名刺から猫ちゃんが飛び出してきて、とっても可愛い。

ARの実装にあたっては、AR.jsというJavaScriptのライブラリを使用しています。
scriptタグで埋め込めば、HTMLだけで完結するので github.io にお手軽公開することもできます。

書いたコードはたったこれだけです(3dモデルは別に必要)

<!DOCTYPE html>
<html>
    <script src="https://aframe.io/releases/1.4.0/aframe.min.js"></script>
    <script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
    <body style="margin : 0px; overflow: hidden;">
        <a-scene
            cursor="rayOrigin: mouse"
            vr-mode-ui="enabled: false;"
            renderer="logarithmicDepthBuffer: true;"
            embedded
            arjs="trackingMethod: best; sourceType: webcam;debugUIEnabled: false;"
        >
            <a-assets>
                <a-asset-item id="cat-obj" src="./cat.obj"></a-asset-item>
                <a-asset-item id="cat-mtl" src="./cat.mtl"></a-asset-item>
            </a-assets>
            <a-marker type="pattern" url="./apple.patt">
                <a-entity>
                    <a-obj-model
                      position="0 0 0"
                      scale="0.05 0.05 0.05"
                      rotation="270 0 0"
                      src="#cat-obj"
                      mtl="#cat-mtl"
                      id="sample"
                    >
                    </a-obj-model>
                </a-entity>
            </a-marker>
            <a-entity camera></a-entity>
        </a-scene>
        <script>
            function boxClick() {
                window.location.href = "https://hiroki-yod.com";
            }
            let box = document.getElementById('sample');
            box.addEventListener('click', boxClick);
        </script>
    </body>
</html>

これからリアルでお会いする方はぜひAR名刺を受け取ってもらえると嬉しいです。

以上、AR名刺を作ろう!でした。

14
7
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
14
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?