Convert Figma logo to code with AI

jeromeetienne logoAR.js

Efficient Augmented Reality for the Web - 60fps on mobile!

15,782
2,222
15,782
19

Top Related Projects

Web Augmented Reality. Image Tracking, Face Tracking. Tensorflow.js

Quick Overview

AR.js is an open-source library for Augmented Reality on the web. It allows developers to create AR experiences that run directly in web browsers, without the need for any app installation. AR.js supports marker-based and location-based AR, making it versatile for various applications.

Pros

  • Easy to use and implement, with minimal setup required
  • Works on most modern devices with a web browser and camera
  • Supports both marker-based and location-based AR
  • Lightweight and performant, even on mobile devices

Cons

  • Limited advanced features compared to native AR SDKs
  • Marker detection can be inconsistent in challenging lighting conditions
  • Dependency on device capabilities and browser support
  • Limited 3D object tracking capabilities

Code Examples

  1. Basic marker-based AR scene:
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>

<a-scene embedded arjs>
  <a-marker preset="hiro">
    <a-box position="0 0.5 0" material="color: red;"></a-box>
  </a-marker>
  <a-entity camera></a-entity>
</a-scene>
  1. Location-based AR:
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar-nft.js"></script>

<a-scene vr-mode-ui="enabled: false" embedded arjs="sourceType: webcam; debugUIEnabled: false;">
  <a-text value="Hello, AR!" look-at="[gps-camera]" scale="50 50 50" gps-entity-place="latitude: YOUR_LAT; longitude: YOUR_LON;"></a-text>
  <a-camera gps-camera rotation-reader></a-camera>
</a-scene>
  1. Custom marker with image:
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>

<a-scene embedded arjs="detectionMode: mono_and_matrix; matrixCodeType: 3x3;">
  <a-marker type="pattern" url="path/to/pattern-marker.patt">
    <a-image src="path/to/image.png" position="0 0 0" scale="1 1 1"></a-image>
  </a-marker>
  <a-entity camera></a-entity>
</a-scene>

Getting Started

  1. Include AR.js and A-Frame in your HTML file:

    <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
    <script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
    
  2. Create an AR scene with a marker and 3D object:

    <a-scene embedded arjs>
      <a-marker preset="hiro">
        <a-box position="0 0.5 0" material="color: yellow;"></a-box>
      </a-marker>
      <a-entity camera></a-entity>
    </a-scene>
    
  3. Open the HTML file in a web browser on a device with a camera to experience the AR content.

Competitor Comparisons

Web Augmented Reality. Image Tracking, Face Tracking. Tensorflow.js

Pros of mind-ar-js

  • Image tracking capabilities, allowing for markerless AR experiences
  • Built-in support for custom image targets
  • Optimized for mobile devices with better performance

Cons of mind-ar-js

  • Smaller community and fewer resources compared to AR.js
  • Limited documentation and examples for advanced use cases
  • Potentially steeper learning curve for beginners

Code Comparison

mind-ar-js:

<script src="https://cdn.jsdelivr.net/npm/mind-ar@1.1.5/dist/mindar-image.prod.js"></script>
<a-scene mindar-image="imageTargetSrc: ./targets.mind;" vr-mode-ui="enabled: false">
  <a-camera position="0 0 0" look-controls="enabled: false"></a-camera>
  <a-entity mindar-image-target="targetIndex: 0">
    <a-box position="0 0.1 0" scale="0.3 0.3 0.3" color="red"></a-box>
  </a-entity>
</a-scene>

AR.js:

<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
<a-scene embedded arjs>
  <a-marker preset="hiro">
    <a-box position="0 0.5 0" material="color: red;"></a-box>
  </a-marker>
  <a-entity camera></a-entity>
</a-scene>

Both libraries use A-Frame for 3D rendering, but mind-ar-js focuses on image tracking, while AR.js primarily uses marker-based tracking. mind-ar-js requires specifying image targets, whereas AR.js uses predefined markers like "hiro" in this example.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

AR.js - Augmented Reality for the Web

Logo by Simon Poulter


npm npm Build Status
Gitter chat Patreon donate button Twitter Follow Twitter Follow

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

⚠️ This project repository has been moved to a Github organization account ⚠️

You can find the maintened version of AR.js at this link.

The old repository (the one you are now) will be left up, so all links and CDNs will continue to be available, but this version will not be updated anymore.

⚠️ AR.js repository has been moved, please check it out at: https://github.com/AR-js-org/AR.js ⚠️

Please, open issues and Pull Requests on the new repository: https://github.com/AR-js-org/AR.js

Thank you.

Why move AR.js

AR.js was among those great projects, with great technologies, often disruptive ones, that eventually were lacking from documentation and support.

We tried to carry on the author's terrific work by maintaining this project, handling new versions, issues, pull requests, the community itself. We continued promoting this project through blogs, Medium articles, socials. And we released new features, like the Location Based AR that was not initially present on AR.js.

Now, that we are also ready to ship a new feature, Image Tracking, we feel ready to start a new path, and so we have created a new repository that is not owned by individuals, but by one organization.

Anyone can be added to it, and more people will manage it, in order to make the project more collaborative and avoid "bottlenecks".

We feel this is a new chapter for this project, to not let it die alone. We feel the current Web Augmented Reality market really needed something like AR.js, but only if owned by no-one apart from the community itself. A technology free and Open Source, created by users for the users.

We'd like to thank all contributors and passionate people who help us in this journey.

On the new repository, you will find all the feature you already had here, plus:

  • Image Tracking feature
  • more examples to learn by doing
  • a new, contributive place to get started
  • a new Documentation.

See you on new AR.js org.

Nicolò Carpignoli


AR.js is a free and Open Source software, created by @jeromeetienne and maintained by @nicolocarpignoli. Check the LICENSE.txt to learn more.

NPM DownloadsLast 30 Days