-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdss.html
186 lines (136 loc) · 5.39 KB
/
sdss.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
<html>
<head>
<title>Example 07.03 - Particle Basic Material</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r69/three.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="dat.gui.js"></script>
<script type="text/javascript" src="FirstPersonControls.js"></script>
<style>
body {
/* set margin to 0 and overflow to hidden, to go fullscreen */
margin: 0;
overflow: hidden;
}
</style>
</head>
<body>
<div id="WebGL-output"></div>
<div style="position: relative; background-color:rgba(0,0,0,0.0)">
<div style="position: absolute; bottom: 10px; color: rgba(255,255,255,1.0)">
Navigate using mouse and arrow keys
</div>
</div>
<script type="text/javascript">
function init() {
var clock = new THREE.Clock();
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
var webGLRenderer = new THREE.WebGLRenderer();
webGLRenderer.setClearColor(new THREE.Color(0x000000, 1.0));
webGLRenderer.setSize(window.innerWidth, window.innerHeight);
var axcolour = new THREE.Color("rgb(0, 255, 0)");
var lineMat;
var xAxGeom, yAxGeom, zAxGeom;
var xAx, yAx, zAx;
var v = function (x,y,z){ return new THREE.Vector3(x,y,z); }
lineMat = new THREE.LineBasicMaterial({color: axcolour, lineWidth: 1, opacity: 0.1});
xAxGeom = new THREE.Geometry();
xAxGeom.vertices.push(
v(-3000, 0, 0), v(3000, 0, 0)
);
yAxGeom = new THREE.Geometry();
yAxGeom.vertices.push(
v(0, -3000, 0), v(0, 3000, 0)
);
zAxGeom = new THREE.Geometry();
zAxGeom.vertices.push(
v(0, 0, -3000), v(0, 0, 3000)
);
xAx = new THREE.Line(xAxGeom, lineMat);
xAx.type = THREE.Lines;
scene.add(xAx);
yAx = new THREE.Line(yAxGeom, lineMat);
yAx.type = THREE.Lines;
scene.add(yAx);
zAx = new THREE.Line(zAxGeom, lineMat);
zAx.type = THREE.Lines;
scene.add(zAx);
// position and point the camera to the center of the scene
camera.position.x = 100;
camera.position.y = 10;
camera.position.z = 10;
camera.lookAt(new THREE.Vector3(0, 0, 0));
var camControls = new THREE.FirstPersonControls(camera);
camControls.lookSpeed = 0.4;
camControls.movementSpeed = 20;
camControls.noFly = true;
camControls.lookVertical = true;
camControls.constrainVertical = true;
camControls.verticalMin = 1.0;
camControls.verticalMax = 2.0;
camControls.lon = -150;
camControls.lat = 120;
// add the output of the renderer to the html element
document.getElementById("WebGL-output").appendChild(webGLRenderer.domElement);
var object = new THREE.PointCloud();
$.getJSON('xyz_gminr_new.json', function(data) {
var geom = new THREE.Geometry();
var material = new THREE.PointCloudMaterial({
color: 0xffffff,
size: 0.4,
opacity: 0.6,
transparent: true,
blending: THREE.AdditiveBlending,
map: generateSprite()
});
for (var i=0;i<800000;i++) {
var vertex = new THREE.Vector3();
vertex.x = data[i].x;
vertex.y = data[i].y;
vertex.z = data[i].z;
geom.vertices.push( vertex );
geom.colors.push(new THREE.Color(data[i].gminr, 0, 1 - data[i].gminr));
}
object = new THREE.PointCloud(geom, material);
object.dynamic = true;
scene.add( object );
render();
debugger
});
// setup the control gui
var controls = new function () {
// we need the first child, since it's a multimaterial
};
var gui = new dat.GUI();
function setCamControls() {
}
// render();
function generateSprite() {
var canvas = document.createElement('canvas');
canvas.width = 16;
canvas.height = 16;
var context = canvas.getContext('2d');
var gradient = context.createRadialGradient(canvas.width / 2, canvas.height / 2, 0, canvas.width / 2, canvas.height / 2, canvas.width / 2);
gradient.addColorStop(0, 'rgba(255,255,255,1)');
gradient.addColorStop(0.2, 'rgba(0,255,255,1)');
gradient.addColorStop(0.4, 'rgba(0,0,64,1)');
gradient.addColorStop(1, 'rgba(0,0,0,1)');
context.fillStyle = gradient;
context.fillRect(0, 0, canvas.width, canvas.height);
var texture = new THREE.Texture(canvas);
texture.needsUpdate = true;
return texture;
}
function render() {
var delta = clock.getDelta();
camControls.update(delta);
webGLRenderer.clear();
// render using requestAnimationFrame
requestAnimationFrame(render);
webGLRenderer.render(scene, camera)
}
}
window.onload = init;
</script>
</body>
</html>