-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUI.js
75 lines (64 loc) · 2.79 KB
/
UI.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
window.onresize = function(){canvasResize(); document.getElementById('nA').innerText = null; document.getElementById('nB').innerText = null;};
canvasResize();
function canvasResize(){sceneEl.style.width = window.innerWidth+"px";sceneEl.style.height = (window.innerHeight*.75)+"px";}
function Pos(){return worldPos.setFromMatrixPosition(cameraEl.object3D.matrixWorld);}
function Rot(){return camParentEl.getAttribute('rotation');}
function calibrateLocalRotate(){
camParentEl.setAttribute('position',Pos());
cameraEl.setAttribute('position',{x:0,y:0,z:0});
}
function toggleCSS(Str){
switch(Str){
case 'biDir':
document.getElementById('biDir').style.backgroundColor = (biDir) ? '#99cc00': 'white';
document.querySelector('font').innerText = (biDir) ? '\u2015' : '\u2192';
break;
case 'xyz':
document.getElementById('xyz').style.backgroundColor = (xyz) ? '#99cc00': 'white';
break;
case 'grnd':
document.getElementById('grnd').style.backgroundColor = (grnd) ? '#99cc00': 'white';
break;
case 'edgeAni':
document.getElementById('edgeAni').style.backgroundColor = (edgeAni) ? '#99cc00': 'white';
console.log(edgeAni);
case 'del':
document.getElementById('del').style.backgroundColor = (del) ? '#ff275d': 'white';
document.getElementById('add').style.backgroundColor = (!del) ? '#99cc00': 'white';
break;
default:
console.log('toggleCSS - Invalid Entry');
break;
}
}
function toggleXYZ() {
var axisEl = document.querySelector('#axes');
if (!xyz) {
axisEl.setAttribute("visible", "false");
}
else {
axisEl.setAttribute("visible", "true");
}
}
function toggleGrnd() {
var axisEl = sceneEl.querySelector("a-plane");
if (!grnd) { axisEl.setAttribute("visible", "false");}
else { axisEl.setAttribute("visible", "true"); }
}
function toggleEdgeAni(){
for (var i = 0; i<graphEl.childNodes.length;i++){
if (!edgeAni&&graphEl.childNodes[i].getAttribute('id').includes('~')){console.log(graphEl.childNodes[i]); graphEl.childNodes[i].setAttribute('visible','false');}
else if (graphEl.childNodes[i].getAttribute('id').includes('~')){graphEl.childNodes[i].setAttribute('visible','true');}
}
}
function checkEdges(){
col = (nodeA==nodeB) ? '#ff275d': '#99cc00';
if (contains(adjList[nodeA],nodeB)){col = '#ff275d';}
//for (var k = 0; k<adjList[nodeA].length;k++){ if (adjList[nodeA][k] === nodeB){col= '#ff275d';break;}}
nA.innerText = ""; nB.innerText="";
nA.style.backgroundColor = col;nB.style.backgroundColor = col;
setTimeout(function(){nA.style.backgroundColor = 'white';nB.style.backgroundColor = 'white';},1000);
setTimeout(function(){nA.style.backgroundColor = col;nB.style.backgroundColor = col;},1000);
setTimeout(function(){nA.style.backgroundColor = 'white';nB.style.backgroundColor = 'white';},1000);
return nodeA!=nodeB;
}