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.
- package/components/filters/babia-selector.js +256 -79
- package/components/filters/babia-treebuilder.js +1 -2
- package/components/geometries/babia-bar.js +13 -1
- package/components/geometries/babia-cyl.js +189 -0
- package/components/others/assets/tooltip.png +0 -0
- package/components/others/babia-camera.js +195 -0
- package/components/others/babia-controls.js +56 -31
- package/components/others/babia-navigator.js +55 -49
- package/components/others/babia-range-selector.js +218 -0
- package/components/others/babia-slider.js +36 -8
- package/components/others/babia-ui.js +246 -73
- package/components/others/common.js +91 -83
- package/components/queriers/babia-querycsv.js +96 -0
- package/components/queriers/babia-queryes.js +209 -131
- package/components/visualizers/babia-bars.js +15 -38
- package/components/visualizers/babia-barsmap.js +19 -34
- package/components/visualizers/babia-boats.js +221 -134
- package/components/visualizers/babia-bubbles.js +13 -26
- package/components/visualizers/babia-cyls.js +203 -201
- package/components/visualizers/babia-cylsmap.js +173 -241
- package/components/visualizers/babia-doughnut.js +6 -28
- package/components/visualizers/babia-network.js +191 -124
- package/components/visualizers/babia-pie.js +6 -30
- package/dist/aframe-babia-components.js +21913 -19571
- package/dist/aframe-babia-components.min.js +7 -1
- package/dist/aframe-babia-components.min.js.map +1 -1
- package/docs/APIs/CHARTS.md +33 -14
- package/docs/APIs/DATAMANAGEMENT.md +7 -0
- package/docs/APIs/OTHERS.md +42 -0
- package/docs/APIs/QUERIERS.md +18 -0
- package/docs/RELEASE_NOTES.md +58 -21
- package/docs/Tutorials/multiuser.md +47 -2
- package/examples/assets/door/New Bitmap Image.jpg +0 -0
- package/examples/assets/door/door.mtl +26 -0
- package/examples/assets/door/door.obj +6927 -0
- package/examples/assets/popups/0.png +0 -0
- package/examples/assets/popups/1.png +0 -0
- package/examples/assets/popups/10.png +0 -0
- package/examples/assets/popups/2.png +0 -0
- package/examples/assets/popups/3.png +0 -0
- package/examples/assets/popups/4.png +0 -0
- package/examples/assets/popups/5.png +0 -0
- package/examples/assets/popups/6.png +0 -0
- package/examples/assets/popups/7.png +0 -0
- package/examples/assets/popups/8.png +0 -0
- package/examples/assets/popups/9.png +0 -0
- package/examples/assets/popups/close.jpg +0 -0
- package/examples/assets/popups/info.jpg +0 -0
- package/examples/assets/textures/brownwall.png +0 -0
- package/examples/assets/textures/concrete.png +0 -0
- package/examples/assets/textures/white-wall-texture.jpg +0 -0
- package/examples/charts/cyls/index.html +13 -4
- package/examples/charts/cyls/primitive.html +76 -0
- package/examples/charts/cylsmap/index.html +14 -5
- package/examples/charts_querier/bars_querier/data.csv +10 -0
- package/examples/charts_querier/bars_querier/index_csv.html +80 -0
- package/examples/charts_querier/multichart_querier/manual_colors.html +81 -0
- package/examples/dashboard/chaoss-dashboards.html +259 -0
- package/examples/dashboard/chaoss-issues.html +248 -0
- package/examples/dashboard/chaoss-pr.html +248 -0
- package/examples/dashboard/index.html +247 -0
- package/examples/dashboard/issues_queries/80-percent-open-time.json +123 -0
- package/examples/dashboard/issues_queries/issues-by-organization.json +107 -0
- package/examples/dashboard/issues_queries/issues.json +117 -0
- package/examples/dashboard/issues_queries/median-open-time.json +123 -0
- package/examples/dashboard/issues_queries/organizations.json +130 -0
- package/examples/dashboard/issues_queries/projects.json +130 -0
- package/examples/dashboard/issues_queries/repositories.json +130 -0
- package/examples/dashboard/issues_queries/status.json +107 -0
- package/examples/dashboard/issues_queries/submitter.json +125 -0
- package/examples/dashboard/issues_queries/submitters.json +113 -0
- package/examples/dashboard/pullrequests_queries/80-percent-open-time.json +123 -0
- package/examples/dashboard/pullrequests_queries/median-open-time.json +123 -0
- package/examples/dashboard/pullrequests_queries/organizations.json +130 -0
- package/examples/dashboard/pullrequests_queries/projects.json +130 -0
- package/examples/dashboard/pullrequests_queries/pull-requests-by-organization.json +107 -0
- package/examples/dashboard/pullrequests_queries/pull-requests.json +117 -0
- package/examples/dashboard/pullrequests_queries/repositories.json +130 -0
- package/examples/dashboard/pullrequests_queries/status.json +107 -0
- package/examples/dashboard/pullrequests_queries/submitter.json +125 -0
- package/examples/dashboard/pullrequests_queries/submitters.json +113 -0
- package/examples/dashboard/range.html +88 -0
- package/examples/dashboard/template.html +136 -0
- package/examples/demos/1.0.11/index_multiuser_ui.html +1 -1
- package/examples/multi_bars/data.json +14 -0
- package/examples/multi_bars/data2.json +15 -0
- package/examples/multi_bars/data3.json +23 -0
- package/examples/multi_bars/easyrtc.js +11984 -0
- package/examples/multi_bars/index.html +97 -0
- package/examples/multi_bars/index1.html +111 -0
- package/examples/multi_bars/index2.html +102 -0
- package/examples/multi_bars/index3.html +104 -0
- package/examples/multi_boats/data3.json +174 -0
- package/examples/multi_boats/data4.json +192 -0
- package/examples/multi_boats/{index.html → index_multi_boats.html} +50 -55
- package/examples/multi_boats/jetuml.html +124 -115
- package/examples/multi_boats/jetuml_evolution_experiment.html +419 -0
- package/examples/multi_boats/only_queryjson.html +132 -0
- package/examples/multi_boats/only_queryjson2.html +167 -0
- package/examples/multi_boats/only_queryjson3.html +165 -0
- package/examples/multi_boats/queryjson_treebuilder.html +132 -0
- package/examples/multi_boats/with_selector.html +121 -111
- package/examples/multiuser/choose_avatar/index.html +18 -8
- package/examples/selector_boats/jetuml_from_3_2_to_1_0.json +62382 -0
- package/examples/ui/network/data.json +123 -0
- package/examples/ui/network/links.json +13 -0
- package/examples/ui/network/network.html +75 -0
- package/examples/ui/network/network_nodes_links.html +82 -0
- package/examples/ui/network/nodes.json +12 -0
- package/index.html +69 -3
- package/index.js +6 -1
- package/package.json +4 -3
- package/tests/screenshots/other_snapshots.js/chaoss-issues.png +0 -0
- package/tests/screenshots/other_snapshots.js/chaoss-pr.png +0 -0
- package/tests/screenshots/other_snapshots.js/template.png +0 -0
- package/tests/ui.js +7 -0
- package/webpack.common.js +1 -1
- package/webpack.devnossl.js +16 -0
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -79
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
let findProdComponent = require('../others/common').findProdComponent;
|
|
2
|
+
let updateFunction = require('../others/common').updateFunction;
|
|
2
3
|
|
|
3
4
|
const NotiBuffer = require("../../common/noti-buffer").NotiBuffer;
|
|
4
5
|
|
|
@@ -32,13 +33,15 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
32
33
|
height_quarter_legend_title: { type: 'number', default: 12 },
|
|
33
34
|
height_building_legend: { type: 'number', default: 0 },
|
|
34
35
|
legend_scale: { type: 'number', default: 1 },
|
|
35
|
-
|
|
36
|
+
legend_lookat: { type: 'string', default: "[camera]" },
|
|
37
|
+
field: { type: 'string', default: 'uid' },
|
|
36
38
|
},
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
41
|
* Entities with legend activated
|
|
40
42
|
*/
|
|
41
43
|
entitiesWithLegend: [],
|
|
44
|
+
legendsActive: [],
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
47
|
* Querier component target
|
|
@@ -86,44 +89,61 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
86
89
|
*/
|
|
87
90
|
|
|
88
91
|
update: function (oldData) {
|
|
89
|
-
|
|
90
|
-
let el = this.el;
|
|
91
|
-
if (!this.figures){
|
|
92
|
-
this.figures = [];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Highest priority to data
|
|
96
|
-
if (data.data && oldData.data !== data.data) {
|
|
97
|
-
// Get from the json or embedded
|
|
98
|
-
let _data = JSON.parse(data.data);
|
|
99
|
-
this.processData(_data);
|
|
100
|
-
} else if (data.from !== oldData.from) {
|
|
101
|
-
// Unregister for old treegenerator
|
|
102
|
-
if (this.prodComponent) {
|
|
103
|
-
this.prodComponent.notiBuffer.unregister(this.notiBufferId)
|
|
104
|
-
};
|
|
105
|
-
// Register for the new one
|
|
106
|
-
this.prodComponent = findProdComponent(data, el)
|
|
107
|
-
if (this.prodComponent.notiBuffer){
|
|
108
|
-
this.notiBufferId = this.prodComponent.notiBuffer
|
|
109
|
-
.register(this.processData.bind(this))
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
// If changed whatever, re-print with the current data
|
|
113
|
-
else if (data !== oldData && this.newData) {
|
|
114
|
-
this.processData(this.newData)
|
|
115
|
-
}
|
|
92
|
+
updateFunction(this, oldData)
|
|
116
93
|
},
|
|
117
|
-
|
|
94
|
+
|
|
118
95
|
/**
|
|
119
96
|
* Called on each scene tick.
|
|
120
97
|
*/
|
|
121
98
|
tick: function (t, delta) {
|
|
99
|
+
let self = this;
|
|
122
100
|
if (this.animation) {
|
|
123
101
|
let t = { x: 0, y: 0, z: 0 };
|
|
124
102
|
if ((Date.now() - this.start_time) > this.duration) {
|
|
125
103
|
this.animation = false;
|
|
126
104
|
this.setFigures(this.figures, t);
|
|
105
|
+
|
|
106
|
+
//Reactivate legends, check PERFORMANCE
|
|
107
|
+
self.entitiesWithLegend = self.entitiesWithLegend.filter(item => document.getElementById(item.entity.id))
|
|
108
|
+
self.entitiesWithLegend.forEach(item => {
|
|
109
|
+
let entity = item.entity
|
|
110
|
+
let figure = item.figure
|
|
111
|
+
|
|
112
|
+
if (figure.children) {
|
|
113
|
+
// Quarter
|
|
114
|
+
entity.legend = generateLegend(figure.name, self.data.legend_scale, self.data.legend_lookat, 'black', 'white');
|
|
115
|
+
let worldPos = new THREE.Vector3();
|
|
116
|
+
let coordinates = worldPos.setFromMatrixPosition(entity.object3D.matrixWorld);
|
|
117
|
+
let coordinatesFinal = {
|
|
118
|
+
x: coordinates.x,
|
|
119
|
+
y: self.data.height_quarter_legend_title,
|
|
120
|
+
z: coordinates.z
|
|
121
|
+
}
|
|
122
|
+
entity.legend.setAttribute('position', coordinatesFinal)
|
|
123
|
+
entity.legend.setAttribute('visible', true);
|
|
124
|
+
self.el.parentElement.appendChild(entity.legend)
|
|
125
|
+
|
|
126
|
+
self.legendsActive.push(entity.legend)
|
|
127
|
+
entity.alreadyActive = true
|
|
128
|
+
} else {
|
|
129
|
+
// Building
|
|
130
|
+
entity.legend = generateLegend(figure.name, self.data.legend_scale, self.data.legend_lookat, 'white', 'black', entity.babiaRawData, self.data.height, self.data.area, self.data.depth, self.data.width, self.data.color);
|
|
131
|
+
let worldPos = new THREE.Vector3();
|
|
132
|
+
let coordinates = worldPos.setFromMatrixPosition(entity.object3D.matrixWorld);
|
|
133
|
+
let height_real = new THREE.Box3().setFromObject(entity.object3D)
|
|
134
|
+
let coordinatesFinal = {
|
|
135
|
+
x: coordinates.x,
|
|
136
|
+
y: height_real.max.y + 1 + self.data.height_building_legend,
|
|
137
|
+
z: coordinates.z
|
|
138
|
+
}
|
|
139
|
+
entity.legend.setAttribute('position', coordinatesFinal)
|
|
140
|
+
entity.legend.setAttribute('visible', true);
|
|
141
|
+
self.el.parentElement.appendChild(entity.legend);
|
|
142
|
+
|
|
143
|
+
self.legendsActive.push(entity.legend)
|
|
144
|
+
entity.alreadyActive = true
|
|
145
|
+
}
|
|
146
|
+
});
|
|
127
147
|
} else {
|
|
128
148
|
this.Animation(this.el, this.figures, this.figures_old, delta, t, t);
|
|
129
149
|
}
|
|
@@ -135,17 +155,17 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
135
155
|
let t = { x: 0, y: 0, z: 0 };
|
|
136
156
|
|
|
137
157
|
// when animation not finished, delete figures and opa 1 to inserted
|
|
138
|
-
if (this.animation){
|
|
158
|
+
if (this.animation) {
|
|
139
159
|
this.figures_del.forEach(figure => {
|
|
140
160
|
let entity = document.getElementById(figure.id);
|
|
141
|
-
if (entity){
|
|
161
|
+
if (entity) {
|
|
142
162
|
entity.remove();
|
|
143
163
|
}
|
|
144
164
|
})
|
|
145
165
|
this.figures_in.forEach(figure => {
|
|
146
166
|
let entity = document.getElementById(figure.id);
|
|
147
|
-
if (entity){
|
|
148
|
-
setOpacity(entity, 1.0);
|
|
167
|
+
if (entity) {
|
|
168
|
+
setOpacity(entity, 1.0);
|
|
149
169
|
}
|
|
150
170
|
})
|
|
151
171
|
this.setFigures(this.figures, t);
|
|
@@ -183,7 +203,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
183
203
|
this.el.firstChild.remove();
|
|
184
204
|
this.drawElements(el, this.figures, t);
|
|
185
205
|
} else {
|
|
186
|
-
if (this.figures_old !== this.figures){
|
|
206
|
+
if (this.figures_old !== this.figures) {
|
|
187
207
|
this.animation = true;
|
|
188
208
|
this.start_time = Date.now();
|
|
189
209
|
}
|
|
@@ -336,7 +356,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
336
356
|
if (this.data.area) {
|
|
337
357
|
figure = {
|
|
338
358
|
id: "boat-" + elements[i][this.data.field],
|
|
339
|
-
name: elements[i][this.data.field],
|
|
359
|
+
name: (elements[i].name) ? elements[i].name : elements[i][this.data.field],
|
|
340
360
|
posX: posX,
|
|
341
361
|
posY: posY,
|
|
342
362
|
width: Math.sqrt(element.area),
|
|
@@ -346,7 +366,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
346
366
|
} else {
|
|
347
367
|
figure = {
|
|
348
368
|
id: "boat-" + elements[i][this.data.field],
|
|
349
|
-
name: elements[i][this.data.field],
|
|
369
|
+
name: (elements[i].name) ? elements[i].name : elements[i][this.data.field],
|
|
350
370
|
posX: posX,
|
|
351
371
|
posY: posY,
|
|
352
372
|
width: element.width,
|
|
@@ -419,7 +439,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
419
439
|
|
|
420
440
|
let entity = this.createElement(figures[i], position);
|
|
421
441
|
this.addEvents(entity, figures[i]);
|
|
422
|
-
|
|
442
|
+
|
|
423
443
|
element.appendChild(entity);
|
|
424
444
|
}
|
|
425
445
|
|
|
@@ -526,34 +546,42 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
526
546
|
let new_time = Date.now();
|
|
527
547
|
let entity;
|
|
528
548
|
|
|
549
|
+
// First, remove all the legends that are active
|
|
550
|
+
self.legendsActive.forEach(legend => {
|
|
551
|
+
legend.remove()
|
|
552
|
+
});
|
|
553
|
+
self.legendsActive = []
|
|
554
|
+
|
|
529
555
|
for (let i in figures) {
|
|
530
556
|
if (document.getElementById(figures[i].id)) {
|
|
531
557
|
// If exists
|
|
532
558
|
entity = document.getElementById(figures[i].id);
|
|
533
559
|
// Creating... (next ticks)
|
|
534
560
|
if (figures[i].inserted) {
|
|
561
|
+
|
|
562
|
+
//TODO: This code increments the opacity in the animation part, but it adds several performance issues
|
|
535
563
|
//Increment opacity
|
|
536
|
-
let opa_inc = delta / this.duration;
|
|
537
|
-
let opacity = parseFloat(entity.getAttribute('material').opacity);
|
|
538
|
-
if (opacity + opa_inc < 1) {
|
|
539
|
-
|
|
540
|
-
} else {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
544
|
-
setOpacity(entity, opacity);
|
|
564
|
+
// let opa_inc = delta / this.duration;
|
|
565
|
+
// let opacity = parseFloat(entity.getAttribute('material').opacity);
|
|
566
|
+
// if (opacity + opa_inc < 1) {
|
|
567
|
+
// opacity += opa_inc;
|
|
568
|
+
// } else {
|
|
569
|
+
// opacity = 1.0;
|
|
570
|
+
// figures[i].inserted = false;
|
|
571
|
+
// }
|
|
572
|
+
//setOpacity(entity, opacity);
|
|
545
573
|
|
|
546
574
|
// If animation stops before finish
|
|
547
575
|
let cond = 'id=' + figures[i].id
|
|
548
|
-
if (findIndex(self.figures_in, cond) < 0){
|
|
576
|
+
if (findIndex(self.figures_in, cond) < 0) {
|
|
549
577
|
self.figures_in.push(figures[i])
|
|
550
578
|
}
|
|
551
579
|
|
|
552
|
-
} else {
|
|
580
|
+
} else {
|
|
553
581
|
// find index in old_figures
|
|
554
582
|
let cond = 'id=' + figures[i].id
|
|
555
583
|
let index = findIndex(figures_old, cond)
|
|
556
|
-
if (index < 0
|
|
584
|
+
if (index < 0) {
|
|
557
585
|
// encontrar el elemento que no esta en la escena con id y darle opacidad
|
|
558
586
|
// y cambiar sus propiedades a la nueva si es necesario
|
|
559
587
|
figures[i].inserted = true;
|
|
@@ -575,6 +603,15 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
575
603
|
|
|
576
604
|
if (figures[i].children) {
|
|
577
605
|
this.Animation(entity, figures[i].children, figures_old[index].children, delta, figures[i].translate_matrix, figures_old[index].translate_matrix);
|
|
606
|
+
} else {
|
|
607
|
+
// Building color if changed, force to the new one
|
|
608
|
+
if(figures[i].rawData[self.data.color] !== figures_old[index].rawData[self.data.color]) {
|
|
609
|
+
let color = heatMapColorforValue(figures[i].rawData[self.data.color], self.babiaMetadata['color_max'], self.babiaMetadata['color_min'])
|
|
610
|
+
let oldColor = entity.getAttribute('color')
|
|
611
|
+
if (color !== oldColor) {
|
|
612
|
+
entity.setAttribute('color', color)
|
|
613
|
+
}
|
|
614
|
+
}
|
|
578
615
|
}
|
|
579
616
|
}
|
|
580
617
|
}
|
|
@@ -590,8 +627,11 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
590
627
|
let new_entity = this.createElement(figures[i], position);
|
|
591
628
|
this.addEvents(new_entity, figures[i]);
|
|
592
629
|
|
|
593
|
-
//Opacity 0
|
|
594
|
-
setOpacity(new_entity, 0);
|
|
630
|
+
//TODO: bad perfomance when Opacity 0 at the beginning
|
|
631
|
+
//setOpacity(new_entity, 0);
|
|
632
|
+
|
|
633
|
+
// New building and quarter, it appears with 0.5 opacity
|
|
634
|
+
setOpacity(new_entity, 0.5);
|
|
595
635
|
|
|
596
636
|
element.appendChild(new_entity);
|
|
597
637
|
figures[i].inserted = true;
|
|
@@ -600,37 +640,42 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
600
640
|
|
|
601
641
|
// Delete figures
|
|
602
642
|
let opa_dec = delta / this.duration;
|
|
603
|
-
for (let i in figures_old){
|
|
643
|
+
for (let i in figures_old) {
|
|
604
644
|
let deleted = false;
|
|
605
645
|
let cond = 'id=' + figures_old[i].id
|
|
606
646
|
let index = findIndex(figures, cond)
|
|
607
|
-
if (index < 0){
|
|
608
|
-
if (findIndex(self.figures_del, cond) < 0){
|
|
647
|
+
if (index < 0) {
|
|
648
|
+
if (findIndex(self.figures_del, cond) < 0) {
|
|
609
649
|
self.figures_del.push(figures_old[i])
|
|
610
650
|
}
|
|
611
651
|
let entity_del = document.getElementById(figures_old[i].id);
|
|
612
|
-
if (entity_del){
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
652
|
+
if (entity_del) {
|
|
653
|
+
|
|
654
|
+
//TODO: Bad perfomance issue when changing dinamically the opacity, better to just make it non vissible
|
|
655
|
+
entity_del.object3D.visible = false
|
|
656
|
+
entity_del.remove();
|
|
657
|
+
|
|
658
|
+
// let opacity = parseFloat(entity_del.components.material.opacity);
|
|
659
|
+
// if (opacity - opa_dec > 0) {
|
|
660
|
+
// opacity -= opa_dec;
|
|
661
|
+
// } else {
|
|
662
|
+
// opacity = 0.0;
|
|
663
|
+
// deleted = true;
|
|
664
|
+
// self.figures_del.pop(figures_old[i]);
|
|
665
|
+
// }
|
|
666
|
+
// setOpacity(entity_del, opacity);
|
|
667
|
+
// if (deleted) {
|
|
668
|
+
// entity_del.remove();
|
|
669
|
+
// }
|
|
625
670
|
}
|
|
626
671
|
}
|
|
627
672
|
}
|
|
628
673
|
},
|
|
629
674
|
|
|
630
|
-
setFigures: function (figures, translate){
|
|
675
|
+
setFigures: function (figures, translate) {
|
|
631
676
|
figures.forEach(figure => {
|
|
632
677
|
let entity = document.getElementById(figure.id);
|
|
633
|
-
if (entity){
|
|
678
|
+
if (entity) {
|
|
634
679
|
if (entity.getAttribute('width') != figure.width) {
|
|
635
680
|
entity.setAttribute('width', figure.width);
|
|
636
681
|
}
|
|
@@ -640,13 +685,18 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
640
685
|
if (entity.getAttribute('depth') != figure.depth) {
|
|
641
686
|
entity.setAttribute('depth', figure.depth);
|
|
642
687
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
|
|
688
|
+
|
|
689
|
+
//TODO: Full opacity because it was in 0.5 if new building/quarter
|
|
690
|
+
if (entity.components.material.data.opacity < 1) {
|
|
691
|
+
setOpacity(entity, 1)
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
entity.object3D.position.set(
|
|
695
|
+
figure.posX - translate.x,
|
|
696
|
+
((parseFloat(figure.height) + translate.y) / 2),
|
|
697
|
+
(- figure.posY + translate.z),
|
|
698
|
+
)
|
|
699
|
+
if (figure.children) {
|
|
650
700
|
this.setFigures(figure.children, figure.translate_matrix);
|
|
651
701
|
}
|
|
652
702
|
}
|
|
@@ -697,6 +747,19 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
697
747
|
entity.setAttribute('width', new_width);
|
|
698
748
|
entity.setAttribute('height', new_height);
|
|
699
749
|
entity.setAttribute('depth', new_depth);
|
|
750
|
+
entity.babiaRawData = figure.rawData
|
|
751
|
+
|
|
752
|
+
//Check if has transparent box as a quarter
|
|
753
|
+
if (entity.classList.contains('babiaquarterboxactivated')) {
|
|
754
|
+
entity.childNodes.forEach(child => {
|
|
755
|
+
if (child.classList.contains('babiaquarterlegendbox')){
|
|
756
|
+
child.setAttribute('geometry', 'width', new_width);
|
|
757
|
+
child.setAttribute('geometry', 'depth', new_depth);
|
|
758
|
+
child.setAttribute('material', 'opacity', 0.4);
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
|
|
700
763
|
|
|
701
764
|
} else if (((new_time - this.start_time) > this.duration) &&
|
|
702
765
|
((figure.width != figure_old.width) ||
|
|
@@ -706,7 +769,18 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
706
769
|
entity.setAttribute('width', figure.width);
|
|
707
770
|
entity.setAttribute('height', figure.height);
|
|
708
771
|
entity.setAttribute('depth', figure.depth);
|
|
709
|
-
entity.
|
|
772
|
+
entity.babiaRawData = figure.rawData
|
|
773
|
+
|
|
774
|
+
//Check if has transparent box as a quarter
|
|
775
|
+
if (entity.classList.contains('babiaquarterboxactivated')) {
|
|
776
|
+
entity.childNodes.forEach(child => {
|
|
777
|
+
if (child.classList.contains('babiaquarterlegendbox')){
|
|
778
|
+
child.setAttribute('geometry', 'width', new_width);
|
|
779
|
+
child.setAttribute('geometry', 'depth', new_depth);
|
|
780
|
+
child.setAttribute('material', 'opacity', 0.4);
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
}
|
|
710
784
|
}
|
|
711
785
|
},
|
|
712
786
|
|
|
@@ -722,9 +796,9 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
722
796
|
let inc_y = (delta * dist_y) / (2 * this.duration);
|
|
723
797
|
let inc_z = (delta * dist_z) / this.duration;
|
|
724
798
|
|
|
725
|
-
let last_x = parseFloat(entity.
|
|
726
|
-
let last_y = parseFloat(entity.
|
|
727
|
-
let last_z = parseFloat(entity.
|
|
799
|
+
let last_x = parseFloat(entity.object3D.position.x);
|
|
800
|
+
let last_y = parseFloat(entity.object3D.position.y);
|
|
801
|
+
let last_z = parseFloat(entity.object3D.position.z);
|
|
728
802
|
|
|
729
803
|
let new_x = last_x - inc_x;
|
|
730
804
|
let new_y = last_y + inc_y;
|
|
@@ -732,18 +806,18 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
732
806
|
|
|
733
807
|
|
|
734
808
|
// Update entity
|
|
735
|
-
entity.
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
809
|
+
entity.object3D.position.set(
|
|
810
|
+
new_x,
|
|
811
|
+
new_y,
|
|
812
|
+
new_z
|
|
813
|
+
)
|
|
740
814
|
|
|
741
815
|
} else if ((new_time - this.start_time) > this.duration) {
|
|
742
|
-
entity.
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
816
|
+
entity.object3D.position.set(
|
|
817
|
+
(figure.posX - translate.x),
|
|
818
|
+
((parseFloat(figure.height) + translate.y) / 2),
|
|
819
|
+
(- figure.posY + translate.z),
|
|
820
|
+
)
|
|
747
821
|
}
|
|
748
822
|
}
|
|
749
823
|
},
|
|
@@ -779,7 +853,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
779
853
|
entity.setAttribute('depth', depth);
|
|
780
854
|
// rawData building
|
|
781
855
|
if (figure.rawData) {
|
|
782
|
-
entity.
|
|
856
|
+
entity.babiaRawData = figure.rawData
|
|
783
857
|
}
|
|
784
858
|
|
|
785
859
|
// add into scene
|
|
@@ -800,7 +874,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
800
874
|
let data = this.data;
|
|
801
875
|
this.newData = _data;
|
|
802
876
|
this.babiaMetadata = { id: this.babiaMetadata.id++ };
|
|
803
|
-
|
|
877
|
+
|
|
804
878
|
// If color metric activated, save in the metadata the max and min value for mapping
|
|
805
879
|
if (data.color) {
|
|
806
880
|
let [color_max, color_min] = getMaxMinColorValues(this.newData, data.color)
|
|
@@ -809,34 +883,41 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
809
883
|
}
|
|
810
884
|
this.notiBuffer.set(this.newData)
|
|
811
885
|
// Create city
|
|
812
|
-
this.updateChart(this.newData)
|
|
886
|
+
this.updateChart(this.newData)
|
|
813
887
|
},
|
|
814
888
|
|
|
815
889
|
addEvents: function (entity, figure) {
|
|
816
890
|
let self = this;
|
|
817
891
|
if (figure.children) {
|
|
818
892
|
// Quarter
|
|
819
|
-
let legend;
|
|
820
893
|
let transparentBox;
|
|
821
894
|
entity.addEventListener('click', function (e) {
|
|
822
895
|
// Just launch the event on the child
|
|
823
896
|
if (e.target !== this)
|
|
824
897
|
return;
|
|
825
898
|
|
|
826
|
-
if (legend) {
|
|
899
|
+
if (entity.legend) {
|
|
827
900
|
entity.removeChild(transparentBox)
|
|
828
|
-
|
|
829
|
-
legend
|
|
830
|
-
transparentBox = undefined
|
|
901
|
+
entity.classList.remove("babiaquarterboxactivated");
|
|
902
|
+
self.el.parentElement.removeChild(entity.legend)
|
|
831
903
|
|
|
832
|
-
// Remove from the array that has the entity activated
|
|
833
|
-
const index = self.entitiesWithLegend.
|
|
904
|
+
// Remove from the array that has the entity activated and the legend
|
|
905
|
+
const index = self.entitiesWithLegend.findIndex(item => item.entity === entity);
|
|
834
906
|
if (index > -1) {
|
|
835
907
|
self.entitiesWithLegend.splice(index, 1);
|
|
836
908
|
}
|
|
909
|
+
const indexLegend = self.legendsActive.indexOf(entity.legend);
|
|
910
|
+
if (index > -1) {
|
|
911
|
+
self.legendsActive.splice(indexLegend, 1);
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
entity.legend = undefined
|
|
915
|
+
transparentBox = undefined
|
|
916
|
+
|
|
837
917
|
} else {
|
|
838
918
|
transparentBox = document.createElement('a-entity');
|
|
839
|
-
transparentBox.setAttribute('class', '
|
|
919
|
+
transparentBox.setAttribute('class', 'babiaquarterlegendbox')
|
|
920
|
+
entity.classList.add("babiaquarterboxactivated");
|
|
840
921
|
let oldGeometry = entity.getAttribute('geometry')
|
|
841
922
|
let scale = self.el.getAttribute("scale")
|
|
842
923
|
let tsBoxHeight = oldGeometry.height + self.data.height_quarter_legend_box
|
|
@@ -854,7 +935,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
854
935
|
});
|
|
855
936
|
entity.appendChild(transparentBox)
|
|
856
937
|
|
|
857
|
-
legend = generateLegend(figure.name, self.data.legend_scale, 'black', 'white');
|
|
938
|
+
entity.legend = generateLegend(figure.name, self.data.legend_scale, self.data.legend_lookat, 'black', 'white');
|
|
858
939
|
let worldPos = new THREE.Vector3();
|
|
859
940
|
let coordinates = worldPos.setFromMatrixPosition(entity.object3D.matrixWorld);
|
|
860
941
|
let coordinatesFinal = {
|
|
@@ -862,28 +943,28 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
862
943
|
y: self.data.height_quarter_legend_title,
|
|
863
944
|
z: coordinates.z
|
|
864
945
|
}
|
|
865
|
-
legend.setAttribute('position', coordinatesFinal)
|
|
866
|
-
legend.setAttribute('visible', true);
|
|
867
|
-
self.el.parentElement.appendChild(legend)
|
|
946
|
+
entity.legend.setAttribute('position', coordinatesFinal)
|
|
947
|
+
entity.legend.setAttribute('visible', true);
|
|
948
|
+
self.el.parentElement.appendChild(entity.legend)
|
|
868
949
|
|
|
869
950
|
// Add to the elements that has the legend activated
|
|
870
|
-
self.entitiesWithLegend.push(entity)
|
|
951
|
+
self.entitiesWithLegend.push({'figure': figure, 'entity': entity})
|
|
952
|
+
self.legendsActive.push(entity.legend)
|
|
871
953
|
}
|
|
872
954
|
})
|
|
873
955
|
|
|
874
956
|
this.drawElements(entity, figure.children, figure.translate_matrix);
|
|
875
957
|
} else {
|
|
876
958
|
// Building
|
|
877
|
-
let legend;
|
|
878
959
|
let entityGeometry;
|
|
879
|
-
|
|
960
|
+
entity.alreadyActive = false;
|
|
880
961
|
|
|
881
962
|
entity.addEventListener('click', function (e) {
|
|
882
963
|
if (e.target !== this)
|
|
883
964
|
return;
|
|
884
965
|
|
|
885
|
-
if (alreadyActive) {
|
|
886
|
-
legend.setAttribute('visible', false);
|
|
966
|
+
if (entity.alreadyActive) {
|
|
967
|
+
entity.legend.setAttribute('visible', false);
|
|
887
968
|
entity.setAttribute('geometry', {
|
|
888
969
|
height: entityGeometry.height - 0.1,
|
|
889
970
|
depth: entityGeometry.depth - 0.1,
|
|
@@ -892,20 +973,25 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
892
973
|
entity.setAttribute('material', {
|
|
893
974
|
'color': entity.getAttribute('babiaxrFirstColor')
|
|
894
975
|
});
|
|
895
|
-
self.el.parentElement.removeChild(legend)
|
|
896
|
-
legend = undefined
|
|
897
|
-
alreadyActive = false
|
|
976
|
+
self.el.parentElement.removeChild(entity.legend)
|
|
898
977
|
|
|
899
978
|
// Remove from the array that has the entity activated
|
|
900
|
-
const index = self.entitiesWithLegend.
|
|
979
|
+
const index = self.entitiesWithLegend.findIndex(item => item.entity === entity);
|
|
901
980
|
if (index > -1) {
|
|
902
981
|
self.entitiesWithLegend.splice(index, 1);
|
|
903
982
|
}
|
|
983
|
+
const indexLegend = self.legendsActive.indexOf(entity.legend);
|
|
984
|
+
if (index > -1) {
|
|
985
|
+
self.legendsActive.splice(indexLegend, 1);
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
entity.legend = undefined
|
|
989
|
+
entity.alreadyActive = false
|
|
904
990
|
} else {
|
|
905
|
-
alreadyActive = true
|
|
991
|
+
entity.alreadyActive = true
|
|
906
992
|
|
|
907
993
|
// If clicked again but not mouseover
|
|
908
|
-
if (!legend) {
|
|
994
|
+
if (!entity.legend) {
|
|
909
995
|
// COPY FROM 626
|
|
910
996
|
entityGeometry = entity.getAttribute('geometry')
|
|
911
997
|
let boxPosition = entity.getAttribute("position")
|
|
@@ -919,7 +1005,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
919
1005
|
depth: entityGeometry.depth + 0.1,
|
|
920
1006
|
width: entityGeometry.width + 0.1
|
|
921
1007
|
});
|
|
922
|
-
legend = generateLegend(figure.name, self.data.legend_scale, 'white', 'black',
|
|
1008
|
+
entity.legend = generateLegend(figure.name, self.data.legend_scale, self.data.legend_lookat, 'white', 'black', entity.babiaRawData, self.data.height, self.data.area, self.data.depth, self.data.width, self.data.color);
|
|
923
1009
|
let worldPos = new THREE.Vector3();
|
|
924
1010
|
let coordinates = worldPos.setFromMatrixPosition(entity.object3D.matrixWorld);
|
|
925
1011
|
let height_real = new THREE.Box3().setFromObject(entity.object3D)
|
|
@@ -928,19 +1014,20 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
928
1014
|
y: height_real.max.y + 1 + self.data.height_building_legend,
|
|
929
1015
|
z: coordinates.z
|
|
930
1016
|
}
|
|
931
|
-
legend.setAttribute('position', coordinatesFinal)
|
|
932
|
-
legend.setAttribute('visible', true);
|
|
933
|
-
self.el.parentElement.appendChild(legend);
|
|
1017
|
+
entity.legend.setAttribute('position', coordinatesFinal)
|
|
1018
|
+
entity.legend.setAttribute('visible', true);
|
|
1019
|
+
self.el.parentElement.appendChild(entity.legend);
|
|
934
1020
|
}
|
|
935
1021
|
|
|
936
1022
|
// Add to the elements that has the legend activated
|
|
937
|
-
self.entitiesWithLegend.push(entity)
|
|
1023
|
+
self.entitiesWithLegend.push({'figure': figure, 'entity': entity})
|
|
1024
|
+
self.legendsActive.push(entity.legend)
|
|
938
1025
|
}
|
|
939
1026
|
|
|
940
1027
|
})
|
|
941
1028
|
|
|
942
1029
|
entity.addEventListener('mouseenter', function () {
|
|
943
|
-
if (!alreadyActive) {
|
|
1030
|
+
if (!entity.alreadyActive) {
|
|
944
1031
|
entityGeometry = entity.getAttribute('geometry')
|
|
945
1032
|
let boxPosition = entity.getAttribute("position")
|
|
946
1033
|
entity.setAttribute('position', boxPosition)
|
|
@@ -953,7 +1040,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
953
1040
|
depth: entityGeometry.depth + 0.1,
|
|
954
1041
|
width: entityGeometry.width + 0.1
|
|
955
1042
|
});
|
|
956
|
-
legend = generateLegend(figure.name, self.data.legend_scale, 'white', 'black',
|
|
1043
|
+
entity.legend = generateLegend(figure.name, self.data.legend_scale, self.data.legend_lookat, 'white', 'black', entity.babiaRawData, self.data.height, self.data.area, self.data.depth, self.data.width, self.data.color);
|
|
957
1044
|
let worldPos = new THREE.Vector3();
|
|
958
1045
|
let coordinates = worldPos.setFromMatrixPosition(entity.object3D.matrixWorld);
|
|
959
1046
|
let height_real = new THREE.Box3().setFromObject(entity.object3D)
|
|
@@ -962,15 +1049,15 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
962
1049
|
y: height_real.max.y + 1 + self.data.height_building_legend,
|
|
963
1050
|
z: coordinates.z
|
|
964
1051
|
}
|
|
965
|
-
legend.setAttribute('position', coordinatesFinal)
|
|
966
|
-
legend.setAttribute('visible', true);
|
|
967
|
-
self.el.parentElement.appendChild(legend);
|
|
1052
|
+
entity.legend.setAttribute('position', coordinatesFinal)
|
|
1053
|
+
entity.legend.setAttribute('visible', true);
|
|
1054
|
+
self.el.parentElement.appendChild(entity.legend);
|
|
968
1055
|
}
|
|
969
1056
|
|
|
970
1057
|
});
|
|
971
1058
|
entity.addEventListener('mouseleave', function () {
|
|
972
|
-
if (!alreadyActive && legend) {
|
|
973
|
-
legend.setAttribute('visible', false);
|
|
1059
|
+
if (!entity.alreadyActive && entity.legend) {
|
|
1060
|
+
entity.legend.setAttribute('visible', false);
|
|
974
1061
|
entity.setAttribute('geometry', {
|
|
975
1062
|
height: entityGeometry.height - 0.1,
|
|
976
1063
|
depth: entityGeometry.depth - 0.1,
|
|
@@ -979,8 +1066,8 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
979
1066
|
entity.setAttribute('material', {
|
|
980
1067
|
'color': entity.getAttribute('babiaxrFirstColor')
|
|
981
1068
|
});
|
|
982
|
-
self.el.parentElement.removeChild(legend)
|
|
983
|
-
legend = undefined
|
|
1069
|
+
self.el.parentElement.removeChild(entity.legend)
|
|
1070
|
+
entity.legend = undefined
|
|
984
1071
|
}
|
|
985
1072
|
});
|
|
986
1073
|
}
|
|
@@ -990,7 +1077,7 @@ AFRAME.registerComponent('babia-boats', {
|
|
|
990
1077
|
/**
|
|
991
1078
|
* This function generate a plane at the top of the building with the desired text
|
|
992
1079
|
*/
|
|
993
|
-
let generateLegend = (name, legend_scale, colorPlane, colorText, data, fheight, farea, fdepth, fwidth, fcolor) => {
|
|
1080
|
+
let generateLegend = (name, legend_scale, lookat, colorPlane, colorText, data, fheight, farea, fdepth, fwidth, fcolor) => {
|
|
994
1081
|
let width = 2;
|
|
995
1082
|
let height = 1;
|
|
996
1083
|
if (name.length > 16)
|
|
@@ -1031,7 +1118,7 @@ let generateLegend = (name, legend_scale, colorPlane, colorText, data, fheight,
|
|
|
1031
1118
|
}
|
|
1032
1119
|
|
|
1033
1120
|
let entity = document.createElement('a-plane');
|
|
1034
|
-
entity.setAttribute('babia-lookat',
|
|
1121
|
+
entity.setAttribute('babia-lookat', lookat);
|
|
1035
1122
|
|
|
1036
1123
|
entity.setAttribute('rotation', { x: 0, y: 0, z: 0 });
|
|
1037
1124
|
entity.setAttribute('height', height);
|
|
@@ -1117,8 +1204,8 @@ function heatMapColorforValue(val, max, min) {
|
|
|
1117
1204
|
let findIndex = (list, condicion) => {
|
|
1118
1205
|
condicion = condicion.split('=')
|
|
1119
1206
|
//console.log(condicion)
|
|
1120
|
-
for (i = 0; i < list.length; i++){
|
|
1121
|
-
if (list[i][condicion[0]] === condicion[1]){
|
|
1207
|
+
for (i = 0; i < list.length; i++) {
|
|
1208
|
+
if (list[i][condicion[0]] === condicion[1]) {
|
|
1122
1209
|
return i
|
|
1123
1210
|
}
|
|
1124
1211
|
}
|