@@ -2,6 +2,9 @@ import Store from '@dojo/framework/stores/Store';
2
2
import { State } from '../interfaces' ;
3
3
import { Media } from 'present-core/api/websocket/screen' ;
4
4
import { nextSlide , previousSlide } from 'present-core/api/websocket/revealjs' ;
5
+ import { enterVrProcess , exitVrProcess } from '../processes/vr.process' ;
6
+ import { startSharingPose , stopSharingPose } from './aframe/pose' ;
7
+ import { snackbar } from './aframe/snackbar' ;
5
8
6
9
export function initialize ( store : Store < State > ) {
7
10
const { get, path } = store ;
@@ -14,8 +17,32 @@ export function initialize(store: Store<State>) {
14
17
setScreenMedia ( get ( path ( 'space' , 'screen' , 'source' ) ) ) ;
15
18
} ) ;
16
19
20
+ store . onChange ( path ( 'isPresenter' ) , ( ) => {
21
+ const isPresenter = get ( path ( 'isPresenter' ) ) ;
22
+ const isInVr = get ( path ( 'isInVr' ) ) ;
23
+
24
+ if ( isPresenter && isInVr ) {
25
+ startSharingPose ( ) ;
26
+ }
27
+ else {
28
+ stopSharingPose ( ) ;
29
+ }
30
+ } ) ;
31
+
32
+ store . onChange ( path ( 'isInVr' ) , ( ) => {
33
+ const isPresenter = get ( path ( 'isPresenter' ) ) ;
34
+ const isInVr = get ( path ( 'isInVr' ) ) ;
35
+
36
+ if ( isPresenter && isInVr ) {
37
+ startSharingPose ( ) ;
38
+ }
39
+ else {
40
+ stopSharingPose ( ) ;
41
+ }
42
+ } ) ;
43
+
17
44
// Attach event handlers to Aframe
18
- initializeHandlers ( ) ;
45
+ initializeHandlers ( store ) ;
19
46
20
47
// Wait for Aframe to load before continuing
21
48
const scene = document . querySelector ( 'a-scene' ) ;
@@ -27,28 +54,24 @@ export function initialize(store: Store<State>) {
27
54
// TODO load the tracked initial values in to the store
28
55
}
29
56
30
- function initializeHandlers ( ) {
57
+ function initializeHandlers ( store : Store < State > ) {
31
58
// const leftHand = document.getElementById('leftControl');
32
59
const rightHand = document . getElementById ( 'rightControl' ) ;
60
+ const scene = document . querySelector ( 'a-scene' ) ;
33
61
34
62
rightHand ?. addEventListener ( 'abuttondown' , ( ) => {
35
63
nextSlide ( { } ) ;
36
64
} ) ;
37
65
rightHand ?. addEventListener ( 'bbuttondown' , ( ) => {
38
66
previousSlide ( { } ) ;
39
67
} ) ;
40
- // TODO track pose when connected && is presenter
41
- }
42
-
43
- export function snackbar ( message : string , timeout : number = 3000 ) {
44
- const textNode = document . querySelector ( 'a-text' ) ;
45
- textNode ?. setAttribute ( 'value' , message ) ;
46
- setTimeout ( ( ) => {
47
- const currentValue = textNode ?. getAttribute ( 'value' ) ;
48
- if ( currentValue === message ) {
49
- textNode ?. removeAttribute ( 'value' ) ;
50
- }
51
- } , timeout ) ;
68
+ scene ?. addEventListener ( 'enter-vr' , ( ) => {
69
+ enterVrProcess ( store ) ( { } ) ;
70
+ snackbar ( 'Welcome' ) ;
71
+ } ) ;
72
+ scene ?. addEventListener ( 'exit-vr' , ( ) => {
73
+ exitVrProcess ( store ) ( { } ) ;
74
+ } ) ;
52
75
}
53
76
54
77
function setSkyColor ( color : string ) {
0 commit comments