|
1 | 1 | <!DOCTYPE html>
|
2 | 2 | <meta name='viewport' content='width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0'>
|
3 |
| -<!-- three.js library --> |
4 |
| -<script src='vendor/three.js/build/three.js'></script> |
| 3 | +<!-- statsmin..js library --> |
| 4 | + |
5 | 5 | <script src='vendor/three.js/examples/js/libs/stats.min.js'></script>
|
6 |
| -<!-- ar.js --> |
7 |
| -<script src="../build/ar-threex.js"></script> |
8 |
| -<script>THREEx.ArToolkitContext.baseURL = '../'</script> |
| 6 | + |
| 7 | +<!-- import three.js and ar-threex library as a module--> |
| 8 | +<script type="importmap"> |
| 9 | + { |
| 10 | + "imports": { |
| 11 | + "threex": "../build/ar-threex.module.js", |
| 12 | + "three": "./vendor/three.js/build/three.module.min.js" |
| 13 | + } |
| 14 | + } |
| 15 | +</script> |
9 | 16 |
|
10 | 17 | <!-- Bind window error for error handling -->
|
11 | 18 | <script>
|
|
18 | 25 | <a href='https://github.com/AR-js-org/AR.js/' target='_blank'>AR.js</a> - use a ar.js marker with pattRatio 0.9
|
19 | 26 | <br/>
|
20 | 27 | Contact me any time at <a href='https://twitter.com/nicolocarp' target='_blank'>@nicolocarp</a>
|
21 |
| -</div><script> |
| 28 | +</div> |
| 29 | +<script type="module"> |
| 30 | + import * as THREE from 'three' |
| 31 | + import { ArSmoothedControls, ArToolkitSource, ArToolkitContext, ArToolkitProfile, ArMarkerControls } from 'threex' |
| 32 | + |
| 33 | + ArToolkitContext.baseURL = '../' |
22 | 34 | //////////////////////////////////////////////////////////////////////////////////
|
23 | 35 | // Init
|
24 | 36 | //////////////////////////////////////////////////////////////////////////////////
|
|
54 | 66 | // handle arToolkitSource
|
55 | 67 | ////////////////////////////////////////////////////////////////////////////////
|
56 | 68 |
|
57 |
| - var artoolkitProfile = new THREEx.ArToolkitProfile() |
| 69 | + var artoolkitProfile = new ArToolkitProfile() |
58 | 70 | // artoolkitProfile.sourceWebcam()
|
59 |
| - artoolkitProfile.sourceImage(THREEx.ArToolkitContext.baseURL + '../test/data/images/marker-artoolkit-pattern-pattratio-09.png') |
| 71 | + artoolkitProfile.sourceImage(ArToolkitContext.baseURL + '../test/data/images/marker-artoolkit-pattern-pattratio-09.png') |
60 | 72 |
|
61 |
| - var arToolkitSource = new THREEx.ArToolkitSource(artoolkitProfile.sourceParameters) |
| 73 | + var arToolkitSource = new ArToolkitSource(artoolkitProfile.sourceParameters) |
62 | 74 |
|
63 | 75 | arToolkitSource.init(function onReady(){
|
64 | 76 | onResize()
|
|
84 | 96 | artoolkitProfile.contextParameters.patternRatio = 0.9
|
85 | 97 |
|
86 | 98 | // create atToolkitContext
|
87 |
| - var arToolkitContext = new THREEx.ArToolkitContext(artoolkitProfile.contextParameters) |
| 99 | + var arToolkitContext = new ArToolkitContext(artoolkitProfile.contextParameters) |
88 | 100 | // initialize it
|
89 | 101 | arToolkitContext.init(function onCompleted(){
|
90 | 102 | // copy projection matrix to camera
|
|
105 | 117 |
|
106 | 118 | var markerGroup = new THREE.Group
|
107 | 119 | scene.add(markerGroup)
|
108 |
| - var markerControls = new THREEx.ArMarkerControls(arToolkitContext, markerGroup, { |
| 120 | + var markerControls = new ArMarkerControls(arToolkitContext, markerGroup, { |
109 | 121 | type : 'pattern',
|
110 | 122 | // patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro',
|
111 |
| - patternUrl : THREEx.ArToolkitContext.baseURL + 'examples/marker-training/examples/pattern-files/pattern-arjs.patt', |
| 123 | + patternUrl : ArToolkitContext.baseURL + 'examples/marker-training/examples/pattern-files/pattern-arjs.patt', |
112 | 124 | })
|
113 | 125 |
|
114 | 126 |
|
115 | 127 | // build a smoothedControls
|
116 | 128 | var smoothedGroup = new THREE.Group()
|
117 | 129 | scene.add(smoothedGroup)
|
118 |
| - var smoothedControls = new THREEx.ArSmoothedControls(smoothedGroup) |
| 130 | + var smoothedControls = new ArSmoothedControls(smoothedGroup) |
119 | 131 | onRenderFcts.push(function(delta){
|
120 | 132 | smoothedControls.update(markerGroup)
|
121 | 133 | })
|
|
0 commit comments