-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtwelve.html
136 lines (106 loc) · 4.03 KB
/
twelve.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hyperbolic 12 Tones of Christmas</title>
<!--
Hyperbolic space, 12 tones of christmas, with webVR support. WASD + Arrows to move, space or p to play/pause.
A websperience by Vi Hart, Andrea Hawksley, and Henry Segerman, using the hyperbolic space prototype developed at a hyperbolic webVR "hackalot" with Vi Hart, Mike Stay, Henry Segerman, Andrea Hawksley, and Andrew Lutomirski, with help from Marc ten Bosch's 4d graphics shader, Jeff Week's Curved Spaces, Mozilla's webVR framework for THREEjs, etc.
http://vihart.com
http://andreahawksley.com
http://segerman.org/
http://reperiendi.wordpress.com/
https://github.com/hawksley
http://www.geometrygames.org/CurvedSpaces/
http://www.marctenbosch.com
https://github.com/MozVR/vr-web-examples/tree/master/threejs-vr-boilerplate
Music:
https://soundcloud.com/vihartvihart/the-12-tones-of-christmas
-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
background-color: #000;
color: #fff;
margin: 0px;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<audio id='music' src="media/12tonesofchristmas.ogg" autoplay />
</body>
<script type="x-shader/x-vertex" id="vertexShader">
// This shader moves vertices around
// input
uniform float time; // global time in seconds
uniform mat4 translation; // dodecahedral
uniform mat4 boost;
vec3 ChooseColor( in vec3 nBase )
{
float r = nBase.x;
float g = nBase.y;
float b = nBase.z;
float sin_a = 0.973255;
float cos_a = 0.229727;
float rot_r = cos_a * r + sin_a * g;
float rot_g = -sin_a * r + cos_a * g;
return vec3(-rot_r*0.5 + 0.5,-rot_g*0.5 + 0.5,-b*0.5 + 0.5);
}
// output
varying vec3 vColor; // this shader computes the color of each vertex
vec4 projectToHyperboloid(vec4 v) {
float scaleFactor = sqrt(v.w * v.w - v.x * v.x - v.y * v.y - v.z * v.z);
vec4 result;
result.x = v.x / scaleFactor;
result.y = v.y / scaleFactor;
result.z = v.z / scaleFactor;
result.w = v.w / scaleFactor;
return result;
}
void main()
{
// base position
vec4 p = projectToHyperboloid( vec4(position.zyx / 1.3, 1.0) );
p = boost * translation * p;
// compute the color from the normal
vColor = ChooseColor(-normal.zyx);
// take the final 3D position and project it onto the screen
gl_Position = projectionMatrix * modelViewMatrix * p;
}
</script>
<script type="x-shader/x-vertex" id="fragmentShader">
// this gets called once per pixel
varying vec3 vColor;
void main()
{
// just use the color we computed and assign it to this pixel
gl_FragColor = vec4( vColor, 1. );
}
</script>
<!--
three.js 3d library
-->
<script src="js/lib/three.min.js"></script>
<!--
library for fast quaternion rotation
-->
<script src="js/lib/gl-matrix.js"></script>
<script src="js/hypMath.js"></script>
<!--
VRControlsHyperbolic.js acquires positional information from connected VR devices and applies the transformations to a three.js camera object. Also deals with hyperbolic and parabolic motions.
-->
<script src="js/vr/PhoneVR.js"></script>
<script src="js/vr/VRControlsHyperbolic.js"></script>
<!--
VREffect.js handles stereo camera setup and rendering.
-->
<script src="js/vr/VREffect.js"></script>
<script src="js/loaders/OBJLoader.js"></script>
<!--
dodec_no_id.js stores hyperbolic translation matrices to make copies of the dodecahedron.
-->
<script src="js/534Reflect.js"></script>
<script src="js/twelve.js" type="text/javascript" id="mainCode"></script>
</html>