Browse Source

add matrix.perspective() function.

Lucas Stadler 12 years ago
parent
commit
6a013f3d09
1 changed files with 10 additions and 8 deletions
  1. 10 8
      js/pixl/public/trixl.html

+ 10 - 8
js/pixl/public/trixl.html

@ -228,6 +228,15 @@
228 228
				 0, 0, 0, 1
229 229
			];
230 230
		}
231
232
		matrix.persective = function(fov, aspect) {
233
			return [
234
				Math.PI / 3 / aspect, 0, 0, 0,
235
				0, Math.PI / 3, 0, 0,
236
				0, 0, 1, 1,
237
				0, 0, 0, 1
238
			];
239
		}
231 240
	</script>
232 241
	<script>
233 242
		window.trixl = {};
@ -282,14 +291,7 @@
282 291
					//matrix.rotateY(angle.y / 10),
283 292
					matrix.rotateX(angle.x / 10),
284 293
					matrix.translate(pos[0] + offset.x, pos[1] + offset.y, pos[2] + offset.z),
285
					[1, 0, 0, 0,
286
					 0, 1, 0, 0,
287
					 0, 0, 1, 1,
288
					 0, 0, 0, 1],
289
					[Math.PI / 3 / aspect, 0, 0, 0,
290
					 0, Math.PI / 3, 0, 0,
291
					 0, 0, 1, 0,
292
					 0, 0, 0, 1]
294
					matrix.persective(Math.PI / 3, aspect)
293 295
				);
294 296
			}
295 297
			var t = transform([0.0, 0.0, 2]);