|
@@ -178,17 +178,13 @@ export class Session extends AREventTarget<SessionEventType>
|
178
|
178
|
else
|
179
|
179
|
this._viewport._init(() => Utils.resolution('sm', window.innerWidth / window.innerHeight), mode);
|
180
|
180
|
|
181
|
|
- // setup the main loop
|
182
|
|
- this._setupUpdateLoop();
|
183
|
|
- this._setupRenderLoop();
|
184
|
|
-
|
185
|
181
|
// setup the stats panel
|
186
|
182
|
this._statsPanel = new StatsPanel(this._viewport);
|
187
|
183
|
this._statsPanel.visible = stats;
|
188
|
184
|
|
189
|
185
|
// done!
|
190
|
186
|
Session._count++;
|
191
|
|
- Utils.log(`The ${mode} session is now active!`);
|
|
187
|
+ Utils.log(`The ${this._mode} session is now active!`);
|
192
|
188
|
}
|
193
|
189
|
|
194
|
190
|
/**
|
|
@@ -330,7 +326,7 @@ export class Session extends AREventTarget<SessionEventType>
|
330
|
326
|
|
331
|
327
|
}).then(session => {
|
332
|
328
|
|
333
|
|
- // validate trackers
|
|
329
|
+ // validate the trackers
|
334
|
330
|
if(trackers.length == 0)
|
335
|
331
|
Utils.warning(`No trackers have been attached to the session!`);
|
336
|
332
|
|
|
@@ -339,10 +335,16 @@ export class Session extends AREventTarget<SessionEventType>
|
339
|
335
|
throw new IllegalArgumentError(`Found repeated trackers`);
|
340
|
336
|
}
|
341
|
337
|
|
342
|
|
- // attach trackers and return the session
|
|
338
|
+ // attach the trackers
|
343
|
339
|
return Speedy.Promise.all(
|
344
|
340
|
trackers.map(tracker => session._attachTracker(tracker))
|
345
|
|
- ).then(() => session).catch(err => { throw err; });
|
|
341
|
+ ).then(() => session);
|
|
342
|
+
|
|
343
|
+ }).then(session => {
|
|
344
|
+
|
|
345
|
+ // start the main loop and return the session
|
|
346
|
+ session._startMainLoop();
|
|
347
|
+ return session;
|
346
|
348
|
|
347
|
349
|
}).catch(err => {
|
348
|
350
|
|
|
@@ -502,6 +504,17 @@ export class Session extends AREventTarget<SessionEventType>
|
502
|
504
|
}
|
503
|
505
|
|
504
|
506
|
/**
|
|
507
|
+ * Start the main loop
|
|
508
|
+ */
|
|
509
|
+ private _startMainLoop(): void
|
|
510
|
+ {
|
|
511
|
+ this._setupUpdateLoop();
|
|
512
|
+ this._setupRenderLoop();
|
|
513
|
+
|
|
514
|
+ Utils.log('The main loop has been started!');
|
|
515
|
+ }
|
|
516
|
+
|
|
517
|
+ /**
|
505
|
518
|
* Find the primary source of data (generally a camera stream)
|
506
|
519
|
* @param sources
|
507
|
520
|
* @returns the primary source, or null if there isn't any
|
|
@@ -597,12 +610,12 @@ export class Session extends AREventTarget<SessionEventType>
|
597
|
610
|
private _setupUpdateLoop(): void
|
598
|
611
|
{
|
599
|
612
|
const scheduleNextFrame = () => {
|
600
|
|
- if(this._active) {
|
601
|
|
- if(Settings.powerPreference == 'high-performance')
|
602
|
|
- asap(repeat);
|
603
|
|
- else
|
604
|
|
- window.requestAnimationFrame(repeat);
|
605
|
|
- }
|
|
613
|
+ if(!this._active)
|
|
614
|
+ return;
|
|
615
|
+ else if(Settings.powerPreference == 'high-performance')
|
|
616
|
+ asap(repeat);
|
|
617
|
+ else
|
|
618
|
+ window.requestAnimationFrame(repeat);
|
606
|
619
|
};
|
607
|
620
|
|
608
|
621
|
const update = () => {
|
|
@@ -675,7 +688,7 @@ export class Session extends AREventTarget<SessionEventType>
|
675
|
688
|
|
676
|
689
|
// skip frames
|
677
|
690
|
if(!enableFrameSkipping || !(skip = !skip))
|
678
|
|
- this._render(timestamp, false);
|
|
691
|
+ this._render(timestamp);
|
679
|
692
|
//this._render(timestamp, !enableFrameSkipping && !highPerformance && (toggle = !toggle));
|
680
|
693
|
|
681
|
694
|
// repeat
|
|
@@ -691,7 +704,7 @@ export class Session extends AREventTarget<SessionEventType>
|
691
|
704
|
* @param time current time, in ms
|
692
|
705
|
* @param skipUserMedia skip copying the pixels of the user media to the background canvas in order to reduce the processing load (video stream is probably at 30fps?)
|
693
|
706
|
*/
|
694
|
|
- private _render(time: DOMHighResTimeStamp, skipUserMedia: boolean): void
|
|
707
|
+ private _render(time: DOMHighResTimeStamp, skipUserMedia: boolean = false): void
|
695
|
708
|
{
|
696
|
709
|
// is the session active?
|
697
|
710
|
if(this._active) {
|