소스 검색

Set the namespace to AR

customisations
alemart 1 년 전
부모
커밋
52d5b3aeab

+ 3
- 3
demos/assets/aframe-with-encantar.js 파일 보기

11
 });
11
 });
12
 
12
 
13
 /**
13
 /**
14
- * Connect encantar.js to aframe
14
+ * Do magic to connect encantar.js to aframe
15
  * @param {(canvas: HTMLCanvasElement) => Promise<Session> | SpeedyPromise<Session>} startARSession
15
  * @param {(canvas: HTMLCanvasElement) => Promise<Session> | SpeedyPromise<Session>} startARSession
16
  */
16
  */
17
 function encantar(startARSession)
17
 function encantar(startARSession)
228
  */
228
  */
229
 function __THIS_PLUGIN_HAS_BEEN_TESTED_WITH__(json)
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
     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;
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
     for(const [x, expected] of Object.entries(json)) check(x, expected.version, versionOf[x]);
234
     for(const [x, expected] of Object.entries(json)) check(x, expected.version, versionOf[x]);
235
     } catch(e) { alert(e.message); }
235
     } catch(e) { alert(e.message); }

+ 3
- 3
demos/assets/three-with-encantar.js 파일 보기

23
  */
23
  */
24
 
24
 
25
 /**
25
 /**
26
- * Connect encantar.js to three.js
26
+ * Do magic to connect encantar.js to three.js
27
  * @param {() => Promise<Session> | SpeedyPromise<Session>} startARSession
27
  * @param {() => Promise<Session> | SpeedyPromise<Session>} startARSession
28
  * @param {(ar: ARSystem) => void} [animateVirtualScene] animation callback
28
  * @param {(ar: ARSystem) => void} [animateVirtualScene] animation callback
29
  * @param {(ar: ARSystem) => void | Promise<void> | SpeedyPromise<Session>} [initializeVirtualScene] initialization callback
29
  * @param {(ar: ARSystem) => void | Promise<void> | SpeedyPromise<Session>} [initializeVirtualScene] initialization callback
147
 function __THIS_PLUGIN_HAS_BEEN_TESTED_WITH__(json)
147
 function __THIS_PLUGIN_HAS_BEEN_TESTED_WITH__(json)
148
 {
148
 {
149
     window.addEventListener('load', () => {
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
     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;
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
     for(const [x, expected] of Object.entries(json)) check(x, expected.version, versionOf[x]);
153
     for(const [x, expected] of Object.entries(json)) check(x, expected.version, versionOf[x]);
154
     } catch(e) { alert(e.message); }
154
     } catch(e) { alert(e.message); }

+ 7
- 7
demos/hello-aframe/demo.js 파일 보기

1
 async function startARSession(canvas)
1
 async function startARSession(canvas)
2
 {
2
 {
3
-    if(!Martins.isSupported()) {
3
+    if(!AR.isSupported()) {
4
         throw new Error(
4
         throw new Error(
5
             'This device is not compatible with this AR experience.\n\n' +
5
             'This device is not compatible with this AR experience.\n\n' +
6
             'User agent: ' + navigator.userAgent
6
             'User agent: ' + navigator.userAgent
10
     if(!(canvas instanceof HTMLCanvasElement))
10
     if(!(canvas instanceof HTMLCanvasElement))
11
         throw new Error(`startARSession expects a <canvas>`);
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
     await tracker.database.add([{
16
     await tracker.database.add([{
17
         name: 'my-reference-image',
17
         name: 'my-reference-image',
18
         image: document.getElementById('my-reference-image')
18
         image: document.getElementById('my-reference-image')
19
     }]);
19
     }]);
20
 
20
 
21
-    const viewport = Martins.Viewport({
21
+    const viewport = AR.Viewport({
22
         canvas: canvas,
22
         canvas: canvas,
23
         container: document.getElementById('ar-viewport'),
23
         container: document.getElementById('ar-viewport'),
24
         hudContainer: document.getElementById('ar-hud')
24
         hudContainer: document.getElementById('ar-hud')
27
     const video = document.getElementById('my-video');
27
     const video = document.getElementById('my-video');
28
     const useWebcam = (video === null);
28
     const useWebcam = (video === null);
29
     const source = useWebcam ?
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
         mode: 'immersive',
34
         mode: 'immersive',
35
         viewport: viewport,
35
         viewport: viewport,
36
         trackers: [ tracker ],
36
         trackers: [ tracker ],

+ 7
- 7
demos/hello-three/demo.js 파일 보기

99
 
99
 
100
     async function startARSession()
100
     async function startARSession()
101
     {
101
     {
102
-        if(!Martins.isSupported()) {
102
+        if(!AR.isSupported()) {
103
             throw new Error(
103
             throw new Error(
104
                 'This device is not compatible with this AR experience.\n\n' +
104
                 'This device is not compatible with this AR experience.\n\n' +
105
                 'User agent: ' + navigator.userAgent
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
         await tracker.database.add([{
112
         await tracker.database.add([{
113
             name: 'my-reference-image',
113
             name: 'my-reference-image',
114
             image: document.getElementById('my-reference-image')
114
             image: document.getElementById('my-reference-image')
115
         }]);
115
         }]);
116
 
116
 
117
-        const viewport = Martins.Viewport({
117
+        const viewport = AR.Viewport({
118
             container: document.getElementById('ar-viewport'),
118
             container: document.getElementById('ar-viewport'),
119
             hudContainer: document.getElementById('ar-hud')
119
             hudContainer: document.getElementById('ar-hud')
120
         });
120
         });
122
         const video = document.getElementById('my-video');
122
         const video = document.getElementById('my-video');
123
         const useWebcam = (video === null);
123
         const useWebcam = (video === null);
124
         const source = useWebcam ?
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
             mode: 'immersive',
129
             mode: 'immersive',
130
             viewport: viewport,
130
             viewport: viewport,
131
             trackers: [ tracker ],
131
             trackers: [ tracker ],

+ 7
- 7
demos/hello-webgl/demo.js 파일 보기

911
 
911
 
912
     async function startARSession()
912
     async function startARSession()
913
     {
913
     {
914
-        if(!Martins.isSupported()) {
914
+        if(!AR.isSupported()) {
915
             throw new Error(
915
             throw new Error(
916
                 'This device is not compatible with this AR experience.\n\n' +
916
                 'This device is not compatible with this AR experience.\n\n' +
917
                 'User agent: ' + navigator.userAgent
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
         await tracker.database.add([{
924
         await tracker.database.add([{
925
             name: 'my-reference-image',
925
             name: 'my-reference-image',
926
             image: document.getElementById('my-reference-image')
926
             image: document.getElementById('my-reference-image')
927
         }]);
927
         }]);
928
 
928
 
929
-        const viewport = Martins.Viewport({
929
+        const viewport = AR.Viewport({
930
             container: document.getElementById('ar-viewport'),
930
             container: document.getElementById('ar-viewport'),
931
             hudContainer: document.getElementById('ar-hud')
931
             hudContainer: document.getElementById('ar-hud')
932
         });
932
         });
934
         const video = document.getElementById('my-video');
934
         const video = document.getElementById('my-video');
935
         const useWebcam = (video === null);
935
         const useWebcam = (video === null);
936
         const source = useWebcam ?
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
             mode: 'immersive',
941
             mode: 'immersive',
942
             viewport: viewport,
942
             viewport: viewport,
943
             trackers: [ tracker ],
943
             trackers: [ tracker ],

+ 7
- 7
demos/hello-world/demo.js 파일 보기

15
 
15
 
16
     async function startARSession()
16
     async function startARSession()
17
     {
17
     {
18
-        if(!Martins.isSupported()) {
18
+        if(!AR.isSupported()) {
19
             throw new Error(
19
             throw new Error(
20
                 'This device is not compatible with this AR experience.\n\n' +
20
                 'This device is not compatible with this AR experience.\n\n' +
21
                 'User agent: ' + navigator.userAgent
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
         await tracker.database.add([{
28
         await tracker.database.add([{
29
             name: 'my-reference-image',
29
             name: 'my-reference-image',
30
             image: document.getElementById('my-reference-image')
30
             image: document.getElementById('my-reference-image')
31
         }]);
31
         }]);
32
 
32
 
33
-        const viewport = Martins.Viewport({
33
+        const viewport = AR.Viewport({
34
             container: document.getElementById('ar-viewport'),
34
             container: document.getElementById('ar-viewport'),
35
             hudContainer: document.getElementById('ar-hud')
35
             hudContainer: document.getElementById('ar-hud')
36
         });
36
         });
38
         const video = document.getElementById('my-video');
38
         const video = document.getElementById('my-video');
39
         const useWebcam = (video === null);
39
         const useWebcam = (video === null);
40
         const source = useWebcam ?
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
             mode: 'immersive',
45
             mode: 'immersive',
46
             viewport: viewport,
46
             viewport: viewport,
47
             trackers: [ tracker ],
47
             trackers: [ tracker ],

+ 7
- 7
demos/touch-three/demo.js 파일 보기

129
 
129
 
130
     async function startARSession()
130
     async function startARSession()
131
     {
131
     {
132
-        if(!Martins.isSupported()) {
132
+        if(!AR.isSupported()) {
133
             throw new Error(
133
             throw new Error(
134
                 'This device is not compatible with this AR experience.\n\n' +
134
                 'This device is not compatible with this AR experience.\n\n' +
135
                 'User agent: ' + navigator.userAgent
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
         await tracker.database.add([{
142
         await tracker.database.add([{
143
             name: 'my-reference-image',
143
             name: 'my-reference-image',
144
             image: document.getElementById('my-reference-image')
144
             image: document.getElementById('my-reference-image')
145
         }]);
145
         }]);
146
 
146
 
147
-        const viewport = Martins.Viewport({
147
+        const viewport = AR.Viewport({
148
             container: document.getElementById('ar-viewport'),
148
             container: document.getElementById('ar-viewport'),
149
             hudContainer: document.getElementById('ar-hud')
149
             hudContainer: document.getElementById('ar-hud')
150
         });
150
         });
152
         const video = document.getElementById('my-video');
152
         const video = document.getElementById('my-video');
153
         const useWebcam = (video === null);
153
         const useWebcam = (video === null);
154
         const source = useWebcam ?
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
             mode: 'immersive',
159
             mode: 'immersive',
160
             viewport: viewport,
160
             viewport: viewport,
161
             trackers: [ tracker ],
161
             trackers: [ tracker ],

docs/api/martins.md → docs/api/ar.md 파일 보기

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
 I have documented the instantiation of the components of the engine in their respective pages.
5
 I have documented the instantiation of the components of the engine in their respective pages.
6
 
6
 
8
 
8
 
9
 ### Settings
9
 ### Settings
10
 
10
 
11
-`Martins.Settings: Settings, read-only`
11
+`AR.Settings: Settings, read-only`
12
 
12
 
13
 The [settings](settings.md) of the engine.
13
 The [settings](settings.md) of the engine.
14
 
14
 
15
 ### version
15
 ### version
16
 
16
 
17
-`Martins.version: string, read-only`
17
+`AR.version: string, read-only`
18
 
18
 
19
 The version of encantAR.js.
19
 The version of encantAR.js.
20
 
20
 
22
 
22
 
23
 ### isSupported
23
 ### isSupported
24
 
24
 
25
-`Martins.isSupported(): boolean`
25
+`AR.isSupported(): boolean`
26
 
26
 
27
 Checks if the user agent is capable of running the engine.
27
 Checks if the user agent is capable of running the engine.
28
 
28
 

+ 3
- 3
docs/api/camera-source.md 파일 보기

4
 
4
 
5
 ## Instantiation
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
 Create a new webcam-based source of data with the specified `settings`.
11
 Create a new webcam-based source of data with the specified `settings`.
12
 
12
 
24
 **Example**
24
 **Example**
25
 
25
 
26
 ```js
26
 ```js
27
-const webcam = Martins.Source.Camera({
27
+const webcam = AR.Source.Camera({
28
     resolution: 'md+',
28
     resolution: 'md+',
29
     constraints: {
29
     constraints: {
30
         facingMode: 'environment' // will prefer the rear camera on mobile devices
30
         facingMode: 'environment' // will prefer the rear camera on mobile devices

+ 2
- 2
docs/api/canvas-source.md 파일 보기

4
 
4
 
5
 ## Instantiation
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
 Create a new source of data linked to the provided `canvas`.
11
 Create a new source of data linked to the provided `canvas`.
12
 
12
 

+ 2
- 2
docs/api/session.md 파일 보기

4
 
4
 
5
 ## Instantiation
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
 Start a new session.
11
 Start a new session.
12
 
12
 

+ 1
- 1
docs/api/settings.md 파일 보기

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

+ 1
- 1
docs/api/speedy.md 파일 보기

12
 
12
 
13
 `Speedy: Speedy, read-only`
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
 
4
 
5
 ## Instantiation
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
 Create a new source of data linked to the provided `video`.
11
 Create a new source of data linked to the provided `video`.
12
 
12
 

+ 3
- 3
docs/api/viewport.md 파일 보기

4
 
4
 
5
 ## Instantiation
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
 Create a new viewport with the specified `settings`.
11
 Create a new viewport with the specified `settings`.
12
 
12
 
26
 **Example**
26
 **Example**
27
 
27
 
28
 ```js
28
 ```js
29
-const viewport = Martins.Viewport({
29
+const viewport = AR.Viewport({
30
     container: document.getElementById('ar-viewport'),
30
     container: document.getElementById('ar-viewport'),
31
     resolution: 'lg'
31
     resolution: 'lg'
32
 });
32
 });

+ 25
- 25
docs/getting-started/activate-your-webcam.md 파일 보기

9
 ```js title="ar-demo.js" hl_lines="20-22"
9
 ```js title="ar-demo.js" hl_lines="20-22"
10
 async function startARSession()
10
 async function startARSession()
11
 {
11
 {
12
-    if(!Martins.isSupported()) {
12
+    if(!AR.isSupported()) {
13
         throw new Error(
13
         throw new Error(
14
             'This device is not compatible with this AR experience.\n\n' +
14
             'This device is not compatible with this AR experience.\n\n' +
15
             'User agent: ' + navigator.userAgent
15
             'User agent: ' + navigator.userAgent
16
         );
16
         );
17
     }
17
     }
18
 
18
 
19
-    const tracker = Martins.Tracker.ImageTracker();
19
+    const tracker = AR.Tracker.ImageTracker();
20
     await tracker.database.add([{
20
     await tracker.database.add([{
21
         name: 'my-reference-image',
21
         name: 'my-reference-image',
22
         image: document.getElementById('my-reference-image')
22
         image: document.getElementById('my-reference-image')
23
     }]);
23
     }]);
24
 
24
 
25
-    const viewport = Martins.Viewport({
25
+    const viewport = AR.Viewport({
26
         container: document.getElementById('ar-viewport')
26
         container: document.getElementById('ar-viewport')
27
     });
27
     });
28
 
28
 
29
     //const video = document.getElementById('my-video'); // comment this line
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
         mode: 'immersive',
34
         mode: 'immersive',
35
         viewport: viewport,
35
         viewport: viewport,
36
         trackers: [ tracker ],
36
         trackers: [ tracker ],
154
 ```js title="ar-demo.js" hl_lines="17-18"
154
 ```js title="ar-demo.js" hl_lines="17-18"
155
 async function startARSession()
155
 async function startARSession()
156
 {
156
 {
157
-    if(!Martins.isSupported()) {
157
+    if(!AR.isSupported()) {
158
         throw new Error(
158
         throw new Error(
159
             'This device is not compatible with this AR experience.\n\n' +
159
             'This device is not compatible with this AR experience.\n\n' +
160
             'User agent: ' + navigator.userAgent
160
             'User agent: ' + navigator.userAgent
161
         );
161
         );
162
     }
162
     }
163
 
163
 
164
-    const tracker = Martins.Tracker.ImageTracker();
164
+    const tracker = AR.Tracker.ImageTracker();
165
     await tracker.database.add([{
165
     await tracker.database.add([{
166
         name: 'my-reference-image',
166
         name: 'my-reference-image',
167
         image: document.getElementById('my-reference-image')
167
         image: document.getElementById('my-reference-image')
168
     }]);
168
     }]);
169
 
169
 
170
-    const viewport = Martins.Viewport({
170
+    const viewport = AR.Viewport({
171
         container: document.getElementById('ar-viewport'),
171
         container: document.getElementById('ar-viewport'),
172
         hudContainer: document.getElementById('ar-hud')
172
         hudContainer: document.getElementById('ar-hud')
173
     });
173
     });
174
 
174
 
175
     //const video = document.getElementById('my-video');
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
         mode: 'immersive',
180
         mode: 'immersive',
181
         viewport: viewport,
181
         viewport: viewport,
182
         trackers: [ tracker ],
182
         trackers: [ tracker ],
200
 ```js title="ar-demo.js" hl_lines="34-42"
200
 ```js title="ar-demo.js" hl_lines="34-42"
201
 async function startARSession()
201
 async function startARSession()
202
 {
202
 {
203
-    if(!Martins.isSupported()) {
203
+    if(!AR.isSupported()) {
204
         throw new Error(
204
         throw new Error(
205
             'This device is not compatible with this AR experience.\n\n' +
205
             'This device is not compatible with this AR experience.\n\n' +
206
             'User agent: ' + navigator.userAgent
206
             'User agent: ' + navigator.userAgent
207
         );
207
         );
208
     }
208
     }
209
 
209
 
210
-    const tracker = Martins.Tracker.ImageTracker();
210
+    const tracker = AR.Tracker.ImageTracker();
211
     await tracker.database.add([{
211
     await tracker.database.add([{
212
         name: 'my-reference-image',
212
         name: 'my-reference-image',
213
         image: document.getElementById('my-reference-image')
213
         image: document.getElementById('my-reference-image')
214
     }]);
214
     }]);
215
 
215
 
216
-    const viewport = Martins.Viewport({
216
+    const viewport = AR.Viewport({
217
         container: document.getElementById('ar-viewport'),
217
         container: document.getElementById('ar-viewport'),
218
         hudContainer: document.getElementById('ar-hud')
218
         hudContainer: document.getElementById('ar-hud')
219
     });
219
     });
220
 
220
 
221
     //const video = document.getElementById('my-video');
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
         mode: 'immersive',
226
         mode: 'immersive',
227
         viewport: viewport,
227
         viewport: viewport,
228
         trackers: [ tracker ],
228
         trackers: [ tracker ],
247
 
247
 
248
 ## Hide the gizmos
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
 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:
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
 ```js title="ar-demo.js" hl_lines="38 43"
254
 ```js title="ar-demo.js" hl_lines="38 43"
255
 async function startARSession()
255
 async function startARSession()
256
 {
256
 {
257
-    if(!Martins.isSupported()) {
257
+    if(!AR.isSupported()) {
258
         throw new Error(
258
         throw new Error(
259
             'This device is not compatible with this AR experience.\n\n' +
259
             'This device is not compatible with this AR experience.\n\n' +
260
             'User agent: ' + navigator.userAgent
260
             'User agent: ' + navigator.userAgent
261
         );
261
         );
262
     }
262
     }
263
 
263
 
264
-    const tracker = Martins.Tracker.ImageTracker();
264
+    const tracker = AR.Tracker.ImageTracker();
265
     await tracker.database.add([{
265
     await tracker.database.add([{
266
         name: 'my-reference-image',
266
         name: 'my-reference-image',
267
         image: document.getElementById('my-reference-image')
267
         image: document.getElementById('my-reference-image')
268
     }]);
268
     }]);
269
 
269
 
270
-    const viewport = Martins.Viewport({
270
+    const viewport = AR.Viewport({
271
         container: document.getElementById('ar-viewport'),
271
         container: document.getElementById('ar-viewport'),
272
         hudContainer: document.getElementById('ar-hud')
272
         hudContainer: document.getElementById('ar-hud')
273
     });
273
     });
274
 
274
 
275
     //const video = document.getElementById('my-video');
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
         mode: 'immersive',
280
         mode: 'immersive',
281
         viewport: viewport,
281
         viewport: viewport,
282
         trackers: [ tracker ],
282
         trackers: [ tracker ],

+ 8
- 8
docs/getting-started/next-steps.md 파일 보기

6
 
6
 
7
 ## Change the power preference
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
 ```js title="ar-demo.js" hl_lines="10"
11
 ```js title="ar-demo.js" hl_lines="10"
12
 async function startARSession()
12
 async function startARSession()
13
 {
13
 {
14
-    if(!Martins.isSupported()) {
14
+    if(!AR.isSupported()) {
15
         throw new Error(
15
         throw new Error(
16
             'This device is not compatible with this AR experience.\n\n' +
16
             'This device is not compatible with this AR experience.\n\n' +
17
             'User agent: ' + navigator.userAgent
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
     await tracker.database.add([{
24
     await tracker.database.add([{
25
         name: 'my-reference-image',
25
         name: 'my-reference-image',
26
         image: document.getElementById('my-reference-image')
26
         image: document.getElementById('my-reference-image')
27
     }]);
27
     }]);
28
 
28
 
29
-    const viewport = Martins.Viewport({
29
+    const viewport = AR.Viewport({
30
         container: document.getElementById('ar-viewport'),
30
         container: document.getElementById('ar-viewport'),
31
         hudContainer: document.getElementById('ar-hud')
31
         hudContainer: document.getElementById('ar-hud')
32
     });
32
     });
33
 
33
 
34
     //const video = document.getElementById('my-video');
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
         mode: 'immersive',
39
         mode: 'immersive',
40
         viewport: viewport,
40
         viewport: viewport,
41
         trackers: [ tracker ],
41
         trackers: [ tracker ],

+ 18
- 18
docs/getting-started/set-up-the-session.md 파일 보기

32
 window.onload = async function()
32
 window.onload = async function()
33
 {
33
 {
34
     try {
34
     try {
35
-        if(!Martins.isSupported()) {
35
+        if(!AR.isSupported()) {
36
             throw new Error(
36
             throw new Error(
37
                 'This device is not compatible with this AR experience.\n\n' +
37
                 'This device is not compatible with this AR experience.\n\n' +
38
                 'User agent: ' + navigator.userAgent
38
                 'User agent: ' + navigator.userAgent
39
             );
39
             );
40
         }
40
         }
41
 
41
 
42
-        const tracker = Martins.Tracker.ImageTracker();
42
+        const tracker = AR.Tracker.ImageTracker();
43
         await tracker.database.add([{
43
         await tracker.database.add([{
44
             name: 'my-reference-image',
44
             name: 'my-reference-image',
45
             image: document.getElementById('my-reference-image')
45
             image: document.getElementById('my-reference-image')
46
         }]);
46
         }]);
47
 
47
 
48
-        const viewport = Martins.Viewport({
48
+        const viewport = AR.Viewport({
49
             container: document.getElementById('ar-viewport')
49
             container: document.getElementById('ar-viewport')
50
         });
50
         });
51
     }
51
     }
63
 window.onload = async function()
63
 window.onload = async function()
64
 {
64
 {
65
     try {
65
     try {
66
-        if(!Martins.isSupported()) {
66
+        if(!AR.isSupported()) {
67
             throw new Error(
67
             throw new Error(
68
                 'This device is not compatible with this AR experience.\n\n' +
68
                 'This device is not compatible with this AR experience.\n\n' +
69
                 'User agent: ' + navigator.userAgent
69
                 'User agent: ' + navigator.userAgent
70
             );
70
             );
71
         }
71
         }
72
 
72
 
73
-        const tracker = Martins.Tracker.ImageTracker();
73
+        const tracker = AR.Tracker.ImageTracker();
74
         await tracker.database.add([{
74
         await tracker.database.add([{
75
             name: 'my-reference-image',
75
             name: 'my-reference-image',
76
             image: document.getElementById('my-reference-image')
76
             image: document.getElementById('my-reference-image')
77
         }]);
77
         }]);
78
 
78
 
79
-        const viewport = Martins.Viewport({
79
+        const viewport = AR.Viewport({
80
             container: document.getElementById('ar-viewport')
80
             container: document.getElementById('ar-viewport')
81
         });
81
         });
82
 
82
 
83
         const video = document.getElementById('my-video');
83
         const video = document.getElementById('my-video');
84
-        const source = Martins.Source.Video(video);
84
+        const source = AR.Source.Video(video);
85
     }
85
     }
86
     catch(error) {
86
     catch(error) {
87
         alert(error.message);
87
         alert(error.message);
91
 
91
 
92
 ## Start the session
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
 ```js title="ar-demo.js" hl_lines="24-31"
96
 ```js title="ar-demo.js" hl_lines="24-31"
97
 window.onload = async function()
97
 window.onload = async function()
98
 {
98
 {
99
     try {
99
     try {
100
-        if(!Martins.isSupported()) {
100
+        if(!AR.isSupported()) {
101
             throw new Error(
101
             throw new Error(
102
                 'This device is not compatible with this AR experience.\n\n' +
102
                 'This device is not compatible with this AR experience.\n\n' +
103
                 'User agent: ' + navigator.userAgent
103
                 'User agent: ' + navigator.userAgent
104
             );
104
             );
105
         }
105
         }
106
 
106
 
107
-        const tracker = Martins.Tracker.ImageTracker();
107
+        const tracker = AR.Tracker.ImageTracker();
108
         await tracker.database.add([{
108
         await tracker.database.add([{
109
             name: 'my-reference-image',
109
             name: 'my-reference-image',
110
             image: document.getElementById('my-reference-image')
110
             image: document.getElementById('my-reference-image')
111
         }]);
111
         }]);
112
 
112
 
113
-        const viewport = Martins.Viewport({
113
+        const viewport = AR.Viewport({
114
             container: document.getElementById('ar-viewport')
114
             container: document.getElementById('ar-viewport')
115
         });
115
         });
116
 
116
 
117
         const video = document.getElementById('my-video');
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
             mode: 'immersive',
121
             mode: 'immersive',
122
             viewport: viewport,
122
             viewport: viewport,
123
             trackers: [ tracker ],
123
             trackers: [ tracker ],
160
 
160
 
161
 async function startARSession()
161
 async function startARSession()
162
 {
162
 {
163
-    if(!Martins.isSupported()) {
163
+    if(!AR.isSupported()) {
164
         throw new Error(
164
         throw new Error(
165
             'This device is not compatible with this AR experience.\n\n' +
165
             'This device is not compatible with this AR experience.\n\n' +
166
             'User agent: ' + navigator.userAgent
166
             'User agent: ' + navigator.userAgent
167
         );
167
         );
168
     }
168
     }
169
 
169
 
170
-    const tracker = Martins.Tracker.ImageTracker();
170
+    const tracker = AR.Tracker.ImageTracker();
171
     await tracker.database.add([{
171
     await tracker.database.add([{
172
         name: 'my-reference-image',
172
         name: 'my-reference-image',
173
         image: document.getElementById('my-reference-image')
173
         image: document.getElementById('my-reference-image')
174
     }]);
174
     }]);
175
 
175
 
176
-    const viewport = Martins.Viewport({
176
+    const viewport = AR.Viewport({
177
         container: document.getElementById('ar-viewport')
177
         container: document.getElementById('ar-viewport')
178
     });
178
     });
179
 
179
 
180
     const video = document.getElementById('my-video');
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
         mode: 'immersive',
184
         mode: 'immersive',
185
         viewport: viewport,
185
         viewport: viewport,
186
         trackers: [ tracker ],
186
         trackers: [ tracker ],

+ 5
- 5
docs/getting-started/set-up-the-tracker.md 파일 보기

137
 window.onload = async function()
137
 window.onload = async function()
138
 {
138
 {
139
     try {
139
     try {
140
-        if(!Martins.isSupported()) {
140
+        if(!AR.isSupported()) {
141
             throw new Error(
141
             throw new Error(
142
                 'This device is not compatible with this AR experience.\n\n' +
142
                 'This device is not compatible with this AR experience.\n\n' +
143
                 'User agent: ' + navigator.userAgent
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
     catch(error) {
149
     catch(error) {
150
         alert(error.message);
150
         alert(error.message);
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
 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.
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
 window.onload = async function()
178
 window.onload = async function()
179
 {
179
 {
180
     try {
180
     try {
181
-        if(!Martins.isSupported()) {
181
+        if(!AR.isSupported()) {
182
             throw new Error(
182
             throw new Error(
183
                 'This device is not compatible with this AR experience.\n\n' +
183
                 'This device is not compatible with this AR experience.\n\n' +
184
                 'User agent: ' + navigator.userAgent
184
                 'User agent: ' + navigator.userAgent
185
             );
185
             );
186
         }
186
         }
187
 
187
 
188
-        const tracker = Martins.Tracker.ImageTracker();
188
+        const tracker = AR.Tracker.ImageTracker();
189
         await tracker.database.add([{
189
         await tracker.database.add([{
190
             name: 'my-reference-image',
190
             name: 'my-reference-image',
191
             image: document.getElementById('my-reference-image')
191
             image: document.getElementById('my-reference-image')

+ 1
- 1
mkdocs.yml 파일 보기

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

+ 2
- 2
src/core/stats-panel.ts 파일 보기

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

+ 3
- 3
src/main.ts 파일 보기

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

+ 1
- 1
webpack.config.js 파일 보기

13
         path: path.resolve(__dirname, 'dist'),
13
         path: path.resolve(__dirname, 'dist'),
14
         publicPath: '/dist/',
14
         publicPath: '/dist/',
15
         library: {
15
         library: {
16
-            name: 'Martins',
16
+            name: 'AR',
17
             type: 'umd',
17
             type: 'umd',
18
             export: 'default',
18
             export: 'default',
19
         },
19
         },

Loading…
취소
저장