Sfoglia il codice sorgente

merge branch 'perf-more-trixls'.

Lucas Stadler 12 anni fa
parent
commit
b427685ba6
1 ha cambiato i file con 7 aggiunte e 20 eliminazioni
  1. 7 20
      js/pixl/public/trixl.html

+ 7 - 20
js/pixl/public/trixl.html

@ -394,23 +394,17 @@
394 394
			}
395 395
		}
396 396
397
		var angle = {x: 0, y: 0, z: 0};
398
		var offset = {x: 0, y: 0, z: 0};
399 397
		program.transform = gl.getUniformLocation(program, 'transform');
400 398
		trixl.redraw = function(t) {
401 399
			var view = mat4.lookAt([], trixl.camera.pos, trixl.camera.focus, trixl.camera.up);
402 400
403 401
			var aspect = trixl.window.w / trixl.window.h;
404 402
			var transform = function(pos) {
405
				return mat4.multiplyMany(
406
					matrix.translate(-0.5, -0.5, -0.5),
407
					matrix.rotateZ(angle.z / 10),
408
					//matrix.rotateY(angle.y / 10),
409
					matrix.rotateX(angle.x / 10),
410
					matrix.translate(pos[0] + offset.x, pos[1] + offset.y, pos[2] + offset.z),
411
					view,
412
					matrix.perspective(Math.PI / 3, aspect)
413
				);
403
				var m = mat4.create();
404
				mat4.translate(m, m, [-0.5 + pos[0], -0.5 + pos[1], -0.5 + pos[2]]);
405
				mat4.multiply(m, view, m);
406
				mat4.multiply(m, matrix.perspective(Math.PI / 3, aspect), m);
407
				return m;
414 408
			}
415 409
416 410
			gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
@ -432,19 +426,12 @@
432 426
			});
433 427
434 428
			gl.uniform4f(program.color, -1, -1, -1, 0);
435
436
			//angle.x += Math.PI / 10;
437
			//angle.y += Math.PI / 10;
438
			//angle.z += Math.PI / 10;
439
440
			//offset.x = Math.sin(angle.x * 0.1);
441
			//offset.y = Math.sin(angle.y * 0.1);
442
			//offset.z = Math.cos(angle.z * 0.1) * 2;
443 429
		}
444 430
445 431
		trixl.step = function(t) {
446
			trixl.redraw(t);
447 432
			trixl.step.reqId = requestAnimationFrame(trixl.step);
433
434
			trixl.redraw(t);
448 435
		}
449 436
		trixl.start = function() {
450 437
			trixl.step.reqId = requestAnimationFrame(trixl.step);