-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeca-flu.html
55 lines (43 loc) · 1.37 KB
/
meca-flu.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - custom attributes</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body>
<!-- JS dependencies -->
<script src="meca-flu//js/Three.js"></script>
<!-- WEBGL mountpoint -->
<div id="container"></div>
<!-- Vertex shader -->
<script type="x-shader/x-vertex" id="vertexshader">
uniform float amplitude;
uniform float scaleFactor;
attribute float displacement;
varying vec2 vUv;
void main() {
vUv = uv;
mat3 scaleZ = mat3(
vec3(1, 0, 0),
vec3(0, 1, 0),
vec3(0, 0, scaleFactor)
);
vec3 newPosition = position + amplitude * normal * vec3( displacement );
vec3 newPosition2 = scaleZ * ( newPosition );
gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition2, 1.0 );
}
</script>
<!-- Fragment shader -->
<script type="x-shader/x-fragment" id="fragmentshader">
varying vec2 vUv;
uniform sampler2D texture;
void main() {
gl_FragColor = texture2D(texture, vUv);
}
</script>
<!-- JS setup code -->
<script src="meca-flu/js/meca-flu.js">
</script>
</body>
</html>