aframe-babia-components 1.2.2 → 1.2.5

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 (120) hide show
  1. package/components/filters/babia-selector.js +256 -79
  2. package/components/filters/babia-treebuilder.js +1 -2
  3. package/components/geometries/babia-bar.js +13 -1
  4. package/components/geometries/babia-cyl.js +189 -0
  5. package/components/others/assets/tooltip.png +0 -0
  6. package/components/others/babia-camera.js +195 -0
  7. package/components/others/babia-controls.js +56 -31
  8. package/components/others/babia-navigator.js +55 -49
  9. package/components/others/babia-range-selector.js +218 -0
  10. package/components/others/babia-slider.js +36 -8
  11. package/components/others/babia-ui.js +246 -73
  12. package/components/others/common.js +91 -83
  13. package/components/queriers/babia-querycsv.js +96 -0
  14. package/components/queriers/babia-queryes.js +209 -131
  15. package/components/visualizers/babia-bars.js +15 -38
  16. package/components/visualizers/babia-barsmap.js +19 -34
  17. package/components/visualizers/babia-boats.js +221 -134
  18. package/components/visualizers/babia-bubbles.js +13 -26
  19. package/components/visualizers/babia-cyls.js +203 -201
  20. package/components/visualizers/babia-cylsmap.js +173 -241
  21. package/components/visualizers/babia-doughnut.js +6 -28
  22. package/components/visualizers/babia-network.js +191 -124
  23. package/components/visualizers/babia-pie.js +6 -30
  24. package/dist/aframe-babia-components.js +21913 -19571
  25. package/dist/aframe-babia-components.min.js +7 -1
  26. package/dist/aframe-babia-components.min.js.map +1 -1
  27. package/docs/APIs/CHARTS.md +33 -14
  28. package/docs/APIs/DATAMANAGEMENT.md +7 -0
  29. package/docs/APIs/OTHERS.md +42 -0
  30. package/docs/APIs/QUERIERS.md +18 -0
  31. package/docs/RELEASE_NOTES.md +58 -21
  32. package/docs/Tutorials/multiuser.md +47 -2
  33. package/examples/assets/door/New Bitmap Image.jpg +0 -0
  34. package/examples/assets/door/door.mtl +26 -0
  35. package/examples/assets/door/door.obj +6927 -0
  36. package/examples/assets/popups/0.png +0 -0
  37. package/examples/assets/popups/1.png +0 -0
  38. package/examples/assets/popups/10.png +0 -0
  39. package/examples/assets/popups/2.png +0 -0
  40. package/examples/assets/popups/3.png +0 -0
  41. package/examples/assets/popups/4.png +0 -0
  42. package/examples/assets/popups/5.png +0 -0
  43. package/examples/assets/popups/6.png +0 -0
  44. package/examples/assets/popups/7.png +0 -0
  45. package/examples/assets/popups/8.png +0 -0
  46. package/examples/assets/popups/9.png +0 -0
  47. package/examples/assets/popups/close.jpg +0 -0
  48. package/examples/assets/popups/info.jpg +0 -0
  49. package/examples/assets/textures/brownwall.png +0 -0
  50. package/examples/assets/textures/concrete.png +0 -0
  51. package/examples/assets/textures/white-wall-texture.jpg +0 -0
  52. package/examples/charts/cyls/index.html +13 -4
  53. package/examples/charts/cyls/primitive.html +76 -0
  54. package/examples/charts/cylsmap/index.html +14 -5
  55. package/examples/charts_querier/bars_querier/data.csv +10 -0
  56. package/examples/charts_querier/bars_querier/index_csv.html +80 -0
  57. package/examples/charts_querier/multichart_querier/manual_colors.html +81 -0
  58. package/examples/dashboard/chaoss-dashboards.html +259 -0
  59. package/examples/dashboard/chaoss-issues.html +248 -0
  60. package/examples/dashboard/chaoss-pr.html +248 -0
  61. package/examples/dashboard/index.html +247 -0
  62. package/examples/dashboard/issues_queries/80-percent-open-time.json +123 -0
  63. package/examples/dashboard/issues_queries/issues-by-organization.json +107 -0
  64. package/examples/dashboard/issues_queries/issues.json +117 -0
  65. package/examples/dashboard/issues_queries/median-open-time.json +123 -0
  66. package/examples/dashboard/issues_queries/organizations.json +130 -0
  67. package/examples/dashboard/issues_queries/projects.json +130 -0
  68. package/examples/dashboard/issues_queries/repositories.json +130 -0
  69. package/examples/dashboard/issues_queries/status.json +107 -0
  70. package/examples/dashboard/issues_queries/submitter.json +125 -0
  71. package/examples/dashboard/issues_queries/submitters.json +113 -0
  72. package/examples/dashboard/pullrequests_queries/80-percent-open-time.json +123 -0
  73. package/examples/dashboard/pullrequests_queries/median-open-time.json +123 -0
  74. package/examples/dashboard/pullrequests_queries/organizations.json +130 -0
  75. package/examples/dashboard/pullrequests_queries/projects.json +130 -0
  76. package/examples/dashboard/pullrequests_queries/pull-requests-by-organization.json +107 -0
  77. package/examples/dashboard/pullrequests_queries/pull-requests.json +117 -0
  78. package/examples/dashboard/pullrequests_queries/repositories.json +130 -0
  79. package/examples/dashboard/pullrequests_queries/status.json +107 -0
  80. package/examples/dashboard/pullrequests_queries/submitter.json +125 -0
  81. package/examples/dashboard/pullrequests_queries/submitters.json +113 -0
  82. package/examples/dashboard/range.html +88 -0
  83. package/examples/dashboard/template.html +136 -0
  84. package/examples/demos/1.0.11/index_multiuser_ui.html +1 -1
  85. package/examples/multi_bars/data.json +14 -0
  86. package/examples/multi_bars/data2.json +15 -0
  87. package/examples/multi_bars/data3.json +23 -0
  88. package/examples/multi_bars/easyrtc.js +11984 -0
  89. package/examples/multi_bars/index.html +97 -0
  90. package/examples/multi_bars/index1.html +111 -0
  91. package/examples/multi_bars/index2.html +102 -0
  92. package/examples/multi_bars/index3.html +104 -0
  93. package/examples/multi_boats/data3.json +174 -0
  94. package/examples/multi_boats/data4.json +192 -0
  95. package/examples/multi_boats/{index.html → index_multi_boats.html} +50 -55
  96. package/examples/multi_boats/jetuml.html +124 -115
  97. package/examples/multi_boats/jetuml_evolution_experiment.html +419 -0
  98. package/examples/multi_boats/only_queryjson.html +132 -0
  99. package/examples/multi_boats/only_queryjson2.html +167 -0
  100. package/examples/multi_boats/only_queryjson3.html +165 -0
  101. package/examples/multi_boats/queryjson_treebuilder.html +132 -0
  102. package/examples/multi_boats/with_selector.html +121 -111
  103. package/examples/multiuser/choose_avatar/index.html +18 -8
  104. package/examples/selector_boats/jetuml_from_3_2_to_1_0.json +62382 -0
  105. package/examples/ui/network/data.json +123 -0
  106. package/examples/ui/network/links.json +13 -0
  107. package/examples/ui/network/network.html +75 -0
  108. package/examples/ui/network/network_nodes_links.html +82 -0
  109. package/examples/ui/network/nodes.json +12 -0
  110. package/index.html +69 -3
  111. package/index.js +6 -1
  112. package/package.json +4 -3
  113. package/tests/screenshots/other_snapshots.js/chaoss-issues.png +0 -0
  114. package/tests/screenshots/other_snapshots.js/chaoss-pr.png +0 -0
  115. package/tests/screenshots/other_snapshots.js/template.png +0 -0
  116. package/tests/ui.js +7 -0
  117. package/webpack.common.js +1 -1
  118. package/webpack.devnossl.js +16 -0
  119. package/.idea/vcs.xml +0 -6
  120. package/.idea/workspace.xml +0 -79
@@ -0,0 +1,189 @@
1
+ const colors = require('../others/common').colors;
2
+
3
+ /*
4
+ * BabiaXR Cyl component
5
+ *
6
+ * Builds a cylinder (usually for the cyls chart)
7
+ */
8
+ AFRAME.registerComponent('babia-cyl', {
9
+ schema: {
10
+ // Height of the cylinder
11
+ height: { type: 'number' },
12
+ // Width of the cylinder
13
+ radius: { type: 'number' },
14
+ // Color for axis and labels
15
+ color: { type: 'color', default: '#000' },
16
+ // Should this be animated
17
+ animation: { type: 'boolean', default: true},
18
+ // Duration of animations
19
+ dur: { type: 'number', default: 2000},
20
+ // Label for the cylinder ('', 'fixed', 'events')
21
+ label: { type: 'string', default: ''},
22
+ // Label text (valid if label is not empty)
23
+ labelText: { type: 'string', default: ''},
24
+ // Label lookat for following
25
+ labelLookat: { type: 'string', default: "[camera]" }
26
+ },
27
+
28
+ init: function() {
29
+ console.log("Starting cyl:", this.data.height, this.data.color);
30
+ let data = this.data;
31
+ this.cylinder = document.createElement('a-entity');
32
+ this.cylinder.classList.add("babiaxraycasterclass");
33
+ this.el.appendChild(this.cylinder);
34
+ let props = {}
35
+ if (data.animation) {
36
+ props = {'height': 0, 'radius': data.radius};
37
+ } else {
38
+ props = {'height': data.height,
39
+ 'radius': data.radius};
40
+ }
41
+ this.cylinder.setAttribute('geometry', {
42
+ 'primitive': 'cylinder',
43
+ 'height': props.height,
44
+ 'radius': props.radius
45
+ });
46
+ this.cylinder.setAttribute('material', {
47
+ 'color': data.color
48
+ });
49
+ },
50
+
51
+ update: function (oldData) {
52
+ let data = this.data;
53
+ let cylinder = this.cylinder;
54
+
55
+ this.updateProperty(cylinder, 'geometry', 'height', data.animation,
56
+ data['height'], oldData.height);
57
+ // Update height
58
+ if (data.height != oldData.height) {
59
+ // If there is change in height, update position
60
+ if (data.animation) {
61
+ cylinder.setAttribute('animation__pos', {
62
+ 'property': 'position',
63
+ 'to': { x: 0, y: data.height/2, z:0 },
64
+ 'dur': data.dur
65
+ });
66
+ if (data.height <= 0 && oldData.height > 0){
67
+ cylinder.setAttribute('animation__opacity', {
68
+ 'property': 'material.opacity',
69
+ 'to': 0,
70
+ 'dur': data.dur
71
+ });
72
+ } else if (oldData.height <= 0 && data.height > 0){
73
+ cylinder.setAttribute('animation__opacity', {
74
+ 'property': 'material.opacity',
75
+ 'to': 100,
76
+ 'dur': data.dur
77
+ });
78
+ }
79
+ } else {
80
+ cylinder.setAttribute('position', { x: 0, y: data.height/2, z: 0 });
81
+ if (data.height <= 0 && oldData.height > 0){
82
+ cylinder.setAttribute('material', 'opacity', 0);
83
+ } else if (oldData.height <= 0 && data.height > 0){
84
+ cylinder.setAttribute('material', 'opacity', 100);
85
+ }
86
+ };
87
+ };
88
+ this.updateProperty(cylinder, 'geometry', 'radius', data.animation,
89
+ data.radius, oldData.radius);
90
+ this.updateProperty(cylinder, 'material', 'color', data.animation,
91
+ data.color, oldData.color);
92
+ if (this.data.label === 'events') {
93
+ cylinder.addEventListener('mouseenter', this.showLabel.bind(this));
94
+ cylinder.addEventListener('mouseleave', this.hideLabel.bind(this));
95
+ } else if (this.data.label === 'fixed') {
96
+ this.showLabel(oldData);
97
+ };
98
+ },
99
+
100
+ /*
101
+ * Update a property in an element, having animation into account
102
+ *
103
+ * @param el Element
104
+ * @param component Component in which to update property
105
+ * @param property Property to update in element
106
+ * @param name: Property name in data, oldData
107
+ * @param oldValue: Old value
108
+ */
109
+ updateProperty: function (el, component, property, anim, newValue, oldValue) {
110
+ let data = this.data;
111
+
112
+ if (newValue !== oldValue) {
113
+ if (anim) {
114
+ let prop = component;
115
+ if (property) { prop = prop + '.' + property };
116
+ el.setAttribute('animation__'+component+'_'+property, {
117
+ 'property': prop,
118
+ 'to': newValue,
119
+ 'dur': data.dur
120
+ });
121
+ } else {
122
+ if (property) {
123
+ el.setAttribute(component, { [property]: newValue });
124
+ } else {
125
+ el.setAttribute(component, newValue);
126
+ }
127
+ };
128
+ };
129
+ },
130
+
131
+ showLabel: function (oldData) {
132
+ let data = this.data;
133
+
134
+ if (data.label === 'events') {
135
+ this.el.setAttribute('scale', { x: 1.1, y: 1.1, z: 1.1 });
136
+ };
137
+
138
+ text = data.labelText;
139
+ let width = 2;
140
+ if (text.length > 16) { width = text.length / 8 };
141
+ let height = 1;
142
+ oldHeight = oldData.height || 0;
143
+ let oldPosition = {
144
+ x: 0, y: oldHeight + 0.6 * height,
145
+ z: 0
146
+ }
147
+
148
+ if (!this.labelEl) {
149
+ this.labelEl = document.createElement('a-entity');
150
+ this.labelEl.setAttribute('babia-label', {
151
+ 'width': width, 'textWidth': 6
152
+ });
153
+ if (data.animation && (data.label === 'fixed')) {
154
+ this.labelEl.setAttribute('position', oldPosition);
155
+ };
156
+ this.el.appendChild(this.labelEl);
157
+ };
158
+
159
+ let position = {
160
+ x: 0, y: data.height + 0.7 * height,
161
+ z: 0.7 * data.radius
162
+ };
163
+
164
+ let anim = data.animation && (data.label === 'fixed');
165
+ this.updateProperty(this.labelEl, 'position', '', anim, position, oldPosition);
166
+ this.labelEl.setAttribute('rotation', {x: 0, y: 0, z: 0});
167
+ if (text != oldData.labelText) {
168
+ this.labelEl.setAttribute('babia-label', { 'text': data.labelText });
169
+ }
170
+
171
+ if(data.labelLookat && oldData.labelLookat !== data.labelLookat){
172
+ this.labelEl.setAttribute('babia-lookat', data.labelLookat);
173
+ }
174
+
175
+ if(data.labelScale && oldData.labelScale !== data.labelScale){
176
+ this.labelEl.setAttribute('scale',{x: data.labelScale, y: data.labelScale, z: data.labelScale});
177
+ }
178
+ },
179
+
180
+ hideLabel: function () {
181
+ if (this.data.label === 'events') {
182
+ this.el.setAttribute('scale', { x: 1, y: 1, z: 1 });
183
+ };
184
+ if (this.labelEl) {
185
+ this.el.removeChild(this.labelEl);
186
+ this.labelEl = null;
187
+ }
188
+ }
189
+ });
@@ -0,0 +1,195 @@
1
+ /* global AFRAME */
2
+ if (typeof AFRAME === 'undefined') {
3
+ throw new Error('Component attempted to register before AFRAME was available.');
4
+ }
5
+
6
+
7
+ AFRAME.registerComponent('babia-camera', {
8
+ schema: {
9
+ raycasterMouse: { type: 'string', default: '.babiaxraycasterclass'},
10
+ raycasterHand: {type: 'string', default: '.babiaxraycasterclass'},
11
+ tipsOpened: { type: 'boolean', default: true},
12
+ gripRLabel: {type: 'string', default: 'Open/Close \nTips'},
13
+ gripLLabel: {type: 'string', default: 'Stop Audio'},
14
+ triggerRLabel: {type: 'string', default: 'Click'},
15
+ triggerLLabel: {type: 'string', default: 'Teleport' },
16
+ teleportCollisions: {type: 'string', default: '.environmentGround'}
17
+ },
18
+
19
+ /**
20
+ * Set if component needs multiple instancing.
21
+ */
22
+ multiple: false,
23
+
24
+ /**
25
+ * Initial creation and setting of the mesh.
26
+ */
27
+ init: function () {},
28
+
29
+ /**
30
+ * Called when component is attached and when component data changes.
31
+ * Generally modifies the entity based on the data.
32
+ */
33
+
34
+ update: function (oldData) {
35
+ if(this.data != this.oldData){
36
+ // Add camera
37
+ this.el.setAttribute('camera', '');
38
+ // Add mouse
39
+ this.addCursor();
40
+ // OCULUS CASE
41
+ this.setOculusConnected();
42
+ }
43
+ },
44
+
45
+ addCursor: function(){
46
+ this.cursor = document.createElement('a-entity');
47
+ this.cursor.id = 'cursor';
48
+ this.cursor.setAttribute('cursor', {rayOrigin: 'mouse'});
49
+ this.cursor.setAttribute('raycaster', {
50
+ objects: this.data.raycasterMouse,
51
+ })
52
+ this.el.parentElement.append(this.cursor);
53
+ },
54
+
55
+ createTip: function(id, config, position){
56
+ let entity = document.createElement('a-entity');
57
+ entity.id = id;
58
+ entity.classList.add('tips');
59
+ entity.setAttribute('tooltip', config);
60
+ entity.setAttribute('position', position);
61
+ return entity ;
62
+ },
63
+
64
+ setOculusConnected: function(){
65
+ let self = this;
66
+ self.tooltips = [];
67
+ /**
68
+ * You need create and add controllers before listener otherwise
69
+ * it will not listen the event controllerconnected.
70
+ */
71
+ self.leftHand = document.createElement('a-entity');
72
+ self.leftHand.id = 'babia-leftHand';
73
+ self.leftHand.setAttribute('oculus-touch-controls', {hand: 'left'});
74
+ self.el.parentElement.append(self.leftHand);
75
+ self.rightHand = document.createElement('a-entity');
76
+ self.rightHand.id = 'babia-rightHand';
77
+ self.rightHand.setAttribute('oculus-touch-controls', {hand: 'right'});
78
+ self.el.parentElement.append(self.rightHand);
79
+
80
+ document.addEventListener('controllerconnected', (event) => {
81
+ // Update height of the view
82
+ let parentPos = self.el.parentElement.object3D.position;
83
+ self.el.parentElement.setAttribute('position', {x: parentPos.x, y: 0, z: parentPos.z});
84
+
85
+ // Add hand controllers
86
+ /** LEFT HAND (with teleport) */
87
+ if(event.target.id === 'babia-leftHand'){
88
+ self.leftHand.setAttribute('teleport-controls', {
89
+ cameraRig: `#${self.el.parentElement.id}`,
90
+ teleportOrigin: `#${self.el.id}`,
91
+ collisionEntities: self.data.teleportCollisions,
92
+ hitCylinderColor: '#ff3468',
93
+ curveHitColor: '#ff3468',
94
+ curveMissColor: '#333333',
95
+ curveLineWidth: 0.01,
96
+ button: 'trigger'
97
+ });
98
+
99
+ /** TIP TRIGGER L */
100
+ tipTriggerLconfig = {
101
+ text: self.data.triggerLLabel,
102
+ width: 0.07,
103
+ height: 0.03,
104
+ targetPosition: '0.002 -0.02 -0.014',
105
+ lineHorizontalAlign: 'right',
106
+ rotation: '-90 0 0',
107
+ src: tooltip.default,
108
+ };
109
+ tipTriggerLpos = {x: -0.09, y: -0.04, z: -0.08};
110
+ self.tipTriggerL = this.createTip('babia-tooltip_trigger_L', tipTriggerLconfig, tipTriggerLpos);
111
+ self.leftHand.append(self.tipTriggerL);
112
+ self.tooltips.push(self.tipTriggerL);
113
+ /** TIP GRIP L */
114
+ tipGripLconfig = {
115
+ text: self.data.gripLLabel,
116
+ width: 0.08,
117
+ height: 0.04,
118
+ targetPosition: '0.006 -0.008 0.033',
119
+ rotation: '-90 0 0',
120
+ src: tooltip.default,
121
+ };
122
+ tipGripLpos = {x: 0.085, y: -0.01, z: 0.07};
123
+ self.tipGripL = this.createTip('babia-tooltip_grip_L', tipGripLconfig, tipGripLpos);
124
+ self.leftHand.append(self.tipGripL);
125
+ self.tooltips.push(self.tipGripL);
126
+ }
127
+
128
+ /** RIGHT HAND (with laser raycaster) */
129
+ if(event.target.id === 'babia-rightHand'){
130
+ self.rightHand.setAttribute('laser-controls', {hand: 'right'});
131
+ self.rightHand.setAttribute('raycaster', {
132
+ objects: this.data.raycasterHand,
133
+ });
134
+ /** TIP TRIGGER R */
135
+ tipTriggerRconfig = {
136
+ text: self.data.triggerRLabel,
137
+ width: 0.07,
138
+ height: 0.03,
139
+ targetPosition: '0.005 -0.02 -0.014',
140
+ lineHorizontalAlign: 'left',
141
+ rotation: '-90 0 0',
142
+ src: tooltip.default,
143
+ };
144
+ tipTriggerRpos = {x: -0.09, y: -0.04, z: -0.08};
145
+ self.tipTriggerR = this.createTip('babia-tooltip_trigger_R', tipTriggerRconfig, tipTriggerRpos);
146
+ self.rightHand.append(self.tipTriggerR);
147
+ self.tooltips.push(self.tipTriggerR);
148
+ /** TIP GRIP L */
149
+ tipGripRconfig = {
150
+ text: self.data.gripRLabel,
151
+ width: 0.08,
152
+ height: 0.04,
153
+ targetPosition: '0.006 -0.008 0.033',
154
+ lineHorizontalAlign: 'right',
155
+ rotation: '-90 0 0',
156
+ src: tooltip.default,
157
+ };
158
+ tipGripRpos = {x: -0.085, y: -0.01, z: 0.07};
159
+ self.tipGripR = this.createTip('babia-tooltip_grip_R', tipGripRconfig, tipGripRpos);
160
+ self.rightHand.append(self.tipGripR);
161
+ self.tooltips.push(self.tipGripR);
162
+ }
163
+
164
+ this.tipsController();
165
+ if (this.data.networkedAudio){
166
+ this.setAudioController();
167
+ }
168
+ });
169
+ },
170
+
171
+ tipsController: function (){
172
+ let self = this;
173
+ this.tipsOpened = self.data.tipsOpened;
174
+ if (!self.tipsOpened){
175
+ self.tooltips.forEach(tip => {
176
+ tip.setAttribute('visible', false);
177
+ });
178
+ }
179
+
180
+ self.rightHand.addEventListener('gripdown', () => {
181
+ if (self.tipsOpened) {
182
+ self.tipsOpened = false;
183
+ self.tooltips.forEach(tip => {
184
+ tip.setAttribute('visible', false);
185
+ });
186
+ } else {
187
+ self.tipsOpened = true;
188
+ self.tooltips.forEach(tip => {
189
+ tip.setAttribute('visible', true);
190
+ });
191
+ }
192
+ })
193
+ },
194
+
195
+ })
@@ -4,7 +4,12 @@ if (typeof AFRAME === 'undefined') {
4
4
  }
5
5
 
6
6
  AFRAME.registerComponent('babia-controls', {
7
- schema: {},
7
+ schema: {
8
+ // Current direction
9
+ direction: { type: 'string', default: ''},
10
+ // Current state
11
+ state: { type: 'string', default: ''},
12
+ },
8
13
 
9
14
  /**
10
15
  * Set if component needs multiple instancing.
@@ -24,6 +29,43 @@ AFRAME.registerComponent('babia-controls', {
24
29
  */
25
30
 
26
31
  update: function (oldData) {
32
+ let data = this.data;
33
+ if ((data.state) && (data.state != oldData.state)) {
34
+ let pause = document.getElementsByClassName('babiaPause')[0];
35
+ let play = document.getElementsByClassName('babiaPlay')[0];
36
+ if (data.state === 'pause') {
37
+ if (pause){
38
+ this.el.children[0].removeChild(pause)
39
+ }
40
+ if (!play){
41
+ this.createButton('play', 'white')
42
+ }
43
+ } else {
44
+ if (play){
45
+ this.el.children[0].removeChild(play)
46
+ }
47
+ if (!pause){
48
+ this.createButton('pause', 'white')
49
+ }
50
+ }
51
+ this.el.parentEl.setAttribute('babia-navigator', 'state', data.state)
52
+ }
53
+ if ((data.direction) && (data.direction != oldData.direction)) {
54
+ let rewind = document.getElementsByClassName('babiaRewind')[0];
55
+ let forward = document.getElementsByClassName('babiaForward')[0];
56
+ if (data.direction === 'rewind'){
57
+ forward.color = 'white'
58
+ rewind.color = 'grey'
59
+ changeMaterial(forward, 'white')
60
+ changeMaterial(rewind, 'grey')
61
+ } else {
62
+ forward.color = 'grey'
63
+ rewind.color = 'white'
64
+ changeMaterial(forward, 'grey')
65
+ changeMaterial(rewind, 'white')
66
+ }
67
+ this.el.parentEl.setAttribute('babia-navigator', 'direction', data.direction)
68
+ }
27
69
  },
28
70
 
29
71
  player: undefined,
@@ -46,40 +88,33 @@ AFRAME.registerComponent('babia-controls', {
46
88
  let url
47
89
  let pos_x
48
90
  let class_name
49
- let event
50
91
  let inverse = false
51
92
 
52
93
  if (type === 'play'){
53
94
  url = playButton.default
54
95
  pos_x = 0.2
55
96
  class_name = 'babiaPlay'
56
- event = 'babiaContinue'
57
97
  } else if (type === 'pause') {
58
98
  url = pauseButton.default
59
99
  pos_x = 0
60
100
  class_name = 'babiaPause'
61
- event = 'babiaStop'
62
101
  } else if (type === 'skipNext') {
63
102
  url = skipButton.default
64
103
  pos_x = 3
65
104
  class_name = 'babiaSkipNext'
66
- event = class_name
67
105
  inverse = true
68
106
  } else if (type === "skipPrev") {
69
107
  url = skipButton.default
70
108
  pos_x = -3
71
109
  class_name = 'babiaSkipPrev'
72
- event = class_name
73
110
  } else if (type === "rewind") {
74
111
  url = rewindButton.default
75
112
  pos_x = -6
76
113
  class_name = 'babiaRewind'
77
- event = 'babiaToPast'
78
114
  } else if ( type === "forward"){
79
115
  url = rewindButton.default
80
116
  pos_x = 6
81
117
  class_name = 'babiaForward'
82
- event = 'babiaToPresent'
83
118
  inverse = true
84
119
  } else {
85
120
  throw new Error("That button type doesn't exist.");
@@ -99,8 +134,8 @@ AFRAME.registerComponent('babia-controls', {
99
134
  this.player.appendChild(button)
100
135
 
101
136
  // Events
102
- this.emitEvents(button, event)
103
137
  this.mouseOver(button)
138
+ this.processEvents(button)
104
139
  },
105
140
 
106
141
  mouseOver: function(element){
@@ -113,37 +148,27 @@ AFRAME.registerComponent('babia-controls', {
113
148
  })
114
149
  },
115
150
 
116
- emitEvents: function(element, event){
151
+ processEvents: function(element){
117
152
  let self = this
118
153
  element.addEventListener('click', function () {
119
154
  if (element.classList.contains('babiaPlay')){
120
- this.parentEl.removeChild(this)
121
- self.createButton('pause', 'white')
155
+ this.parentEl.parentEl.setAttribute('babia-controls','state', 'play');
122
156
  } else if (element.classList.contains('babiaPause')){
123
- this.parentEl.removeChild(this)
124
- self.createButton('play', 'white')
157
+ this.parentEl.parentEl.setAttribute('babia-controls','state', 'pause');
125
158
  } else if ((element.classList.contains('babiaSkipNext')) || (element.classList.contains('babiaSkipPrev'))){
126
- let pause = document.getElementsByClassName('babiaPause')[0]
127
- if (pause){
128
- self.player.removeChild(pause)
129
- self.createButton('play', 'white')
159
+ if (self.data.state != 'pause') {
160
+ this.parentEl.parentEl.setAttribute('babia-controls','state', 'pause')
161
+ }
162
+ let class_name = 'skipPrev';
163
+ if (element.classList.contains('babiaSkipNext')) {
164
+ class_name = 'skipNext';
130
165
  }
166
+ self.el.parentEl.components['babia-navigator'].controlNavigator(class_name);
131
167
  } else if (element.classList.contains('babiaForward')){
132
- this.color = 'grey'
133
- changeMaterial(this, this.color)
134
- let rewind = document.getElementsByClassName('babiaRewind')[0]
135
- rewind.color = 'white'
136
- changeMaterial(rewind, rewind.color)
168
+ this.parentEl.parentEl.setAttribute('babia-controls','direction', 'forward');
137
169
  } else if (element.classList.contains('babiaRewind')){
138
- this.color = 'grey'
139
- changeMaterial(this, this.color)
140
- let forward = document.getElementsByClassName('babiaForward')[0]
141
- forward.color = 'white'
142
- changeMaterial(forward, forward.color)
170
+ this.parentEl.parentEl.setAttribute('babia-controls','direction', 'rewind');
143
171
  }
144
- //console.log('Emit... ' + event)
145
- //self.el.parentEl.emit(event)
146
- self.el.parentEl.components['babia-navigator'].controlNavigator(event)
147
172
  });
148
173
  }
149
174