Newer
Older
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
<head>
<style> body { margin: 0; } </style>
<title>MetaVoxel</title>
<script src="//unpkg.com/three"></script>
<script src="../lib/js-colormaps.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="//unpkg.com/3d-force-graph"></script>
<!-- <script src="../lib/3d-force-graph.js"></script> -->
<script src="//unpkg.com/three-spritetext"></script>
<script src="../visualization/utils.js"></script>
<script src="../visualization/drawGraph.js"></script>
</head>
<body>
<div id="3d-graph"></div>
<script>
var color1= 0xffffff; /*white*/
var color2= '#020227'; /*kohly*/
var color3= 0x1c5c61; /*teal*/
var color4= 0xfa6e70; //red/orange
var color5="#380152"; //purple
var color6="#696767"; //grey
var color7="#03dbfc"; //blue
$.getJSON("../json/multiscale.json", function(json) {
var setup=json.setup;
setup.viz.colorMaps=[YlGnBu,coolwarm, winter ,jet];
scale=100000;
var stress=0.0;
var container='3d-graph';
var Graph=drawGraph(container,setup,scale,true);
// example to test relPos rotations
var scene=Graph.scene();
var trialBox= new THREE.Mesh(
new THREE.BoxGeometry(scale, scale, scale),
new THREE.MeshLambertMaterial({
color: color4,
transparent: false,
})
);
var trialBoxSmall= new THREE.Mesh(
new THREE.BoxGeometry(scale, scale, scale),
new THREE.MeshLambertMaterial({
color: color4,
transparent: false,
})
);
var trialBoxInfer= new THREE.Mesh(
new THREE.BoxGeometry(scale, scale/2, scale),
new THREE.MeshLambertMaterial({
color: color3,
transparent: false,
})
);
// var pos=new THREE.Vector3(-10,-10,-10);
// var posSmall=new THREE.Vector3(-5,-15,-5);
// var rot=new THREE.Vector3(30,30,0);
// trialBox.rotation.x=rot.x;
// trialBox.rotation.y=rot.y;
// trialBox.rotation.z=rot.z;
// trialBox.position.x=pos.x;
// trialBox.position.y=pos.y;
// trialBox.position.z=pos.z;
// trialBox.add(trialBoxSmall)
// trialBoxSmall.position.x=posSmall.x;
// trialBoxSmall.position.y=posSmall.y;
// trialBoxSmall.position.z=posSmall.z;
// var posInfer=pos.clone().add(applyQuaternion1(posSmall,setQuaternionFromEuler(rot)) )
// console.log(posInfer)
// trialBoxInfer.position.x=posInfer.x;
// trialBoxInfer.position.y=posInfer.y;
// trialBoxInfer.position.z=posInfer.z;
// trialBoxInfer.rotation.x=rot.x;
// trialBoxInfer.rotation.y=rot.y;
// trialBoxInfer.rotation.z=rot.z;
// scene.add(trialBox)
// scene.add(trialBoxInfer)
// console.log(trialBoxSmall)
});
function toRadians (angle) {
return angle * (Math.PI / 180.0);
}
function toDegrees (angle) {
return angle * (180.0 / Math.PI);
}
function setQuaternionFromEuler(euler){//euler::Vector3
var x=euler.x
var y=euler.y
var z=euler.z
var c1 = Math.cos( x / 2.0 )
var c2 = Math.cos( y / 2.0 )
var c3 = Math.cos( z / 2.0 )
var s1 = Math.sin( x / 2.0 )
var s2 = Math.sin( y / 2.0 )
var s3 = Math.sin( z / 2.0 )
var x = s1 * c2 * c3 + c1 * s2 * s3
var y = c1 * s2 * c3 - s1 * c2 * s3
var z = c1 * c2 * s3 + s1 * s2 * c3
var w = c1 * c2 * c3 - s1 * s2 * s3
return new THREE.Quaternion(x,y,z,w)
}
function applyQuaternion1(e,q2){ //e::Vector3,q2::Quaternion
var x = e.x
var y = e.y
var z = e.z
var qx = q2.x
var qy = q2.y
var qz = q2.z
var qw = q2.w
// calculate quat * vector
var ix = qw * x + qy * z - qz * y
var iy = qw * y + qz * x - qx * z
var iz = qw * z + qx * y - qy * x
var iw = - qx * x - qy * y - qz * z
// calculate result * inverse quat
var xx = ix * qw + iw * - qx + iy * - qz - iz * - qy
var yy = iy * qw + iw * - qy + iz * - qx - ix * - qz
var zz = iz * qw + iw * - qz + ix * - qy - iy * - qx
return new THREE.Vector3(xx,yy,zz)
}
</script>
</body>