-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtween.html
50 lines (48 loc) · 1.23 KB
/
tween.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
position: fixed;
overflow: hidden;
margin: 0;
width: 100%;
height: 100%;
}
canvas {
width: 100%;
height: 100%;
display: block;
}
</style>
</head>
<body>
<canvas id="c"></canvas>
</body>
<script id="dir-color-vs" type="notjs">
attribute vec4 a_position;
attribute vec3 a_normal;
uniform mat4 u_world;
uniform mat4 u_worldInverseTranspose;
uniform mat4 u_viewProjection;
varying vec3 v_normal;
void main() {
v_normal = (u_worldInverseTranspose * vec4(a_normal, 0)).xyz;
gl_Position = u_viewProjection * u_world * a_position;
}
</script>
<script id="dir-color-fs" type="notjs">
precision mediump float;
varying vec3 v_normal;
uniform vec3 u_lightDir;
uniform vec4 u_color;
uniform float u_lightMix;
void main() {
float light = dot(normalize(v_normal), u_lightDir) * .5 + .5;
gl_FragColor = vec4(u_color.xyz * mix(1.0, light, u_lightMix), 1);
}
</script>
<script data-main="js/tween.js" src="js/require.js"></script>
</html>