-
Notifications
You must be signed in to change notification settings - Fork 0
/
final.html
68 lines (55 loc) · 2.48 KB
/
final.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
<!DOCTYPE html>
<html>
<head>
<title>Stereo Cubemaps demo</title>
<script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
<script src="stereocube.js"></script>
</head>
<body>
<a-scene>
<a-camera stereocam position="-47 0 -35" >
<a-cursor fuse="true" color="#2E3A87" timeout="700"> </a-cursor>
</a-camera>
<a-mixin id="waypt" rotation="0 0 25" scale="2 2 2"></a-mixin>
<a-mixin id="spin" attribute="rotation" dur="10000" fill="forwards" to="0 360 25" repeat="indefinite"></a-mixin>
<a-mixin id="enter" begin="cursor-mouseenter" easing="ease-in" attribute="scale" dur="200" to="4 4 4"></a-mixin>
<a-mixin id="leave" begin="cursor-mouseleave" easing="ease-out" attribute="scale" dur="200" to="2 2 2"></a-mixin>
<a-entity id="skyL" position="-47 0 -35" skycube="folder:brooke2L; eye:left" scale="1 1 -1"></a-entity>
<a-entity id="skyR" position="-47 0 -35" skycube="folder:brooke2R; eye:right" scale="1 1 -1"></a-entity>
</a-scene>
</body>
<script>
var app = {
init: function() {
// Add Click handler's to our waypoints in javascript
[].forEach.call(document.querySelectorAll('a-box'), function(box) {
box.addEventListener('cursor-click', function () {
window.setTimeout(function(){
app.setSkybox ( box.getAttribute('href') );
app.moveCamera ( box.getAttribute('position'), document.querySelectorAll('a-camera')[0] );
// app.hideWaypoints(box.id);
},600)
})
});
//app.hideWaypoints("wp4");
},
setSkybox: function(selectedFolder) {
document.querySelector('#skyL').setAttribute('skycube',{folder: selectedFolder+"L", eye:"left"});
document.querySelector('#skyR').setAttribute('skycube',{folder: selectedFolder+"R", eye:"right"});
},
<!-- hideWaypoints: function(boxid) { -->
<!-- document.querySelector('#wp4').setAttribute('visible',boxid === "wp1"); -->
<!-- document.querySelector('#wp2').setAttribute('visible',boxid != "wp4"); -->
<!-- document.querySelector('#wp3').setAttribute('visible',boxid != "wp4"); -->
<!-- }, -->
moveCamera: function(newPosition, camera) {
var pos = newPosition.x +" 0 "+ newPosition.z;
camera.setAttribute('position', pos );
// move the cubemap to the same position as the camera, to avoid distortion
document.querySelector('#skyL').setAttribute('position', pos );
document.querySelector('#skyR').setAttribute('position', pos );
},
}
app.init();
</script>
</html>