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

Package detail

arjs-fork-fix-threejs-imports

AR-js-org21MIT3.4.5

Efficient Augmented Reality for the Web

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

readme

AR.js - Augmented Reality on the Web

CI code style: prettier Gitter chat Twitter Follow Twitter Follow

You can now own the first commit of AR.js! 👉OpenSea

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

30/12/21 Update: There is now also a brand new OSS Web AR JS library around, called MindAR. If you need a great Image tracking feature (also multiple image tracking) and Face tracking, go check it out!
As for now, AR.js is still the only library providing Marker based and Location based AR features.

This project has been created by @jeromeetienne, previously managed by Nicolò Carpignoli and it is now maintained by the AR.js org.

🚀For frequent updates on AR.js you can follow @the official Twitter account and Watch this repo!

Logo is courtesy of Simon Poulter .


⚡️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 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.4.5/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@1.3.0/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; precision: medium;"
    embedded
    arjs="trackingMethod: best; sourceType: webcam;debugUIEnabled: false;"
  >
    <!-- we use cors proxy to avoid cross-origin problems ATTENTION! you need to set up your server -->
    <a-nft
      type="nft"
      url="your-server/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="your-server/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/scene.gltf"
        scale="5 5 5"
        position="150 300 -100"
      >
      </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.3.0/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>
    <a-scene
      vr-mode-ui="enabled: false"
      arjs="sourceType: webcam; videoTexture: true; 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.3.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">
            <!-- we use cors proxy to avoid cross-origin problems ATTENTION! you need to set up your server -->
            <a-entity
            position="0 0 0"
            scale="0.05 0.05 0.05"
            gltf-model="your-server/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>

Important! Be aware that if you are referring to external resources, in any app, especially those using NFT, you will encounter CORS problems if those resources are not in the same server of the code. If you can’t see the tracking, please open your Browser Dev Tools and check if you have CORS errors in the console. If so, you have to fix those errors in order to see your content. The correct fix is to place your resources on the same server of your code.

If you cannot do that, you can host a proxy anywhere server to solve that (https://github.com/Rob--W/cors-anywhere). Please note that several hosting services have policies that does not permit to use such server. Always check hosting services policies before using them to avoid account suspensions

Learn more on the AR.js Official Documentation.

ES6 npm package

You can install AR.js with npm and use in any compatible project that support npm modules (React.js, Vue.js, Next.js or whatelse), to install it run:

// Install with npm
npm install @ar-js-org/ar.js
// Install with yarn
yarn add @ar-js-org/ar.js

For some examples read this issue.

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! artoolkit5-js is under LGPLv3 license and additional permission. And all my code in the AR.js repository is under MIT license. :)

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

Full Changelog: AR.js changelog

changelog

3.4.5

  • Fix for MathUtils issue see #523 #532

3.4.4

  • Make the distance property of gps-new-entity-place available as soon as it's added #507
  • Add option to use the initial GPS location as the world origin, restoring the behaviour of the "classic" components and lessening the possibilty of precision errors due to large values for world coordinates #508
  • Update artoolkit5-js to 0.3.0

3.4.3

  • Add the "reduce shaking" feature (using sensor smoothing) to the new-location-based A-Frame components #483
  • Include missing THREEx import in gps-new-camera, to allow use of ES6 modules #484
  • Add latLonToWorld() method to gps-new-camera, for compatibility with gps-projected-camera #485
  • Enable the gpsTimeInterval property in gps-new-camera (this sets the geolocation maximumAge property)
  • Add a distance property to gps-new-entity-place, representing the distance in metres from the GPS position to the entity. This is dynamically updated as the GPS position changes.
  • Enhanced new-location-based examples.

3.4.2

  • Display webcam errors via DOM element rather than alert box in three.js location based #429
  • Bugfix for undefined this.orientationChangeEventName in new A-Frame location based #464
  • Bugfix for undefined this.el and eventName in AR.js fork of three.js DeviceOrientationControls #471
  • Tweaks to location-based three.js example

    3.4.1

  • Support for other Barcode Markers #469:

    • AR_MATRIX_CODE_5x5_BCH_22_12_5
    • AR_MATRIX_CODE_5x5_BCH_22_7_7
    • AR_MATRIX_CODE_5x5
    • AR_MATRIX_CODE_6x6
  • New arjs-nft-init-data event to get importan NFT marker data (width, height and dpi) #469;
  • Fix for oriantation on iOS #432
  • Typo fix in an example #431

    3.4.0

  • New gh build script to compile libs see #415

  • Restored multimarker examples (learner and player) see #419
  • New A-Frame location based code see #406

    3.4.0-alpha-rc2

  • Fixed bug in aframe image tracking see #407

  • Enhanced three location based code #409 #410
  • Removed double build in Three.js (nft or not) #407
  • Added prettier as formatter and husky as pre-formatter #407
  • New action github script to test linting and code formatting #407

    3.4.0-alpha-rc1

  • ES6 feature into master

  • New threejs location based
  • New dispose methods in arjs-context.js and arjs-source.js
  • Use of artoolkit5-js instead of old jsartoolkit5 as base code
  • Other bug fixes see PR #400

    3.3.3

  • Fixed bug which prevents minDistance and maxDistance working with a simulated location

  • Fixed typo in name of gps-entity-place-update-position event

3.3.2

  • Fixed bug in arjs-webcam-texture component which caused the webcam stream to freeze on iOS. Thanks to @stevenlybeck for this.

  • CORS proxy removed from examples

  • Added custom found/lost events to markerControls for three.js core (thanks to @fcor)

  • Deactivated GPS listener when AR.js app not in the foreground (thanks to @NVFedorov for raising this issue)

  • update license wording (thanks to @chingucoding)

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