aframe-babia-components 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/filters/babia-treebuilder.js +17 -12
- package/components/others/babia-camera.js +52 -40
- package/components/others/babia-experiment.js +457 -0
- package/components/others/babia-poster.js +383 -0
- package/components/others/babia-task.js +247 -0
- package/components/others/babia-ui.js +312 -147
- package/components/others/common.js +36 -5
- package/components/visualizers/babia-boats.js +708 -87
- package/components/visualizers/babia-network.js +268 -212
- package/dist/aframe-babia-components.js +20590 -18317
- package/dist/aframe-babia-components.min.js +3 -3
- package/dist/aframe-babia-components.min.js.map +1 -1
- package/docs/APIs/CHARTS.md +233 -207
- package/docs/APIs/OTHERS.md +143 -56
- package/docs/RELEASE_NOTES.md +5 -0
- package/docs/Tutorials/how_to_prepare_an_experiment.md +148 -0
- package/examples/assets/palettes/bluetored.jpg +0 -0
- package/examples/assets/textures/360-panorama.jpg +0 -0
- package/examples/assets/textures/floor-texture.jpg +0 -0
- package/examples/assets/textures/metalic-texture.jpg +0 -0
- package/examples/boats/boats_dependency/dependencieslist_cloudinary.json +1 -0
- package/examples/boats/boats_dependency/dependencieslist_express.json +4376 -0
- package/examples/boats/boats_dependency/dependencieslist_filestash.json +39533 -0
- package/examples/boats/boats_dependency/dependencieslist_ghdesktop.json +127660 -0
- package/examples/boats/boats_dependency/dependencieslist_karma.json +1 -0
- package/examples/boats/boats_dependency/dependencieslist_pm2.json +13726 -0
- package/examples/boats/boats_dependency/dependencieslist_portainer.json +41818 -0
- package/examples/boats/boats_dependency/dependencieslist_sh.json +5194 -0
- package/examples/boats/boats_dependency/experiment.html +277 -0
- package/examples/boats/boats_dependency/index.html +300 -0
- package/examples/boats/boats_dependency/index_gradient.html +209 -0
- package/examples/boats/boats_dependency/index_normalcity.html +207 -0
- package/examples/boats/boats_dependency/index_quarter_levels_01.html +213 -0
- package/examples/boats/boats_dependency/index_quarter_levels_02.html +213 -0
- package/examples/boats/boats_dependency/index_quarter_levels_03.html +213 -0
- package/examples/boats/boats_dependency/index_quarter_levels_querystring.html +243 -0
- package/examples/boats/boats_dependency/index_tree.html +211 -0
- package/examples/boats/boats_dependency/index_tree_gradient.html +212 -0
- package/examples/boats/boats_dependency/index_tree_wireframe.html +243 -0
- package/examples/charts/network_chart/network_chart.html +10 -2
- package/examples/charts/pie/index.html +3 -4
- package/examples/codecityjs/perceval2021/index.html +1 -1
- package/examples/codecityjs/projects_analysis/argouml_landscape.html +1 -1
- package/examples/codecityjs/projects_analysis/argouml_numfuns.html +3 -3
- package/examples/codecityjs/projects_analysis/argouml_table.html +1 -1
- package/examples/codecityjs/projects_analysis/argouml_tokens.html +1 -1
- package/examples/codecityjs/projects_analysis/experiment_interface.html +1 -1
- package/examples/codecityjs/projects_analysis/experiment_interface_task5.html +1 -1
- package/examples/codecityjs/projects_analysis/experiment_interface_vr_2021.html +1 -1
- package/examples/codecityjs/projects_analysis/experiment_interface_vr_task5.html +1 -1
- package/examples/codecityjs/projects_analysis/perceval_landscape.html +1 -1
- package/examples/codecityjs/projects_analysis/perceval_table.html +1 -1
- package/examples/dashboard/chaoss-dashboards.html +1 -1
- package/examples/dashboard/chaoss-issues.html +1 -1
- package/examples/dashboard/chaoss-pr.html +1 -1
- package/examples/dashboard/range.html +1 -1
- package/examples/dashboard/template.html +1 -1
- package/examples/experiment/city.html +352 -0
- package/examples/experiment/index.html +527 -0
- package/examples/experiment/pie.html +90 -0
- package/examples/experiment/sample-3s.mp3 +0 -0
- package/examples/experiment/sample.mp4 +0 -0
- package/examples/experiment/staticdata/80-percent-open-time-issues2.json +1 -0
- package/examples/experiment/staticdata/80-percent-open-time-pr.json +1 -0
- package/examples/experiment/staticdata/issues-by-organization.json +1 -0
- package/examples/experiment/staticdata/issues.json +1 -0
- package/examples/experiment/staticdata/jetuml_code_data.json +1 -0
- package/examples/experiment/staticdata/median-open-time-issues.json +1 -0
- package/examples/experiment/staticdata/median-open-time-pr.json +1 -0
- package/examples/experiment/staticdata/organizations-issues.json +1 -0
- package/examples/experiment/staticdata/organizations-pr.json +1 -0
- package/examples/experiment/staticdata/projects-issues.json +1 -0
- package/examples/experiment/staticdata/projects-pr.json +1 -0
- package/examples/experiment/staticdata/pull-requests-by-organization.json +1 -0
- package/examples/experiment/staticdata/pull-requests.json +1 -0
- package/examples/experiment/staticdata/repositories-issues-asignees.json +1 -0
- package/examples/experiment/staticdata/repositories-issues-avgdays.json +1 -0
- package/examples/experiment/staticdata/repositories-issues-count.json +1 -0
- package/examples/experiment/staticdata/repositories-issues-submitters.json +1 -0
- package/examples/experiment/staticdata/repositories-pr-asignees.json +1 -0
- package/examples/experiment/staticdata/repositories-pr-avgdays.json +1 -0
- package/examples/experiment/staticdata/repositories-pr-count.json +1 -0
- package/examples/experiment/staticdata/repositories-pr-submitters.json +1 -0
- package/examples/experiment/staticdata/status-issues.json +1 -0
- package/examples/experiment/staticdata/status-pr.json +1 -0
- package/examples/experiment/staticdata/submitter-issues-avgdays.json +1 -0
- package/examples/experiment/staticdata/submitter-issues-count.json +1 -0
- package/examples/experiment/staticdata/submitter-issues-repo.json +1 -0
- package/examples/experiment/staticdata/submitter-pr-avgdays.json +1 -0
- package/examples/experiment/staticdata/submitter-pr-count.json +1 -0
- package/examples/experiment/staticdata/submitter-pr-repo.json +1 -0
- package/examples/experiment/staticdata/submitters-issues.json +1 -0
- package/examples/experiment/staticdata/submitters-pr.json +1 -0
- package/examples/multi_boats/jetuml_evolution_experiment.html +1 -1
- package/index.js +23 -9
- package/package.json +1 -1
- package/examples/charts_querier/network_chart_querier/data.json +0 -123
- package/examples/charts_querier/network_chart_querier/links.json +0 -13
- package/examples/charts_querier/network_chart_querier/network_chart_querier.html +0 -68
- package/examples/charts_querier/network_chart_querier/network_chart_querier_nodes_links.html +0 -74
- package/examples/charts_querier/network_chart_querier/nodes.json +0 -12
|
@@ -52,7 +52,7 @@ let parseFn = function (prop) {
|
|
|
52
52
|
try {
|
|
53
53
|
let evalled = geval('(' + prop + ')');
|
|
54
54
|
return evalled;
|
|
55
|
-
} catch (e) {} // Can't eval, not a function
|
|
55
|
+
} catch (e) { } // Can't eval, not a function
|
|
56
56
|
return null;
|
|
57
57
|
};
|
|
58
58
|
|
|
@@ -71,36 +71,42 @@ let cursor = '';
|
|
|
71
71
|
AFRAME.registerComponent('babia-network', {
|
|
72
72
|
schema: {
|
|
73
73
|
nodeLegend: { type: 'boolean', default: false },
|
|
74
|
-
linkLegend: {type: 'boolean', default: false},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
linkLegend: { type: 'boolean', default: false },
|
|
75
|
+
|
|
76
|
+
// Label lookat for following
|
|
77
|
+
legend_lookat: { type: 'string', default: "[camera]" },
|
|
78
|
+
// Scale for the label
|
|
79
|
+
legend_scale: { type: 'number', default: 1 },
|
|
80
|
+
|
|
81
|
+
from: { type: 'string' },
|
|
82
|
+
nodesFrom: { type: 'string' },
|
|
83
|
+
linksFrom: { type: 'string' },
|
|
84
|
+
data: { type: 'string', default: '' },
|
|
85
|
+
nodes: { type: 'string', default: '' },
|
|
80
86
|
links: { type: 'string', default: '' },
|
|
81
87
|
nodeId: { type: 'string', default: 'id' },
|
|
82
88
|
nodeLabel: { parse: parseAccessor, default: 'id' },
|
|
83
|
-
linkId: { type: 'string', default: ''},
|
|
89
|
+
linkId: { type: 'string', default: '' },
|
|
84
90
|
linkSource: { type: 'string', default: 'source' },
|
|
85
91
|
linkTarget: { type: 'string', default: 'target' },
|
|
86
|
-
nodeVal: { type: 'string', default: '' },
|
|
87
|
-
nodeRelSize: { type: 'number', default: 4 },
|
|
92
|
+
nodeVal: { type: 'string', default: '' },
|
|
93
|
+
nodeRelSize: { type: 'number', default: 4 },
|
|
88
94
|
nodeColor: { parse: parseAccessor, default: 'color' },
|
|
89
|
-
nodeAutoColorBy: { parse: parseAccessor, default: '' },
|
|
90
|
-
nodeResolution: { type: 'number', default: 8 },
|
|
95
|
+
nodeAutoColorBy: { parse: parseAccessor, default: '' },
|
|
96
|
+
nodeResolution: { type: 'number', default: 8 },
|
|
91
97
|
linkColor: { parse: parseAccessor, default: 'color' },
|
|
92
98
|
linkAutoColorBy: { parse: parseAccessor, default: '' },
|
|
93
99
|
linkWidth: { parse: parseAccessor, default: 0 },
|
|
94
|
-
linkResolution: { type: 'number', default: 6 },
|
|
100
|
+
linkResolution: { type: 'number', default: 6 },
|
|
95
101
|
linkLabel: { parse: parseAccessor, default: '' },
|
|
96
|
-
|
|
102
|
+
|
|
97
103
|
nodeDesc: { parse: parseAccessor, default: 'desc' },
|
|
98
104
|
linkDesc: { parse: parseAccessor, default: 'desc' },
|
|
99
105
|
nodeVisibility: { parse: parseAccessor, default: true },
|
|
100
106
|
nodeOpacity: { type: 'number', default: 1 },
|
|
101
107
|
linkVisibility: { parse: parseAccessor, default: true },
|
|
102
108
|
linkOpacity: { type: 'number', default: 1 },
|
|
103
|
-
|
|
109
|
+
|
|
104
110
|
nodeThreeObject: { parse: parseAccessor, default: null },
|
|
105
111
|
nodeThreeObjectExtend: { parse: parseAccessor, default: false },
|
|
106
112
|
linkCurvature: { parse: parseAccessor, default: 0 },
|
|
@@ -111,37 +117,38 @@ AFRAME.registerComponent('babia-network', {
|
|
|
111
117
|
linkPositionUpdate: { parse: parseFn, default: null },
|
|
112
118
|
linkDirectionalArrowLength: { parse: parseAccessor, default: 0 },
|
|
113
119
|
linkDirectionalArrowColor: { parse: parseAccessor, default: null },
|
|
114
|
-
linkDirectionalArrowRelPos: { parse: parseAccessor, default: 0.5 },
|
|
115
|
-
linkDirectionalArrowResolution: { type: 'number', default: 8 },
|
|
116
|
-
linkDirectionalParticles: { parse: parseAccessor, default: 0 },
|
|
117
|
-
linkDirectionalParticleSpeed: { parse: parseAccessor, default: 0.01 },
|
|
120
|
+
linkDirectionalArrowRelPos: { parse: parseAccessor, default: 0.5 },
|
|
121
|
+
linkDirectionalArrowResolution: { type: 'number', default: 8 },
|
|
122
|
+
linkDirectionalParticles: { parse: parseAccessor, default: 0 },
|
|
123
|
+
linkDirectionalParticleSpeed: { parse: parseAccessor, default: 0.01 },
|
|
118
124
|
linkDirectionalParticleWidth: { parse: parseAccessor, default: 0.5 },
|
|
119
125
|
linkDirectionalParticleColor: { parse: parseAccessor, default: null },
|
|
120
|
-
linkDirectionalParticleResolution: { type: 'number', default: 4 },
|
|
121
|
-
|
|
126
|
+
linkDirectionalParticleResolution: { type: 'number', default: 4 },
|
|
127
|
+
linkDistance: { type: 'number', default: 30 },
|
|
128
|
+
|
|
122
129
|
linkHoverPrecision: { type: 'number', default: 2 },
|
|
123
|
-
onNodeCenterHover: { parse: parseFn, default: function () {} },
|
|
124
|
-
onLinkCenterHover: { parse: parseFn, default: function () {} },
|
|
125
|
-
|
|
130
|
+
onNodeCenterHover: { parse: parseFn, default: function () { } },
|
|
131
|
+
onLinkCenterHover: { parse: parseFn, default: function () { } },
|
|
132
|
+
|
|
126
133
|
numDimensions: { type: 'number', default: 3 },
|
|
127
134
|
dagMode: { type: 'string', default: '' },
|
|
128
135
|
dagLevelDistance: { type: 'number', default: 0 },
|
|
129
|
-
dagNodeFilter: { parse: parseFn, function() { return true; }},
|
|
136
|
+
dagNodeFilter: { parse: parseFn, function() { return true; } },
|
|
130
137
|
onDagError: { parse: parseFn, default: undefined },
|
|
131
|
-
forceEngine: { type: 'string', default: 'd3' },
|
|
138
|
+
forceEngine: { type: 'string', default: 'd3' },
|
|
132
139
|
d3AlphaMin: { type: 'number', default: 0 },
|
|
133
140
|
d3AlphaDecay: { type: 'number', default: 0.0228 },
|
|
134
141
|
d3VelocityDecay: { type: 'number', default: 0.4 },
|
|
135
142
|
ngraphPhysics: { parse: parseJson, default: null },
|
|
136
|
-
warmupTicks: { type: 'int', default: 0 },
|
|
137
|
-
cooldownTicks: { type: 'int', default: 1e18 },
|
|
138
|
-
cooldownTime: { type: 'int', default: 15000 },
|
|
139
|
-
onEngineTick: { parse: parseFn, default: function () {} },
|
|
140
|
-
onEngineStop: { parse: parseFn, default: function () {} }
|
|
143
|
+
warmupTicks: { type: 'int', default: 0 },
|
|
144
|
+
cooldownTicks: { type: 'int', default: 1e18 },
|
|
145
|
+
cooldownTime: { type: 'int', default: 15000 },
|
|
146
|
+
onEngineTick: { parse: parseFn, default: function () { } },
|
|
147
|
+
onEngineStop: { parse: parseFn, default: function () { } }
|
|
141
148
|
},
|
|
142
149
|
|
|
143
150
|
// Bind component methods
|
|
144
|
-
getGraphBbox: function() {
|
|
151
|
+
getGraphBbox: function () {
|
|
145
152
|
if (!this.forceGraph) {
|
|
146
153
|
// Got here before component init -> initialize forceGraph
|
|
147
154
|
this.forceGraph = new ThreeForceGraph();
|
|
@@ -188,14 +195,17 @@ AFRAME.registerComponent('babia-network', {
|
|
|
188
195
|
return this;
|
|
189
196
|
},
|
|
190
197
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
198
|
+
/**
|
|
199
|
+
* List of visualization properties
|
|
200
|
+
*/
|
|
201
|
+
visProperties: {
|
|
202
|
+
'nodes': ['nodeId'],
|
|
203
|
+
'links0': ['linkId'],
|
|
204
|
+
'links1': ['linkSource', 'linkTarget']
|
|
205
|
+
},
|
|
197
206
|
|
|
198
207
|
init: function () {
|
|
208
|
+
const self = this;
|
|
199
209
|
this.isFirstTimeNodes = true;
|
|
200
210
|
this.isFirstTimeLinks = true;
|
|
201
211
|
|
|
@@ -220,6 +230,11 @@ AFRAME.registerComponent('babia-network', {
|
|
|
220
230
|
if (!this.forceGraph) this.forceGraph = new ThreeForceGraph(); // initialize forceGraph if it doesn't exist yet
|
|
221
231
|
this.el.object3D.add(this.forceGraph);
|
|
222
232
|
|
|
233
|
+
// Force distance if selected
|
|
234
|
+
if (this.data.linkDistance) {
|
|
235
|
+
this.forceGraph.d3Force('link').distance(function () { return self.data.linkDistance })
|
|
236
|
+
}
|
|
237
|
+
|
|
223
238
|
// setup cursor
|
|
224
239
|
setCursor();
|
|
225
240
|
},
|
|
@@ -233,22 +248,22 @@ AFRAME.registerComponent('babia-network', {
|
|
|
233
248
|
* Update or create chart component
|
|
234
249
|
*/
|
|
235
250
|
// Highest priority to data
|
|
236
|
-
if(elData.data && oldData.data !== elData.data){
|
|
251
|
+
if (elData.data && oldData.data !== elData.data) {
|
|
237
252
|
let _data = parseJson(elData.data);
|
|
238
253
|
this.processData(_data);
|
|
239
254
|
|
|
240
255
|
} else {
|
|
241
256
|
// Second highest priority to nodes and links
|
|
242
|
-
if (elData.nodes){
|
|
243
|
-
if(oldData.nodes !== elData.nodes){
|
|
257
|
+
if (elData.nodes) {
|
|
258
|
+
if (oldData.nodes !== elData.nodes) {
|
|
244
259
|
let _nodes = parseJson(elData.nodes);
|
|
245
260
|
this.processNodes(_nodes);
|
|
246
261
|
}
|
|
247
|
-
if (oldData.links !== elData.links){
|
|
262
|
+
if (oldData.links !== elData.links) {
|
|
248
263
|
let _links = parseJson(elData.links);
|
|
249
264
|
this.processLinks(_links)
|
|
250
265
|
}
|
|
251
|
-
|
|
266
|
+
// Data from querier
|
|
252
267
|
} else {
|
|
253
268
|
// If changed from, need to re-register to the new data component
|
|
254
269
|
if (elData.from !== oldData.from && !elData.nodesFrom) {
|
|
@@ -256,17 +271,17 @@ AFRAME.registerComponent('babia-network', {
|
|
|
256
271
|
if (this.prodComponent) {
|
|
257
272
|
this.prodComponent.notiBuffer.unregister(this.notiBufferId)
|
|
258
273
|
};
|
|
259
|
-
if (this.nodesProdComponent){
|
|
274
|
+
if (this.nodesProdComponent) {
|
|
260
275
|
this.nodesProdComponent.notiBuffer.unregister(this.notiBufferId)
|
|
261
276
|
};
|
|
262
|
-
if (this.linksProdComponent){
|
|
277
|
+
if (this.linksProdComponent) {
|
|
263
278
|
this.linksProdComponent.notiBuffer.unregister(this.notiBufferId)
|
|
264
279
|
};
|
|
265
|
-
|
|
266
|
-
this.prodComponent = findProdComponent
|
|
267
|
-
if (this.prodComponent.notiBuffer){
|
|
280
|
+
|
|
281
|
+
this.prodComponent = findProdComponent(elData, el)
|
|
282
|
+
if (this.prodComponent.notiBuffer) {
|
|
268
283
|
this.notiBufferId = this.prodComponent.notiBuffer
|
|
269
|
-
|
|
284
|
+
.register(this.processData.bind(this))
|
|
270
285
|
}
|
|
271
286
|
} else if (elData.nodesFrom !== oldData.nodesFrom || elData.linksFrom !== oldData.linksFrom) {
|
|
272
287
|
// Now we have nodesFrom, should have linksFrom too
|
|
@@ -274,36 +289,36 @@ AFRAME.registerComponent('babia-network', {
|
|
|
274
289
|
if (this.prodComponent) {
|
|
275
290
|
this.prodComponent.notiBuffer.unregister(this.notiBufferId)
|
|
276
291
|
};
|
|
277
|
-
if (this.nodesProdComponent){
|
|
292
|
+
if (this.nodesProdComponent) {
|
|
278
293
|
this.nodesProdComponent.notiBuffer.unregister(this.notiBufferId)
|
|
279
294
|
};
|
|
280
|
-
if (this.linksProdComponent){
|
|
295
|
+
if (this.linksProdComponent) {
|
|
281
296
|
this.linksProdComponent.notiBuffer.unregister(this.notiBufferId)
|
|
282
297
|
};
|
|
283
|
-
|
|
284
|
-
let prodComponent = findProdComponent
|
|
285
|
-
|
|
298
|
+
|
|
299
|
+
let prodComponent = findProdComponent(elData, el)
|
|
300
|
+
|
|
286
301
|
// First, nodes
|
|
287
302
|
this.nodesProdComponent = prodComponent.nodes
|
|
288
|
-
if (this.nodesProdComponent.notiBuffer){
|
|
303
|
+
if (this.nodesProdComponent.notiBuffer) {
|
|
289
304
|
this.notiBufferId = this.nodesProdComponent.notiBuffer
|
|
290
|
-
|
|
305
|
+
.register(this.processNodes.bind(this))
|
|
291
306
|
}
|
|
292
|
-
|
|
307
|
+
|
|
293
308
|
// Now, the same for links
|
|
294
309
|
this.linksProdComponent = prodComponent.links
|
|
295
|
-
if (this.linksProdComponent.notiBuffer){
|
|
310
|
+
if (this.linksProdComponent.notiBuffer) {
|
|
296
311
|
this.notiBufferId = this.linksProdComponent.notiBuffer
|
|
297
|
-
|
|
312
|
+
.register(this.processLinks.bind(this))
|
|
298
313
|
}
|
|
299
|
-
}
|
|
300
|
-
|
|
314
|
+
}
|
|
315
|
+
|
|
301
316
|
// If changed whatever, re-print with the current data
|
|
302
317
|
else if (elData !== oldData) {
|
|
303
|
-
if (this.newData){
|
|
318
|
+
if (this.newData) {
|
|
304
319
|
let _data = parseJson(this.newData);
|
|
305
320
|
this.processData(_data, true)
|
|
306
|
-
} else if (this.newNodes){
|
|
321
|
+
} else if (this.newNodes) {
|
|
307
322
|
if (elData.linkSource != oldData.linkSource || elData.linkTarget != oldData.linkTarget) {
|
|
308
323
|
let _links = parseJson(this.newLinks);
|
|
309
324
|
this.processLinks(_links, true)
|
|
@@ -311,57 +326,63 @@ AFRAME.registerComponent('babia-network', {
|
|
|
311
326
|
let _nodes = parseJson(this.newNodes);
|
|
312
327
|
this.processNodes(_nodes, true)
|
|
313
328
|
}
|
|
314
|
-
|
|
329
|
+
|
|
315
330
|
}
|
|
316
331
|
}
|
|
317
332
|
}
|
|
318
|
-
}
|
|
333
|
+
}
|
|
319
334
|
},
|
|
320
335
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
336
|
+
/**
|
|
337
|
+
* Called on each scene tick.
|
|
338
|
+
*/
|
|
324
339
|
tick: function (t, td) {
|
|
340
|
+
// Cursor may not be initialized
|
|
341
|
+
if (!cursor) {
|
|
342
|
+
cursor = document.querySelector('[cursor]');
|
|
343
|
+
} else {
|
|
344
|
+
if (cursor.components.raycaster.raycaster) {
|
|
345
|
+
let intersects = cursor.components.raycaster.raycaster.intersectObjects(this.forceGraph.children)
|
|
346
|
+
.filter(function (o) { // Check only node/link objects
|
|
347
|
+
return ['node', 'link'].indexOf(o.object.__graphObjType) !== -1;
|
|
348
|
+
})
|
|
349
|
+
.sort(function (a, b) { // Prioritize nodes over links
|
|
350
|
+
return isNode(b) - isNode(a);
|
|
351
|
+
function isNode(o) { return o.object.__graphObjType === 'node'; }
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
let topObject = intersects.length ? intersects[0].object : null;
|
|
355
|
+
|
|
356
|
+
if (topObject !== this.state.hoverObj) {
|
|
357
|
+
const prevObjType = this.state.hoverObj ? this.state.hoverObj.__graphObjType : null;
|
|
358
|
+
const prevObjData = this.state.hoverObj ? this.state.hoverObj.__data : null;
|
|
359
|
+
const objType = topObject ? topObject.__graphObjType : null;
|
|
360
|
+
const objData = topObject ? topObject.__data : null;
|
|
361
|
+
|
|
362
|
+
if (prevObjType && prevObjType !== objType) {
|
|
363
|
+
// Hover out
|
|
364
|
+
this.data['on' + (prevObjType === 'node' ? 'Node' : 'Link') + 'CenterHover'](null, prevObjData);
|
|
365
|
+
}
|
|
366
|
+
if (this.data.nodeLegend && prevObjType === 'node') {
|
|
367
|
+
this.removeLegend(this)
|
|
368
|
+
} else if (this.data.linkLegend && this.data.linkLabel != "" && prevObjType === 'link') {
|
|
369
|
+
this.removeLegend(this)
|
|
370
|
+
}
|
|
371
|
+
if (objType) {
|
|
372
|
+
// Hover in
|
|
373
|
+
this.data['on' + (objType === 'node' ? 'Node' : 'Link') + 'CenterHover'](objData, prevObjType === objType ? prevObjData : null);
|
|
374
|
+
}
|
|
325
375
|
|
|
326
|
-
|
|
327
|
-
.filter(function (o) { // Check only node/link objects
|
|
328
|
-
return ['node', 'link'].indexOf(o.object.__graphObjType) !== -1;
|
|
329
|
-
})
|
|
330
|
-
.sort(function (a, b) { // Prioritize nodes over links
|
|
331
|
-
return isNode(b) - isNode(a);
|
|
332
|
-
function isNode (o) { return o.object.__graphObjType === 'node'; }
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
let topObject = intersects.length ? intersects[0].object : null;
|
|
336
|
-
|
|
337
|
-
if (topObject !== this.state.hoverObj) {
|
|
338
|
-
const prevObjType = this.state.hoverObj ? this.state.hoverObj.__graphObjType : null;
|
|
339
|
-
const prevObjData = this.state.hoverObj ? this.state.hoverObj.__data : null;
|
|
340
|
-
const objType = topObject ? topObject.__graphObjType : null;
|
|
341
|
-
const objData = topObject ? topObject.__data : null;
|
|
342
|
-
|
|
343
|
-
if (prevObjType && prevObjType !== objType) {
|
|
344
|
-
// Hover out
|
|
345
|
-
this.data['on' + (prevObjType === 'node' ? 'Node' : 'Link') + 'CenterHover'](null, prevObjData);
|
|
346
|
-
}
|
|
347
|
-
if (this.data.nodeLegend && prevObjType === 'node' ){
|
|
348
|
-
this.removeLegend(this)
|
|
349
|
-
} else if(this.data.linkLegend && this.data.linkLabel!="" && prevObjType === 'link'){
|
|
350
|
-
this.removeLegend(this)
|
|
351
|
-
}
|
|
352
|
-
if (objType) {
|
|
353
|
-
// Hover in
|
|
354
|
-
this.data['on' + (objType === 'node' ? 'Node' : 'Link') + 'CenterHover'](objData, prevObjType === objType ? prevObjData : null);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
this.state.hoverObj = topObject;
|
|
376
|
+
this.state.hoverObj = topObject;
|
|
358
377
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
378
|
+
if (topObject) {
|
|
379
|
+
if (this.data.nodeLegend && topObject.__graphObjType === 'node') {
|
|
380
|
+
this.showLegend(topObject, topObject.__data, this.data.nodeLabel, this.el.getAttribute("scale"))
|
|
381
|
+
} else if (this.data.linkLegend && topObject.__graphObjType === 'link') {
|
|
382
|
+
if (this.data.linkLabel != "") {
|
|
383
|
+
this.showLinkLegend(topObject, topObject.__data, this.data.linkLabel, this.el.getAttribute("scale"))
|
|
384
|
+
}
|
|
385
|
+
}
|
|
365
386
|
}
|
|
366
387
|
}
|
|
367
388
|
}
|
|
@@ -389,7 +410,7 @@ AFRAME.registerComponent('babia-network', {
|
|
|
389
410
|
newData: undefined,
|
|
390
411
|
newNodes: undefined,
|
|
391
412
|
newLinks: undefined,
|
|
392
|
-
|
|
413
|
+
|
|
393
414
|
|
|
394
415
|
/**
|
|
395
416
|
* Boolean to know if it's first time for getting the ui fields
|
|
@@ -421,12 +442,12 @@ AFRAME.registerComponent('babia-network', {
|
|
|
421
442
|
* Update chart
|
|
422
443
|
*/
|
|
423
444
|
updateChart: function (nodes_links, self) {
|
|
424
|
-
if (self.currentData){
|
|
445
|
+
if (self.currentData) {
|
|
425
446
|
let elData = [];
|
|
426
|
-
for (let attr in this.data){
|
|
447
|
+
for (let attr in this.data) {
|
|
427
448
|
elData[attr] = this.data[attr]
|
|
428
449
|
}
|
|
429
|
-
|
|
450
|
+
|
|
430
451
|
elData.nodes = nodes_links.nodes;
|
|
431
452
|
elData.links = nodes_links.links;
|
|
432
453
|
|
|
@@ -482,13 +503,13 @@ AFRAME.registerComponent('babia-network', {
|
|
|
482
503
|
'onEngineTick',
|
|
483
504
|
'onEngineStop'
|
|
484
505
|
];
|
|
485
|
-
|
|
506
|
+
|
|
486
507
|
fgProps
|
|
487
508
|
.filter(function (p) { return p in diff; })
|
|
488
509
|
.forEach(function (p) {
|
|
489
510
|
self.forceGraph[p](elData[p] !== '' ? elData[p] : null);
|
|
490
511
|
}); // Convert blank values into nulls
|
|
491
|
-
|
|
512
|
+
|
|
492
513
|
if ('nodes' in diff || 'links' in diff) {
|
|
493
514
|
self.forceGraph.graphData({
|
|
494
515
|
nodes: elData.nodes,
|
|
@@ -503,27 +524,27 @@ AFRAME.registerComponent('babia-network', {
|
|
|
503
524
|
*/
|
|
504
525
|
processData: function (_data, newData) {
|
|
505
526
|
console.log("processData", this);
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
527
|
+
if (this.newData != _data || newData) {
|
|
528
|
+
this.newData = _data;
|
|
529
|
+
let nodes_links = this.elDataFromData(_data);
|
|
530
|
+
this.babiaMetadata = { id: this.babiaMetadata.id++ };
|
|
531
|
+
console.log("Generating network...")
|
|
532
|
+
this.updateChart(nodes_links, this)
|
|
533
|
+
this.notiBuffer.set(_data)
|
|
534
|
+
}
|
|
514
535
|
},
|
|
515
536
|
|
|
516
|
-
processNodes: function (nodes, forceProcess){
|
|
537
|
+
processNodes: function (nodes, forceProcess) {
|
|
517
538
|
console.log("processNodes", this);
|
|
518
|
-
if (this.newNodes != nodes || forceProcess){
|
|
539
|
+
if (this.newNodes != nodes || forceProcess) {
|
|
519
540
|
this.newNodes = nodes;
|
|
520
541
|
let nodes_links = this.elDataFromNodesAndLinks(nodes, this.newLinks)
|
|
521
|
-
|
|
522
|
-
if (!nodes_links){
|
|
542
|
+
|
|
543
|
+
if (!nodes_links) {
|
|
523
544
|
if (this.data.links) {
|
|
524
545
|
let _links = parseJson(this.data.links);
|
|
525
546
|
this.processLinks(_links)
|
|
526
|
-
} else if (this.data.linksFrom){
|
|
547
|
+
} else if (this.data.linksFrom) {
|
|
527
548
|
this.babiaMetadata = { id: this.babiaMetadata.id++ }
|
|
528
549
|
console.log("Generating network...")
|
|
529
550
|
}
|
|
@@ -531,22 +552,22 @@ AFRAME.registerComponent('babia-network', {
|
|
|
531
552
|
this.babiaMetadata = { id: this.babiaMetadata.id++ }
|
|
532
553
|
console.log("Generating network...")
|
|
533
554
|
this.updateChart(nodes_links, this)
|
|
534
|
-
this.notiBuffer.set({'nodes': nodes_links.nodes, 'links': nodes_links.links})
|
|
555
|
+
this.notiBuffer.set({ 'nodes': nodes_links.nodes, 'links': nodes_links.links })
|
|
535
556
|
}
|
|
536
557
|
}
|
|
537
558
|
},
|
|
538
559
|
|
|
539
|
-
processLinks: function (_links, forceProcess){
|
|
560
|
+
processLinks: function (_links, forceProcess) {
|
|
540
561
|
console.log("processLinks", this);
|
|
541
562
|
let links = parseJson(_links);
|
|
542
|
-
if (this.newLinks != links || forceProcess){
|
|
563
|
+
if (this.newLinks != links || forceProcess) {
|
|
543
564
|
this.newLinks = links;
|
|
544
565
|
let nodes_links = this.elDataFromNodesAndLinks(this.newNodes, links)
|
|
545
|
-
if (!nodes_links){
|
|
566
|
+
if (!nodes_links) {
|
|
546
567
|
if (this.data.nodes) {
|
|
547
568
|
let _nodes = parseJson(this.data.nodes);
|
|
548
569
|
this.processNodes(_nodes)
|
|
549
|
-
} else if (this.data.nodesFrom){
|
|
570
|
+
} else if (this.data.nodesFrom) {
|
|
550
571
|
this.babiaMetadata = { id: this.babiaMetadata.id++ }
|
|
551
572
|
console.log("Generating network...")
|
|
552
573
|
}
|
|
@@ -554,15 +575,15 @@ AFRAME.registerComponent('babia-network', {
|
|
|
554
575
|
this.babiaMetadata = { id: this.babiaMetadata.id++ }
|
|
555
576
|
console.log("Generating network...")
|
|
556
577
|
this.updateChart(nodes_links, this)
|
|
557
|
-
this.notiBuffer.set({'nodes': nodes_links.nodes, 'links': nodes_links.links})
|
|
578
|
+
this.notiBuffer.set({ 'nodes': nodes_links.nodes, 'links': nodes_links.links })
|
|
558
579
|
}
|
|
559
580
|
}
|
|
560
581
|
},
|
|
561
582
|
// Format from data to nodes and links
|
|
562
|
-
elDataFromData: function(data){
|
|
583
|
+
elDataFromData: function (data) {
|
|
563
584
|
let nodes = [];
|
|
564
585
|
let links = [];
|
|
565
|
-
|
|
586
|
+
|
|
566
587
|
const nodeId = this.data.nodeId;
|
|
567
588
|
const linkId = this.data.linkId;
|
|
568
589
|
const nodeVal = this.data.nodeVal;
|
|
@@ -576,10 +597,10 @@ AFRAME.registerComponent('babia-network', {
|
|
|
576
597
|
Object.keys(element).forEach(function (k) {
|
|
577
598
|
if (k === nodeId) {
|
|
578
599
|
node[nodeId] = element[k];
|
|
579
|
-
}
|
|
600
|
+
}
|
|
580
601
|
if (k === linkId) {
|
|
581
602
|
node.linkId = element[k];
|
|
582
|
-
}
|
|
603
|
+
}
|
|
583
604
|
if (k === nodeVal) {
|
|
584
605
|
node[nodeVal] = element[k];
|
|
585
606
|
}
|
|
@@ -591,7 +612,7 @@ AFRAME.registerComponent('babia-network', {
|
|
|
591
612
|
nodes.forEach(secondNode => {
|
|
592
613
|
if (firstNode[nodeId] !== secondNode[nodeId]) { // not same id
|
|
593
614
|
if (firstNode.linkId === secondNode.linkId) { // same linkId, make link
|
|
594
|
-
if (links.length > 0){
|
|
615
|
+
if (links.length > 0) {
|
|
595
616
|
let linkExists = false;
|
|
596
617
|
links.forEach(link => {
|
|
597
618
|
if ((link[source] === firstNode[nodeId] && link[target] === secondNode[nodeId]) || (link[source] === secondNode[nodeId] && link[target] === firstNode[nodeId])) { // the link does already exists, in any direction
|
|
@@ -613,40 +634,40 @@ AFRAME.registerComponent('babia-network', {
|
|
|
613
634
|
newLink[source] = firstNode[nodeId]
|
|
614
635
|
newLink[target] = secondNode[nodeId]
|
|
615
636
|
links.push(newLink);
|
|
616
|
-
}
|
|
637
|
+
}
|
|
617
638
|
}
|
|
618
639
|
}
|
|
619
640
|
})
|
|
620
641
|
});
|
|
621
|
-
|
|
622
|
-
return {nodes: nodes, links: links};
|
|
642
|
+
|
|
643
|
+
return { nodes: nodes, links: links };
|
|
623
644
|
},
|
|
624
645
|
|
|
625
646
|
// Format nodes and links
|
|
626
647
|
|
|
627
|
-
elDataFromNodesAndLinks: function(nodes, links) {
|
|
648
|
+
elDataFromNodesAndLinks: function (nodes, links) {
|
|
628
649
|
if (!Array.isArray(nodes) || !Array.isArray(links)) {
|
|
629
650
|
// Either nodes or links are not ready yet
|
|
630
651
|
return false
|
|
631
652
|
}
|
|
632
653
|
|
|
633
|
-
if (this.isFirstTimeNodes){
|
|
654
|
+
if (this.isFirstTimeNodes) {
|
|
634
655
|
this.nodeFields = []
|
|
635
656
|
Object.keys(nodes[0]).forEach((k) => {
|
|
636
|
-
|
|
657
|
+
this.nodeFields.push(k)
|
|
637
658
|
})
|
|
638
659
|
this.isFirstTimeNodes = false;
|
|
639
660
|
}
|
|
640
|
-
if (this.isFirstTimeLinks){
|
|
661
|
+
if (this.isFirstTimeLinks) {
|
|
641
662
|
this.linkFields = []
|
|
642
663
|
Object.keys(links[0]).forEach((k) => {
|
|
643
|
-
|
|
664
|
+
this.linkFields.push(k)
|
|
644
665
|
})
|
|
645
666
|
this.isFirstTimeLinks = false;
|
|
646
667
|
}
|
|
647
668
|
|
|
648
|
-
if (typeof(links[0].source) === 'object') {
|
|
649
|
-
links.forEach
|
|
669
|
+
if (typeof (links[0].source) === 'object') {
|
|
670
|
+
links.forEach((link) => {
|
|
650
671
|
link.source = link.source[this.data.nodeId];
|
|
651
672
|
link.target = link.target[this.data.nodeId];
|
|
652
673
|
})
|
|
@@ -656,8 +677,8 @@ AFRAME.registerComponent('babia-network', {
|
|
|
656
677
|
nodes.forEach((node) => {
|
|
657
678
|
let _node = {};
|
|
658
679
|
Object.keys(node).forEach((k) => {
|
|
659
|
-
for (let f in this.nodeFields){
|
|
660
|
-
if (k == this.nodeFields[f]){
|
|
680
|
+
for (let f in this.nodeFields) {
|
|
681
|
+
if (k == this.nodeFields[f]) {
|
|
661
682
|
_node[k] = node[k]
|
|
662
683
|
}
|
|
663
684
|
}
|
|
@@ -669,8 +690,8 @@ AFRAME.registerComponent('babia-network', {
|
|
|
669
690
|
links.forEach((link) => {
|
|
670
691
|
let _link = {};
|
|
671
692
|
Object.keys(link).forEach((k) => {
|
|
672
|
-
for (let f in this.linkFields){
|
|
673
|
-
if (k == this.linkFields[f] && k != this.data.linkId){
|
|
693
|
+
for (let f in this.linkFields) {
|
|
694
|
+
if (k == this.linkFields[f] && k != this.data.linkId) {
|
|
674
695
|
_link[k] = link[k]
|
|
675
696
|
}
|
|
676
697
|
}
|
|
@@ -679,122 +700,157 @@ AFRAME.registerComponent('babia-network', {
|
|
|
679
700
|
|
|
680
701
|
})
|
|
681
702
|
|
|
682
|
-
return {nodes: _nodes, links: _links};
|
|
703
|
+
return { nodes: _nodes, links: _links };
|
|
683
704
|
},
|
|
684
|
-
|
|
705
|
+
|
|
685
706
|
showLegend: function (nodeThree, node, nodeLabel, scale) {
|
|
686
707
|
let worldPosition = new THREE.Vector3();
|
|
687
708
|
nodeThree.getWorldPosition(worldPosition);
|
|
688
709
|
let radius = nodeThree.geometry.boundingSphere.radius
|
|
689
710
|
let sceneEl = document.querySelector('a-scene');
|
|
690
|
-
this.legend = generateLegend(node, nodeLabel, worldPosition, radius, scale);
|
|
691
|
-
if (this.legend){
|
|
711
|
+
this.legend = generateLegend(this.data, node, nodeLabel, worldPosition, radius, scale);
|
|
712
|
+
if (this.legend) {
|
|
692
713
|
sceneEl.appendChild(this.legend);
|
|
693
714
|
}
|
|
694
715
|
},
|
|
695
716
|
|
|
696
|
-
showLinkLegend: function(linkThree, link, linkLabel, scale) {
|
|
717
|
+
showLinkLegend: function (linkThree, link, linkLabel, scale) {
|
|
697
718
|
let worldPosition = new THREE.Vector3();
|
|
698
719
|
let radius = linkThree.geometry.boundingSphere.radius
|
|
699
|
-
|
|
720
|
+
|
|
700
721
|
let sourcePos = new THREE.Vector3();
|
|
701
722
|
let targetPos = new THREE.Vector3();
|
|
702
|
-
|
|
723
|
+
|
|
703
724
|
let nodes = this.forceGraph.children.filter(element => element.__graphObjType == "node")
|
|
704
|
-
|
|
725
|
+
|
|
705
726
|
nodes.forEach(node => {
|
|
706
|
-
if(node.__data[this.data.nodeId] == link.source[this.data.nodeId]){
|
|
727
|
+
if (node.__data[this.data.nodeId] == link.source[this.data.nodeId]) {
|
|
707
728
|
node.getWorldPosition(sourcePos)
|
|
708
729
|
}
|
|
709
|
-
if(node.__data[this.data.nodeId] == link.target[this.data.nodeId]){
|
|
730
|
+
if (node.__data[this.data.nodeId] == link.target[this.data.nodeId]) {
|
|
710
731
|
node.getWorldPosition(targetPos)
|
|
711
732
|
}
|
|
712
733
|
})
|
|
713
|
-
|
|
714
|
-
worldPosition.x = (sourcePos.x + targetPos.x)/2
|
|
715
|
-
worldPosition.y = (sourcePos.y + targetPos.y)/2
|
|
716
|
-
worldPosition.z = (sourcePos.z + targetPos.z)/2
|
|
717
|
-
|
|
734
|
+
|
|
735
|
+
worldPosition.x = (sourcePos.x + targetPos.x) / 2
|
|
736
|
+
worldPosition.y = (sourcePos.y + targetPos.y) / 2
|
|
737
|
+
worldPosition.z = (sourcePos.z + targetPos.z) / 2
|
|
738
|
+
|
|
718
739
|
let sceneEl = document.querySelector('a-scene');
|
|
719
|
-
this.legend = generateLinkLegend(link, linkLabel, worldPosition, radius, scale);
|
|
720
|
-
if (this.legend){
|
|
740
|
+
this.legend = generateLinkLegend(this.data, link, linkLabel, worldPosition, radius, scale);
|
|
741
|
+
if (this.legend) {
|
|
721
742
|
sceneEl.appendChild(this.legend);
|
|
722
743
|
}
|
|
723
744
|
},
|
|
724
|
-
|
|
725
|
-
removeLegend: function() {
|
|
726
|
-
if (this.legend){
|
|
745
|
+
|
|
746
|
+
removeLegend: function () {
|
|
747
|
+
if (this.legend) {
|
|
727
748
|
let sceneEl = document.querySelector('a-scene');
|
|
728
749
|
sceneEl.removeChild(this.legend)
|
|
729
750
|
}
|
|
730
751
|
}
|
|
731
752
|
});
|
|
732
753
|
|
|
733
|
-
function generateLegend(node, nodeLabel, nodePosition, radius, scale) {
|
|
734
|
-
let
|
|
735
|
-
if (
|
|
754
|
+
function generateLegend(data, node, nodeLabel, nodePosition, radius, scale) {
|
|
755
|
+
let name = node[nodeLabel];
|
|
756
|
+
if (name) {
|
|
736
757
|
let width = 2;
|
|
758
|
+
let height = 1;
|
|
759
|
+
|
|
760
|
+
if (name.length > 16)
|
|
761
|
+
width = name.length / 5;
|
|
762
|
+
|
|
763
|
+
if (data) {
|
|
764
|
+
let radiusText = "\n " + data.nodeVal + " (radius): " + Math.round(node[data.nodeVal] * 100) / 100
|
|
765
|
+
if (radiusText.length > 16)
|
|
766
|
+
width = radiusText.length / 5;
|
|
767
|
+
name += radiusText
|
|
768
|
+
|
|
769
|
+
if (data.nodeAutoColorBy) {
|
|
770
|
+
let autoColorText = "\n " + data.nodeAutoColorBy + " (color): " + node[data.nodeAutoColorBy]
|
|
771
|
+
if (autoColorText.length > 16 && autoColorText > radiusText)
|
|
772
|
+
width = autoColorText.length / 5;
|
|
773
|
+
name += autoColorText
|
|
774
|
+
} else {
|
|
775
|
+
let autoColorText = "\n " + data.nodeAutoColorBy + " (color): " + node[data.nodeAutoColorBy]
|
|
776
|
+
if (autoColorText.length > 16 && autoColorText > radiusText)
|
|
777
|
+
width = autoColorText.length / 5;
|
|
778
|
+
name += autoColorText
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
|
|
737
784
|
let x = 3;
|
|
738
785
|
let y = 3;
|
|
739
786
|
let z = 3;
|
|
740
|
-
if (
|
|
741
|
-
width =
|
|
742
|
-
if(scale){
|
|
743
|
-
x = x * scale.x;
|
|
744
|
-
y = y * scale.y;
|
|
745
|
-
z = z * scale.z;
|
|
746
|
-
radius = (radius + 3) * scale.y;
|
|
787
|
+
if (name.length > 16)
|
|
788
|
+
width = name.length / 16;
|
|
789
|
+
if (scale) {
|
|
790
|
+
x = x * scale.x * data.legend_scale;
|
|
791
|
+
y = y * scale.y * data.legend_scale;
|
|
792
|
+
z = z * scale.z * data.legend_scale;
|
|
793
|
+
radius = (radius + 3) * scale.y * data.legend_scale;
|
|
747
794
|
}
|
|
748
|
-
|
|
795
|
+
|
|
749
796
|
let entity = document.createElement('a-plane');
|
|
750
|
-
entity.setAttribute('position', {x: nodePosition.x, y: nodePosition.y + radius, z: nodePosition.z})
|
|
751
|
-
entity.setAttribute('babia-lookat',
|
|
797
|
+
entity.setAttribute('position', { x: nodePosition.x, y: nodePosition.y + radius, z: nodePosition.z })
|
|
798
|
+
entity.setAttribute('babia-lookat', data.legend_lookat);
|
|
752
799
|
entity.setAttribute('width', width);
|
|
753
|
-
entity.setAttribute('height',
|
|
800
|
+
entity.setAttribute('height', height);
|
|
754
801
|
entity.setAttribute('color', 'white');
|
|
755
|
-
entity.setAttribute('scale', {x: x, y: y, z: z})
|
|
802
|
+
entity.setAttribute('scale', { x: x * data.legend_scale, y: y * data.legend_scale, z: z * data.legend_scale })
|
|
803
|
+
entity.setAttribute('material', { 'side': 'double' });
|
|
756
804
|
entity.setAttribute('text', {
|
|
757
|
-
'value':
|
|
805
|
+
'value': name,
|
|
758
806
|
'align': 'center',
|
|
759
807
|
'width': 6,
|
|
760
|
-
'color': 'black'
|
|
808
|
+
'color': 'black',
|
|
809
|
+
'alphaTest': 6,
|
|
810
|
+
'opacity': 6,
|
|
811
|
+
'transparent': false
|
|
761
812
|
});
|
|
813
|
+
|
|
762
814
|
entity.classList.add("babiaxrLegend")
|
|
763
815
|
return entity;
|
|
764
|
-
}
|
|
816
|
+
}
|
|
765
817
|
}
|
|
766
818
|
|
|
767
|
-
function generateLinkLegend(link, linkLabel, linkPosition, radius, scale) {
|
|
819
|
+
function generateLinkLegend(data, link, linkLabel, linkPosition, radius, scale) {
|
|
768
820
|
let text = link[linkLabel];
|
|
769
|
-
if (text){
|
|
821
|
+
if (text) {
|
|
770
822
|
let width = 2;
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
823
|
+
let x = 3;
|
|
824
|
+
let y = 3;
|
|
825
|
+
let z = 3;
|
|
826
|
+
if (text.length > 16)
|
|
827
|
+
width = text.length / 8;
|
|
828
|
+
if (scale) {
|
|
777
829
|
x = x * scale.x;
|
|
778
830
|
y = y * scale.y;
|
|
779
831
|
z = z * scale.z;
|
|
780
832
|
radius = (radius + 3) * scale.y;
|
|
781
|
-
|
|
833
|
+
}
|
|
782
834
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
'
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
835
|
+
let entity = document.createElement('a-plane');
|
|
836
|
+
entity.setAttribute('position', { x: linkPosition.x, y: linkPosition.y + radius, z: linkPosition.z })
|
|
837
|
+
entity.setAttribute('babia-lookat', data.legend_lookat);
|
|
838
|
+
entity.setAttribute('width', width);
|
|
839
|
+
entity.setAttribute('height', '1');
|
|
840
|
+
entity.setAttribute('color', 'white');
|
|
841
|
+
entity.setAttribute('scale', { x: x * data.legend_scale, y: y * data.legend_scale, z: z * data.legend_scale })
|
|
842
|
+
entity.setAttribute('material', { 'side': 'double' });
|
|
843
|
+
entity.setAttribute('text', {
|
|
844
|
+
'value': link[linkLabel],
|
|
845
|
+
'align': 'center',
|
|
846
|
+
'width': 6,
|
|
847
|
+
'color': 'black',
|
|
848
|
+
'alphaTest': 6,
|
|
849
|
+
'opacity': 6,
|
|
850
|
+
'transparent': false
|
|
851
|
+
});
|
|
852
|
+
entity.classList.add("babiaxrLegend")
|
|
853
|
+
return entity;
|
|
798
854
|
}
|
|
799
855
|
}
|
|
800
856
|
|