-
Notifications
You must be signed in to change notification settings - Fork 1
/
oolite.html
78 lines (74 loc) · 2.67 KB
/
oolite.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Various HTML5 tests</title>
<script src=webgl-utils.js></script>
<script src=gl-matrix-min.js></script>
<script src=oolite/hipparcos-extract.js></script>
<script src=oolite/image-preloader.js></script>
<script src=oolite.js></script>
<script src=sphere.js></script>
<script src=cobra3.js></script>
<script src=coriolis.js></script>
</head>
<body>
<canvas id=oolite></canvas>
<div id=debugline></div>
<input type=range min=-1 max=1 step=0.1 value=0 id=X></input>
<input type=range min=-1 max=1 step=0.1 value=0 id=Y></input>
<input type=range min=-1 max=1 step=0.1 value=0 id=Z></input>
<input type=range min=100 max=500 step=0.1 value=0 id=distance></input>
<script>
var canvas = document.querySelector("#oolite");
var gl = WebGLUtils.setupWebGL(canvas);
var renderer = new Oolite.Renderer(gl);
var stars = new Oolite.PointCloud(Oolite.convertStarCatalog(hipparcos_extract));
var cam = new Oolite.Camera();
var sphere = makeSphere(3400e3, 50, 50);
sphere.texture = {
offsets : [0],
images : [ "planets/mars2k.png" ],
coordinates : sphere.uv
};
var mars = new Oolite.Mesh(sphere);
mars.near = 1000;
mars.translate([0, 0, -30000e3]);
var scene = new Oolite.Scene(stars, mars, cobra3);
var theta = 2*Math.PI * Math.random();
var phi = Math.PI / (Math.random() - 1);
var distance = 4000;
var c = Math.cos, s = Math.sin;
//coriolis.translate([distance*c(phi)*c(theta), distance*c(phi)*s(theta), distance*s(phi) - 30000]);
//cobra3.translate([0, 0, 0]);
cam.translate([0, 0, 200]);
loadImages( [
"images/textures/oolite_cobra3_subents.png",
"images/textures/oolite_cobra3_diffuse.png",
"images/textures/oolite_coriolis_dock_diffuse.png",
"images/textures/oolite_coriolis_tris_diffuse.png",
"images/textures/oolite_coriolis_faceplate_diffuse.png",
"images/textures/oolite_coriolis_diffuse.png",
"images/textures/mars512x512.png",
"images/textures/planets/mars2k.png",
],
animate
);
var now;
function animate() {
requestAnimFrame(animate);
var then = now;
now = Date.now();
var elapsed = then ? (now - then) / 1000 : 0;
var pov = mars;
cam.matrix[14] = parseFloat(document.querySelector("#distance").value);
pov.rotateX(parseFloat(document.querySelector("#X").value) * elapsed);
pov.rotateY(parseFloat(document.querySelector("#Y").value) * elapsed);
pov.rotateZ(parseFloat(document.querySelector("#Z").value) * elapsed);
coriolis.rotateZ(0.1 * elapsed);
mars.rotateY(0.0001 * elapsed);
renderer.render(scene, cam);
};
</script>
</body>
</html>