Since version 3.4.6, Three.js and AR.js modules (ar-threex.mjs, ar.mjs, and ar-threex-location-only.mjs) can be imported using standard ES module syntax via an import map. This is the recommended way to use AR.js in modern JavaScript environments.
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.164.0/build/three.module.js",
"threex": "./path/to/ar-threex.mjs",
}
}
</script>
<script type="module">
import * as THREE from 'three';
import { ArToolkitSource, ArToolkitContext, ArMarkerControls } from 'threex'
// Your AR.js code here
</script>