Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Image tracking, Location Based AR, Marker tracking. All on the Web.

License

NotificationsYou must be signed in to change notification settings

AR-js-org/AR.js

Repository files navigation

CIcode style: prettierGitter chatTwitter FollowTwitter 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, calledMindAR.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!⚡️

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 replacingmaster keyword with version tag:

<scriptsrc="https://raw.githack.com/AR-js-org/AR.js/3.4.7/aframe/build/aframe-ar-nft.js">

Get started

🖼Image Tracking

Please follow these simple steps:

  • Create a new project with the code below (oropen this live example and go directly to the last step)
  • Run it on a server
  • Open the website on your phone
  • Scanthis picture to see content through the camera.
<scriptsrc="https://cdn.jsdelivr.net/gh/aframevr/aframe@1.6.0/dist/aframe-master.min.js"></script><scriptsrc="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-loaderdiv {text-align: center;font-size:1.25em;color: white;  }</style><bodystyle="margin : 0px; overflow: hidden;"><!-- minimal loader shown until image descriptors are loaded --><divclass="arjs-loader"><div>Loading, please wait...</div></div><a-scenevr-mode-ui="enabled: false;"renderer="logarithmicDepthBuffer: true; precision: medium;"embeddedarjs="trackingMethod: best; sourceType: webcam;debugUIEnabled: false;"><!-- we use cors proxy to avoid cross-origin problems ATTENTION! you need to set up your server --><a-nfttype="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-entitygltf-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-entitycamera></a-entity></a-scene></body>

🌍Location Based Example

Please follow these simple steps:

  • Create a new project with the following snippet, and changeadd-your-latitude andadd-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><metacharset="utf-8"/><metahttp-equiv="X-UA-Compatible"content="IE=edge"/><title>GeoAR.js demo</title><scriptsrc="https://aframe.io/releases/1.6.0/aframe.min.js"></script><scriptsrc="https://unpkg.com/aframe-look-at-component@1.0.0/dist/aframe-look-at-component.min.js"></script><scriptsrc="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar-nft.js"></script></head><body><a-scenevr-mode-ui="enabled: false"arjs="sourceType: webcam; videoTexture: true; debugUIEnabled: false;"><a-textvalue="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-cameragps-camerarotation-reader></a-camera></a-scene></body></html>

🔲 Marker Based Example

Please follow this simple steps:

  • Create a new project with the code below (oropen this live example and go directly to the last step)
  • Run it on a server
  • Open the website on your phone
  • Scanthis picture to see content through the camera.
<!DOCTYPE html><html><scriptsrc="https://aframe.io/releases/1.6.0/aframe.min.js"></script><!-- we import arjs version without NFT but with marker + location based support --><scriptsrc="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script><bodystyle="margin : 0px; overflow: hidden;"><a-sceneembeddedarjs><a-markerpreset="hiro"><!-- we use cors proxy to avoid cross-origin problems ATTENTION! you need to set up your server --><a-entityposition="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-entitycamera></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 theAR.js Official Documentation.

ES6 npm package

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

// Install with npmnpm install @ar-js-org/ar.js
// Install with yarnyarn add @ar-js-org/ar.js

For some examples read thisissue.

New Import Syntax forar-threex.mjs andar.mjs

With the updates 3.4.6,three.js can now be imported using the ES module syntax.To align with this standard,ar-threex.mjs,ar.mjs andar-threex-location-only.mjs should also be imported in the same way using an import map. Here is an example of how to import these modules in your project:

// Example importing ar-threex.mjs<scripttype="importmap">{"imports":{"three":"https://cdn.jsdelivr.net/npm/three@0.164.0/build/three.module.js","threex":"./path/to/ar-threex.mjs",}}</script><scripttype="module">import*asTHREEfrom'three';import{ArToolkitSource,ArToolkitContext,ArMarkerControls}from'threex'// Your AR.js code here</script>

Read the examples included in this repository for more information, but basically the only change is the import syntax.

Troubleshooting, feature requests, community

You can find a lot of help on the oldAR.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 isappreciated and welcome. If you're planning to implement a new feature or changethe api please create an issue first. This way we can ensure that your preciouswork is not in vain.

Issues

If you are having configuration or setup problems, please posta question toStackOverflow.You can also address the question to us in ourGitter 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. Wemay suggest some changes or improvements or alternatives, but for small changesyour pull request should be accepted quickly.

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

Licenses

It isall 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 checkartoolkit5-js licenseandAR.js license.

Full Changelog:AR.js changelog


[8]ページ先頭

©2009-2025 Movatter.jp