Browse Source

Introduce the ARBaseSystem

customisations
alemart 10 months ago
parent
commit
c37b6740e1
1 changed files with 40 additions and 7 deletions
  1. 40
    7
      plugins/aframe-with-encantar.js

+ 40
- 7
plugins/aframe-with-encantar.js View File

13
 });
13
 });
14
 
14
 
15
 /**
15
 /**
16
+ * AR Base System
17
+ * @mixin ARBaseSystem
18
+ */
19
+const ARBaseSystem = () => ({
20
+
21
+    /**
22
+     * AR Session
23
+     * @type {Session | null}
24
+     */
25
+    session: null,
26
+
27
+    /**
28
+     * Current frame: an object holding data to augment the physical scene.
29
+     * If the AR scene is not initialized, this will be null.
30
+     * @type {Frame | null}
31
+     */
32
+    frame: null,
33
+
34
+    /**
35
+     * AR Viewer
36
+     * @type {Viewer | null}
37
+     */
38
+    viewer: null,
39
+
40
+    /**
41
+     * Pointer-based input in the current frame (touch, mouse, pen...)
42
+     * You need a PointerTracker in your session in order to use these
43
+     * @type {TrackablePointer[]}
44
+     */
45
+    pointers: [],
46
+
47
+});
48
+
49
+/**
16
  * AR Utilities
50
  * AR Utilities
17
  */
51
  */
18
 const ARUtils = () => ({
52
 const ARUtils = () => ({
73
 
107
 
74
 /**
108
 /**
75
  * AR System
109
  * AR System
110
+ * @name ARSystem
111
+ * @type {object}
112
+ * @mixes ARBaseSystem
76
  */
113
  */
77
-AFRAME.registerSystem('ar', {
114
+AFRAME.registerSystem('ar', Object.assign(ARBaseSystem(), {
78
 
115
 
79
     // el;
116
     // el;
80
     // data;
117
     // data;
81
     // schema;
118
     // schema;
82
 
119
 
83
-    session: /** @type {Session | null} */ (null),
84
-    frame: /** @type {Frame | null} */ (null),
85
-    viewer: /** @type {Viewer | null} */ (null),
86
-    pointers: /** @type {TrackablePointer[]} */ ([]),
87
-
88
     _utils: ARUtils(),
120
     _utils: ARUtils(),
89
     _started: false,
121
     _started: false,
90
     _components: [],
122
     _components: [],
335
             this.pointers.push.apply(this.pointers, newPointers);
367
             this.pointers.push.apply(this.pointers, newPointers);
336
     },
368
     },
337
 
369
 
338
-});
370
+}));
339
 
371
 
340
 /**
372
 /**
341
  * AR Component
373
  * AR Component
374
+ * @mixin ARComponent
342
  */
375
  */
343
 const ARComponent = obj => Object.assign({}, obj, {
376
 const ARComponent = obj => Object.assign({}, obj, {
344
 
377
 

Loading…
Cancel
Save