Просмотр исходного кода

Set the namespace to AR

customisations
alemart 1 год назад
Родитель
Сommit
52d5b3aeab

+ 3
- 3
demos/assets/aframe-with-encantar.js Просмотреть файл

@@ -11,7 +11,7 @@ __THIS_PLUGIN_HAS_BEEN_TESTED_WITH__({
11 11
 });
12 12
 
13 13
 /**
14
- * Connect encantar.js to aframe
14
+ * Do magic to connect encantar.js to aframe
15 15
  * @param {(canvas: HTMLCanvasElement) => Promise<Session> | SpeedyPromise<Session>} startARSession
16 16
  */
17 17
 function encantar(startARSession)
@@ -228,8 +228,8 @@ else
228 228
  */
229 229
 function __THIS_PLUGIN_HAS_BEEN_TESTED_WITH__(json)
230 230
 {
231
-    try { Martins, AFRAME;
232
-    const versionOf = { 'encantar.js': Martins.version.replace(/-.*$/, ''), 'aframe': AFRAME.version };
231
+    try { AR, AFRAME;
232
+    const versionOf = { 'encantar.js': AR.version.replace(/-.*$/, ''), 'aframe': AFRAME.version };
233 233
     const check = (x,v,w) => v !== w ? console.warn(`\n\n\nWARNING\n\nThis plugin has been tested with ${x} version ${v}. The version in use is ${w}. Usage of ${x} version ${v} is recommended instead.\n\n\n`) : void 0;
234 234
     for(const [x, expected] of Object.entries(json)) check(x, expected.version, versionOf[x]);
235 235
     } catch(e) { alert(e.message); }

+ 3
- 3
demos/assets/three-with-encantar.js Просмотреть файл

@@ -23,7 +23,7 @@ __THIS_PLUGIN_HAS_BEEN_TESTED_WITH__({
23 23
  */
24 24
 
25 25
 /**
26
- * Connect encantar.js to three.js
26
+ * Do magic to connect encantar.js to three.js
27 27
  * @param {() => Promise<Session> | SpeedyPromise<Session>} startARSession
28 28
  * @param {(ar: ARSystem) => void} [animateVirtualScene] animation callback
29 29
  * @param {(ar: ARSystem) => void | Promise<void> | SpeedyPromise<Session>} [initializeVirtualScene] initialization callback
@@ -147,8 +147,8 @@ function encantar(startARSession, animateVirtualScene, initializeVirtualScene)
147 147
 function __THIS_PLUGIN_HAS_BEEN_TESTED_WITH__(json)
148 148
 {
149 149
     window.addEventListener('load', () => {
150
-    try { Martins, __THREE__;
151
-    const versionOf = { 'encantar.js': Martins.version.replace(/-.*$/, ''), 'three.js': __THREE__ };
150
+    try { AR, __THREE__;
151
+    const versionOf = { 'encantar.js': AR.version.replace(/-.*$/, ''), 'three.js': __THREE__ };
152 152
     const check = (x,v,w) => v !== w ? console.warn(`\n\n\nWARNING\n\nThis plugin has been tested with ${x} version ${v}. The version in use is ${w}. Usage of ${x} version ${v} is recommended instead.\n\n\n`) : void 0;
153 153
     for(const [x, expected] of Object.entries(json)) check(x, expected.version, versionOf[x]);
154 154
     } catch(e) { alert(e.message); }

+ 7
- 7
demos/hello-aframe/demo.js Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 async function startARSession(canvas)
2 2
 {
3
-    if(!Martins.isSupported()) {
3
+    if(!AR.isSupported()) {
4 4
         throw new Error(
5 5
             'This device is not compatible with this AR experience.\n\n' +
6 6
             'User agent: ' + navigator.userAgent
@@ -10,15 +10,15 @@ async function startARSession(canvas)
10 10
     if(!(canvas instanceof HTMLCanvasElement))
11 11
         throw new Error(`startARSession expects a <canvas>`);
12 12
 
13
-    //Martins.Settings.powerPreference = 'low-power';
13
+    //AR.Settings.powerPreference = 'low-power';
14 14
 
15
-    const tracker = Martins.Tracker.ImageTracker();
15
+    const tracker = AR.Tracker.ImageTracker();
16 16
     await tracker.database.add([{
17 17
         name: 'my-reference-image',
18 18
         image: document.getElementById('my-reference-image')
19 19
     }]);
20 20
 
21
-    const viewport = Martins.Viewport({
21
+    const viewport = AR.Viewport({
22 22
         canvas: canvas,
23 23
         container: document.getElementById('ar-viewport'),
24 24
         hudContainer: document.getElementById('ar-hud')
@@ -27,10 +27,10 @@ async function startARSession(canvas)
27 27
     const video = document.getElementById('my-video');
28 28
     const useWebcam = (video === null);
29 29
     const source = useWebcam ?
30
-        Martins.Source.Camera({ resolution: 'md' }) :
31
-        Martins.Source.Video(video);
30
+        AR.Source.Camera({ resolution: 'md' }) :
31
+        AR.Source.Video(video);
32 32
 
33
-    const session = await Martins.startSession({
33
+    const session = await AR.startSession({
34 34
         mode: 'immersive',
35 35
         viewport: viewport,
36 36
         trackers: [ tracker ],

+ 7
- 7
demos/hello-three/demo.js Просмотреть файл

@@ -99,22 +99,22 @@ window.addEventListener('load', () => {
99 99
 
100 100
     async function startARSession()
101 101
     {
102
-        if(!Martins.isSupported()) {
102
+        if(!AR.isSupported()) {
103 103
             throw new Error(
104 104
                 'This device is not compatible with this AR experience.\n\n' +
105 105
                 'User agent: ' + navigator.userAgent
106 106
             );
107 107
         }
108 108
 
109
-        //Martins.Settings.powerPreference = 'low-power';
109
+        //AR.Settings.powerPreference = 'low-power';
110 110
 
111
-        const tracker = Martins.Tracker.ImageTracker();
111
+        const tracker = AR.Tracker.ImageTracker();
112 112
         await tracker.database.add([{
113 113
             name: 'my-reference-image',
114 114
             image: document.getElementById('my-reference-image')
115 115
         }]);
116 116
 
117
-        const viewport = Martins.Viewport({
117
+        const viewport = AR.Viewport({
118 118
             container: document.getElementById('ar-viewport'),
119 119
             hudContainer: document.getElementById('ar-hud')
120 120
         });
@@ -122,10 +122,10 @@ window.addEventListener('load', () => {
122 122
         const video = document.getElementById('my-video');
123 123
         const useWebcam = (video === null);
124 124
         const source = useWebcam ?
125
-            Martins.Source.Camera({ resolution: 'md' }) :
126
-            Martins.Source.Video(video);
125
+            AR.Source.Camera({ resolution: 'md' }) :
126
+            AR.Source.Video(video);
127 127
 
128
-        const session = await Martins.startSession({
128
+        const session = await AR.startSession({
129 129
             mode: 'immersive',
130 130
             viewport: viewport,
131 131
             trackers: [ tracker ],

+ 7
- 7
demos/hello-webgl/demo.js Просмотреть файл

@@ -911,22 +911,22 @@ window.addEventListener('load', async function() {
911 911
 
912 912
     async function startARSession()
913 913
     {
914
-        if(!Martins.isSupported()) {
914
+        if(!AR.isSupported()) {
915 915
             throw new Error(
916 916
                 'This device is not compatible with this AR experience.\n\n' +
917 917
                 'User agent: ' + navigator.userAgent
918 918
             );
919 919
         }
920 920
 
921
-        //Martins.Settings.powerPreference = 'low-power';
921
+        //AR.Settings.powerPreference = 'low-power';
922 922
 
923
-        const tracker = Martins.Tracker.ImageTracker();
923
+        const tracker = AR.Tracker.ImageTracker();
924 924
         await tracker.database.add([{
925 925
             name: 'my-reference-image',
926 926
             image: document.getElementById('my-reference-image')
927 927
         }]);
928 928
 
929
-        const viewport = Martins.Viewport({
929
+        const viewport = AR.Viewport({
930 930
             container: document.getElementById('ar-viewport'),
931 931
             hudContainer: document.getElementById('ar-hud')
932 932
         });
@@ -934,10 +934,10 @@ window.addEventListener('load', async function() {
934 934
         const video = document.getElementById('my-video');
935 935
         const useWebcam = (video === null);
936 936
         const source = useWebcam ?
937
-            Martins.Source.Camera({ resolution: 'md' }) :
938
-            Martins.Source.Video(video);
937
+            AR.Source.Camera({ resolution: 'md' }) :
938
+            AR.Source.Video(video);
939 939
 
940
-        const session = await Martins.startSession({
940
+        const session = await AR.startSession({
941 941
             mode: 'immersive',
942 942
             viewport: viewport,
943 943
             trackers: [ tracker ],

+ 7
- 7
demos/hello-world/demo.js Просмотреть файл

@@ -15,22 +15,22 @@ window.addEventListener('load', async function() {
15 15
 
16 16
     async function startARSession()
17 17
     {
18
-        if(!Martins.isSupported()) {
18
+        if(!AR.isSupported()) {
19 19
             throw new Error(
20 20
                 'This device is not compatible with this AR experience.\n\n' +
21 21
                 'User agent: ' + navigator.userAgent
22 22
             );
23 23
         }
24 24
 
25
-        //Martins.Settings.powerPreference = 'low-power';
25
+        //AR.Settings.powerPreference = 'low-power';
26 26
 
27
-        const tracker = Martins.Tracker.ImageTracker();
27
+        const tracker = AR.Tracker.ImageTracker();
28 28
         await tracker.database.add([{
29 29
             name: 'my-reference-image',
30 30
             image: document.getElementById('my-reference-image')
31 31
         }]);
32 32
 
33
-        const viewport = Martins.Viewport({
33
+        const viewport = AR.Viewport({
34 34
             container: document.getElementById('ar-viewport'),
35 35
             hudContainer: document.getElementById('ar-hud')
36 36
         });
@@ -38,10 +38,10 @@ window.addEventListener('load', async function() {
38 38
         const video = document.getElementById('my-video');
39 39
         const useWebcam = (video === null);
40 40
         const source = useWebcam ?
41
-            Martins.Source.Camera({ resolution: 'md' }) :
42
-            Martins.Source.Video(video);
41
+            AR.Source.Camera({ resolution: 'md' }) :
42
+            AR.Source.Video(video);
43 43
 
44
-        const session = await Martins.startSession({
44
+        const session = await AR.startSession({
45 45
             mode: 'immersive',
46 46
             viewport: viewport,
47 47
             trackers: [ tracker ],

+ 7
- 7
demos/touch-three/demo.js Просмотреть файл

@@ -129,22 +129,22 @@ window.addEventListener('load', () => {
129 129
 
130 130
     async function startARSession()
131 131
     {
132
-        if(!Martins.isSupported()) {
132
+        if(!AR.isSupported()) {
133 133
             throw new Error(
134 134
                 'This device is not compatible with this AR experience.\n\n' +
135 135
                 'User agent: ' + navigator.userAgent
136 136
             );
137 137
         }
138 138
 
139
-        //Martins.Settings.powerPreference = 'low-power';
139
+        //AR.Settings.powerPreference = 'low-power';
140 140
 
141
-        const tracker = Martins.Tracker.ImageTracker();
141
+        const tracker = AR.Tracker.ImageTracker();
142 142
         await tracker.database.add([{
143 143
             name: 'my-reference-image',
144 144
             image: document.getElementById('my-reference-image')
145 145
         }]);
146 146
 
147
-        const viewport = Martins.Viewport({
147
+        const viewport = AR.Viewport({
148 148
             container: document.getElementById('ar-viewport'),
149 149
             hudContainer: document.getElementById('ar-hud')
150 150
         });
@@ -152,10 +152,10 @@ window.addEventListener('load', () => {
152 152
         const video = document.getElementById('my-video');
153 153
         const useWebcam = (video === null);
154 154
         const source = useWebcam ?
155
-            Martins.Source.Camera({ resolution: 'md' }) :
156
-            Martins.Source.Video(video);
155
+            AR.Source.Camera({ resolution: 'md' }) :
156
+            AR.Source.Video(video);
157 157
 
158
-        const session = await Martins.startSession({
158
+        const session = await AR.startSession({
159 159
             mode: 'immersive',
160 160
             viewport: viewport,
161 161
             trackers: [ tracker ],

docs/api/martins.md → docs/api/ar.md Просмотреть файл

@@ -1,6 +1,6 @@
1
-# Martins
1
+# AR
2 2
 
3
-The `Martins` namespace is the entry point of the features and components of encantAR.js.
3
+The `AR` namespace is the entry point of the features and components of encantAR.js.
4 4
 
5 5
 I have documented the instantiation of the components of the engine in their respective pages.
6 6
 
@@ -8,13 +8,13 @@ I have documented the instantiation of the components of the engine in their res
8 8
 
9 9
 ### Settings
10 10
 
11
-`Martins.Settings: Settings, read-only`
11
+`AR.Settings: Settings, read-only`
12 12
 
13 13
 The [settings](settings.md) of the engine.
14 14
 
15 15
 ### version
16 16
 
17
-`Martins.version: string, read-only`
17
+`AR.version: string, read-only`
18 18
 
19 19
 The version of encantAR.js.
20 20
 
@@ -22,7 +22,7 @@ The version of encantAR.js.
22 22
 
23 23
 ### isSupported
24 24
 
25
-`Martins.isSupported(): boolean`
25
+`AR.isSupported(): boolean`
26 26
 
27 27
 Checks if the user agent is capable of running the engine.
28 28
 

+ 3
- 3
docs/api/camera-source.md Просмотреть файл

@@ -4,9 +4,9 @@ A [source of data](source.md) linked to a webcam.
4 4
 
5 5
 ## Instantiation
6 6
 
7
-### Martins.Source.Camera
7
+### AR.Source.Camera
8 8
 
9
-`Martins.Source.Camera(settings: object): CameraSource`
9
+`AR.Source.Camera(settings: object): CameraSource`
10 10
 
11 11
 Create a new webcam-based source of data with the specified `settings`.
12 12
 
@@ -24,7 +24,7 @@ A new webcam-based source of data.
24 24
 **Example**
25 25
 
26 26
 ```js
27
-const webcam = Martins.Source.Camera({
27
+const webcam = AR.Source.Camera({
28 28
     resolution: 'md+',
29 29
     constraints: {
30 30
         facingMode: 'environment' // will prefer the rear camera on mobile devices

+ 2
- 2
docs/api/canvas-source.md Просмотреть файл

@@ -4,9 +4,9 @@ A [source of data](source.md) linked to a `<canvas>` element.
4 4
 
5 5
 ## Instantiation
6 6
 
7
-### Martins.Source.Canvas
7
+### AR.Source.Canvas
8 8
 
9
-`Martins.Source.Canvas(canvas: HTMLCanvasElement): CanvasSource`
9
+`AR.Source.Canvas(canvas: HTMLCanvasElement): CanvasSource`
10 10
 
11 11
 Create a new source of data linked to the provided `canvas`.
12 12
 

+ 2
- 2
docs/api/session.md Просмотреть файл

@@ -4,9 +4,9 @@ A central component of a WebAR experience. Read the [concepts](../getting-starte
4 4
 
5 5
 ## Instantiation
6 6
 
7
-### Martins.startSession
7
+### AR.startSession
8 8
 
9
-`Martins.startSession(options: object): SpeedyPromise<Session>`
9
+`AR.startSession(options: object): SpeedyPromise<Session>`
10 10
 
11 11
 Start a new session.
12 12
 

+ 1
- 1
docs/api/settings.md Просмотреть файл

@@ -6,7 +6,7 @@ Engine settings.
6 6
 
7 7
 ### powerPreference
8 8
 
9
-`Martins.Settings.powerPreference: string`
9
+`AR.Settings.powerPreference: string`
10 10
 
11 11
 Power profile. One of the following: `"default"`, `"low-power"`, `"high-performance"`.
12 12
 

+ 1
- 1
docs/api/speedy.md Просмотреть файл

@@ -12,4 +12,4 @@ In this documentation, I provide a quick reference of some of the classes used i
12 12
 
13 13
 `Speedy: Speedy, read-only`
14 14
 
15
-The `Speedy` namespace is provided in global scope. It's also available as `Martins.Speedy`.
15
+The `Speedy` namespace is provided in global scope. It's also available as `AR.Speedy`.

+ 2
- 2
docs/api/video-source.md Просмотреть файл

@@ -4,9 +4,9 @@ A [source of data](source.md) linked to a `<video>` element.
4 4
 
5 5
 ## Instantiation
6 6
 
7
-### Martins.Source.Video
7
+### AR.Source.Video
8 8
 
9
-`Martins.Source.Video(video: HTMLVideoElement): VideoSource`
9
+`AR.Source.Video(video: HTMLVideoElement): VideoSource`
10 10
 
11 11
 Create a new source of data linked to the provided `video`.
12 12
 

+ 3
- 3
docs/api/viewport.md Просмотреть файл

@@ -4,9 +4,9 @@ The viewport is the area of the web page in which the augmented scene is display
4 4
 
5 5
 ## Instantiation
6 6
 
7
-### Martins.Viewport
7
+### AR.Viewport
8 8
 
9
-`Martins.Viewport(settings: object): Viewport`
9
+`AR.Viewport(settings: object): Viewport`
10 10
 
11 11
 Create a new viewport with the specified `settings`.
12 12
 
@@ -26,7 +26,7 @@ A new viewport.
26 26
 **Example**
27 27
 
28 28
 ```js
29
-const viewport = Martins.Viewport({
29
+const viewport = AR.Viewport({
30 30
     container: document.getElementById('ar-viewport'),
31 31
     resolution: 'lg'
32 32
 });

+ 25
- 25
docs/getting-started/activate-your-webcam.md Просмотреть файл

@@ -9,28 +9,28 @@ Instead of using a video file, we're going to use your webcam. We simply need to
9 9
 ```js title="ar-demo.js" hl_lines="20-22"
10 10
 async function startARSession()
11 11
 {
12
-    if(!Martins.isSupported()) {
12
+    if(!AR.isSupported()) {
13 13
         throw new Error(
14 14
             'This device is not compatible with this AR experience.\n\n' +
15 15
             'User agent: ' + navigator.userAgent
16 16
         );
17 17
     }
18 18
 
19
-    const tracker = Martins.Tracker.ImageTracker();
19
+    const tracker = AR.Tracker.ImageTracker();
20 20
     await tracker.database.add([{
21 21
         name: 'my-reference-image',
22 22
         image: document.getElementById('my-reference-image')
23 23
     }]);
24 24
 
25
-    const viewport = Martins.Viewport({
25
+    const viewport = AR.Viewport({
26 26
         container: document.getElementById('ar-viewport')
27 27
     });
28 28
 
29 29
     //const video = document.getElementById('my-video'); // comment this line
30
-    //const source = Martins.Source.Video(video); // comment this line
31
-    const source = Martins.Source.Camera();
30
+    //const source = AR.Source.Video(video); // comment this line
31
+    const source = AR.Source.Camera();
32 32
 
33
-    const session = await Martins.startSession({
33
+    const session = await AR.startSession({
34 34
         mode: 'immersive',
35 35
         viewport: viewport,
36 36
         trackers: [ tracker ],
@@ -154,29 +154,29 @@ In order to display that scan gimmick, we need to create a HUD (<em>Heads-Up Dis
154 154
 ```js title="ar-demo.js" hl_lines="17-18"
155 155
 async function startARSession()
156 156
 {
157
-    if(!Martins.isSupported()) {
157
+    if(!AR.isSupported()) {
158 158
         throw new Error(
159 159
             'This device is not compatible with this AR experience.\n\n' +
160 160
             'User agent: ' + navigator.userAgent
161 161
         );
162 162
     }
163 163
 
164
-    const tracker = Martins.Tracker.ImageTracker();
164
+    const tracker = AR.Tracker.ImageTracker();
165 165
     await tracker.database.add([{
166 166
         name: 'my-reference-image',
167 167
         image: document.getElementById('my-reference-image')
168 168
     }]);
169 169
 
170
-    const viewport = Martins.Viewport({
170
+    const viewport = AR.Viewport({
171 171
         container: document.getElementById('ar-viewport'),
172 172
         hudContainer: document.getElementById('ar-hud')
173 173
     });
174 174
 
175 175
     //const video = document.getElementById('my-video');
176
-    //const source = Martins.Source.Video(video);
177
-    const source = Martins.Source.Camera();
176
+    //const source = AR.Source.Video(video);
177
+    const source = AR.Source.Camera();
178 178
 
179
-    const session = await Martins.startSession({
179
+    const session = await AR.startSession({
180 180
         mode: 'immersive',
181 181
         viewport: viewport,
182 182
         trackers: [ tracker ],
@@ -200,29 +200,29 @@ A simple way to know whether or not we're tracking a target image is to use even
200 200
 ```js title="ar-demo.js" hl_lines="34-42"
201 201
 async function startARSession()
202 202
 {
203
-    if(!Martins.isSupported()) {
203
+    if(!AR.isSupported()) {
204 204
         throw new Error(
205 205
             'This device is not compatible with this AR experience.\n\n' +
206 206
             'User agent: ' + navigator.userAgent
207 207
         );
208 208
     }
209 209
 
210
-    const tracker = Martins.Tracker.ImageTracker();
210
+    const tracker = AR.Tracker.ImageTracker();
211 211
     await tracker.database.add([{
212 212
         name: 'my-reference-image',
213 213
         image: document.getElementById('my-reference-image')
214 214
     }]);
215 215
 
216
-    const viewport = Martins.Viewport({
216
+    const viewport = AR.Viewport({
217 217
         container: document.getElementById('ar-viewport'),
218 218
         hudContainer: document.getElementById('ar-hud')
219 219
     });
220 220
 
221 221
     //const video = document.getElementById('my-video');
222
-    //const source = Martins.Source.Video(video);
223
-    const source = Martins.Source.Camera();
222
+    //const source = AR.Source.Video(video);
223
+    const source = AR.Source.Camera();
224 224
 
225
-    const session = await Martins.startSession({
225
+    const session = await AR.startSession({
226 226
         mode: 'immersive',
227 227
         viewport: viewport,
228 228
         trackers: [ tracker ],
@@ -247,36 +247,36 @@ async function startARSession()
247 247
 
248 248
 ## Hide the gizmos
249 249
 
250
-Let's polish our work even more by hiding the gizmos. You may just set `gizmos` to `false` in `Martins.startSession()` and there will be no more gizmos. Do the same to hide the stats panel.
250
+Let's polish our work even more by hiding the gizmos. You may just set `gizmos` to `false` in `AR.startSession()` and there will be no more gizmos. Do the same to hide the stats panel.
251 251
 
252 252
 Let me show you a different approach. Instead of getting rid of the gizmos completely, we're going to hide them partially. They will be displayed when the tracker is scanning the physical scene, but not when the physical scene is being augmented. That's easy to do with the event listeners we have just set up:
253 253
 
254 254
 ```js title="ar-demo.js" hl_lines="38 43"
255 255
 async function startARSession()
256 256
 {
257
-    if(!Martins.isSupported()) {
257
+    if(!AR.isSupported()) {
258 258
         throw new Error(
259 259
             'This device is not compatible with this AR experience.\n\n' +
260 260
             'User agent: ' + navigator.userAgent
261 261
         );
262 262
     }
263 263
 
264
-    const tracker = Martins.Tracker.ImageTracker();
264
+    const tracker = AR.Tracker.ImageTracker();
265 265
     await tracker.database.add([{
266 266
         name: 'my-reference-image',
267 267
         image: document.getElementById('my-reference-image')
268 268
     }]);
269 269
 
270
-    const viewport = Martins.Viewport({
270
+    const viewport = AR.Viewport({
271 271
         container: document.getElementById('ar-viewport'),
272 272
         hudContainer: document.getElementById('ar-hud')
273 273
     });
274 274
 
275 275
     //const video = document.getElementById('my-video');
276
-    //const source = Martins.Source.Video(video);
277
-    const source = Martins.Source.Camera();
276
+    //const source = AR.Source.Video(video);
277
+    const source = AR.Source.Camera();
278 278
 
279
-    const session = await Martins.startSession({
279
+    const session = await AR.startSession({
280 280
         mode: 'immersive',
281 281
         viewport: viewport,
282 282
         trackers: [ tracker ],

+ 8
- 8
docs/getting-started/next-steps.md Просмотреть файл

@@ -6,36 +6,36 @@ Let me tell you some of the steps you can take from now on.
6 6
 
7 7
 ## Change the power preference
8 8
 
9
-Image tracking is no trivial task: lots of computations are being performed behind the scenes. The WebAR engine prioritizes processing performance over power consumption by default. You may reduce power consumption by reducing processing performance. This is simple to do: just set `Martins.Settings.powerPreference` to `"low-power"`.
9
+Image tracking is no trivial task: lots of computations are being performed behind the scenes. The WebAR engine prioritizes processing performance over power consumption by default. You may reduce power consumption by reducing processing performance. This is simple to do: just set `AR.Settings.powerPreference` to `"low-power"`.
10 10
 
11 11
 ```js title="ar-demo.js" hl_lines="10"
12 12
 async function startARSession()
13 13
 {
14
-    if(!Martins.isSupported()) {
14
+    if(!AR.isSupported()) {
15 15
         throw new Error(
16 16
             'This device is not compatible with this AR experience.\n\n' +
17 17
             'User agent: ' + navigator.userAgent
18 18
         );
19 19
     }
20 20
 
21
-    Martins.Settings.powerPreference = 'low-power'; // OPTIONAL
21
+    AR.Settings.powerPreference = 'low-power'; // OPTIONAL
22 22
 
23
-    const tracker = Martins.Tracker.ImageTracker();
23
+    const tracker = AR.Tracker.ImageTracker();
24 24
     await tracker.database.add([{
25 25
         name: 'my-reference-image',
26 26
         image: document.getElementById('my-reference-image')
27 27
     }]);
28 28
 
29
-    const viewport = Martins.Viewport({
29
+    const viewport = AR.Viewport({
30 30
         container: document.getElementById('ar-viewport'),
31 31
         hudContainer: document.getElementById('ar-hud')
32 32
     });
33 33
 
34 34
     //const video = document.getElementById('my-video');
35
-    //const source = Martins.Source.Video(video);
36
-    const source = Martins.Source.Camera();
35
+    //const source = AR.Source.Video(video);
36
+    const source = AR.Source.Camera();
37 37
 
38
-    const session = await Martins.startSession({
38
+    const session = await AR.startSession({
39 39
         mode: 'immersive',
40 40
         viewport: viewport,
41 41
         trackers: [ tracker ],

+ 18
- 18
docs/getting-started/set-up-the-session.md Просмотреть файл

@@ -32,20 +32,20 @@ We begin by creating the viewport. Remember that the viewport is the area in whi
32 32
 window.onload = async function()
33 33
 {
34 34
     try {
35
-        if(!Martins.isSupported()) {
35
+        if(!AR.isSupported()) {
36 36
             throw new Error(
37 37
                 'This device is not compatible with this AR experience.\n\n' +
38 38
                 'User agent: ' + navigator.userAgent
39 39
             );
40 40
         }
41 41
 
42
-        const tracker = Martins.Tracker.ImageTracker();
42
+        const tracker = AR.Tracker.ImageTracker();
43 43
         await tracker.database.add([{
44 44
             name: 'my-reference-image',
45 45
             image: document.getElementById('my-reference-image')
46 46
         }]);
47 47
 
48
-        const viewport = Martins.Viewport({
48
+        const viewport = AR.Viewport({
49 49
             container: document.getElementById('ar-viewport')
50 50
         });
51 51
     }
@@ -63,25 +63,25 @@ Let's set up our source of data. We get the `HTMLVideoElement` corresponding to
63 63
 window.onload = async function()
64 64
 {
65 65
     try {
66
-        if(!Martins.isSupported()) {
66
+        if(!AR.isSupported()) {
67 67
             throw new Error(
68 68
                 'This device is not compatible with this AR experience.\n\n' +
69 69
                 'User agent: ' + navigator.userAgent
70 70
             );
71 71
         }
72 72
 
73
-        const tracker = Martins.Tracker.ImageTracker();
73
+        const tracker = AR.Tracker.ImageTracker();
74 74
         await tracker.database.add([{
75 75
             name: 'my-reference-image',
76 76
             image: document.getElementById('my-reference-image')
77 77
         }]);
78 78
 
79
-        const viewport = Martins.Viewport({
79
+        const viewport = AR.Viewport({
80 80
             container: document.getElementById('ar-viewport')
81 81
         });
82 82
 
83 83
         const video = document.getElementById('my-video');
84
-        const source = Martins.Source.Video(video);
84
+        const source = AR.Source.Video(video);
85 85
     }
86 86
     catch(error) {
87 87
         alert(error.message);
@@ -91,33 +91,33 @@ window.onload = async function()
91 91
 
92 92
 ## Start the session
93 93
 
94
-The session is a central component of a WebAR experience. The `Martins` namespace has a very special method called `startSession`. It receives a settings dictionary that lets us configure the new session in different ways. Add the following code to `ar-demo.js`:
94
+The session is a central component of a WebAR experience. The `AR` namespace has a very special method called `startSession`. It receives a settings dictionary that lets us configure the new session in different ways. Add the following code to `ar-demo.js`:
95 95
 
96 96
 ```js title="ar-demo.js" hl_lines="24-31"
97 97
 window.onload = async function()
98 98
 {
99 99
     try {
100
-        if(!Martins.isSupported()) {
100
+        if(!AR.isSupported()) {
101 101
             throw new Error(
102 102
                 'This device is not compatible with this AR experience.\n\n' +
103 103
                 'User agent: ' + navigator.userAgent
104 104
             );
105 105
         }
106 106
 
107
-        const tracker = Martins.Tracker.ImageTracker();
107
+        const tracker = AR.Tracker.ImageTracker();
108 108
         await tracker.database.add([{
109 109
             name: 'my-reference-image',
110 110
             image: document.getElementById('my-reference-image')
111 111
         }]);
112 112
 
113
-        const viewport = Martins.Viewport({
113
+        const viewport = AR.Viewport({
114 114
             container: document.getElementById('ar-viewport')
115 115
         });
116 116
 
117 117
         const video = document.getElementById('my-video');
118
-        const source = Martins.Source.Video(video);
118
+        const source = AR.Source.Video(video);
119 119
 
120
-        const session = await Martins.startSession({
120
+        const session = await AR.startSession({
121 121
             mode: 'immersive',
122 122
             viewport: viewport,
123 123
             trackers: [ tracker ],
@@ -160,27 +160,27 @@ window.onload = async function()
160 160
 
161 161
 async function startARSession()
162 162
 {
163
-    if(!Martins.isSupported()) {
163
+    if(!AR.isSupported()) {
164 164
         throw new Error(
165 165
             'This device is not compatible with this AR experience.\n\n' +
166 166
             'User agent: ' + navigator.userAgent
167 167
         );
168 168
     }
169 169
 
170
-    const tracker = Martins.Tracker.ImageTracker();
170
+    const tracker = AR.Tracker.ImageTracker();
171 171
     await tracker.database.add([{
172 172
         name: 'my-reference-image',
173 173
         image: document.getElementById('my-reference-image')
174 174
     }]);
175 175
 
176
-    const viewport = Martins.Viewport({
176
+    const viewport = AR.Viewport({
177 177
         container: document.getElementById('ar-viewport')
178 178
     });
179 179
 
180 180
     const video = document.getElementById('my-video');
181
-    const source = Martins.Source.Video(video);
181
+    const source = AR.Source.Video(video);
182 182
 
183
-    const session = await Martins.startSession({
183
+    const session = await AR.startSession({
184 184
         mode: 'immersive',
185 185
         viewport: viewport,
186 186
         trackers: [ tracker ],

+ 5
- 5
docs/getting-started/set-up-the-tracker.md Просмотреть файл

@@ -137,14 +137,14 @@ Create a new file called `ar-demo.js` and store it in the `ar-demo/` folder. Wri
137 137
 window.onload = async function()
138 138
 {
139 139
     try {
140
-        if(!Martins.isSupported()) {
140
+        if(!AR.isSupported()) {
141 141
             throw new Error(
142 142
                 'This device is not compatible with this AR experience.\n\n' +
143 143
                 'User agent: ' + navigator.userAgent
144 144
             );
145 145
         }
146 146
 
147
-        const tracker = Martins.Tracker.ImageTracker();
147
+        const tracker = AR.Tracker.ImageTracker();
148 148
     }
149 149
     catch(error) {
150 150
         alert(error.message);
@@ -152,7 +152,7 @@ window.onload = async function()
152 152
 };
153 153
 ```
154 154
 
155
-The `Martins` namespace holds the various elements featured by the engine. We'll be using it extensively.
155
+The `AR` namespace holds the various elements featured by the engine. We'll be using it extensively.
156 156
 
157 157
 encantAR.js only requires standard web technologies that have been around for a while. Still, it's a good practice to check if those technologies are supported by the target system. If they are not, we display a message and quit. If they are, we instantiate an Image Tracker.
158 158
 
@@ -178,14 +178,14 @@ Let's link the image to the tracker. Add the following code to `ar-demo.js`:
178 178
 window.onload = async function()
179 179
 {
180 180
     try {
181
-        if(!Martins.isSupported()) {
181
+        if(!AR.isSupported()) {
182 182
             throw new Error(
183 183
                 'This device is not compatible with this AR experience.\n\n' +
184 184
                 'User agent: ' + navigator.userAgent
185 185
             );
186 186
         }
187 187
 
188
-        const tracker = Martins.Tracker.ImageTracker();
188
+        const tracker = AR.Tracker.ImageTracker();
189 189
         await tracker.database.add([{
190 190
             name: 'my-reference-image',
191 191
             image: document.getElementById('my-reference-image')

+ 1
- 1
mkdocs.yml Просмотреть файл

@@ -64,10 +64,10 @@ nav:
64 64
     - 'Demo gallery': 'demos.md'
65 65
   - 'API':
66 66
     - 'General':
67
+      - 'AR': 'api/ar.md'
67 68
       - 'Session': 'api/session.md'
68 69
       - 'Frame': 'api/frame.md'
69 70
       - 'Time': 'api/time.md'
70
-      - 'Martins': 'api/martins.md'
71 71
       - 'Settings': 'api/settings.md'
72 72
       - 'Resolution': 'api/resolution.md'
73 73
     - 'Trackers':

+ 2
- 2
src/core/stats-panel.ts Просмотреть файл

@@ -26,7 +26,7 @@ import { Viewport } from './viewport';
26 26
 import { Tracker } from '../trackers/tracker';
27 27
 import { Source } from '../sources/source';
28 28
 import { Utils, Nullable } from '../utils/utils';
29
-import Martins from '../main';
29
+import AR from '../main';
30 30
 
31 31
 
32 32
 /** Update interval, in ms */
@@ -195,7 +195,7 @@ export class StatsPanel
195 195
         container.style.fontSize = '14px';
196 196
 
197 197
         // all sanitized
198
-        container.innerText = 'encantAR.js ' + Martins.version;
198
+        container.innerText = 'encantAR.js ' + AR.version;
199 199
 
200 200
         print('<br>');
201 201
         print('FPS: <span class="_ar_fps"></span> | ');

+ 3
- 3
src/main.ts Просмотреть файл

@@ -35,7 +35,7 @@ declare const __AR_WEBSITE__: string;
35 35
 /**
36 36
  * GPU-accelerated Augmented Reality for the web
37 37
  */
38
-export default class Martins
38
+export default class AR
39 39
 {
40 40
     /**
41 41
      * Start a new session
@@ -111,14 +111,14 @@ export default class Martins
111 111
 }
112 112
 
113 113
 // Freeze the namespace
114
-Object.freeze(Martins);
114
+Object.freeze(AR);
115 115
 
116 116
 // Add Speedy Vision to global scope
117 117
 ((window: any) => window.Speedy = window.Speedy || Speedy)(window);
118 118
 
119 119
 // Display a notice
120 120
 Utils.log(
121
-    `encantAR.js version ${Martins.version}. ` +
121
+    `encantAR.js version ${AR.version}. ` +
122 122
     `GPU-accelerated Augmented Reality for the web by Alexandre Martins. ` +
123 123
     __AR_WEBSITE__
124 124
 );

+ 1
- 1
webpack.config.js Просмотреть файл

@@ -13,7 +13,7 @@ module.exports = (env, argv) => ({
13 13
         path: path.resolve(__dirname, 'dist'),
14 14
         publicPath: '/dist/',
15 15
         library: {
16
-            name: 'Martins',
16
+            name: 'AR',
17 17
             type: 'umd',
18 18
             export: 'default',
19 19
         },

Загрузка…
Отмена
Сохранить