|
@@ -0,0 +1,442 @@
|
|
1
|
+# A-Frame plugin
|
|
2
|
+
|
|
3
|
+Documentation of the A-Frame plugin.
|
|
4
|
+
|
|
5
|
+We'll get to the details, but a basic augmented scene can be constructed as follows:
|
|
6
|
+
|
|
7
|
+```html
|
|
8
|
+<a-scene encantar="stats: true; gizmos: true">
|
|
9
|
+
|
|
10
|
+ <!-- Sources of data -->
|
|
11
|
+ <ar-sources>
|
|
12
|
+ <ar-camera-source></ar-camera-source> <!-- webcam -->
|
|
13
|
+ </ar-sources>
|
|
14
|
+
|
|
15
|
+ <!-- Trackers -->
|
|
16
|
+ <ar-trackers>
|
|
17
|
+ <ar-image-tracker>
|
|
18
|
+ <ar-reference-image name="mage" src="mage.png"></ar-reference-image>
|
|
19
|
+ </ar-image-tracker>
|
|
20
|
+ </ar-trackers>
|
|
21
|
+
|
|
22
|
+ <!-- AR Viewport -->
|
|
23
|
+ <ar-viewport></ar-viewport>
|
|
24
|
+
|
|
25
|
+ <!-- Virtual camera for AR -->
|
|
26
|
+ <ar-camera></ar-camera>
|
|
27
|
+
|
|
28
|
+ <!-- Root node: this will be displayed in AR -->
|
|
29
|
+ <ar-root reference-image="mage">
|
|
30
|
+ <a-box color="yellow" position="0 0 0.5"></a-box>
|
|
31
|
+ </ar-root>
|
|
32
|
+
|
|
33
|
+</a-scene>
|
|
34
|
+```
|
|
35
|
+
|
|
36
|
+*Since:* 0.3.0
|
|
37
|
+
|
|
38
|
+## Basics
|
|
39
|
+
|
|
40
|
+### encantar
|
|
41
|
+
|
|
42
|
+The `encantar` component *enchants* (augments) `<a-scene>`, so that it displays content in AR.
|
|
43
|
+
|
|
44
|
+**Properties**
|
|
45
|
+
|
|
46
|
+* `mode: string`. The [session mode](./session.md#mode). Defaults to `"immersive"`.
|
|
47
|
+* `stats: boolean`. Whether or not to display the built-in stats panel. It's useful during development. Defaults to `false`.
|
|
48
|
+* `gizmos: boolean`. Whether or not to display the [gizmos](./session.md#gizmos). Defaults to `false`.
|
|
49
|
+* `autoplay: boolean`. Whether or not to start the AR [session](./session.md) automatically. Defaults to `true`.
|
|
50
|
+
|
|
51
|
+**Example**
|
|
52
|
+
|
|
53
|
+```html
|
|
54
|
+<a-scene encantar="stats: true; gizmos: true">
|
|
55
|
+ ...
|
|
56
|
+</a-scene>
|
|
57
|
+```
|
|
58
|
+
|
|
59
|
+### ar-root
|
|
60
|
+
|
|
61
|
+The `<ar-root>` primitive sets up a node of the virtual scene that is automatically aligned to the physical scene. Simply put, children of this node will augment physical reality. `<ar-root>` must be a direct child of `<a-scene>`. It does not have to be unique. See also: [ar-camera](#ar-camera).
|
|
62
|
+
|
|
63
|
+**Properties**
|
|
64
|
+
|
|
65
|
+* `reference-image: string`. The name of a [reference image](./reference-image.md) or the empty string. This node will be matched to the specified reference image, or to any reference image if this property is the empty string. Defaults to the empty string. See also: [ar-reference-image](#ar-reference-image).
|
|
66
|
+
|
|
67
|
+**Example**
|
|
68
|
+
|
|
69
|
+```html
|
|
70
|
+<a-scene encantar>
|
|
71
|
+
|
|
72
|
+ ...
|
|
73
|
+
|
|
74
|
+ <!-- Matches only the specified reference image -->
|
|
75
|
+ <ar-root reference-image="mage">
|
|
76
|
+ ...
|
|
77
|
+ </ar-root>
|
|
78
|
+
|
|
79
|
+ <!-- Matches any reference image -->
|
|
80
|
+ <ar-root>
|
|
81
|
+ ...
|
|
82
|
+ </ar-root>
|
|
83
|
+
|
|
84
|
+ ...
|
|
85
|
+
|
|
86
|
+</a-scene>
|
|
87
|
+```
|
|
88
|
+
|
|
89
|
+## Visualization
|
|
90
|
+
|
|
91
|
+### ar-viewport
|
|
92
|
+
|
|
93
|
+The `<ar-viewport>` primitive sets up the [viewport](./viewport.md) that will be linked to the AR [session](./session.md). It must be unique and a direct child of `<a-scene>`. See also: [ar-hud](#ar-hud).
|
|
94
|
+
|
|
95
|
+**Properties**
|
|
96
|
+
|
|
97
|
+* `resolution: string`. The [resolution of the viewport](./viewport.md#resolution), which corresponds to the resolution of the virtual scene. See also: [Resolution](./resolution.md).
|
|
98
|
+* `style: string`. The [style of the viewport](./viewport.md#style).
|
|
99
|
+* `fullscreen-ui: component`. A component that controls the built-in fullscreen button. This button included as a convenience if the fullscreen mode is [available](./viewport.md#fullscreenavailable) on the target platform. The following properties are available:
|
|
100
|
+ * `enabled: boolean`. Whether or not to display the fullscreen button. Defaults to `true`.
|
|
101
|
+
|
|
102
|
+**Example**
|
|
103
|
+
|
|
104
|
+```html
|
|
105
|
+<a-scene encantar>
|
|
106
|
+
|
|
107
|
+ ...
|
|
108
|
+
|
|
109
|
+ <ar-viewport resolution="lg">
|
|
110
|
+ ...
|
|
111
|
+ </ar-viewport>
|
|
112
|
+
|
|
113
|
+ ...
|
|
114
|
+
|
|
115
|
+</a-scene>
|
|
116
|
+```
|
|
117
|
+
|
|
118
|
+### ar-hud
|
|
119
|
+
|
|
120
|
+The `<ar-hud>` primitive sets up a [Heads Up Display](./hud.md), a 2D overlay that is displayed in front of the augmented scene. It's meant to contain HTML elements. Additionally, it must be a direct child of `<ar-viewport>`. See also: [ar-viewport](#ar-viewport).
|
|
121
|
+
|
|
122
|
+**Example**
|
|
123
|
+
|
|
124
|
+```html
|
|
125
|
+<ar-viewport>
|
|
126
|
+ <ar-hud>
|
|
127
|
+
|
|
128
|
+ <!-- This will be displayed in front of the augmented scene -->
|
|
129
|
+ <button id="example-button">Tap me</button>
|
|
130
|
+
|
|
131
|
+ </ar-hud>
|
|
132
|
+</ar-viewport>
|
|
133
|
+```
|
|
134
|
+
|
|
135
|
+### ar-camera
|
|
136
|
+
|
|
137
|
+`<ar-camera>` sets up a virtual camera that is ready for AR. It should be unique and a direct child of `<a-scene>`. Do not confuse it with `<a-camera>`, the standard camera from A-Frame. See also: [ar-root](#ar-root).
|
|
138
|
+
|
|
139
|
+**Example**
|
|
140
|
+
|
|
141
|
+```html
|
|
142
|
+<a-scene encantar>
|
|
143
|
+
|
|
144
|
+ ...
|
|
145
|
+
|
|
146
|
+ <ar-camera></ar-camera>
|
|
147
|
+
|
|
148
|
+ ...
|
|
149
|
+
|
|
150
|
+</a-scene>
|
|
151
|
+```
|
|
152
|
+
|
|
153
|
+## Sources
|
|
154
|
+
|
|
155
|
+### ar-sources
|
|
156
|
+
|
|
157
|
+The `<ar-sources>` primitive is used to specify the [sources of data](./source.md) that will be linked to the AR [session](./session.md). It must be unique and a direct child of `<a-scene>`.
|
|
158
|
+
|
|
159
|
+**Example**
|
|
160
|
+
|
|
161
|
+```html
|
|
162
|
+<a-scene encantar>
|
|
163
|
+
|
|
164
|
+ ...
|
|
165
|
+
|
|
166
|
+ <ar-sources>
|
|
167
|
+ ...
|
|
168
|
+ </ar-sources>
|
|
169
|
+
|
|
170
|
+ ...
|
|
171
|
+
|
|
172
|
+</a-scene>
|
|
173
|
+```
|
|
174
|
+
|
|
175
|
+### ar-camera-source
|
|
176
|
+
|
|
177
|
+`<ar-camera-source>` sets up a [CameraSource](./camera-source.md), which is source of data linked to a webcam. It must be a direct child of `<ar-sources>`.
|
|
178
|
+
|
|
179
|
+**Properties**
|
|
180
|
+
|
|
181
|
+* `resolution: string`. The preferred [resolution of the camera](./camera-source.md#resolution). See also: [Resolution](./resolution.md).
|
|
182
|
+* `facing-mode: string`. The preferred camera on mobile devices. Typically `"environment"` (rear camera) or `"user"` (front camera). Defaults to `"environment"`.
|
|
183
|
+
|
|
184
|
+**Example**
|
|
185
|
+
|
|
186
|
+```html
|
|
187
|
+<ar-sources>
|
|
188
|
+ <ar-camera-source resolution="md"></ar-camera-source>
|
|
189
|
+</ar-sources>
|
|
190
|
+```
|
|
191
|
+
|
|
192
|
+### ar-video-source
|
|
193
|
+
|
|
194
|
+`<ar-video-source>` sets up a [VideoSource](./video-source.md), which is a source of data linked to a `<video>` element. It must be a direct child of `<ar-sources>`.
|
|
195
|
+
|
|
196
|
+**Properties**
|
|
197
|
+
|
|
198
|
+* `video: selector`. A selector of a `<video>` element.
|
|
199
|
+
|
|
200
|
+**Example**
|
|
201
|
+
|
|
202
|
+```html
|
|
203
|
+<ar-sources>
|
|
204
|
+ <ar-video-source video="#my-video"></ar-video-source>
|
|
205
|
+</ar-sources>
|
|
206
|
+
|
|
207
|
+...
|
|
208
|
+
|
|
209
|
+<!-- External assets -->
|
|
210
|
+<a-assets>
|
|
211
|
+ <video id="my-video" hidden muted loop playsinline autoplay>
|
|
212
|
+ <source src="my-video.webm" type="video/webm" />
|
|
213
|
+ <source src="my-video.mp4" type="video/mp4" />
|
|
214
|
+ </video>
|
|
215
|
+</a-assets>
|
|
216
|
+```
|
|
217
|
+
|
|
218
|
+### ar-pointer-source
|
|
219
|
+
|
|
220
|
+`<ar-pointer-source>` sets up a [PointerSource](./pointer-source.md), a source of pointer-based input. It must be a direct child of `<ar-sources>`. See also: [ar-pointer-tracker](#ar-pointer-tracker).
|
|
221
|
+
|
|
222
|
+*Since:* 0.4.0
|
|
223
|
+
|
|
224
|
+**Example**
|
|
225
|
+
|
|
226
|
+```html
|
|
227
|
+<ar-sources>
|
|
228
|
+ ...
|
|
229
|
+ <ar-pointer-source></ar-pointer-source>
|
|
230
|
+</ar-sources>
|
|
231
|
+```
|
|
232
|
+
|
|
233
|
+## Trackers
|
|
234
|
+
|
|
235
|
+### ar-trackers
|
|
236
|
+
|
|
237
|
+The `<ar-trackers>` primitive is used to specify the [trackers](./tracker.md) that will be linked to the AR [session](./session.md). It must be unique and a direct child of `<a-scene>`.
|
|
238
|
+
|
|
239
|
+**Example**
|
|
240
|
+
|
|
241
|
+```html
|
|
242
|
+<a-scene encantar>
|
|
243
|
+
|
|
244
|
+ ...
|
|
245
|
+
|
|
246
|
+ <ar-trackers>
|
|
247
|
+ ...
|
|
248
|
+ </ar-trackers>
|
|
249
|
+
|
|
250
|
+ ...
|
|
251
|
+
|
|
252
|
+</a-scene>
|
|
253
|
+```
|
|
254
|
+
|
|
255
|
+### ar-image-tracker
|
|
256
|
+
|
|
257
|
+`<ar-image-tracker>` sets up an [ImageTracker](./image-tracker.md), which is used to track images in a video. You must include at least one `<ar-reference-image>` as a direct child. See also: [ar-reference-image](#ar-reference-image), [ar-camera-source](#ar-camera-source), [ar-video-source](#ar-video-source).
|
|
258
|
+
|
|
259
|
+**Properties**
|
|
260
|
+
|
|
261
|
+* `resolution: string`. The [resolution of the tracker](./image-tracker.md#resolution). See also: [Resolution](./resolution.md).
|
|
262
|
+
|
|
263
|
+**Example**
|
|
264
|
+
|
|
265
|
+```html
|
|
266
|
+<ar-trackers>
|
|
267
|
+ <ar-image-tracker resolution="md">
|
|
268
|
+ <ar-reference-image name="mage" src="mage.png"></ar-reference-image>
|
|
269
|
+ <ar-reference-image name="magic" src="magic.png"></ar-reference-image>
|
|
270
|
+ </ar-image-tracker>
|
|
271
|
+</ar-trackers>
|
|
272
|
+```
|
|
273
|
+
|
|
274
|
+### ar-reference-image
|
|
275
|
+
|
|
276
|
+`<ar-reference-image>` defines a [ReferenceImage](./reference-image.md) to be used by an image tracker. It must be a direct child of `<ar-image-tracker>`. See also: [ar-image-tracker](#ar-image-tracker).
|
|
277
|
+
|
|
278
|
+**Properties**
|
|
279
|
+
|
|
280
|
+* `name: string`. The name of the reference image. You may link it with `<ar-root>`. Names must be unique. See also: [ar-root](#ar-root).
|
|
281
|
+* `src: string`. Path to the image.
|
|
282
|
+
|
|
283
|
+**Example**
|
|
284
|
+
|
|
285
|
+```html
|
|
286
|
+<ar-image-tracker>
|
|
287
|
+ <ar-reference-image name="mage" src="mage.png"></ar-reference-image>
|
|
288
|
+</ar-image-tracker>
|
|
289
|
+```
|
|
290
|
+
|
|
291
|
+### ar-pointer-tracker
|
|
292
|
+
|
|
293
|
+`<ar-pointer-tracker>` sets up a [PointerTracker](./pointer-tracker.md), which is used to track pointer-based input. It must be a direct child of `<ar-trackers>`. See also: [ar-pointer-source](#ar-pointer-source), [pointers](#pointers).
|
|
294
|
+
|
|
295
|
+*Since:* 0.4.0
|
|
296
|
+
|
|
297
|
+**Example**
|
|
298
|
+
|
|
299
|
+```html
|
|
300
|
+<ar-trackers>
|
|
301
|
+ ...
|
|
302
|
+ <ar-pointer-tracker></ar-pointer-tracker>
|
|
303
|
+</ar-trackers>
|
|
304
|
+```
|
|
305
|
+
|
|
306
|
+## AR System
|
|
307
|
+
|
|
308
|
+### ar
|
|
309
|
+
|
|
310
|
+The `ar` system conveniently exposes useful objects and methods in JavaScript. It may be accessed from any component by writing `this.el.sceneEl.systems.ar`.
|
|
311
|
+
|
|
312
|
+**Example**
|
|
313
|
+
|
|
314
|
+```js
|
|
315
|
+AFRAME.registerComponent('my-component', {
|
|
316
|
+
|
|
317
|
+ // ...
|
|
318
|
+
|
|
319
|
+ tick()
|
|
320
|
+ {
|
|
321
|
+ const ar = this.el.sceneEl.systems.ar;
|
|
322
|
+ const session = ar.session;
|
|
323
|
+
|
|
324
|
+ // ...
|
|
325
|
+ },
|
|
326
|
+
|
|
327
|
+ // ...
|
|
328
|
+
|
|
329
|
+});
|
|
330
|
+```
|
|
331
|
+
|
|
332
|
+### session
|
|
333
|
+
|
|
334
|
+`ar.session: Session | null`
|
|
335
|
+
|
|
336
|
+The AR [Session](./session.md). If the AR session hasn't been started, this will be `null`.
|
|
337
|
+
|
|
338
|
+### frame
|
|
339
|
+
|
|
340
|
+`ar.frame: Frame | null`
|
|
341
|
+
|
|
342
|
+The current [Frame](./frame.md). If the AR scene isn't initialized, this will be `null`.
|
|
343
|
+
|
|
344
|
+### viewer
|
|
345
|
+
|
|
346
|
+`ar.viewer: Viewer | null`
|
|
347
|
+
|
|
348
|
+A reference to the [Viewer](./viewer.md) of the current frame, if any.
|
|
349
|
+
|
|
350
|
+*Since:* 0.4.0
|
|
351
|
+
|
|
352
|
+### pointers
|
|
353
|
+
|
|
354
|
+`ar.pointers: TrackablePointer[]`
|
|
355
|
+
|
|
356
|
+The [TrackablePointers](./trackable-pointer.md) of the current frame, if any. Make sure to add a `<ar-pointer-tracker>` in order to use these. See also: [ar-pointer-tracker](#ar-pointer-tracker).
|
|
357
|
+
|
|
358
|
+*Since:* 0.4.0
|
|
359
|
+
|
|
360
|
+### utils
|
|
361
|
+
|
|
362
|
+`ar.utils: object`
|
|
363
|
+
|
|
364
|
+[Utilities](#utilities) for AR.
|
|
365
|
+
|
|
366
|
+*Since:* 0.4.0
|
|
367
|
+
|
|
368
|
+## Utilities
|
|
369
|
+
|
|
370
|
+### convertVector2
|
|
371
|
+
|
|
372
|
+`ar.utils.convertVector2(v: Vector2): THREE.Vector2`
|
|
373
|
+
|
|
374
|
+Convert a [Vector2](./vector2.md) into a `THREE.Vector2`.
|
|
375
|
+
|
|
376
|
+*Since:* 0.4.0
|
|
377
|
+
|
|
378
|
+**Arguments**
|
|
379
|
+
|
|
380
|
+* `v: Vector2`. A 2D vector.
|
|
381
|
+
|
|
382
|
+**Returns**
|
|
383
|
+
|
|
384
|
+A corresponding `THREE.Vector2`.
|
|
385
|
+
|
|
386
|
+### convertVector3
|
|
387
|
+
|
|
388
|
+`ar.utils.convertVector3(v: Vector3): THREE.Vector3`
|
|
389
|
+
|
|
390
|
+Convert a [Vector3](./vector3.md) into a `THREE.Vector3`.
|
|
391
|
+
|
|
392
|
+*Since:* 0.4.0
|
|
393
|
+
|
|
394
|
+**Arguments**
|
|
395
|
+
|
|
396
|
+* `v: Vector3`. A 3D vector.
|
|
397
|
+
|
|
398
|
+**Returns**
|
|
399
|
+
|
|
400
|
+A corresponding `THREE.Vector3`.
|
|
401
|
+
|
|
402
|
+### convertQuaternion
|
|
403
|
+
|
|
404
|
+`ar.utils.convertQuaternion(q: Quaternion): THREE.Quaternion`
|
|
405
|
+
|
|
406
|
+Convert a [Quaternion](./quaternion.md) into a `THREE.Quaternion`.
|
|
407
|
+
|
|
408
|
+*Since:* 0.4.0
|
|
409
|
+
|
|
410
|
+**Arguments**
|
|
411
|
+
|
|
412
|
+* `q: Quaternion`. A quaternion.
|
|
413
|
+
|
|
414
|
+**Returns**
|
|
415
|
+
|
|
416
|
+A corresponding `THREE.Quaternion`.
|
|
417
|
+
|
|
418
|
+### convertRay
|
|
419
|
+
|
|
420
|
+`ar.utils.convertRay(r: Ray): THREE.Ray`
|
|
421
|
+
|
|
422
|
+Convert a [Ray](./ray.md) into a `THREE.Ray`.
|
|
423
|
+
|
|
424
|
+*Since:* 0.4.0
|
|
425
|
+
|
|
426
|
+**Arguments**
|
|
427
|
+
|
|
428
|
+* `r: Ray`. A ray.
|
|
429
|
+
|
|
430
|
+**Returns**
|
|
431
|
+
|
|
432
|
+A corresponding `THREE.Ray`.
|
|
433
|
+
|
|
434
|
+## Events
|
|
435
|
+
|
|
436
|
+### ar-started
|
|
437
|
+
|
|
438
|
+The `ar-started` event is emitted when the main loop of the AR scene is set up, just after the AR session starts.
|
|
439
|
+
|
|
440
|
+**Details**
|
|
441
|
+
|
|
442
|
+* `ar: object`. A reference to the [ar](#ar) system.
|