How to create custom marker in Ar.js?

Gopinath Kaliappan picture Gopinath Kaliappan · Dec 5, 2017 · Viewed 9.4k times · Source

I Was wondering how things work in Ar.js , But i was stuck with creating custom Markers and custom shapes , is there any way to customize things.

this is What i have got things to getting started.

<script src="https://aframe.io/releases/0.6.0/aframe.min.js"></script>
<!-- include ar.js for A-Frame -->
<script src="https://jeromeetienne.github.io/AR.js/aframe/build/aframe-ar.js"></script>
<body style='margin : 0px; overflow: hidden;'>
  <a-scene embedded arjs>
    <!-- create your content here. just a box for now -->
    <a-box position='0 0.5 0' material='opacity: 0.5;'></a-box>
    <!-- define a camera which will move according to the marker position -->
    <a-marker-camera preset='hiro'></a-marker-camera>
  </a-scene>
</body>

This is simple example for getting started

Answer

Chamin Wickramarathna picture Chamin Wickramarathna · Mar 12, 2018

You can use the marker generator.

In the marker generator

  • Upload your image .

  • Download the trained marker.

  • Include it in your Code.

The trained marker is contained in a .patt file. This file contains the encoded marker that you should reuse in your code. You specify you want a pattern marker and you provide the URL to your own marker. So just replace this in your code.

<a-marker-camera preset='custom' type='pattern' url='assets/NAME-OF-PATTERN-FILE.patt'></a-marker-camera>