aframe-babia-components 1.2.8 → 1.3.0
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 +33 -21
- package/components/filters/babia-treebuilder.js +14 -13
- package/components/others/babia-navigator.js +94 -37
- package/components/others/babia-poster.js +369 -368
- package/components/others/babia-slider.js +63 -25
- package/components/others/common.js +60 -80
- package/components/visualizers/babia-doughnut.js +2 -1
- package/components/visualizers/babia-html.js +95 -118
- package/components/visualizers/babia-map.js +796 -0
- package/components/visualizers/babia-pie.js +2 -1
- package/dist/aframe-babia-components.js +7247 -6488
- package/dist/aframe-babia-components.min.js +1 -1
- package/dist/aframe-babia-components.min.js.LICENSE.txt +1 -1
- package/dist/aframe-babia-components.min.js.map +1 -1
- package/docs/APIs/OTHERS.md +4 -4
- package/docs/CONTRIBUTING.md +34 -25
- package/docs/RELEASE_NOTES.md +13 -2
- package/docs/Tutorials/HOW_TO_USE_BABIA_MAP.md +554 -0
- package/docs/Tutorials/ejemplo1.png +0 -0
- package/docs/Tutorials/ejemplo2.png +0 -0
- package/docs/Tutorials/ejemplo3.png +0 -0
- package/docs/Tutorials/pyramids.png +0 -0
- package/docs/Tutorials/singular.png +0 -0
- package/docs/Tutorials/terrain-vr-scenario.png +0 -0
- package/docs/Tutorials/terrain.png +0 -0
- package/examples/boats/boats2/data.json +206 -13
- package/examples/demos/map-terrain/assets/360-panorama.jpg +0 -0
- package/examples/demos/map-terrain/assets/floor-texture.jpg +0 -0
- package/examples/demos/map-terrain/assets/mapTextures/512sample.webp +0 -0
- package/examples/demos/map-terrain/assets/mapTextures/defaultTexture.webp +0 -0
- package/examples/demos/map-terrain/assets/maps/defaultMap.png +0 -0
- package/examples/demos/map-terrain/assets/maps/example.png +0 -0
- package/examples/demos/map-terrain/assets/metalic-texture.jpg +0 -0
- package/examples/demos/map-terrain/dist/aframe-lounge-component.min.js +1 -0
- package/examples/demos/map-terrain/index.html +82 -0
- package/examples/demos/map-terrain/index_gallery.html +188 -0
- package/examples/demos/map-terrain/main_data.json +1 -0
- package/examples/demos/map-terrain/pyramids.html +130 -0
- package/examples/js/aframe-orbit-controls-component.js +1060 -0
- package/examples/ui/pie/index.html +0 -1
- package/index.html +15 -0
- package/index.js +1 -0
- package/package.json +5 -5
- package/tests/screenshots/other_snapshots.js/pyramids.png +0 -0
- package/tests/screenshots/other_snapshots.js/singular.png +0 -0
- package/tests/screenshots/other_snapshots.js/terrain-vr-scenario.png +0 -0
- package/tests/screenshots/other_snapshots.js/terrain.png +0 -0
- package/webpack.common.js +1 -1
- package/webpack.dev.js +17 -0
- package/examples/demos/citations/babiaxr.json +0 -1
- package/examples/demos/citations/citations.html +0 -72
- package/examples/demos/citations/music.mp3 +0 -0
- package/examples/demos/citations/stl.js +0 -28
|
@@ -24,7 +24,7 @@ AFRAME.registerComponent('babia-slider', {
|
|
|
24
24
|
let material = new THREE.MeshBasicMaterial({ color: this.data.color });
|
|
25
25
|
this.material = material
|
|
26
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.
|
|
27
|
+
let track = new THREE.Mesh(new THREE.CylinderGeometry(0.03, 0.03, this.data.size, 12), material);
|
|
28
28
|
track.rotateZ(Math.PI / 2);
|
|
29
29
|
let chassis = new THREE.Group();
|
|
30
30
|
|
|
@@ -202,35 +202,73 @@ AFRAME.registerComponent('babia-slider', {
|
|
|
202
202
|
},
|
|
203
203
|
|
|
204
204
|
mousexPositionToValue: function (x) {
|
|
205
|
-
|
|
206
|
-
let
|
|
207
|
-
|
|
208
|
-
let sliderMin = sliderCenter - (sliderWidth / 2)
|
|
205
|
+
// Create a THREE.Vector3 object to get the world position
|
|
206
|
+
let worldPosition = new THREE.Vector3();
|
|
207
|
+
this.el.object3D.getWorldPosition(worldPosition);
|
|
209
208
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
209
|
+
// Slider center in world coordinates
|
|
210
|
+
let sliderCenter = worldPosition.x;
|
|
211
|
+
|
|
212
|
+
// Slider width considering its scale and the parent's scale
|
|
213
|
+
let sliderWidth = this.data.size * this.el.object3D.scale.x * this.el.parentEl.object3D.scale.x;
|
|
214
|
+
|
|
215
|
+
// Number of divisions or slices we want (sliderRange)
|
|
216
|
+
let sliderRange = Math.abs(this.data.max - this.data.min);
|
|
217
|
+
|
|
218
|
+
// Calculate the left and right limits of the slider
|
|
219
|
+
let sliderMin = sliderCenter - (sliderWidth / 2);
|
|
220
|
+
let sliderMax = sliderCenter + (sliderWidth / 2);
|
|
221
|
+
|
|
222
|
+
// Ensure x is within the slider's range
|
|
223
|
+
if (x < sliderMin) return this.data.min;
|
|
224
|
+
if (x > sliderMax) return this.data.max;
|
|
225
|
+
|
|
226
|
+
// Calculate the size of each slice of the slider
|
|
227
|
+
let sliceSize = sliderWidth / sliderRange;
|
|
228
|
+
|
|
229
|
+
// Identify in which slice x falls
|
|
230
|
+
let sliceIndex = Math.floor((x - sliderMin) / sliceSize);
|
|
231
|
+
|
|
232
|
+
// Convert the slice index to the corresponding value
|
|
233
|
+
let value = this.data.min + sliceIndex;
|
|
234
|
+
|
|
235
|
+
// Return the value ensuring it is within the allowed range
|
|
236
|
+
return Math.min(Math.max(value, this.data.min), this.data.max);
|
|
218
237
|
},
|
|
219
238
|
|
|
220
239
|
mouseyPositionToValue: function (y) {
|
|
221
|
-
|
|
222
|
-
let
|
|
223
|
-
|
|
224
|
-
let sliderMin = sliderCenter - (sliderWidth / 2)
|
|
240
|
+
// Create a THREE.Vector3 object to get the world position
|
|
241
|
+
let worldPosition = new THREE.Vector3();
|
|
242
|
+
this.el.object3D.getWorldPosition(worldPosition);
|
|
225
243
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
244
|
+
// Slider center in world coordinates (Y-axis)
|
|
245
|
+
let sliderCenter = worldPosition.y;
|
|
246
|
+
|
|
247
|
+
// Slider height considering its scale and the parent's scale
|
|
248
|
+
let sliderHeight = this.data.size * this.el.object3D.scale.y * this.el.parentEl.object3D.scale.y;
|
|
249
|
+
|
|
250
|
+
// Number of divisions or slices we want (sliderRange)
|
|
251
|
+
let sliderRange = Math.abs(this.data.max - this.data.min);
|
|
252
|
+
|
|
253
|
+
// Calculate the bottom and top limits of the slider
|
|
254
|
+
let sliderMin = sliderCenter - (sliderHeight / 2);
|
|
255
|
+
let sliderMax = sliderCenter + (sliderHeight / 2);
|
|
256
|
+
|
|
257
|
+
// Ensure y is within the slider's range
|
|
258
|
+
if (y < sliderMin) return this.data.min;
|
|
259
|
+
if (y > sliderMax) return this.data.max;
|
|
260
|
+
|
|
261
|
+
// Calculate the size of each slice of the slider
|
|
262
|
+
let sliceSize = sliderHeight / sliderRange;
|
|
263
|
+
|
|
264
|
+
// Identify in which slice y falls
|
|
265
|
+
let sliceIndex = Math.floor((y - sliderMin) / sliceSize);
|
|
266
|
+
|
|
267
|
+
// Convert the slice index to the corresponding value
|
|
268
|
+
let value = this.data.min + sliceIndex;
|
|
269
|
+
|
|
270
|
+
// Return the value ensuring it is within the allowed range
|
|
271
|
+
return Math.min(Math.max(value, this.data.min), this.data.max);
|
|
234
272
|
},
|
|
235
273
|
|
|
236
274
|
update: function (old) {
|
|
@@ -68,102 +68,82 @@ const colors = {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
let findProdComponent = (data, el, selfProducer) => {
|
|
71
|
-
let prodComponent;
|
|
71
|
+
let prodComponent = null;
|
|
72
|
+
let prodComponentNodes = null;
|
|
73
|
+
let prodComponentLinks = null;
|
|
74
|
+
|
|
72
75
|
if (data.from) {
|
|
73
76
|
// Save the reference to the querier or filterdata
|
|
74
|
-
let prodElement = document.getElementById(data.from)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
prodComponent = prodElement.components['babia-querygithub']
|
|
85
|
-
} else if (prodElement.components['babia-selector']) {
|
|
86
|
-
prodComponent = prodElement.components['babia-selector'];
|
|
87
|
-
} else if (prodElement.components['babia-treebuilder']) {
|
|
88
|
-
prodComponent = prodElement.components['babia-treebuilder'];
|
|
89
|
-
} else {
|
|
77
|
+
let prodElement = document.getElementById(data.from);
|
|
78
|
+
for (const component of ['babia-filter', 'babia-queryjson',
|
|
79
|
+
'babia-querycsv', 'babia-queryes', 'babia-querygithub',
|
|
80
|
+
'babia-selector', 'babia-treebuilder']) {
|
|
81
|
+
if (prodElement.components[component]) {
|
|
82
|
+
prodComponent = prodElement.components[component];
|
|
83
|
+
break;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
if (prodComponent == null) {
|
|
90
87
|
console.error("Problem registering to the querier", el);
|
|
91
|
-
return
|
|
92
|
-
}
|
|
88
|
+
return;
|
|
89
|
+
};
|
|
93
90
|
} else if (data.nodesFrom) {
|
|
94
91
|
// Save the reference to the querier or filterdata
|
|
95
|
-
let prodElementNodes = document.getElementById(data.nodesFrom)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
} else if (prodElementNodes.components['babia-querygithub']) {
|
|
105
|
-
prodComponentNodes = prodElementNodes.components['babia-querygithub']
|
|
106
|
-
} else {
|
|
92
|
+
let prodElementNodes = document.getElementById(data.nodesFrom);
|
|
93
|
+
for (const component of ['babia-filter', 'babia-queryjson',
|
|
94
|
+
'babia-querycsv', 'babia-queryes', 'babia-querygithub']) {
|
|
95
|
+
if (prodElementNodes.components[component]) {
|
|
96
|
+
prodComponentNodes = prodElementNodes.components[component];
|
|
97
|
+
break;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
if (prodComponentNodes == null) {
|
|
107
101
|
console.error("Problem registering to the querier", el);
|
|
108
|
-
return
|
|
109
|
-
}
|
|
102
|
+
return;
|
|
103
|
+
};
|
|
110
104
|
|
|
111
105
|
// Save the reference to the querier or filterdata
|
|
112
106
|
let prodElementLinks = document.getElementById(data.linksFrom)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
} else if (prodElementLinks.components['babia-querygithub']) {
|
|
122
|
-
prodComponentLinks = prodElementLinks.components['babia-querygithub']
|
|
123
|
-
} else {
|
|
107
|
+
for (const component of ['babia-filter', 'babia-queryjson',
|
|
108
|
+
'babia-querycsv', 'babia-queryes', 'babia-querygithub']) {
|
|
109
|
+
if (prodElementLinks.components[component]) {
|
|
110
|
+
prodComponentLinks = prodElementLinks.components[component];
|
|
111
|
+
break;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
if (prodComponentLinks == null) {
|
|
124
115
|
console.error("Problem registering to the querier", el);
|
|
125
|
-
return
|
|
126
|
-
}
|
|
116
|
+
return;
|
|
117
|
+
};
|
|
118
|
+
|
|
127
119
|
return { 'nodes': prodComponentNodes, 'links': prodComponentLinks }
|
|
128
120
|
|
|
129
121
|
} else {
|
|
130
122
|
// Look for a querier or filterdata in the same element and register
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
prodComponent = el.components['babia-querygithub']
|
|
141
|
-
} else if (el.components['babia-selector'] && selfProducer != 'babia-selector') {
|
|
142
|
-
prodComponent = el.components['babia-selector'];
|
|
143
|
-
} else if (el.components['babia-treebuilder']) {
|
|
144
|
-
prodComponent = el.components['babia-treebuilder'];
|
|
145
|
-
} else {
|
|
123
|
+
for (const component of ['babia-filter', 'babia-queryjson',
|
|
124
|
+
'babia-querycsv', 'babia-queryes', 'babia-querygithub',
|
|
125
|
+
'babia-selector', 'babia-treebuilder']) {
|
|
126
|
+
if (el.components[component] && selfProducer != component) {
|
|
127
|
+
prodComponent = el.components[component];
|
|
128
|
+
break;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
if (prodComponent == null) {
|
|
146
132
|
// Look for a querier or filterdata in the scene
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
} else if (document.querySelectorAll('[babia-selector]').length > 0) {
|
|
158
|
-
prodComponent = document.querySelectorAll('[babia-selector]')[0].components['babia-selector'];
|
|
159
|
-
} else if (document.querySelectorAll('[babia-treebuilder]').length > 0) {
|
|
160
|
-
prodComponent = document.querySelectorAll('[babia-treebuilder]')[0].components['babia-treebuilder'];
|
|
161
|
-
} else {
|
|
162
|
-
console.error("Error, querier not found", el, el.components, el.components['babia-selector']);
|
|
133
|
+
for (const component of ['babia-filter', 'babia-queryjson',
|
|
134
|
+
'babia-querycsv', 'babia-queryes', 'babia-querygithub',
|
|
135
|
+
'babia-selector', 'babia-treebuilder']) {
|
|
136
|
+
if (document.querySelectorAll("[" + component + "]").length > 0) {
|
|
137
|
+
prodComponent = document.querySelectorAll("[" + component + "]")[0].components[component];
|
|
138
|
+
break;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
if (prodComponent == null) {
|
|
142
|
+
console.error("Error, querier not found", el, el.components, el.components['babia-querier']);
|
|
163
143
|
return
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
};
|
|
167
147
|
return prodComponent;
|
|
168
148
|
}
|
|
169
149
|
|
|
@@ -57,8 +57,9 @@ AFRAME.registerComponent('babia-doughnut', {
|
|
|
57
57
|
* Called on each scene tick.
|
|
58
58
|
*/
|
|
59
59
|
tick: function (t, delta) {
|
|
60
|
+
let self = this
|
|
60
61
|
if (this.data.animation && this.loaded) {
|
|
61
|
-
let elements =
|
|
62
|
+
let elements = self.el.children[0].children
|
|
62
63
|
for (let slice in this.slice_array) {
|
|
63
64
|
let delay = this.slice_array[slice].delay
|
|
64
65
|
let max_arc = this.slice_array[slice].arc
|
|
@@ -10,28 +10,30 @@ AFRAME.registerComponent('babia-html', {
|
|
|
10
10
|
clickedBoxes: new Map(),
|
|
11
11
|
|
|
12
12
|
init: function () {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let data = this.data;
|
|
13
|
+
// let el = this.el;
|
|
14
|
+
const data = this.data;
|
|
16
15
|
|
|
17
|
-
//
|
|
18
|
-
this.observer = new MutationObserver(
|
|
19
|
-
mutations.forEach(
|
|
16
|
+
// Create an observer to detect the addition of the div to the DOM
|
|
17
|
+
this.observer = new MutationObserver((mutations) => {
|
|
18
|
+
mutations.forEach((mutation) => {
|
|
20
19
|
if (mutation.addedNodes) {
|
|
21
|
-
mutation.addedNodes.forEach(
|
|
20
|
+
mutation.addedNodes.forEach((node) => {
|
|
22
21
|
if (node.id === 'babiaHtmlDiv') {
|
|
23
|
-
console.log('
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
console.log('A div with id "babiaHtmlDiv" has been rendered in the DOM');
|
|
23
|
+
|
|
24
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
25
|
+
this.processNodeNoOffset(node.children[i], null, 0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Disconnect the observer since the div has been added
|
|
29
|
+
this.observer.disconnect();
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
});
|
|
32
34
|
});
|
|
33
35
|
|
|
34
|
-
//
|
|
36
|
+
// Configuring the observer to observe changes to the body of the document
|
|
35
37
|
this.observer.observe(document.body, { childList: true, subtree: true });
|
|
36
38
|
|
|
37
39
|
// Insert the HTML in order to render it
|
|
@@ -39,119 +41,110 @@ AFRAME.registerComponent('babia-html', {
|
|
|
39
41
|
babiaDiv.setAttribute('id', 'babiaHtmlDiv');
|
|
40
42
|
babiaDiv.innerHTML = data.html;
|
|
41
43
|
document.body.appendChild(babiaDiv);
|
|
42
|
-
|
|
43
|
-
|
|
44
44
|
},
|
|
45
45
|
|
|
46
|
-
processNodeNoOffset: function (node,
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
for (let i = 0; i < children.length; i++) {
|
|
51
|
-
const child = children[i];
|
|
52
|
-
const rect = child.getBoundingClientRect();
|
|
46
|
+
processNodeNoOffset: function (node, firstOffsetToDelete, childrenLevel) {
|
|
47
|
+
const el = this.el;
|
|
48
|
+
const rect = node.getBoundingClientRect();
|
|
49
|
+
const NODE_SCALAR = 0.01;
|
|
53
50
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
// Remove the first Y and X offset, since the HTML is rendered below the scene
|
|
52
|
+
if (!firstOffsetToDelete) {
|
|
53
|
+
firstOffsetToDelete = { x: rect.left * NODE_SCALAR, y: rect.top * NODE_SCALAR }
|
|
54
|
+
}
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
// Calculate positions, adjusting the center of the box and removing the firstOffset
|
|
57
|
+
const offsetX = rect.right * NODE_SCALAR - (rect.width * NODE_SCALAR) / 2 - firstOffsetToDelete.x;
|
|
58
|
+
const offsetY = -rect.bottom * NODE_SCALAR + (rect.height * NODE_SCALAR) / 2 + firstOffsetToDelete.y;
|
|
62
59
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
// Create box
|
|
61
|
+
const box = document.createElement('a-box');
|
|
62
|
+
box.setAttribute('position', `${offsetX} ${offsetY} ${childrenLevel * this.data.distanceLevels}`);
|
|
63
|
+
box.setAttribute('width', rect.width * NODE_SCALAR);
|
|
64
|
+
box.setAttribute('height', rect.height * NODE_SCALAR);
|
|
65
|
+
box.setAttribute('depth', 0.01);
|
|
69
66
|
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
// Make box clickable
|
|
69
|
+
box.classList.add("babiaxraycasterclass")
|
|
73
70
|
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
// Store the HTML content in the box for later use
|
|
72
|
+
box.setAttribute('html-content', node.outerHTML);
|
|
76
73
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
// Add mouseenter and mouseleave events
|
|
75
|
+
box.addEventListener('mouseenter', () => {
|
|
76
|
+
if (!box.classList.contains('clicked')) {
|
|
77
|
+
this.showHtmlContent(box, node.outerHTML, 'temp');
|
|
78
|
+
}
|
|
79
|
+
});
|
|
83
80
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
box.addEventListener('mouseleave', () => {
|
|
82
|
+
if (!box.classList.contains('clicked')) {
|
|
83
|
+
this.removeHtmlContent('temp');
|
|
84
|
+
}
|
|
85
|
+
});
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
// Add click event to toggle the plane with the HTML content
|
|
88
|
+
box.addEventListener('click', (event) => {
|
|
89
|
+
event.stopPropagation(); // Prevent mouseenter/leave events from firing
|
|
90
|
+
if (box.classList.contains('clicked')) {
|
|
91
|
+
box.classList.remove('clicked');
|
|
92
|
+
this.removeHtmlContent('permanent', box);
|
|
93
|
+
} else {
|
|
94
|
+
box.classList.add('clicked');
|
|
95
|
+
this.showHtmlContent(box, node.outerHTML, 'permanent');
|
|
96
|
+
}
|
|
97
|
+
});
|
|
101
98
|
|
|
102
99
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
box.setAttribute('material', {
|
|
111
|
-
shader: 'flat',
|
|
112
|
-
src: canvas.toDataURL()
|
|
113
|
-
});
|
|
114
|
-
})
|
|
115
|
-
}else{
|
|
116
|
-
box.setAttribute('color', this.colors_grad[childrenLevel]);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
} else {
|
|
120
|
-
html2canvas(child).then(function (canvas) {
|
|
100
|
+
// Select if we want to render the HTML content as a plane or a texture, if not, color
|
|
101
|
+
if (this.data.renderHTML && typeof html2canvas !== "undefined") {
|
|
102
|
+
// Render all, or render only the last child
|
|
103
|
+
if (this.data.renderHTMLOnlyLeafs) {
|
|
104
|
+
if (node.children.length == 0) {
|
|
105
|
+
// Found a leaf node
|
|
106
|
+
html2canvas(node).then(function (canvas) {
|
|
121
107
|
box.setAttribute('material', {
|
|
122
108
|
shader: 'flat',
|
|
123
109
|
src: canvas.toDataURL()
|
|
124
110
|
});
|
|
125
111
|
})
|
|
112
|
+
}else{
|
|
113
|
+
// Render inner node
|
|
114
|
+
box.setAttribute('color', this.colors_grad[childrenLevel % this.colors_grad.length]);
|
|
126
115
|
}
|
|
127
|
-
} else {
|
|
128
|
-
// If renderHTML is not set, we use the color attribute to color the box
|
|
129
|
-
box.setAttribute('color', this.colors_grad[childrenLevel]);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
116
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
line.setAttribute('line', {
|
|
141
|
-
start: `${offsetX} ${offsetY} ${childrenLevel * this.data.distanceLevels}`,
|
|
142
|
-
end: `${offsetX} ${offsetY} ${(childrenLevel * this.data.distanceLevels) - this.data.distanceLevels}`,
|
|
143
|
-
color: 'yellow'
|
|
117
|
+
} else {
|
|
118
|
+
// Render node with texture
|
|
119
|
+
html2canvas(node).then(function (canvas) {
|
|
120
|
+
box.setAttribute('material', {
|
|
121
|
+
shader: 'flat',
|
|
122
|
+
src: canvas.toDataURL()
|
|
123
|
+
});
|
|
144
124
|
})
|
|
145
|
-
el.appendChild(line);
|
|
146
125
|
}
|
|
126
|
+
} else {
|
|
127
|
+
// If renderHTML is not set, we use the color attribute to color the box
|
|
128
|
+
box.setAttribute('color', this.colors_grad[childrenLevel % this.colors_grad.length]);
|
|
129
|
+
}
|
|
147
130
|
|
|
131
|
+
el.appendChild(box);
|
|
132
|
+
|
|
133
|
+
// Create line to the parent
|
|
134
|
+
if (childrenLevel > 0) {
|
|
135
|
+
let line = document.createElement('a-entity')
|
|
136
|
+
line.setAttribute('line', {
|
|
137
|
+
start: `${offsetX} ${offsetY} ${childrenLevel * this.data.distanceLevels}`,
|
|
138
|
+
end: `${offsetX} ${offsetY} ${(childrenLevel * this.data.distanceLevels) - this.data.distanceLevels}`,
|
|
139
|
+
color: 'yellow'
|
|
140
|
+
})
|
|
141
|
+
el.appendChild(line);
|
|
142
|
+
}
|
|
148
143
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.processNodeNoOffset(child, firstOffestToDelete, newLevel);
|
|
152
|
-
}
|
|
144
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
145
|
+
this.processNodeNoOffset(node.children[i], firstOffsetToDelete, childrenLevel + 1);
|
|
153
146
|
}
|
|
154
|
-
|
|
147
|
+
},
|
|
155
148
|
|
|
156
149
|
showHtmlContent: function (box, htmlContent, type) {
|
|
157
150
|
// Remove any existing temporary plane
|
|
@@ -205,22 +198,7 @@ AFRAME.registerComponent('babia-html', {
|
|
|
205
198
|
}
|
|
206
199
|
},
|
|
207
200
|
|
|
208
|
-
|
|
209
|
-
colors_dif: [
|
|
210
|
-
"#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#FF00FF", "#00FFFF", "#800000", "#808000",
|
|
211
|
-
"#008000", "#800080", "#008080", "#000080", "#FF4500", "#2E8B57", "#4682B4", "#D2691E",
|
|
212
|
-
"#FF69B4", "#8A2BE2", "#5F9EA0", "#7FFF00", "#DDA0DD", "#B0E0E6", "#FF1493", "#32CD32",
|
|
213
|
-
"#FFD700", "#6A5ACD", "#40E0D0", "#FF6347", "#8B0000", "#9ACD32", "#00CED1", "#9400D3",
|
|
214
|
-
"#ADFF2F", "#F0E68C", "#E9967A", "#8FBC8F", "#483D8B", "#2F4F4F", "#7B68EE", "#6B8E23",
|
|
215
|
-
"#FF7F50", "#BA55D3", "#CD5C5C", "#20B2AA", "#778899", "#4682B4", "#D3D3D3", "#FFB6C1",
|
|
216
|
-
"#FFA07A", "#BDB76B", "#8B008B", "#556B2F", "#9932CC", "#B22222", "#5F9EA0", "#FFDAB9",
|
|
217
|
-
"#ADFF2F", "#E0FFFF", "#7CFC00", "#FF00FF", "#DAA520", "#32CD32", "#FA8072", "#8A2BE2",
|
|
218
|
-
"#7FFFD4", "#B8860B", "#FF4500", "#ADFF2F", "#DB7093", "#F08080", "#FF00FF", "#6495ED",
|
|
219
|
-
"#DC143C", "#00FA9A", "#B0C4DE", "#B03060", "#98FB98", "#6A5ACD", "#708090", "#FFD700",
|
|
220
|
-
"#20B2AA", "#66CDAA", "#7B68EE", "#00FF7F", "#8B0000", "#00FF00", "#F0FFF0", "#DC143C",
|
|
221
|
-
"#FF00FF", "#00BFFF", "#B22222", "#00FFFF", "#FFD700", "#DA70D6", "#F5DEB3", "#F4A460"
|
|
222
|
-
],
|
|
223
|
-
|
|
201
|
+
// Gradient for coloring boxes (depending on depth level in DOM)
|
|
224
202
|
colors_grad: [
|
|
225
203
|
"#4B0082", "#800080", "#B22222", "#A0522D", "#CD5C5C", "#8B008B", "#9932CC", "#FF4500",
|
|
226
204
|
"#FF8C00", "#B8860B", "#D2691E", "#DAA520", "#ADFF2F", "#7FFF00", "#32CD32", "#00FF00",
|
|
@@ -249,7 +227,6 @@ AFRAME.registerComponent('babia-html', {
|
|
|
249
227
|
// Call init again to reinitialize the component
|
|
250
228
|
this.init();
|
|
251
229
|
}
|
|
252
|
-
|
|
253
230
|
}
|
|
254
231
|
|
|
255
232
|
});
|