aframe-babia-components 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/components/filters/babia-treebuilder.js +17 -12
  2. package/components/others/babia-camera.js +52 -40
  3. package/components/others/babia-experiment.js +457 -0
  4. package/components/others/babia-poster.js +383 -0
  5. package/components/others/babia-task.js +247 -0
  6. package/components/others/babia-ui.js +312 -147
  7. package/components/others/common.js +36 -5
  8. package/components/visualizers/babia-boats.js +708 -87
  9. package/components/visualizers/babia-network.js +268 -212
  10. package/dist/aframe-babia-components.js +20590 -18317
  11. package/dist/aframe-babia-components.min.js +3 -3
  12. package/dist/aframe-babia-components.min.js.map +1 -1
  13. package/docs/APIs/CHARTS.md +233 -207
  14. package/docs/APIs/OTHERS.md +143 -56
  15. package/docs/RELEASE_NOTES.md +5 -0
  16. package/docs/Tutorials/how_to_prepare_an_experiment.md +148 -0
  17. package/examples/assets/palettes/bluetored.jpg +0 -0
  18. package/examples/assets/textures/360-panorama.jpg +0 -0
  19. package/examples/assets/textures/floor-texture.jpg +0 -0
  20. package/examples/assets/textures/metalic-texture.jpg +0 -0
  21. package/examples/boats/boats_dependency/dependencieslist_cloudinary.json +1 -0
  22. package/examples/boats/boats_dependency/dependencieslist_express.json +4376 -0
  23. package/examples/boats/boats_dependency/dependencieslist_filestash.json +39533 -0
  24. package/examples/boats/boats_dependency/dependencieslist_ghdesktop.json +127660 -0
  25. package/examples/boats/boats_dependency/dependencieslist_karma.json +1 -0
  26. package/examples/boats/boats_dependency/dependencieslist_pm2.json +13726 -0
  27. package/examples/boats/boats_dependency/dependencieslist_portainer.json +41818 -0
  28. package/examples/boats/boats_dependency/dependencieslist_sh.json +5194 -0
  29. package/examples/boats/boats_dependency/experiment.html +277 -0
  30. package/examples/boats/boats_dependency/index.html +300 -0
  31. package/examples/boats/boats_dependency/index_gradient.html +209 -0
  32. package/examples/boats/boats_dependency/index_normalcity.html +207 -0
  33. package/examples/boats/boats_dependency/index_quarter_levels_01.html +213 -0
  34. package/examples/boats/boats_dependency/index_quarter_levels_02.html +213 -0
  35. package/examples/boats/boats_dependency/index_quarter_levels_03.html +213 -0
  36. package/examples/boats/boats_dependency/index_quarter_levels_querystring.html +243 -0
  37. package/examples/boats/boats_dependency/index_tree.html +211 -0
  38. package/examples/boats/boats_dependency/index_tree_gradient.html +212 -0
  39. package/examples/boats/boats_dependency/index_tree_wireframe.html +243 -0
  40. package/examples/charts/network_chart/network_chart.html +10 -2
  41. package/examples/charts/pie/index.html +3 -4
  42. package/examples/codecityjs/perceval2021/index.html +1 -1
  43. package/examples/codecityjs/projects_analysis/argouml_landscape.html +1 -1
  44. package/examples/codecityjs/projects_analysis/argouml_numfuns.html +3 -3
  45. package/examples/codecityjs/projects_analysis/argouml_table.html +1 -1
  46. package/examples/codecityjs/projects_analysis/argouml_tokens.html +1 -1
  47. package/examples/codecityjs/projects_analysis/experiment_interface.html +1 -1
  48. package/examples/codecityjs/projects_analysis/experiment_interface_task5.html +1 -1
  49. package/examples/codecityjs/projects_analysis/experiment_interface_vr_2021.html +1 -1
  50. package/examples/codecityjs/projects_analysis/experiment_interface_vr_task5.html +1 -1
  51. package/examples/codecityjs/projects_analysis/perceval_landscape.html +1 -1
  52. package/examples/codecityjs/projects_analysis/perceval_table.html +1 -1
  53. package/examples/dashboard/chaoss-dashboards.html +1 -1
  54. package/examples/dashboard/chaoss-issues.html +1 -1
  55. package/examples/dashboard/chaoss-pr.html +1 -1
  56. package/examples/dashboard/range.html +1 -1
  57. package/examples/dashboard/template.html +1 -1
  58. package/examples/experiment/city.html +352 -0
  59. package/examples/experiment/index.html +527 -0
  60. package/examples/experiment/pie.html +90 -0
  61. package/examples/experiment/sample-3s.mp3 +0 -0
  62. package/examples/experiment/sample.mp4 +0 -0
  63. package/examples/experiment/staticdata/80-percent-open-time-issues2.json +1 -0
  64. package/examples/experiment/staticdata/80-percent-open-time-pr.json +1 -0
  65. package/examples/experiment/staticdata/issues-by-organization.json +1 -0
  66. package/examples/experiment/staticdata/issues.json +1 -0
  67. package/examples/experiment/staticdata/jetuml_code_data.json +1 -0
  68. package/examples/experiment/staticdata/median-open-time-issues.json +1 -0
  69. package/examples/experiment/staticdata/median-open-time-pr.json +1 -0
  70. package/examples/experiment/staticdata/organizations-issues.json +1 -0
  71. package/examples/experiment/staticdata/organizations-pr.json +1 -0
  72. package/examples/experiment/staticdata/projects-issues.json +1 -0
  73. package/examples/experiment/staticdata/projects-pr.json +1 -0
  74. package/examples/experiment/staticdata/pull-requests-by-organization.json +1 -0
  75. package/examples/experiment/staticdata/pull-requests.json +1 -0
  76. package/examples/experiment/staticdata/repositories-issues-asignees.json +1 -0
  77. package/examples/experiment/staticdata/repositories-issues-avgdays.json +1 -0
  78. package/examples/experiment/staticdata/repositories-issues-count.json +1 -0
  79. package/examples/experiment/staticdata/repositories-issues-submitters.json +1 -0
  80. package/examples/experiment/staticdata/repositories-pr-asignees.json +1 -0
  81. package/examples/experiment/staticdata/repositories-pr-avgdays.json +1 -0
  82. package/examples/experiment/staticdata/repositories-pr-count.json +1 -0
  83. package/examples/experiment/staticdata/repositories-pr-submitters.json +1 -0
  84. package/examples/experiment/staticdata/status-issues.json +1 -0
  85. package/examples/experiment/staticdata/status-pr.json +1 -0
  86. package/examples/experiment/staticdata/submitter-issues-avgdays.json +1 -0
  87. package/examples/experiment/staticdata/submitter-issues-count.json +1 -0
  88. package/examples/experiment/staticdata/submitter-issues-repo.json +1 -0
  89. package/examples/experiment/staticdata/submitter-pr-avgdays.json +1 -0
  90. package/examples/experiment/staticdata/submitter-pr-count.json +1 -0
  91. package/examples/experiment/staticdata/submitter-pr-repo.json +1 -0
  92. package/examples/experiment/staticdata/submitters-issues.json +1 -0
  93. package/examples/experiment/staticdata/submitters-pr.json +1 -0
  94. package/examples/multi_boats/jetuml_evolution_experiment.html +1 -1
  95. package/index.js +23 -9
  96. package/package.json +1 -1
  97. package/examples/charts_querier/network_chart_querier/data.json +0 -123
  98. package/examples/charts_querier/network_chart_querier/links.json +0 -13
  99. package/examples/charts_querier/network_chart_querier/network_chart_querier.html +0 -68
  100. package/examples/charts_querier/network_chart_querier/network_chart_querier_nodes_links.html +0 -74
  101. package/examples/charts_querier/network_chart_querier/nodes.json +0 -12
@@ -0,0 +1,383 @@
1
+ if (typeof AFRAME === 'undefined') {
2
+ throw new Error(
3
+ 'Component attempted to register before AFRAME was available.'
4
+ );
5
+ }
6
+
7
+ /**
8
+ * Poster Popup component for A-Frame.
9
+ */
10
+ AFRAME.registerComponent('babia-poster', {
11
+ schema: {
12
+ title: {
13
+ type: 'string',
14
+ default: 'New Poster'
15
+ },
16
+ titleColor: {
17
+ type: 'string',
18
+ default: 'black'
19
+ },
20
+ titleFont: {
21
+ type: 'string',
22
+ default: 'mozillavr'
23
+ },
24
+ titleWrapCount: {
25
+ type: 'number',
26
+ default: 24
27
+ },
28
+ body: {
29
+ type: 'string',
30
+ default: 'This poster has no body yet.'
31
+ },
32
+ bodyColor: {
33
+ type: 'string',
34
+ default: 'black'
35
+ },
36
+ bodyFont: {
37
+ type: 'string',
38
+ default: 'mozillavr'
39
+ },
40
+ bodyWrapCount: {
41
+ type: 'number',
42
+ default: 30
43
+ },
44
+ openOn: {
45
+ type: 'string',
46
+ default: 'click'
47
+ },
48
+ active: {
49
+ type: 'boolean',
50
+ default: true,
51
+ },
52
+ openIconImage: {
53
+ type: 'asset',
54
+ default: ''
55
+ },
56
+ openIconRadius: {
57
+ type: 'number',
58
+ default: 0.3
59
+ },
60
+ openIconColor: {
61
+ type: 'string',
62
+ default: 'white'
63
+ },
64
+ closeIconImage: {
65
+ type: 'asset',
66
+ default: ''
67
+ },
68
+ closeIconRadius: {
69
+ type: 'number',
70
+ default: 0.3
71
+ },
72
+ closeIconColor: {
73
+ type: 'string',
74
+ default: 'white'
75
+ },
76
+ image: {
77
+ type: 'string',
78
+ default: ''
79
+ },
80
+ imageWidth: {
81
+ type: 'number',
82
+ default: 2
83
+ },
84
+ imageHeight: {
85
+ type: 'number',
86
+ default: 2
87
+ },
88
+ posterBoxWidth: {
89
+ type: 'number',
90
+ default: 4
91
+ },
92
+ posterBoxHeight: {
93
+ type: 'number',
94
+ default: 4
95
+ },
96
+ posterBoxColor: {
97
+ type: 'string',
98
+ default: 'white'
99
+ },
100
+ posterBoxPadding: {
101
+ type: 'number',
102
+ default: 0.2
103
+ }
104
+ },
105
+ multiple: true,
106
+ posterPlaneEl: null,
107
+ closeIconEl: null,
108
+ titleEl: null,
109
+ bodyEl: null,
110
+ imageEl: null,
111
+ hasImage: false,
112
+ /**
113
+ * Spawns the entities required to support this poster.
114
+ */
115
+ init() {
116
+ this.cameraEl = document.querySelector('[camera]');
117
+ this.generateOpenIcon()
118
+ this.spawnEntities();
119
+ this.el.emit('loaded');
120
+ },
121
+ /**
122
+ * If the component is open, ensure it always faces the camera.
123
+ */
124
+ tick() {
125
+ if (this.isOpen) {
126
+ this.positionPosterPlane();
127
+ }
128
+ },
129
+ /**
130
+ * When this component is removed, destruct event listeners.
131
+ */
132
+ remove() {
133
+ const { openOn } = this.data;
134
+ this.el.removeEventListener(
135
+ openOn,
136
+ this.togglePosterOpen.bind(this)
137
+ );
138
+ this.closeIconEl.removeEventListener(
139
+ openOn,
140
+ this.togglePosterOpen.bind(this)
141
+ );
142
+ },
143
+ /**
144
+ * When this component is updated, re-calculate title, body, image, and
145
+ * poster plane to incorporate changes.
146
+ */
147
+ update() {
148
+ this.generateTitle();
149
+ this.generateBody();
150
+ this.generateImage();
151
+ },
152
+ /**
153
+ * Handles opening and closing the poster plane.
154
+ */
155
+ togglePosterOpen(event) {
156
+ // If the close icon is clicked, close the poster.
157
+ if (event.target.getAttribute('id') === `${this.el.getAttribute('id')}--close-icon`) {
158
+ this.posterPlaneEl.setAttribute('visible', false);
159
+ this.isOpen = false;
160
+ }
161
+
162
+ // If the open icon is clicked, and the poster is active, open the poster.
163
+ if (this.data.active && event.target.getAttribute('id') === this.el.getAttribute('id')) {
164
+ this.positionPosterPlane();
165
+ this.posterPlaneEl.setAttribute('visible', true);
166
+ this.isOpen = true;
167
+ }
168
+ },
169
+ /**
170
+ * Generates the open icon.
171
+ */
172
+ generateOpenIcon() {
173
+ const {
174
+ openIconRadius: radius,
175
+ openIconColor: color,
176
+ openIconImage: src,
177
+ openOn
178
+ } = this.data;
179
+
180
+ this.el.setAttribute('geometry', {
181
+ primitive: 'circle',
182
+ radius
183
+ });
184
+ this.el.setAttribute('material', {
185
+ color,
186
+ src
187
+ });
188
+
189
+ this.el.addEventListener(openOn, this.togglePosterOpen.bind(this));
190
+ },
191
+ /**
192
+ * Generates the close icon.
193
+ */
194
+ generateCloseIcon() {
195
+ const {
196
+ closeIconRadius: radius,
197
+ closeIconColor: color,
198
+ closeIconImage: src,
199
+ posterBoxWidth: width,
200
+ posterBoxHeight: height,
201
+ openOn
202
+ } = this.data;
203
+
204
+ const closeIcon = document.createElement('a-entity');
205
+ closeIcon.setAttribute('id', `${this.el.getAttribute('id')}--close-icon`);
206
+ closeIcon.setAttribute('position', {
207
+ x: width / 2,
208
+ y: height / 2,
209
+ z: 0.01
210
+ });
211
+ closeIcon.setAttribute('geometry', {
212
+ primitive: 'circle',
213
+ radius
214
+ });
215
+ closeIcon.setAttribute('material', {
216
+ color,
217
+ src
218
+ });
219
+
220
+ closeIcon.addEventListener(openOn, this.togglePosterOpen.bind(this));
221
+
222
+ this.closeIconEl = closeIcon;
223
+ return closeIcon;
224
+ },
225
+ /**
226
+ * Generates the title text.
227
+ */
228
+ generateTitle() {
229
+ const {
230
+ title: value,
231
+ titleColor: color,
232
+ titleFont: font,
233
+ titleWrapCount: wrapCount,
234
+ posterBoxWidth: width,
235
+ posterBoxHeight: height,
236
+ posterBoxPadding: padding,
237
+ imageHeight
238
+ } = this.data;
239
+
240
+ const title = this.titleEl || document.createElement('a-entity');
241
+ title.setAttribute('id', `${this.el.getAttribute('id')}--title`);
242
+ title.setAttribute('text', {
243
+ value: value.substring(0, wrapCount),
244
+ color,
245
+ font,
246
+ wrapCount,
247
+ width: width - padding * 2,
248
+ baseline: 'top',
249
+ anchor: 'left'
250
+ });
251
+
252
+ let y = height / 2 - padding;
253
+ if (this.hasImage) {
254
+ y -= imageHeight / 2;
255
+ }
256
+
257
+ title.setAttribute('position', {
258
+ x: -(width / 2) + padding,
259
+ y,
260
+ z: 0.01
261
+ });
262
+
263
+ this.titleEl = title;
264
+ return title;
265
+ },
266
+ /**
267
+ * Generates the body text entity.
268
+ */
269
+ generateBody() {
270
+ const {
271
+ body: value,
272
+ bodyColor: color,
273
+ bodyFont: font,
274
+ bodyWrapCount: wrapCount,
275
+ posterBoxWidth: width,
276
+ posterBoxHeight: height,
277
+ posterBoxPadding: padding,
278
+ imageHeight
279
+ } = this.data;
280
+
281
+ const body = this.bodyEl || document.createElement('a-entity');
282
+ body.setAttribute('id', `${this.el.getAttribute('id')}--title`);
283
+ body.setAttribute('text', {
284
+ value,
285
+ color,
286
+ font,
287
+ wrapCount,
288
+ width: width - padding * 2,
289
+ baseline: 'top',
290
+ anchor: 'left'
291
+ });
292
+
293
+ let y = height / 2 - padding * 3;
294
+ if (this.hasImage) {
295
+ y -= imageHeight / 2;
296
+ }
297
+
298
+ body.setAttribute('position', {
299
+ x: -(width / 2) + padding,
300
+ y,
301
+ z: 0.01
302
+ });
303
+
304
+ this.bodyEl = body;
305
+ return body;
306
+ },
307
+ /**
308
+ * Generates the image entity.
309
+ */
310
+ generateImage() {
311
+ const {
312
+ image: src,
313
+ imageWidth: width,
314
+ imageHeight: height,
315
+ posterBoxHeight
316
+ } = this.data;
317
+
318
+ if (!src.length) {
319
+ return null;
320
+ }
321
+
322
+ const image = this.imageEl || document.createElement('a-image');
323
+ image.setAttribute('id', `${this.el.getAttribute('id')}--image`);
324
+ image.setAttribute('src', src);
325
+ image.setAttribute('width', width);
326
+ image.setAttribute('height', height);
327
+ image.setAttribute('position', {
328
+ x: 0,
329
+ y: posterBoxHeight / 2,
330
+ z: 0.01
331
+ });
332
+
333
+ this.hasImage = true;
334
+ this.imageEl = image;
335
+ return image;
336
+ },
337
+ /**
338
+ * Generates the poster plane.
339
+ */
340
+ generatePosterPlane() {
341
+ const {
342
+ posterBoxWidth: width,
343
+ posterBoxHeight: height,
344
+ posterBoxPadding: padding,
345
+ posterBoxColor: color
346
+ } = this.data;
347
+
348
+ const plane = this.posterPlaneEl || document.createElement('a-entity');
349
+ plane.setAttribute('id', `${this.el.getAttribute('id')}--poster-plane`);
350
+ plane.setAttribute('position', { x: 0, y: 0, z: 0.5 });
351
+ plane.setAttribute('visible', false);
352
+ plane.setAttribute('geometry', {
353
+ primitive: 'plane',
354
+ width: width + padding,
355
+ height: height + padding
356
+ });
357
+
358
+ const image = this.generateImage();
359
+ if (image) {
360
+ plane.appendChild(this.generateImage());
361
+ }
362
+
363
+ plane.setAttribute('material', { color });
364
+ plane.appendChild(this.generateCloseIcon());
365
+ plane.appendChild(this.generateTitle());
366
+ plane.appendChild(this.generateBody());
367
+
368
+ this.posterPlaneEl = plane;
369
+
370
+ return plane;
371
+ },
372
+ positionPosterPlane() {
373
+ if (this.posterPlaneEl) {
374
+ const vector = this.posterPlaneEl.object3D.parent.worldToLocal(
375
+ this.cameraEl.object3D.getWorldPosition()
376
+ );
377
+ this.posterPlaneEl.object3D.lookAt(vector);
378
+ }
379
+ },
380
+ spawnEntities() {
381
+ this.el.appendChild(this.generatePosterPlane());
382
+ }
383
+ });
@@ -0,0 +1,247 @@
1
+ const { randFloatSpread } = require("three/src/math/MathUtils");
2
+
3
+ /* global AFRAME */
4
+ if (typeof AFRAME === 'undefined') {
5
+ throw new Error('Component attempted to register before AFRAME was available.');
6
+ }
7
+
8
+
9
+ AFRAME.registerComponent('babia-task', {
10
+ schema: {
11
+ taskTitle: { type: 'string', default: 'Default task title' },
12
+ taskDescription: { type: 'string', default: 'Default task text' },
13
+ openTaskImg: { type: 'string' },
14
+ closeTaskImg: { type: 'string' },
15
+ taskAudio: { type: 'boolean', default: false },
16
+ taskAudioUrl: { type: 'string', default: null },
17
+ taskVideo: { type: 'boolean', default: false },
18
+ taskVideoId: { type: 'string', default: null },
19
+ taskVideoWidth: { type: 'number', default: 3 },
20
+ taskVideoHeight: { type: 'number', default: 1.75 },
21
+ offsetX: { type: 'number', default: 0 },
22
+ lookat: { type: 'string', default: "[camera]" },
23
+ },
24
+
25
+ /**
26
+ * Set if component needs multiple instancing.
27
+ */
28
+ multiple: true,
29
+
30
+ /**
31
+ * Data recorded during the experiment
32
+ */
33
+ recordedData: {},
34
+
35
+ /**
36
+ * If the experiment is still running
37
+ */
38
+ runningExperiment: false,
39
+
40
+ /**
41
+ * Initial creation and setting of the mesh.
42
+ */
43
+ init: function () { },
44
+
45
+ /**
46
+ * Called when component is attached and when component data changes.
47
+ * Generally modifies the entity based on the data.
48
+ */
49
+ taskId: Math.random(),
50
+ update: function (oldData) {
51
+ const self = this
52
+ this.taskId = this.el.getAttribute("id")
53
+ if (this.data != this.oldData) {
54
+ // Get camera
55
+ let isThereBabiaCamera = this.el.sceneEl.querySelectorAll("[babia-camera]")
56
+ if (isThereBabiaCamera.length > 0) {
57
+ this.babiaCameraEl = isThereBabiaCamera[0]
58
+
59
+ // Add raycaster things and others attributes
60
+ let babiaCameraAttribute = this.babiaCameraEl.getAttribute("babia-camera")
61
+ if (typeof babiaCameraAttribute === 'string') {
62
+ this.babiaCameraEl.setAttribute("babia-camera", {
63
+ raycasterMouse: babiaCameraAttribute.split("raycasterMouse:")[1].split(";")[0] + `, #babiaTaskPopup${this.taskId}, #babiaTaskPopup${this.taskId}--close-icon, #babiaStartButton${this.taskId}, #babiaFinishButton${this.taskId}, #babiaTaskAudio${this.taskId}, #babiaTaskVideo${this.taskId}`,
64
+ raycasterHand: babiaCameraAttribute.split("raycasterHand:")[1].split(";")[0] + `, #babiaTaskPopup${this.taskId}, #babiaTaskPopup${this.taskId}--close-icon, #babiaStartButton${this.taskId}, #babiaFinishButton${this.taskId}, #babiaTaskAudio${this.taskId}, #babiaTaskVideo${this.taskId}`,
65
+ teleportCollision: babiaCameraAttribute.split("teleportCollision:")[1].split(";")[0]
66
+ })
67
+ } else if (babiaCameraAttribute == undefined) {
68
+ this.babiaCameraEl.setAttribute("babia-camera", {
69
+ raycasterMouse: this.babiaCameraEl.components['babia-camera'].attrValue['raycasterMouse'] + `, #babiaTaskPopup${this.taskId}, #babiaTaskPopup${this.taskId}--close-icon, #babiaStartButton${this.taskId}, #babiaFinishButton${this.taskId}, #babiaTaskAudio${this.taskId}, #babiaTaskVideo${this.taskId}`,
70
+ raycasterHand: this.babiaCameraEl.components['babia-camera'].attrValue['raycasterHand'] + `, #babiaTaskPopup${this.taskId}, #babiaTaskPopup${this.taskId}--close-icon, #babiaStartButton${this.taskId}, #babiaFinishButton${this.taskId}, #babiaTaskAudio${this.taskId}, #babiaTaskVideo${this.taskId}`,
71
+ teleportCollision: this.babiaCameraEl.components['babia-camera'].attrValue['teleportCollision']
72
+ })
73
+ }
74
+
75
+ } else {
76
+ this.babiaCameraEl = this.el.sceneEl.camera.el;
77
+ }
78
+
79
+ // Add task if not babia task
80
+ if (this.data.taskAudio) {
81
+ this.addAudioTask()
82
+ } else if (this.data.taskVideo) {
83
+ this.addVideoTask()
84
+ } else {
85
+ this.addTask()
86
+ }
87
+
88
+
89
+ }
90
+ },
91
+
92
+ addTask: function () {
93
+ const self = this
94
+
95
+ this.taskEntity = document.createElement('a-entity');
96
+ this.taskEntity.setAttribute('class', 'babiaxrayscasterclass')
97
+ this.taskEntity.setAttribute('id', 'babiaTaskPopup' + this.taskId)
98
+ this.taskEntity.setAttribute('babia-poster', {
99
+ openIconImage: '../assets/popups/info.jpg',
100
+ closeIconImage: '../assets/popups/close.jpg',
101
+ title: self.data.taskTitle,
102
+ titleWrapCount: 30,
103
+ titleColor: 'black',
104
+ bodyColor: 'black',
105
+ posterBoxColor: 'white',
106
+ bodyFont: 'roboto',
107
+ posterBoxHeight: 4.5,
108
+ body: self.data.taskDescription
109
+ })
110
+
111
+
112
+
113
+ // Add position
114
+ let x,y,z
115
+ if (this.babiaCameraEl.attributes['position']){
116
+ [x, y, z] = this.babiaCameraEl.attributes['position'].value.split(" ")
117
+ }else{
118
+ x = 0
119
+ y = 0
120
+ z = 0
121
+ }
122
+
123
+ this.taskEntity.setAttribute('position', { x: parseFloat(x) + this.data.offsetX, y: parseFloat(y) + 1.5, z: parseFloat(z) - 6 })
124
+ this.taskEntity.setAttribute('babia-lookat', this.data.lookat)
125
+
126
+
127
+ // Add to the scene
128
+ this.el.parentElement.append(this.taskEntity)
129
+ },
130
+
131
+ /**
132
+ * Things related to the audio task
133
+ */
134
+ audioPlaying: false,
135
+ addAudioTask: function () {
136
+ const self = this
137
+
138
+ this.taskAudioEntity = document.createElement('a-entity');
139
+ this.taskAudioEntity.setAttribute('class', 'babiaxrayscasterclass')
140
+ this.taskAudioEntity.setAttribute('geometry', {
141
+ primitive: 'plane',
142
+ width: 1.1,
143
+ height: 0.5
144
+ })
145
+ this.taskAudioEntity.setAttribute('text', {
146
+ value: 'Play audio!',
147
+ color: 'white',
148
+ align: 'center',
149
+ wrapCount: 30,
150
+ width: 3.6,
151
+ })
152
+ this.taskAudioEntity.setAttribute('id', 'babiaTaskAudio' + this.taskId)
153
+ this.taskAudioEntity.setAttribute('sound', {
154
+ src: `url(${self.data.taskAudioUrl})`
155
+ })
156
+
157
+ // Play Sound when click
158
+ this.taskAudioEntity.addEventListener('click', function (event) {
159
+ if (self.audioPlaying) {
160
+ self.audioPlaying = false
161
+ self.taskAudioEntity.components.sound.stopSound()
162
+ self.taskAudioEntity.setAttribute('text', 'value', 'Play audio!')
163
+ } else {
164
+ self.audioPlaying = true
165
+ self.taskAudioEntity.components.sound.playSound()
166
+ self.taskAudioEntity.setAttribute('text', 'value', 'Stop audio!')
167
+ }
168
+
169
+ }, false)
170
+
171
+ // When audio finished
172
+ this.taskAudioEntity.addEventListener('sound-ended', function (event) {
173
+ self.audioPlaying = false
174
+ self.taskAudioEntity.setAttribute('text', 'value', 'Play audio!')
175
+ }, false)
176
+
177
+
178
+ // Add position
179
+ let x,y,z
180
+ if (this.babiaCameraEl.attributes['position']){
181
+ [x, y, z] = this.babiaCameraEl.attributes['position'].value.split(" ")
182
+ }else{
183
+ x = 0
184
+ y = 0
185
+ z = 0
186
+ }
187
+
188
+ this.taskAudioEntity.setAttribute('position', { x: parseFloat(x) + this.data.offsetX, y: parseFloat(y) + 3, z: parseFloat(z) - 6 })
189
+ this.taskAudioEntity.setAttribute('babia-lookat', this.data.lookat)
190
+
191
+
192
+ // Add to the scene
193
+ this.el.parentElement.append(this.taskAudioEntity)
194
+ },
195
+
196
+ /**
197
+ * Things related to the audio task
198
+ */
199
+ videoPlaying: false,
200
+ addVideoTask: function () {
201
+ const self = this
202
+
203
+ this.taskVideoEntity = document.createElement('a-video');
204
+ this.taskVideoEntity.setAttribute('class', 'babiaxrayscasterclass')
205
+ this.taskVideoEntity.setAttribute('id', 'babiaTaskVideo' + this.taskId)
206
+ this.taskVideoEntity.setAttribute('src', self.data.taskVideoId)
207
+ this.taskVideoStream = document.querySelector(self.data.taskVideoId)
208
+ this.taskVideoEntity.setAttribute('width', self.data.taskVideoWidth)
209
+ this.taskVideoEntity.setAttribute('height', self.data.taskVideoHeight)
210
+
211
+
212
+ // Play Sound when click
213
+ this.taskVideoEntity.addEventListener('click', function (event) {
214
+ if (self.videoPlaying) {
215
+ self.videoPlaying = false
216
+ self.taskVideoStream.pause();
217
+ } else {
218
+ self.videoPlaying = true
219
+ self.taskVideoStream.play();
220
+ }
221
+
222
+ }, false)
223
+
224
+
225
+ // Add position
226
+ let x,y,z
227
+ if (this.babiaCameraEl.attributes['position']){
228
+ [x, y, z] = this.babiaCameraEl.attributes['position'].value.split(" ")
229
+ }else{
230
+ x = 0
231
+ y = 0
232
+ z = 0
233
+ }
234
+ this.taskVideoEntity.setAttribute('position', { x: parseFloat(x) + this.data.offsetX, y: parseFloat(y) + 3, z: parseFloat(z) - 6 })
235
+ this.taskVideoEntity.setAttribute('babia-lookat', this.data.lookat)
236
+
237
+
238
+ // Add to the scene
239
+ this.el.parentElement.append(this.taskVideoEntity)
240
+ },
241
+
242
+
243
+ tick: function () {
244
+
245
+ }
246
+
247
+ })