This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.esc.js
334 lines (286 loc) · 9.74 KB
/
index.esc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
// Previous Demo Components
import * as helloWorldDemo from "../0-hello-world/index.esc.js"
import * as compositionDemo from "../1-composition/index.esc.js"
import * as webComponentsDemo from "../2-web-components/index.esc.js"
import * as gameDemo from "../3-game-development/multimodal.esc.js"
import * as physiologicalSignalsDemo from "../4-physiological-signals/index.esc.js"
import * as signalDemo from "../4-physiological-signals/components/signal/index.esc.js"
import * as noisySignalDemo from "../4-physiological-signals/components/signal/versions/noisy/index.esc.js"
import * as filteredSignalDemo from "../4-physiological-signals/components/signal/versions/filtered/index.esc.js"
export const __attributes = {
style: {
overflow: 'scroll',
height: '100%',
width: '100%',
padding: '50px',
fontFamily: 'sans-serif',
boxSizing: 'border-box'
}
}
const maxHeight = '400px'
gameDemo.__attributes.style.height = maxHeight
// const __editor = undefined
const __editor = {
style: {
height: maxHeight,
border: '2px solid'
}
}
export const __children = {
header: {
__element: 'h1',
__attributes: {
innerText: 'Brains@Play Starter Kit'
}
},
paragraph1: {
__element: 'p',
__attributes: {
innerText: 'Congratulations on starting your journey with Brains@Play. We are excited to see what you develop with us.'
}
},
hr1: {
__element: 'hr',
},
h2: {
__element: 'h2',
__attributes: {
innerHTML: "Part I: Getting Started"
}
},
paragraph2: {
__element: 'p',
__attributes: {
innerHTML: 'In this tutorial, we first introduced the concept of an <b>ES Component</b> by creating a basic Hello World project with a single header tag.'
}
},
helloworld: {
__editor,
__compose: helloWorldDemo,
},
paragraph3: {
__element: 'p',
__attributes: {
innerHTML: 'Then, we used the principle of <b>composition</b> to extend this by listening to the value of an input tag with the innerText of our header.'
}
},
paragraph3_1: {
__element: 'p',
__children: {
span1: {
__element: 'span',
__attributes: {
innerHTML: 'This allowed you to update the header with '
},
},
em1: {
__element: 'em',
__attributes: {
innerHTML: 'whatever you wanted'
},
},
span2: {
__element: 'span',
__attributes: {
innerHTML: ' when writing in the input.'
},
}
}
},
composition: {
__editor,
__compose: compositionDemo,
},
paragraph4: {
__element: 'p',
__attributes: {
innerHTML: 'Next, we registered this ES Component as a <b>Web Component</b> that can be included anywhere in an existing project. How cool!'
}
},
webcomponents: {
__editor,
__compose: webComponentsDemo,
},
hr2: {
__element: 'hr',
},
paragraph5: {
__element: 'p',
__attributes: {
innerHTML: 'Switching to a more complicated example, we used an existing ES Component to <b>create a simple game</b> using <a href="https://phaser.io/phaser3">Phaser 3</a>, while also introducing the concept of <b>multimodal control</b>.'
}
},
game: {
__editor,
__compose: gameDemo,
},
hr3: {
__element: 'hr',
},
secondsection: {
__children: {
h2: {
__element: 'h2',
__attributes: {
innerHTML: "Part II: Using Physiological Signals as Game Controls"
}
},
block1: {
__children: {
p1: {
__element: 'p',
__attributes: {
innerHTML: "Signals are information being carried in a medium like electricity or light that we can use to understand or communicate with each other."
}
},
demo1: {
__editor,
__compose: signalDemo,
},
}
},
block2: {
__children: {
p2: {
__element: 'p',
__attributes: {
innerHTML: "However, signals usually have to compete with nonsensical noise due to imperfect device measurements and environmental interference."
}
},
demo2: {
__editor,
__compose: noisySignalDemo,
},
}
},
block3: {
__children: {
p3: {
__element: 'p',
__attributes: {
innerHTML: "This makes it hard to use these signals to do things like control a game!"
}
},
demo3: {
__editor,
__compose: physiologicalSignalsDemo,
__children: {
devices: {
__attributes: {
style: {
display:'none'
}
}
}
}
},
}
},
block4: {
__children: {
p4: {
__element: 'p',
__attributes: {
innerHTML: "We can filter some noise, but sometimes there are multiple sources of noise, in this case <b>we still see signals from our power outlet</b>, which oscillates as a 60Hz alternating current that isn't completely converted to DC current."
}
},
demo4: {
__editor,
__compose: filteredSignalDemo,
// Apply Demo-Specific Filter Bank (disable notch)
__children: {
devices: {
__children: {
filter: {
settings: {
useNotch50: false,
useNotch60: false,
},
}
}
},
}
},
}
},
block5: {
__children: {
p5: {
__element: 'p',
__attributes: {
innerHTML: "To solve this we can <b>apply multiple filters</b> to block different ranges (i.e. lowpass, highpass, and bandpass filters) or specific frequencies (e.g. notch filters). "
}
},
demo5: {
__editor,
__compose: filteredSignalDemo,
},
}
},
block6: {
__children: {
p6: {
__element: 'p',
__attributes: {
innerHTML: "With just a low pass and notch filter, we can now control the game with our eyes! Try it!"
}
},
demo6: {
__editor,
__compose: physiologicalSignalsDemo,
__children: {
devices: {
__attributes: {
style: {
display:'none'
}
}
}
}
},
}
}
}
},
hr4: {
__element: 'hr',
},
paragraph7: {
__element: 'p',
__attributes: {
innerHTML: 'We hope you enjoyed this tutorial. And we hope to see you again soon!'
}
},
}
const listeners = {
'paragraph3_1.em1': {
'composition.input': true
},
}
const phaser = [3,6]
const filtered = [4,5]
// Wire together all the data demos
const start = 1
const n = 6
for (let i = start; i < n + 1; i++) {
const list = {}
const spsUpdates = {}
for (let j = start; j < n + 1; j++) {
if (i !== j) {
list[`secondsection.block${j}.demo${j}.devices.connect`] = true
spsUpdates[`secondsection.block${j}.demo${j}.devices.connect.sps`] = true
}
}
if (filtered.includes(i)) listeners[`secondsection.block${i}.demo${i}.devices.filter.settings.sps`] = spsUpdates
if (!phaser.includes(i)) listeners[`secondsection.block${i}.demo${i}.devices.ondata`] = list
}
// Mirror the data above
phaser.forEach(i => {
if (i > start){
listeners[`secondsection.block${i}.demo${i}.devices.output`] = {
[`secondsection.block${i-1}.demo${i-1}.devices.output`]: true
}
}
})
// // const set = new Set()
export const __listeners = listeners