-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstartOriginal.html
190 lines (156 loc) · 6.56 KB
/
startOriginal.html
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html>
<html>
<head>
<title>Getting Started with Three.js</title>
<script src="../../build/three.js"></script>
<script>
//===================================CUSTOM FUNCTIONS=================================================
/*
función para generar las líneas
función para desplegar cada parametro individualmente:
p1: scr address,
p2: dest address,
p3: dest port
CHANGES:
3ro hasta 1400, static,
recibo un array [p1, p2, p3] o mejor un json y tambien recibo #p1, #p2, #p3.
*/
function Lines(yDest, offset, material2){
//summon a geometry object
var geometryP2 = new THREE.Geometry();
offset=((12/12)/2);
yDest-=offset;
//summon the vector lines with fixed x coordinates and moving y coordinates
//p1: scr address
geometryP2.vertices.push(new THREE.Vector3(-4, yDest, 0));
//p2: dest address
geometryP2.vertices.push(new THREE.Vector3(0, yDest+1, 0));
//p3: dest port
geometryP2.vertices.push(new THREE.Vector3(4, yDest, 0));
//summon the line
var lineP2 = new THREE.Line(geometryP2, material2);
//return the mapped flow, and the updated variables
return [lineP2, yDest, offset];
}
//a cada parametro individual se le asigna un yDest unico, el resto de las coordenadas son fijas
//cada scrIP debe contener: size, nombre destIP y port
//cada destIP debe contener: size, nombre y port
//cada port debe contener: size y nombre
//.keys() para sacar el size
function readData(data){
var info = json.parse(data);
info.ScrIP.DestIP.Port;
//---------------
var flow = {};
flow[234] = {ScrIP: 234, ScrIPLink: {DestIP: 30, DestIPLink: {Port: 80}}};
flow[567] = {ScrIP: 567, ScrIPLink: {DestIP: 40, DestIPLink: {Port: 90}}};
flow[42] = {ScrIP: 42, ScrIPLink: {DestIP: 50, DestIPLink: {Port: 100}}};
var flowSize = {};
flowSize[size] ={size:'size', ScrIPSize: 4, DestIPSize: 35, portSize: 10};
// Usage:
var id = 234;
var FL = flow[id];
console.log(FL.ScrIPLink.DestIPLink.Port); //
}
//gives 3 arrays with the possible vector position in the 3 parameters
function offset(yDest,size1, size2, size3){
//calculate the ofsset to spread ¨evenly¨ through the graph
offSet1=((12/size1)/2);
var yDest1Array=[];
var yDest1=yDest;
for(var i=0; i<size1; i++){
//decrease the y coordinate given the offset
yDest1-=offSet1;
yDest1Array[i]=yDest1;
}
offSet2=((12/size2)/2);
var yDest2Array=[];
var yDest2=yDest;
for(var i=0; i<size2; i++){
//decrease the y coordinate given the offset
yDest2-=offSet2;
yDest2Array[i]=yDest2;
}
offSet3=((12/size3)/2);
var yDest3Array=[];
var yDest3=yDest;
for(var i=0; i<size3; i++){
//decrease the y coordinate given the offset
yDest3-=offSet3;
yDest3Array[i]=yDest3;
}
return [yDest1Array, yDest2Array, yDest3Array];
}
//keys should return an array of all the keys of that json
//object and the I can use it to get the lenght, which in turn gives me the size
function size(){
var size = flow.keys();
return size.lenght();
}
//===================================END OF CUSTOM FUNCTIONS=================================================
window.onload = function() {
var renderer = new THREE.WebGLRenderer();
renderer.setSize( 1700, 900 );
document.body.appendChild( renderer.domElement );
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
35, // Field of view
800 / 600, // Aspect ratio
0.1, // Near plane
10000 // Far plane
);
camera.position.set( 0, 0, 10 );
// camera.position.set( 20, 21, 0 );
camera.lookAt( scene.position );
//===================================CANVAS=================================================
//Manage the material of the lines
var material = new THREE.LineDashedMaterial({
color: 0x0000ff, linewidth: 3
});
var material2 = new THREE.LineDashedMaterial({
color: 0x255425, linewidth: 1, dashSize: 5
});
//PermanentLine1 and border
//verificar si el borde de abajo es necesario, no presente en el del paper
var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(-4, 3, 0));
geometry.vertices.push(new THREE.Vector3(-4, -3, 0));
geometry.vertices.push(new THREE.Vector3(4, -3, 0));
geometry.vertices.push(new THREE.Vector3(4, 3, 0));
var line = new THREE.Line(geometry, material);
//PermanentLine2
var geometry2 = new THREE.Geometry();
geometry2.vertices.push(new THREE.Vector3(0,3,0))
geometry2.vertices.push(new THREE.Vector3(0,-3,0))
var line2 = new THREE.Line(geometry2, material);
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MODIFYIER<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//initilize variable yDest to go from 3 to -3
var yDest=3;
//will decrease yDest
var offSet=0;
//holds the result of the function call
var result;
//iterates per flow
for(var i=0; i<12; i++){
//function call
result =Lines(yDest, offset, material2);
//adds the line to the scene
scene.add(result[0]);
//updates variables for next call
yDest = result[1];
offSet = result[2];
}
//Adds the permanent lines
scene.add(line);
scene.add(line2);
//===================================CODE HERE =================================================
var light = new THREE.PointLight( 0xFFFF00 );
light.position.set( 10, 0, 10 );
scene.add( light );
renderer.setClearColor( 0xdddddd, 1);
renderer.render( scene, camera );
};
</script>
</head>
<body></body>
</html>