-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
98 lines (82 loc) · 4.63 KB
/
index.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
<html>
<head>
<title>WebVR ISS</title>
<script src="https://aframe.io/releases/0.7.1/aframe.min.js"></script>
<script src="https://unpkg.com/aframe-event-set-component@3.0.3/dist/aframe-event-set-component.min.js"></script> <!-- for gaze-based interactions -->
<script src="https://code.jquery.com/jquery-1.10.2.js"></script> <!-- for JSON parsing -->
</head>
<body>
<!-- All JS is in an external file for convenience -->
<script src="js/iss.js"></script>
<a-scene enter-vr="document.getElementById('camera').setAttribute('position','0 -0.3 89.6');" exit-vr="document.getElementById('camera').setAttribute('position','0 -0.7 89.6');">
<!-- due to a bug, camera needs to be repositioned after entering and leaving vr -->
<!-- This is the Asset Manager: Textures, models, sounds, etc... -->
<a-assets>
<img id="sky" src="res/starmap.jpg">
<img id="earth-day" src="res/earth_daymap.jpg">
<img id="earth-clouds" src="res/earth_clouds.png">
<a-asset-item id="cupola-iva" src="res/cupola/scene.gltf"></a-asset-item>
<a-asset-item id="sound-atmos" src="res/atmos.mp3" response-type="arraybuffer"></a-asset-item> <!-- arraybuffer is needed for audio or else doesn't work due to a bug: https://github.com/aframevr/aframe/issues/2754 -->
</a-assets>
<a-sky src="#sky"></a-sky> <!-- the stars -->
<a-entity light="type: ambient; color: #CCC; intensity:0.5"></a-entity> <!-- without this, the dark side of the earth would be completely black -->
<a-sphere id="sun" radius="5" material="color: #FFF" position="-800 0 0" light="type:point"></a-sphere> <!-- the sun -->
<a-entity id="earth_orbit"> <!-- using another container like this might be useful for tilting the earth according to the current month/season -->
<a-sphere id="earth" radius=80 material="src: #earth-day; roughness:0.8" position="0 0 0" segments-height="180" segments-width="180"> <!--the actual earth -->
<a-sphere id="clouds" radius="81" material="src: #earth-clouds; roughness:1; opacity:0.4" position="0 0 0" segments-height="180" segments-width="180"></a-sphere> <!-- earth's cloud layer -->
<!-- here comes the orbit of the ISS -->
<a-entity id="iss_orbit" position="0 0 0" rotation="0 90 0">
<!-- the "from" and "to" values will be changed by JavaScript every 5 seconds-->
<a-animation
id="iss_orbit_animation"
easing="linear"
dur="5000"
from="0 90 0"
to="0 90 0"
repeat="indefinite"
></a-animation>
<a-gltf-model id="cupola-model" src="#cupola-iva" position="0 0 86" rotation="0 180 0" visible="true"></a-gltf-model> <!-- the 3D model -->
<a-cylinder id="button" position="0.160 0.210 89.250" rotation="-96.94 0 0" scale="0.05 0.05 0.05" material="" hide-model class="clickable"></a-cylinder> <!-- the interactive button -->
<a-camera wasd-controls="enabled: false" camera="userHeight: 0.82; far: 10000000000000" id="camera" rotation="0 0 0" position="0 -0.3 89.6" > <!-- the camera -->
<!-- the cursor, with an animation and atmospheric sound as its childs -->
<a-entity cursor="fuse: true; fuseTimeout: 500"
position="0 0 -0.35"
geometry="primitive: ring; radiusInner: 0.01; radiusOuter: 0.015"
material="color: gray; shader: flat"
raycaster="objects: .clickable">
<a-animation begin="cursor-fusing" easing="ease-in" attribute="scale" dur="1000" fill="backwards" from="1 1 1" to="0.1 0.1 0.1"></a-animation>
<a-sound src="#sound-atmos" autoplay="true" loop="true"></a-sound>
</a-entity>
</a-camera>
</a-entity>
</a-sphere>
</a-entity>
</a-scene>
<script>
// Get time and set earth rotation relative to the sun. Should update maximum once an hour, so I don't bother.
time();
// Get telemetry once.
telemetry();
// Update telemetry every 5 seconds. Is probably still too often, but increasing this will result in longer preparation time in the beginning.
setInterval(telemetry,5000);
// register the trigger and the target for the gaze-based interaction
AFRAME.registerComponent('hide-model', {
schema: {},
init: function () {
var model = document.getElementById("cupola-model"); // the target
document.getElementById("button").addEventListener('click', function () {
if(model.getAttribute("visible")==true){
// do this if the model is currently visible (default)
console.log("Hide model");
model.setAttribute("visible", false);
} else {
// do this if the model is currently NOT visible
console.log("Show model");
model.setAttribute("visible", true);
}
});
}
});
</script>
</body>
</html>