Search code examples
augmented-realityaframe

aframe and markerless AR, object flickering


I am learning AR and I want to create one without a marker, just show some primitives over the device camera image, I did this example but my objects are flickering. I am using incorrect scripts? What I am doing wrong?

Also, I am looking for a markerless AR tutorial but I can not find any.

Thanks!

<html>
<head>
<script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>
<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.6.0/aframe/build/aframe-ar.js"></script>
</head>
<body style="margin : 0px; overflow: hidden;">
<a-scene embedded arjs renderer='logarithmicDepthBuffer: true;'>
  <a-box position="-1 0 -3" rotation="0 45 0" color="#4CC3D9" ></a-box>
  <a-box position="1 0 -4" rotation="-90 0 0" color="#7BC8A4" ></a-box>
  <a-entity light="type: ambient; intensity: 0.2"></a-entity>
  <a-entity light="type: point; intensity:0.8; distance:10" position="0 2 1.5"></a-entity>
</a-scene>
</body>
</html>

Solution

  • Always use latest libraries and use a-frame site and your main source for learning.

    Here is a working script:

    <!DOCTYPE html>
     <html>
        <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>GeoAR.js demo</title>
        <script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>
        <script src="https://unpkg.com/[email protected]/dist/aframe-look-at-component.min.js"></script>
        <script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar-nft.js"></script>
      </head>
    
      <body>
        <a-scene
          vr-mode-ui="enabled: false"
          arjs="sourceType: webcam; videoTexture: true; debugUIEnabled: false;"
        >
        <a-box width="0.25" height="0.25" depth="0.25" position="-0.25 1.125 -0.75" rotation="0 45 0" color="#4CC3D9"></a-box>
        <a-sphere position="0 1.3125 -1.25" radius="0.3125" color="#EF2D5E"></a-sphere>
        <a-cylinder position="0.25 1.1875 -0.75" radius="0.125" height="0.375" color="#FFC65D"></a-cylinder>
        <a-plane position="0 0 -1" rotation="-90 0 0" width="1" height="1" color="#7BC8A4" shadow></a-plane>
    
          <a-camera  rotation-reader> </a-camera>
        </a-scene>
      </body>
    </html>