/
index.html
65 lines (58 loc) · 1.56 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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Boat Game</title>
<style>
* { margin: 0; padding: 0; overflow: hidden; }
body {
--background: #ffa;
background: linear-gradient(to bottom, #dfeeff 0%, #ffffff 27%, #ffffff 100%);
}
canvas { width: 100vw; height: 100vh; }
</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="js/GLTFLoader.js"></script>
<script src="js/OrbitControls.js"></script>
<script id="vertexShader" type="x-shader/x-vertex">
varying vec2 vUv;
void main() {
vUv = uv;
vec4 modelViewPosition = modelViewMatrix * vec4(position, 1.0);
gl_Position = projectionMatrix * modelViewPosition;
}
</script>
<script id="fragmentShader" type="x-shader/x-fragment">
varying vec2 vUv;
uniform float time;
uniform float speed;
uniform float rotation;
float r = .96;
float g = .91;
float b = 1.0;
float ra = 5.0;
float a, f, t, d, x, y;
bool q;
void main() {
vec2 p = -1.0 + 2.0 * vUv;
d = sqrt(pow(p.x, 2.0)+pow(p.y, 2.0));
t = 1.0-pow(d, 2.0);
float xm = ((0.005+d*0.09)-(1.0+cos(p.y*100.0+time*2.0+speed*0.2))*(0.02*d));
float ym = p.y;
float phi = rotation*1.0+(speed*p.y*rotation*5.0);
x = cos(phi)*p.x+p.y*sin(phi);
y = -sin(phi)*p.x+p.y*cos(phi);
if(abs(x-rotation*0.01) < xm && y < -0.0001) {
b = 0.80+speed/7.0;
r = 0.70;
g = 0.70;
}
a = 1.0-sqrt(pow(p.x, 2.0)+pow(p.y, 2.0))*ra;
gl_FragColor = vec4(r, g, b, a);
}
</script>
<script src="js/game.js"></script>
</body>
</html>