aframe-babia-components 1.2.6 → 1.2.8

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 (220) hide show
  1. package/common/noti-buffer.js +4 -1
  2. package/components/filters/babia-treebuilder.js +14 -4
  3. package/components/others/babia-slider.js +296 -296
  4. package/components/visualizers/babia-boats.js +218 -84
  5. package/components/visualizers/babia-html.js +255 -0
  6. package/cypress.json +1 -1
  7. package/dist/aframe-babia-components.js +41889 -46000
  8. package/dist/aframe-babia-components.min.js +2 -7
  9. package/dist/aframe-babia-components.min.js.LICENSE.txt +12 -0
  10. package/dist/aframe-babia-components.min.js.map +1 -1
  11. package/docs/APIs/CHARTS.md +5 -1
  12. package/docs/APIs/OTHERS.md +18 -8
  13. package/docs/RELEASE_NOTES.md +4 -0
  14. package/docs/Tutorials/get_started.md +2 -2
  15. package/docs/Tutorials/temporal_evol_with_boats.md +3 -3
  16. package/examples/ar/multichart/index.html +75 -0
  17. package/examples/assets/fonts/regular.json +1 -0
  18. package/examples/async/index.html +3 -3
  19. package/examples/async/index_filter.html +3 -3
  20. package/examples/async/index_noti_buffer.html +3 -3
  21. package/examples/async/index_noti_buffer_filter.html +3 -3
  22. package/examples/boats/boats/index.html +3 -3
  23. package/examples/boats/boats2/data.json +13 -206
  24. package/examples/boats/boats2/index.html +4 -4
  25. package/examples/boats/boats_city/index.html +4 -4
  26. package/examples/boats/boats_city_plan_view/index.html +4 -4
  27. package/examples/boats/boats_dependency/experiment.html +8 -7
  28. package/examples/boats/boats_dependency/index.html +1 -1
  29. package/examples/boats/boats_dependency/index_gradient.html +1 -1
  30. package/examples/boats/boats_dependency/index_normalcity.html +1 -1
  31. package/examples/boats/boats_dependency/index_quarter_levels_01.html +1 -1
  32. package/examples/boats/boats_dependency/index_quarter_levels_02.html +1 -1
  33. package/examples/boats/boats_dependency/index_quarter_levels_03.html +1 -1
  34. package/examples/boats/boats_dependency/index_quarter_levels_querystring.html +1 -1
  35. package/examples/boats/boats_dependency/index_tree.html +1 -1
  36. package/examples/boats/boats_dependency/index_tree_gradient.html +1 -1
  37. package/examples/boats/boats_dependency/index_tree_wireframe.html +1 -1
  38. package/examples/boats/boats_new_element/index.html +3 -3
  39. package/examples/boats/boats_new_quarter/index.html +3 -3
  40. package/examples/boats/boats_plan_view/index.html +3 -3
  41. package/examples/boats/boats_plan_view2/index.html +4 -4
  42. package/examples/boats/boats_quarter_resize/index.html +3 -3
  43. package/examples/boats/boats_quarter_resize2/index.html +3 -3
  44. package/examples/boats/boats_resize/index.html +3 -3
  45. package/examples/boats/boats_temporal/index.html +3 -3
  46. package/examples/boats/boats_treegenerator/index.html +3 -3
  47. package/examples/boats/jetuml_evol/ar.html +333 -0
  48. package/examples/boats/jetuml_evol/data.json +62382 -0
  49. package/examples/boats/jetuml_evol/index.html +381 -0
  50. package/examples/charts/bars/bars_change.html +2 -2
  51. package/examples/charts/bars/bars_json.html +2 -2
  52. package/examples/charts/bars/index.html +3 -3
  53. package/examples/charts/barsmap/index.html +3 -3
  54. package/examples/charts/bubbles/index.html +3 -3
  55. package/examples/charts/cyls/index.html +3 -3
  56. package/examples/charts/cyls/primitive.html +3 -3
  57. package/examples/charts/cylsmap/index.html +3 -3
  58. package/examples/charts/doughnut/index.html +3 -3
  59. package/examples/charts/multichart/index.html +3 -3
  60. package/examples/charts/network_chart/network_chart.html +1 -1
  61. package/examples/charts/network_chart/network_large_chart.html +3 -3
  62. package/examples/charts/network_chart/network_nodes_links_chart.html +3 -3
  63. package/examples/charts/network_chart/network_nodes_links_directed_chart.html +2 -2
  64. package/examples/charts/network_chart/network_random_chart.html +2 -2
  65. package/examples/charts/pie/index.html +2 -2
  66. package/examples/charts_querier/bars_querier/bars_axis_name.html +3 -3
  67. package/examples/charts_querier/bars_querier/index.html +3 -3
  68. package/examples/charts_querier/bars_querier/index_csv.html +3 -3
  69. package/examples/charts_querier/barsmap_querier/barsmap_axis_name.html +3 -3
  70. package/examples/charts_querier/barsmap_querier/index.html +3 -3
  71. package/examples/charts_querier/bubbles_querier/index.html +3 -3
  72. package/examples/charts_querier/cyls_querier/index.html +3 -3
  73. package/examples/charts_querier/cylsmap_querier/index.html +3 -3
  74. package/examples/charts_querier/doughnut_querier/index.html +3 -3
  75. package/examples/charts_querier/multichart_querier/index.html +3 -3
  76. package/examples/charts_querier/multichart_querier/manual_colors.html +3 -3
  77. package/examples/charts_querier/pie_querier/index.html +3 -3
  78. package/examples/codecityjs/argouml/index.html +4 -4
  79. package/examples/codecityjs/basic/index.html +2 -2
  80. package/examples/codecityjs/basic_treegenerator/index.html +2 -2
  81. package/examples/codecityjs/perceval/index.html +2 -2
  82. package/examples/codecityjs/perceval2021/index.html +4 -4
  83. package/examples/codecityjs/projects_analysis/argouml_landscape.html +2 -2
  84. package/examples/codecityjs/projects_analysis/argouml_numfuns.html +2 -2
  85. package/examples/codecityjs/projects_analysis/argouml_table.html +2 -2
  86. package/examples/codecityjs/projects_analysis/argouml_tokens.html +2 -2
  87. package/examples/codecityjs/projects_analysis/experiment_interface.html +2 -2
  88. package/examples/codecityjs/projects_analysis/experiment_interface_task5.html +2 -2
  89. package/examples/codecityjs/projects_analysis/experiment_interface_vr_2021.html +2 -2
  90. package/examples/codecityjs/projects_analysis/experiment_interface_vr_task5.html +2 -2
  91. package/examples/codecityjs/projects_analysis/perceval_landscape.html +2 -2
  92. package/examples/codecityjs/projects_analysis/perceval_table.html +2 -2
  93. package/examples/codecityjs/sortinghat/index.html +2 -2
  94. package/examples/codecityjs/sortinghat/indexcolor.html +2 -2
  95. package/examples/codecityjs/time_evolution_angular/index.html +2 -2
  96. package/examples/dashboard/chaoss-dashboards.html +1 -1
  97. package/examples/dashboard/chaoss-issues.html +1 -1
  98. package/examples/dashboard/chaoss-pr.html +1 -1
  99. package/examples/dashboard/index.html +1 -1
  100. package/examples/dashboard/range.html +3 -3
  101. package/examples/dashboard/template.html +1 -1
  102. package/examples/demos/1.0.11/index.html +4 -4
  103. package/examples/demos/1.0.11/index_multiuser.html +3 -3
  104. package/examples/demos/1.0.11/index_multiuser_ui.html +3 -3
  105. package/examples/demos/1.0.7/index.html +3 -3
  106. package/examples/demos/citations/babiaxr.json +1 -0
  107. package/examples/demos/citations/citations.html +72 -0
  108. package/examples/demos/citations/music.mp3 +0 -0
  109. package/examples/demos/citations/stl.js +28 -0
  110. package/examples/elevation/elevation basic/index.html +2 -2
  111. package/examples/elevation/elevation filled/index.html +2 -2
  112. package/{example-template.html → examples/example-template.html} +10 -9
  113. package/examples/experiment/city.html +15 -11
  114. package/examples/experiment/index.html +1 -1
  115. package/examples/experiment/pie.html +2 -2
  116. package/examples/experiment/third_party.html +92 -0
  117. package/examples/htmlinxr/complex.html +219 -0
  118. package/examples/htmlinxr/simple.html +163 -0
  119. package/examples/img/codecitytree.png +0 -0
  120. package/examples/img/codecityvs.png +0 -0
  121. package/examples/img/dashboard.png +0 -0
  122. package/examples/img/elevatedcity.png +0 -0
  123. package/examples/img/experiment.png +0 -0
  124. package/examples/img/time.png +0 -0
  125. package/examples/img/uinetwork.png +0 -0
  126. package/examples/img/uinetwork_json.png +0 -0
  127. package/examples/multi_bars/index.html +3 -3
  128. package/examples/multi_bars/index1.html +3 -3
  129. package/examples/multi_bars/index2.html +3 -3
  130. package/examples/multi_bars/index3.html +3 -3
  131. package/examples/multi_boats/index_multi_boats.html +3 -3
  132. package/examples/multi_boats/jetuml.html +3 -3
  133. package/examples/multi_boats/jetuml_evolution_experiment.html +3 -3
  134. package/examples/multi_boats/only_queryjson.html +3 -3
  135. package/examples/multi_boats/only_queryjson2.html +3 -3
  136. package/examples/multi_boats/only_queryjson3.html +3 -3
  137. package/examples/multi_boats/queryjson_treebuilder.html +3 -3
  138. package/examples/multi_boats/with_selector.html +3 -3
  139. package/examples/multiuser/choose_avatar/desert_demo.html +3 -3
  140. package/examples/multiuser/demo_esLibre_audio.html +3 -3
  141. package/examples/multiuser/demo_esLibre_no_audio.html +3 -3
  142. package/examples/multiuser/demo_no_share_ui.html +3 -3
  143. package/examples/multiuser/meaningful.html +3 -3
  144. package/examples/multiuser/new_demo.html +3 -3
  145. package/examples/multiuser/no_persistence.html +3 -3
  146. package/examples/multiuser/persistence.html +3 -3
  147. package/examples/multiuser/simple_scene.html +3 -3
  148. package/examples/performance/500bars_100anime/index.html +3 -3
  149. package/examples/performance/500bars_anime/index.html +3 -3
  150. package/examples/performance/500simplebars_100anime/index.html +3 -3
  151. package/examples/publications/codecityvs/aframe-lounge-component.min.js +1 -0
  152. package/examples/publications/codecityvs/index.html +535 -0
  153. package/examples/publications/codecityvs/jetuml_code_data.json +1 -0
  154. package/examples/publications/dashboard/index.html +764 -0
  155. package/examples/publications/dashboard/staticdata/80-percent-open-time-issues2.json +1 -0
  156. package/examples/publications/dashboard/staticdata/80-percent-open-time-pr.json +1 -0
  157. package/examples/publications/dashboard/staticdata/issues-by-organization.json +1 -0
  158. package/examples/publications/dashboard/staticdata/issues.json +1 -0
  159. package/examples/publications/dashboard/staticdata/median-open-time-issues.json +1 -0
  160. package/examples/publications/dashboard/staticdata/median-open-time-pr.json +1 -0
  161. package/examples/publications/dashboard/staticdata/organizations-issues.json +1 -0
  162. package/examples/publications/dashboard/staticdata/organizations-pr.json +1 -0
  163. package/examples/publications/dashboard/staticdata/projects-issues.json +1 -0
  164. package/examples/publications/dashboard/staticdata/projects-pr.json +1 -0
  165. package/examples/publications/dashboard/staticdata/pull-requests-by-organization.json +1 -0
  166. package/examples/publications/dashboard/staticdata/pull-requests.json +1 -0
  167. package/examples/publications/dashboard/staticdata/repositories-issues-asignees.json +1 -0
  168. package/examples/publications/dashboard/staticdata/repositories-issues-avgdays.json +1 -0
  169. package/examples/publications/dashboard/staticdata/repositories-issues-count.json +1 -0
  170. package/examples/publications/dashboard/staticdata/repositories-issues-submitters.json +1 -0
  171. package/examples/publications/dashboard/staticdata/repositories-pr-asignees.json +1 -0
  172. package/examples/publications/dashboard/staticdata/repositories-pr-avgdays.json +1 -0
  173. package/examples/publications/dashboard/staticdata/repositories-pr-count.json +1 -0
  174. package/examples/publications/dashboard/staticdata/repositories-pr-submitters.json +1 -0
  175. package/examples/publications/dashboard/staticdata/status-issues.json +1 -0
  176. package/examples/publications/dashboard/staticdata/status-pr.json +1 -0
  177. package/examples/publications/dashboard/staticdata/submitter-issues-avgdays.json +1 -0
  178. package/examples/publications/dashboard/staticdata/submitter-issues-count.json +1 -0
  179. package/examples/publications/dashboard/staticdata/submitter-issues-repo.json +1 -0
  180. package/examples/publications/dashboard/staticdata/submitter-pr-avgdays.json +1 -0
  181. package/examples/publications/dashboard/staticdata/submitter-pr-count.json +1 -0
  182. package/examples/publications/dashboard/staticdata/submitter-pr-repo.json +1 -0
  183. package/examples/publications/dashboard/staticdata/submitters-issues.json +1 -0
  184. package/examples/publications/dashboard/staticdata/submitters-pr.json +1 -0
  185. package/examples/publications/elevated/dependencieslist_ghdesktop.json +127660 -0
  186. package/examples/publications/elevated/dependencieslist_pm2.json +13726 -0
  187. package/examples/publications/elevated/dependencieslist_portainer.json +41818 -0
  188. package/examples/publications/elevated/dependencieslist_sh.json +5194 -0
  189. package/examples/publications/elevated/index.html +278 -0
  190. package/examples/selector/index.html +2 -2
  191. package/examples/selector_boats/index.html +3 -3
  192. package/examples/selector_boats/index2.html +3 -3
  193. package/examples/selector_boats/jetuml.html +3 -3
  194. package/examples/selector_boats/jetumltest.html +3 -3
  195. package/examples/temporal_evol/bars/index.html +3 -3
  196. package/examples/temporal_evol/barsmap/index.html +3 -3
  197. package/examples/timeline/index.html +3 -3
  198. package/examples/timeline/index2.html +3 -3
  199. package/examples/timeline/index3.html +3 -3
  200. package/examples/ui/bars/index.html +3 -3
  201. package/examples/ui/barsmap/index.html +3 -3
  202. package/examples/ui/boats_treegenerator/index.html +3 -3
  203. package/examples/ui/city_treegenerator/index.html +3 -3
  204. package/examples/ui/cylsmap/index.html +3 -3
  205. package/examples/ui/link/index.html +3 -3
  206. package/examples/ui/network/network.html +3 -3
  207. package/examples/ui/network/network_nodes_links.html +2 -2
  208. package/examples/ui/oculus/index.html +3 -3
  209. package/examples/ui/pie/index.html +3 -3
  210. package/examples/ui/ui_treegenerator/index.html +3 -3
  211. package/examples/watcher/querier_watcher/index.html +2 -2
  212. package/index.html +186 -168
  213. package/index.js +6 -1
  214. package/package.json +15 -14
  215. package/tests/index.html +2 -2
  216. package/tests/treebuilder.js +69 -0
  217. package/webpack.dev.js +12 -7
  218. package/webpack.devall.js +12 -7
  219. package/webpack.devnossl.js +5 -4
  220. package/webpack.prod.js +1 -1
@@ -1,300 +1,300 @@
1
1
  /* global AFRAME */
2
2
  if (typeof AFRAME === 'undefined') {
3
- throw new Error('Component attempted to register before AFRAME was available.');
3
+ throw new Error('Component attempted to register before AFRAME was available.');
4
4
  }
5
5
 
6
6
  AFRAME.registerComponent('babia-slider', {
7
- schema: {
8
- color: { type: 'color', default: '#fff' },
9
- size: { type: 'number', default: 0.5 },
10
- min: { type: 'number', default: -6 },
11
- max: { type: 'number', default: -4 },
12
- value: { type: 'number', default: -5 },
13
- innerSize: { type: 'number', default: 0.8 },
14
- precision: { type: 'number', default: 2 },
15
- vertical: {type: 'boolean', default: false},
16
- label: {type: 'string'}
17
- },
18
-
19
- multiple: true,
20
-
21
- init: function () {
22
- this.loader = new THREE.FontLoader();
23
-
24
- let material = new THREE.MeshBasicMaterial({color: this.data.color });
25
- this.material = material
26
- let lever= new THREE.Mesh(new THREE.BoxGeometry( 0.05, 0.15, 0.05 ), material);
27
- let track = new THREE.Mesh(new THREE.CylinderGeometry(0.015,0.015, this.data.size, 12), material);
28
- track.rotateZ(Math.PI / 2);
29
- let chassis = new THREE.Group();
30
-
31
- this.lever = lever;
32
- chassis.add(track);
33
- chassis.add(lever);
34
-
35
- if (this.data.vertical){
36
- chassis.rotateZ(Math.PI / 2)
37
- }
7
+ schema: {
8
+ color: { type: 'color', default: '#fff' },
9
+ size: { type: 'number', default: 0.5 },
10
+ min: { type: 'number', default: -6 },
11
+ max: { type: 'number', default: -4 },
12
+ value: { type: 'number', default: -5 },
13
+ innerSize: { type: 'number', default: 0.8 },
14
+ precision: { type: 'number', default: 2 },
15
+ vertical: { type: 'boolean', default: false },
16
+ label: { type: 'string' }
17
+ },
38
18
 
39
- this.el.setObject3D('mesh', chassis);
40
- this.el.classList.add("babiaxraycasterclass");
41
-
42
- this.controllers = Array.prototype.slice.call(document.querySelectorAll('a-entity[hand-controls]'));
43
-
44
- this.fontURL = 'https://threejsfundamentals.org/threejs/resources/threejs/fonts/helvetiker_regular.typeface.json'
45
- this.loader.load(this.fontURL, (font) => {
46
- this.font = font
47
- let minText = this.createTextGeometry(this.data.min, -this.data.size / 2 - .15, -.025)
48
- let maxText = this.createTextGeometry(this.data.max, this.data.size / 2 + .08, -.025)
49
- chassis.add(minText)
50
- chassis.add(maxText)
51
- })
52
- },
53
-
54
- createTextGeometry: function(text, x, y) {
55
- let textGeometry = new THREE.TextGeometry(text.toString(), {
56
- font: this.font,
57
- size: .07,
58
- height: .01,
59
- curveSegments: 12,
60
- bevelEnabled: false,
61
- });
62
- let textMesh = new THREE.Mesh(textGeometry, this.material)
63
- textMesh.position.x = x
64
- textMesh.position.y = y
65
- if (this.data.vertical){
66
- textMesh.rotation.z = - Math.PI / 2
67
- textMesh.position.y += .05
68
- }
69
- return textMesh
70
- },
19
+ multiple: true,
71
20
 
72
- setTextGeometry: function(text) {
73
- if (this.textmesh) {
74
- this.lever.children = []
75
- }
76
- this.loader.load(this.fontURL, (font) => {
77
- this.font = font
78
- if (!this.data.vertical){
79
- this.textmesh = this.createTextGeometry(text, -.025, .15)
80
- } else {
81
- this.textmesh = this.createTextGeometry(text, -.025, -.2)
82
- }
83
- this.lever.add(this.textmesh)
84
- })
85
- },
86
-
87
- play: function () {
88
- this.grabbed = false;
89
- this.el.addEventListener('rangeout', this.onTriggerUp.bind(this));
90
- this.controllers.forEach(function (controller){
91
- controller.addEventListener('triggerdown', this.onTriggerDown.bind(this));
92
- controller.addEventListener('triggerup', this.onTriggerUp.bind(this));
93
- }.bind(this));
94
- },
95
-
96
- pause: function () {
97
- this.el.removeEventListener('rangeout', this.onTriggerUp.bind(this));
98
- this.controllers.forEach(function (controller){
99
- controller.removeEventListener('triggerdown', this.onTriggerDown.bind(this));
100
- controller.removeEventListener('triggerup', this.onTriggerUp.bind(this));
101
- }.bind(this));
102
- },
103
-
104
- onTriggerDown: function(e) {
105
- var hand = e.target.object3D;
106
- var lever = this.lever;
107
-
108
- var handBB = new THREE.Box3().setFromObject(hand);
109
- var leverBB = new THREE.Box3().setFromObject(lever);
110
- var collision = handBB.intersectsBox(leverBB);
111
-
112
- if (collision) {
113
- let handWorld = new THREE.Vector3();
114
- hand.getWorldPosition(handWorld);
115
- let knobWorld = new THREE.Vector3();;
116
- lever.getWorldPosition(knobWorld);
117
- let distance = handWorld.distanceTo(knobWorld);
118
- if (distance < 0.1) {
119
- this.grabbed = hand;
120
- this.grabbed.visible = false;
121
- this.knob.material = this.knobGrabbedMaterial;
122
- }
123
- };
124
- },
125
-
126
- onTriggerUp: function() {
127
- if (this.grabbed) {
128
- this.grabbed.visible = true;
129
- this.grabbed = false;
130
- this.knob.material = this.knobMaterial;
131
- }
132
- },
133
-
134
- setValue: function(value) {
135
- var lever = this.lever;
136
- if (value < this.data.min) {
137
- value = this.data.min;
138
- } else if (value > this.data.max) {
139
- value = this.data.max;
140
- }
141
-
21
+ init: function () {
22
+ this.loader = new FontLoader.FontLoader();
23
+
24
+ let material = new THREE.MeshBasicMaterial({ color: this.data.color });
25
+ this.material = material
26
+ let lever = new THREE.Mesh(new THREE.BoxGeometry(0.05, 0.15, 0.05), material);
27
+ let track = new THREE.Mesh(new THREE.CylinderGeometry(0.015, 0.015, this.data.size, 12), material);
28
+ track.rotateZ(Math.PI / 2);
29
+ let chassis = new THREE.Group();
30
+
31
+ this.lever = lever;
32
+ chassis.add(track);
33
+ chassis.add(lever);
34
+
35
+ if (this.data.vertical) {
36
+ chassis.rotateZ(Math.PI / 2)
37
+ }
38
+
39
+ this.el.setObject3D('mesh', chassis);
40
+ this.el.classList.add("babiaxraycasterclass");
41
+
42
+ this.controllers = Array.prototype.slice.call(document.querySelectorAll('a-entity[hand-controls]'));
43
+
44
+ this.fontURL = 'https://threejsfundamentals.org/threejs/resources/threejs/fonts/helvetiker_regular.typeface.json'
45
+ this.loader.load(this.fontURL, (font) => {
46
+ this.font = font
47
+ let minText = this.createTextGeometry(this.data.min, -this.data.size / 2 - .15, -.025)
48
+ let maxText = this.createTextGeometry(this.data.max, this.data.size / 2 + .08, -.025)
49
+ chassis.add(minText)
50
+ chassis.add(maxText)
51
+ })
52
+ },
53
+
54
+ createTextGeometry: function (text, x, y) {
55
+ let textGeometry = new TextGeometry.TextGeometry(text.toString(), {
56
+ font: this.font,
57
+ size: .07,
58
+ height: .01,
59
+ curveSegments: 12,
60
+ bevelEnabled: false,
61
+ });
62
+ let textMesh = new THREE.Mesh(textGeometry, this.material)
63
+ textMesh.position.x = x
64
+ textMesh.position.y = y
65
+ if (this.data.vertical) {
66
+ textMesh.rotation.z = - Math.PI / 2
67
+ textMesh.position.y += .05
68
+ }
69
+ return textMesh
70
+ },
71
+
72
+ setTextGeometry: function (text) {
73
+ if (this.textmesh) {
74
+ this.lever.children = []
75
+ }
76
+ this.loader.load(this.fontURL, (font) => {
77
+ this.font = font
78
+ if (!this.data.vertical) {
79
+ this.textmesh = this.createTextGeometry(text, -.025, .15)
80
+ } else {
81
+ this.textmesh = this.createTextGeometry(text, -.025, -.2)
82
+ }
83
+ this.lever.add(this.textmesh)
84
+ })
85
+ },
86
+
87
+ play: function () {
88
+ this.grabbed = false;
89
+ this.el.addEventListener('rangeout', this.onTriggerUp.bind(this));
90
+ this.controllers.forEach(function (controller) {
91
+ controller.addEventListener('triggerdown', this.onTriggerDown.bind(this));
92
+ controller.addEventListener('triggerup', this.onTriggerUp.bind(this));
93
+ }.bind(this));
94
+ },
95
+
96
+ pause: function () {
97
+ this.el.removeEventListener('rangeout', this.onTriggerUp.bind(this));
98
+ this.controllers.forEach(function (controller) {
99
+ controller.removeEventListener('triggerdown', this.onTriggerDown.bind(this));
100
+ controller.removeEventListener('triggerup', this.onTriggerUp.bind(this));
101
+ }.bind(this));
102
+ },
103
+
104
+ onTriggerDown: function (e) {
105
+ var hand = e.target.object3D;
106
+ var lever = this.lever;
107
+
108
+ var handBB = new THREE.Box3().setFromObject(hand);
109
+ var leverBB = new THREE.Box3().setFromObject(lever);
110
+ var collision = handBB.intersectsBox(leverBB);
111
+
112
+ if (collision) {
113
+ let handWorld = new THREE.Vector3();
114
+ hand.getWorldPosition(handWorld);
115
+ let knobWorld = new THREE.Vector3();;
116
+ lever.getWorldPosition(knobWorld);
117
+ let distance = handWorld.distanceTo(knobWorld);
118
+ if (distance < 0.1) {
119
+ this.grabbed = hand;
120
+ this.grabbed.visible = false;
121
+ this.knob.material = this.knobGrabbedMaterial;
122
+ }
123
+ };
124
+ },
125
+
126
+ onTriggerUp: function () {
127
+ if (this.grabbed) {
128
+ this.grabbed.visible = true;
129
+ this.grabbed = false;
130
+ this.knob.material = this.knobMaterial;
131
+ }
132
+ },
133
+
134
+ setValue: function (value) {
135
+ var lever = this.lever;
136
+ if (value < this.data.min) {
137
+ value = this.data.min;
138
+ } else if (value > this.data.max) {
139
+ value = this.data.max;
140
+ }
141
+
142
+ this.value = value;
143
+
144
+ lever.position.x = this.valueToLeverPosition(value);
145
+ if (!this.data.label) {
146
+ this.setTextGeometry(value)
147
+ } else {
148
+ this.setTextGeometry(this.data.label)
149
+ }
150
+
151
+ },
152
+
153
+ valueToLeverPosition: function (value) {
154
+ var sliderRange = this.data.size * this.data.innerSize;
155
+ var valueRange = Math.abs(this.data.max - this.data.min);
156
+
157
+ let sliderMin = -1 * sliderRange / 2;
158
+
159
+ return (((value - this.data.min) * sliderRange) / valueRange) + sliderMin
160
+ },
161
+
162
+ leverPositionToValue: function (position) {
163
+ var sliderRange = this.data.size * this.data.innerSize;
164
+ var valueRange = Math.abs(this.data.max - this.data.min);
165
+
166
+ let sliderMin = -1 * sliderRange / 2;
167
+
168
+ return (((position - sliderMin) * valueRange) / sliderRange) + this.data.min
169
+ },
170
+
171
+ tick: function () {
172
+ if (this.grabbed) {
173
+ var hand = this.grabbed;
174
+ var lever = this.lever;
175
+ var sliderSize = this.data.size;
176
+ var sliderRange = (sliderSize * this.data.innerSize);
177
+
178
+ var handWorld = new THREE.Vector3().setFromMatrixPosition(hand.matrixWorld);
179
+ lever.parent.worldToLocal(handWorld);
180
+
181
+ if (Math.abs(handWorld.x) > sliderRange / 2) {
182
+ lever.position.x = sliderRange / 2 * Math.sign(lever.position.x);
183
+ } else {
184
+ lever.position.x = handWorld.x;
185
+ }
186
+ var value = this.leverPositionToValue(lever.position.x);
187
+
188
+ if (Math.abs(this.value - value) >= Math.pow(10, -this.data.precision)) {
189
+ value = Math.round(value)
142
190
  this.value = value;
143
-
144
- lever.position.x = this.valueToLeverPosition(value);
145
- if (!this.data.label){
146
- this.setTextGeometry(value)
147
- } else {
148
- this.setTextGeometry(this.data.label)
149
- }
150
-
151
- },
152
-
153
- valueToLeverPosition: function(value) {
154
- var sliderRange = this.data.size * this.data.innerSize;
155
- var valueRange = Math.abs(this.data.max - this.data.min);
156
-
157
- let sliderMin = -1 * sliderRange / 2;
158
-
159
- return (((value - this.data.min) * sliderRange) / valueRange) + sliderMin
160
- },
161
-
162
- leverPositionToValue: function(position) {
163
- var sliderRange = this.data.size * this.data.innerSize;
164
- var valueRange = Math.abs(this.data.max - this.data.min);
165
-
166
- let sliderMin = -1 * sliderRange / 2;
167
-
168
- return (((position - sliderMin) * valueRange) / sliderRange) + this.data.min
169
- },
170
-
171
- tick: function() {
172
- if (this.grabbed) {
173
- var hand = this.grabbed;
174
- var lever = this.lever;
175
- var sliderSize = this.data.size;
176
- var sliderRange = (sliderSize * this.data.innerSize);
177
-
178
- var handWorld = new THREE.Vector3().setFromMatrixPosition(hand.matrixWorld);
179
- lever.parent.worldToLocal(handWorld);
180
-
181
- if (Math.abs(handWorld.x) > sliderRange / 2) {
182
- lever.position.x = sliderRange / 2 * Math.sign(lever.position.x);
183
- } else {
184
- lever.position.x = handWorld.x;
185
- }
186
- var value = this.leverPositionToValue(lever.position.x);
187
-
188
- if (Math.abs(this.value - value) >= Math.pow(10, -this.data.precision)) {
189
- value = Math.round(value)
190
- this.value = value;
191
- this.setTextGeometry(value)
192
- // this.el.parentEl.components['babia-navigator'].controlNavigator('babiaSetPosition', this.value)
193
- if (this.el.parentEl.components['babia-navigator']){
194
- this.el.parentEl.components['babia-navigator'].controlNavigator('babiaSetPosition', Math.round(value))
195
- } else if (this.el.parentEl.components['babia-step-controller']){
196
- this.el.parentEl.components['babia-step-controller'].controlStep(Math.round(value))
197
- } else if (this.el.parentEl.components['babia-speed-controller']){
198
- this.el.parentEl.components['babia-speed-controller'].controlSpeed(Math.round(value))
199
- }
200
- }
201
- }
202
- },
203
-
204
- mousexPositionToValue: function(x){
205
- let sliderCenter = this.el.object3D.getWorldPosition().x
206
- let sliderWidth = this.data.size * this.data.innerSize * this.el.object3D.getWorldScale().x
207
- let sliderRange = Math.abs(this.data.max - this.data.min)
208
- let sliderMin = sliderCenter - (sliderWidth / 2)
209
-
210
- let value = (((x - sliderMin) * sliderRange) / sliderWidth) + this.data.min
211
- if (value < this.data.min){
212
- return this.data.min
213
- } else if (value > this.data.max){
214
- return this.data.max
215
- } else {
216
- return value
191
+ this.setTextGeometry(value)
192
+ // this.el.parentEl.components['babia-navigator'].controlNavigator('babiaSetPosition', this.value)
193
+ if (this.el.parentEl.components['babia-navigator']) {
194
+ this.el.parentEl.components['babia-navigator'].controlNavigator('babiaSetPosition', Math.round(value))
195
+ } else if (this.el.parentEl.components['babia-step-controller']) {
196
+ this.el.parentEl.components['babia-step-controller'].controlStep(Math.round(value))
197
+ } else if (this.el.parentEl.components['babia-speed-controller']) {
198
+ this.el.parentEl.components['babia-speed-controller'].controlSpeed(Math.round(value))
217
199
  }
218
- },
219
-
220
- mouseyPositionToValue: function(y){
221
- let sliderCenter = this.el.object3D.getWorldPosition().y
222
- let sliderWidth = this.data.size * this.data.innerSize * this.el.object3D.getWorldScale().y
223
- let sliderRange = Math.abs(this.data.max - this.data.min)
224
- let sliderMin = sliderCenter - (sliderWidth / 2)
225
-
226
- let value = (((y - sliderMin) * sliderRange) / sliderWidth) + this.data.min
227
- if (value < this.data.min){
228
- return this.data.min
229
- } else if (value > this.data.max){
230
- return this.data.max
231
- } else {
232
- return value
233
- }
234
- },
235
-
236
- update: function(old) {
237
- if(this.data.value !== old.value) {
238
- this.setValue(this.data.value);
239
- }
240
- this.el.addEventListener('click', _listener = (e) => {
241
- let mouse = e.detail.intersection.point
242
- let value
243
- if (!this.data.vertical){
244
- value = this.mousexPositionToValue(mouse.x);
245
- } else {
246
- value = this.mouseyPositionToValue(mouse.y);
247
- }
248
- //this.setValue(Math.round(value));
249
-
250
- if (this.el.parentEl.components['babia-navigator']){
251
- this.el.parentEl.components['babia-navigator'].controlNavigator('babiaSetPosition', Math.round(value))
252
- } else if (this.el.parentEl.components['babia-step-controller']){
253
- this.el.parentEl.components['babia-step-controller'].controlStep(Math.round(value))
254
- } else if (this.el.parentEl.components['babia-speed-controller']){
255
- this.el.parentEl.components['babia-speed-controller'].controlSpeed(Math.round(value))
256
- }
257
- })
258
200
  }
201
+ }
202
+ },
203
+
204
+ mousexPositionToValue: function (x) {
205
+ let sliderCenter = this.el.object3D.getWorldPosition().x
206
+ let sliderWidth = this.data.size * this.data.innerSize * this.el.object3D.getWorldScale().x
207
+ let sliderRange = Math.abs(this.data.max - this.data.min)
208
+ let sliderMin = sliderCenter - (sliderWidth / 2)
209
+
210
+ let value = (((x - sliderMin) * sliderRange) / sliderWidth) + this.data.min
211
+ if (value < this.data.min) {
212
+ return this.data.min
213
+ } else if (value > this.data.max) {
214
+ return this.data.max
215
+ } else {
216
+ return value
217
+ }
218
+ },
219
+
220
+ mouseyPositionToValue: function (y) {
221
+ let sliderCenter = this.el.object3D.getWorldPosition().y
222
+ let sliderWidth = this.data.size * this.data.innerSize * this.el.object3D.getWorldScale().y
223
+ let sliderRange = Math.abs(this.data.max - this.data.min)
224
+ let sliderMin = sliderCenter - (sliderWidth / 2)
225
+
226
+ let value = (((y - sliderMin) * sliderRange) / sliderWidth) + this.data.min
227
+ if (value < this.data.min) {
228
+ return this.data.min
229
+ } else if (value > this.data.max) {
230
+ return this.data.max
231
+ } else {
232
+ return value
233
+ }
234
+ },
235
+
236
+ update: function (old) {
237
+ if (this.data.value !== old.value) {
238
+ this.setValue(this.data.value);
239
+ }
240
+ this.el.addEventListener('click', _listener = (e) => {
241
+ let mouse = e.detail.intersection.point
242
+ let value
243
+ if (!this.data.vertical) {
244
+ value = this.mousexPositionToValue(mouse.x);
245
+ } else {
246
+ value = this.mouseyPositionToValue(mouse.y);
247
+ }
248
+ //this.setValue(Math.round(value));
249
+
250
+ if (this.el.parentEl.components['babia-navigator']) {
251
+ this.el.parentEl.components['babia-navigator'].controlNavigator('babiaSetPosition', Math.round(value))
252
+ } else if (this.el.parentEl.components['babia-step-controller']) {
253
+ this.el.parentEl.components['babia-step-controller'].controlStep(Math.round(value))
254
+ } else if (this.el.parentEl.components['babia-speed-controller']) {
255
+ this.el.parentEl.components['babia-speed-controller'].controlSpeed(Math.round(value))
256
+ }
257
+ })
258
+ }
259
259
  })
260
260
 
261
261
  AFRAME.registerComponent('babia-step-controller', {
262
- schema: {
263
- value: { type: 'number', default: -5 },
264
- },
265
-
266
- multiple: true,
267
-
268
- sliderEl: undefined,
269
- step: undefined,
270
-
271
- init: function () {
272
- this.createSlider()
273
- },
274
- update: function(old) {
275
- if(this.data.value !== old.value) {
276
- this.sliderEl.setAttribute('babia-slider','value', this.data.value);
277
- }
278
- },
279
-
280
- createSlider: function(){
281
- this.sliderEl = document.createElement('a-entity');
282
- this.sliderEl.setAttribute('babia-slider', {
283
- size: 1,
284
- min: 1,
285
- max: 10,
286
- value: 1,
287
- vertical: true
288
- }); // When implement with selector, add the attributes
289
- this.sliderEl.classList.add("babiaxraycasterclass");
290
- this.sliderEl.id = "step-controller"
291
- this.el.appendChild(this.sliderEl);
292
- },
293
-
294
- controlStep: function(value){
295
- this.step = value
296
- this.el.parentEl.components['babia-navigator'].controlNavigator('babiaSetStep', this.step)
297
- }
262
+ schema: {
263
+ value: { type: 'number', default: -5 },
264
+ },
265
+
266
+ multiple: true,
267
+
268
+ sliderEl: undefined,
269
+ step: undefined,
270
+
271
+ init: function () {
272
+ this.createSlider()
273
+ },
274
+ update: function (old) {
275
+ if (this.data.value !== old.value) {
276
+ this.sliderEl.setAttribute('babia-slider', 'value', this.data.value);
277
+ }
278
+ },
279
+
280
+ createSlider: function () {
281
+ this.sliderEl = document.createElement('a-entity');
282
+ this.sliderEl.setAttribute('babia-slider', {
283
+ size: 1,
284
+ min: 1,
285
+ max: 10,
286
+ value: 1,
287
+ vertical: true
288
+ }); // When implement with selector, add the attributes
289
+ this.sliderEl.classList.add("babiaxraycasterclass");
290
+ this.sliderEl.id = "step-controller"
291
+ this.el.appendChild(this.sliderEl);
292
+ },
293
+
294
+ controlStep: function (value) {
295
+ this.step = value
296
+ this.el.parentEl.components['babia-navigator'].controlNavigator('babiaSetStep', this.step)
297
+ }
298
298
  })
299
299
 
300
300
 
@@ -311,28 +311,28 @@ AFRAME.registerComponent('babia-speed-controller', {
311
311
  init: function () {
312
312
  this.createSlider()
313
313
  },
314
-
315
- update: function(old) {
316
- if(this.data.value !== old.value) {
317
- this.sliderEl.setAttribute('babia-slider','value', this.data.value);
314
+
315
+ update: function (old) {
316
+ if (this.data.value !== old.value) {
317
+ this.sliderEl.setAttribute('babia-slider', 'value', this.data.value);
318
318
  }
319
319
  },
320
320
 
321
- createSlider: function(){
321
+ createSlider: function () {
322
322
  this.sliderEl = document.createElement('a-entity');
323
323
  this.sliderEl.setAttribute('babia-slider', {
324
- size: 1,
325
- min: 1,
326
- max: 3,
327
- value: 1,
328
- vertical: true
324
+ size: 1,
325
+ min: 1,
326
+ max: 3,
327
+ value: 1,
328
+ vertical: true
329
329
  }); // When implement with selector, add the attributes
330
330
  this.sliderEl.classList.add("babiaxraycasterclass");
331
331
  this.sliderEl.id = "speed-controller"
332
332
  this.el.appendChild(this.sliderEl);
333
333
  },
334
-
335
- controlSpeed: function(value){
334
+
335
+ controlSpeed: function (value) {
336
336
  this.speed = value
337
337
  this.el.parentEl.components['babia-navigator'].controlNavigator('babiaSetSpeed', this.speed)
338
338
  }