-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMtransforms.html
87 lines (55 loc) · 1.94 KB
/
Mtransforms.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
<!DOCTYPE html>
<html>
<head>
<title>hwshen WebGL — Multiple Transformed Objects</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="glMatrix-0.9.5.min.js"></script>
<!-- ************** Fragment Shader ************* -->
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
varying vec4 vColor;
void main(void) {
gl_FragColor = vColor;
}
</script>
<!-- ************** Vertex Shader ************* -->
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
attribute vec3 aVertexColor;
varying vec4 vColor;
uniform mat4 uMVMatrix;
void main(void) {
gl_PointSize = 10.0;
gl_Position = uMVMatrix*vec4(aVertexPosition, 1.0);
vColor = vec4(aVertexColor, 1.0);
}
</script>
<script type="text/javascript" src="shaders_setup.js"></script>
<script type="text/javascript" src="Mtransforms.js"></script>
</head>
<body onload="webGLStart();">
<canvas id="code04-canvas"style="border:none;"width="700"height="700"></canvas>
<h4> Geometry: </h4>
<button onclick="obj(1)"> Square1</button>
<button onclick="obj(2)"> Square2</button>
<button onclick="obj(3)"> Square3</button>
<h4> Background: </h4>
<button onclick="BG(1,0,0)"> Red</button>
<button onclick="BG(0,1,0)"> Green</button>
<button onclick="BG(0,0,1)"> Blue</button>
<button onclick="BG(0.5,0.5,0.5)"> Grey</button>
<button onclick="BG(0,0,0)"> Black</button>
<button onclick="BG(1,1,1)"> White</button>
<h4>
- Click on the left mouse button and move the coursor to rotate; select the squre and apply 'X', 'x', 'Y','y'
</h4>
</h4>
<button onclick="redraw()"> Go Back! </button>
</div>
<footer>
<center>
<p>© WebGL example: Han-Wei Shen, Ohio State University, 2016</p>
</center>
</footer>
</body>
</html>