Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

saiba

AR-js-org48MIT3.3.1

Efficient Augmented Reality for the Web

AR, VR, three.js, aframe, augmented reality, location based, image tracking, marker based

readme

AR.js - Augmented Reality on the Web


Build Status Gitter chat Twitter Follow Twitter Follow

AR.js is a lightweight library for Augmented Reality on the Web, coming with features like Image Tracking, Location-based AR and Marker tracking.

Welcome to the official repository!

This project has been created by @jeromeetienne and it is now maintained by @nicolocarpignoli.

🚀For frequent updates on AR.js you can follow @nicolocarp and Watch this repo!

Logo is courtesy of Simon Poulter .


You can get paid support and new features for AR.js. Check this link.


⚡️AR.js has now an official Documentation!⚡️

Check it out: AR.js Official Documentation.

If you want to give a first look at AR.js potential, you can continue with this Readme.


⚡️ AR.js is coming in two, different builds. They are both maintained. They are exclusive.

Please import the one you need for your project, not both:

You can also import a specific version replacing master keyword with version tag:

  <script src="https://raw.githack.com/AR-js-org/AR.js/3.3.1/aframe/build/aframe-ar-nft.js">

Get started

🖼 Image Tracking

Please follow these simple steps:

  • Create a new project with the code below (or open this live example and go directly to the last step)
  • Run it on a server
  • Open the website on your phone
  • Scan this picture to see content through the camera.
<script src="https://cdn.jsdelivr.net/gh/aframevr/aframe@1c2407b26c61958baa93967b5412487cd94b290b/dist/aframe-master.min.js"></script>
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar-nft.js"></script>

<style>
  .arjs-loader {
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .arjs-loader div {
    text-align: center;
    font-size: 1.25em;
    color: white;
  }
</style>

<body style="margin : 0px; overflow: hidden;">
  <!-- minimal loader shown until image descriptors are loaded -->
  <div class="arjs-loader">
    <div>Loading, please wait...</div>
  </div>
  <a-scene
    vr-mode-ui="enabled: false;"
    renderer="logarithmicDepthBuffer: true;"
    embedded
    arjs="trackingMethod: best; sourceType: webcam;debugUIEnabled: false;"
  >
    <!-- we use cors proxy to avoid cross-origin problems -->
    <a-nft
      type="nft"
      url="https://arjs-cors-proxy.herokuapp.com/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/trex-image/trex"
      smooth="true"
      smoothCount="10"
      smoothTolerance=".01"
      smoothThreshold="5"
    >
      <a-entity
        gltf-model="https://arjs-cors-proxy.herokuapp.com/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/scene.gltf"
        scale="5 5 5"
        position="50 150 0"
      >
      </a-entity>
    </a-nft>
    <a-entity camera></a-entity>
  </a-scene>
</body>

🌍Location Based Example

Please follow these simple steps:

  • Create a new project with the following snippet, and change add-your-latitude and add-your-longitude with your latitude and longitude, without the <>.
  • Run it on a server
  • Activate GPS on your phone and navigate to the example URL
  • Look around. You should see the text looking at you, appearing in the requested position, even if you look around and move.
<!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.0.4/aframe.min.js"></script>
    <script src="https://unpkg.com/aframe-look-at-component@0.8.0/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 style="margin: 0; overflow: hidden;">
    <a-scene
      vr-mode-ui="enabled: false"
      embedded
      arjs="sourceType: webcam; debugUIEnabled: false;"
    >
      <a-text
        value="This content will always face you."
        look-at="[gps-camera]"
        scale="120 120 120"
        gps-entity-place="latitude: <add-your-latitude>; longitude: <add-your-longitude>;"
      ></a-text>
      <a-camera gps-camera rotation-reader> </a-camera>
    </a-scene>
  </body>
</html>

🔲 Marker Based Example

Please follow this simple steps:

  • Create a new project with the code below (or open this live example and go directly to the last step)
  • Run it on a server
  • Open the website on your phone
  • Scan this picture to see content through the camera.
<!DOCTYPE html>
<html>
    <script src="https://aframe.io/releases/1.0.0/aframe.min.js"></script>
    <!-- we import arjs version without NFT but with marker + location based support -->
    <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 embedded arjs>
        <a-marker preset="hiro">
            <a-entity
            position="0 -1 0"
            scale="0.05 0.05 0.05"
            gltf-model="https://arjs-cors-proxy.herokuapp.com/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/scene.gltf"
            ></a-entity>
        </a-marker>
        <a-entity camera></a-entity>
        </a-scene>
    </body>
</html>

Learn more on the AR.js Official Documentation.

Troubleshooting, feature requests, community

You can find a lot of help on the old AR.js repositories issues. Please search on open/closed issues, you may find interesting stuff.

Contributing

From opening a bug report to creating a pull request: every contribution is appreciated and welcome. If you're planning to implement a new feature or change the api please create an issue first. This way we can ensure that your precious work is not in vain.

Issues

If you are having configuration or setup problems, please post a question to StackOverflow. You can also address the question to us in our Gitter chatroom

If you have discovered a bug or have a feature suggestion, feel free to create an issue on Github.

Submitting Changes

After getting some feedback, push to your fork and submit a pull request. We may suggest some changes or improvements or alternatives, but for small changes your pull request should be accepted quickly.

Some things that will increase the chance that your pull request is accepted:

Licenses

It is all open-source! jsartoolkit5 is under LGPLv3 license and additional permission. And All my code in AR.js repository is under MIT license. :)

For legal details, be sure to check jsartoolkit5 license and AR.js license.

Full Changelog: AR.js changelog

changelog

3.3.1

  • Fix minor location-based bugs

3.3.0

  • Fix shaking of far/near entities on location-based using new configurable properties (thanks to @nickw1)

3.2.1

  • show camera error alert after dispatching camera-error event

3.2.0

  • support arbitrarily distant places on location-based (thanks to @nickw1, see PR #119)
  • minor bug fixes

3.1.0

  • added new, alternative version for location-based using a projected camera based on Spherical Mercator. For this purpose we introduce two new aframe components: gps-projected-camera and gps-projected-entity-place (thanks to @nickw1)
  • added video stop on marker being lost (nft-video example)
  • fixed rotation bug on X axis see issue #59, restored shift position on y instead of z
  • removed links to old repository in the examples
  • added maxDistance property on location-based
  • new arjs-nft-loaded event listener for NFT markers, dispatched when all NFT markers are loaded see PR #98 and issue #97

3.0.2

  • update documentation using latest aframe version on every example

3.0.1

  • fixed minDistance property updating on location based
  • enhanced Image tracking examples

3.0.0

  • fix minor Readme paths/typos

3.0.0-beta-3

  • cleaned location based examples
  • removed gps-camera-debug component
  • enhanced Custom Events payloads

3.0.0-beta-2

  • Fixed some path issues to make NFT work with remote sites
  • Updated HOW_TO_RELEASE.md for new structure

3.0.0-beta

  • Added Image Tracking (NFT) support
  • New structure: 2 alternative versions (A-Frame/Three.js image tracking+location based, A-Frame/Three.js markers+location based)
  • Added a Web Worker for Image Tracking performances (as Blob object to be used cross-domain)
  • New examples structure, divided by features
  • Added examples for Image Tracking
  • Removed minified versions
  • Removed UglifyJS dependency
  • ES6 support
  • Move to new organization
  • Move to new repository
  • Change package.json info
  • Cleaned code from some examples/experiments
  • Removed obsolete code of Aruco markers and Google Tango
  • Reduced repository size by ~36%

2.2.2

  • Restored old camera constraints, was giving better performances for some devices but worst for others.

2.2.0

  • it's now possible to track markers with white background and black shapes, using labelingMode: white_region; property on arjs component (thanks to @umutto)
  • in location based is now possible to simulate altitude, longitude and latitude for user position (thanks to @cmcfadden)
  • default package script for jsdelvr (thanks to @benalfree)

2.1.8

  • handle y position (height) of content in Location Based, using position property of A-FRAME

2.1.7

  • enhanced distance property, now calculating combined distance for latitude/longitude

2.1.6

  • set distance in distance property of gps-entity-place (location based) as z axis (previously was x axis)

2.1.5

  • added distance and distanceMsg properties to gps-entity-place (location based)
  • added new example for distance property
  • added new example for a gps-entity-place that is always facing the user (location based)
  • fixed error when source is image or video and not camera
  • enhanced docs

2.1.4

  • fixed wrong positioning of content on markers

2.1.3

  • fixed a bug that causes Overconstrained Error on desktop
  • cleaned repo (removed data like videos and heavy files)

2.1.0

2.0.8

  • Fixed bug on location-based while added places via HTML
  • Added example of location-based using only HTML
  • Added loader during the time between gps-camera initialization and gps-entity-place add

2.0.5

  • Fixed a bug on location-based statically add of places via script

2.0.4

  • Fixed motion and orientation sensors permission for iOS 13+ devices

2.0.1

  • Fixed location-based files build
  • Removed unuseful imports on location-based examples

2.0.0

  • Introduced Location Based Augmented Reality adding new aframe custom components (gps-entity-place, gps-camera, gps-camera-debug)
  • Added new and updated documentation
  • Added examples for Location Based AR
  • Reduced repository size deleting unuseful code

1.7.8

(Release drafted for problems with the release flow. No change from previous version)

1.7.7

  • added event when camera video stream has been appended to the DOM tree (arjs-video-loaded)

1.7.5

  • added events for camera initialization success/error (camera-init, camera-error)
  • enhanced Debug UI style
  • minor documentation fixes

1.7.2

  • updated three.js dependency to r103 version
  • minor documentation fixes
  • replace all rawgit URLs (learn more at https://rawgit.com/)

1.7.1

  • added possibility to change border marker color in marker generator

1.7.0

  • optionally manage smooth parameter (for video entity glitches and similar problems)
  • generate .patt files keeping uploaded image name
  • enhanced marker generator
  • reduce build size

1.6.3-dev

  • added a npm run build script for travis

1.6.2

  • Adds TravisCI config with NPM deployment configured - thanks @joestrong - #344

1.6.1

aframe-ar.js

  • aframe-ar.js - <a-marker> elements will emit markerFound and markerLost events - thanks @nikolaymihaylov! Pull Request #303

Demos

  • Created an example that demonstrates emitting events when markers are found and lost, and registering the respective event listeners.

1.6.0

1.5.5

  • Fix cross domain issue with https://webxr.io/augmented-website/
  • reduced npm package size from 250mbyte to 3.5mbyte #256 (thanks @paztis)
  • fixed perspective in artoolkit portrait #212 (thanks @pikilipita)
  • fixed barcode in a-frame #260 (thanks @basbase)
  • created portableAR.js - a simple way to port ar.js to a non-three.js framework
    • it is in /three.js/contribs/portableAR.js
    • in examples/ you can find babylon.js using portableAR.js
  • made webvr-polyfill obsolete
    • it was more a toy than something currently useful
    • it was far from complete, not even in a workable state, anyway
  • reorganized examples/ folder
    • created demos/ to contain working demos
    • created experiments/ to contain work in progress

Tests

  • Made tests to report failure - yeah i know it is silly but before it reported
  • Added test to measure performance : fps
  • Added test for markers-area learning and usage
  • Added test for artoolkit, aruco and hit-testing

1.5.1

aframe-ar.js

  • aframe-ar.js - added link into https://webxr.io/augmented-website/
  • aframe-ar.js - change debugUIEnabled default from false to true.
  • FIX: in aframe-ar.js object3d stayed visible when marker goes out of screen

babylon-ar.js

  • AR.js now work with babylon.js source
  • It is early but it is working!

Demos

  • drafting a demo for 3d.io - tweet - source
  • Magic door bridging AR and VR tweet
    • nice reuseable components available
  • made demos to celebrate firefox 55 - post - source
  • made demo for mapbox - tweet - source
  • vr-camera-controls - or how to walk in VR with AR.js - tweet

1.4.10

  • support for markers-area
    • Efficient user friendly area scanning
    • More Versatile than single marker tracking 0 larger areas than single markers
    • More Robust than single marker tracking - even if only one sub marker is visible it is still tracking
    • More Stable than single marker tracking - position is averaged based on visible markers
  • Support for multiple tracking
  • single api for all tracking
  • tango support
  • support for aruco WIP - all included but need to fix pose estimation

1.3.0

Totally incomplete

  • added smoothedControls - everything tunable via parameters
    • it applies LERP for position/quaternion/scale on sub-controls
    • if display controls object3d when sub-controls has been visible for minVisibleDelay
    • if display controls object3d when sub-controls has been unvisible for minUnvisibleDelay
  • did THREEx.ArMarkerHelper to help visualize marker
  • AR-Code generator - see AR-Code Generator
  • liquid markers are in! water tweet - boing tweet
  • marker invisible cloak are in! with tweening and all :) first tweet - video tweet
  • minimal.html just got a little bit cleaner
    • aka the simplest way to do AR on the web
    • or webar in less than 10 lines of html! on codepen
  • finished hole-in-the-wall demo - duck on my desk tweet
  • support preset in a-frame a-marker - preset = ["hiro" | "kanji"]
  • experiementation in dead-reckoning ... not conclusive
  • early work about videoInWebgl - a important componant of phone-in-hmd usecase first tweet
  • better handling of .baseUrl in aframe default parameters
  • fixed artoolkit projection matrix to be more webgl - projection matrix
    • it was looking to positive-z and y was upside down compared to the usual webgl one
  • Change marker axis - now positive-y is normal to the marker
  • Added logo by @tentone - AR.js logo Nice and slick! thanks @tentone
  • Added a-frame logo in AR - aframe-logo.html
  • added a profile discovery. It helps choose the performance tradeoff which fit your case - profile

1.0.0 - AR.js has landed

  • Fixed the resize issue in a-frame!
  • Performance improvement of image copy time by 40%!!!
    • massive improvement in the pose detection time
    • so maxDetectionRate can go way up
  • Improved documentations

0.9.0 - Initial Release

I worked a lot on WebAR. But i recently reached 60fps on mobile phones. so i think WebAR is now ready to be released :)

I will keep the usual branch model

  • stable release on master branch
  • current release on dev branch
  • features in progress on their own branch