|
|
@ -262,25 +262,44 @@
|
|
262
|
262
|
gl.vertexAttribPointer(program.vertexPosBuffer, 3, gl.FLOAT, false, 0, 0);
|
|
263
|
263
|
|
|
264
|
264
|
var angle = {x: 0, y: 0, z: 0};
|
|
265
|
|
setInterval(function() {
|
|
266
|
|
program.transform = gl.getUniformLocation(program, 'transform');
|
|
|
265
|
program.transform = gl.getUniformLocation(program, 'transform');
|
|
|
266
|
trixl.redraw = function() {
|
|
267
|
267
|
var transform = matrix.multiplyMany4x4(
|
|
268
|
|
matrix.rotateX(angle.x / 5),
|
|
269
|
|
matrix.rotateY(angle.y / 5),
|
|
270
|
|
matrix.rotateZ(angle.z / 5),
|
|
|
268
|
//matrix.identity(4), matrix.identity(4) /*
|
|
|
269
|
matrix.translate(-0.5, -0.5, -0.0),
|
|
|
270
|
matrix.scale(0.5, 0.5, 0.5),
|
|
|
271
|
matrix.rotateZ(angle.z / 4),
|
|
|
272
|
//matrix.rotateY(angle.y / 10),
|
|
|
273
|
matrix.rotateX(angle.x / 4),
|
|
271
|
274
|
//matrix.translate(-0.5, -0.5, 0),
|
|
272
|
|
matrix.translate(-0.5, -0.5, -0.5),
|
|
273
|
|
matrix.scale(0.5, 0.5, 0.5)
|
|
|
275
|
//matrix.translate(-0.5, -0.5, -0.5),
|
|
|
276
|
matrix.translate(-0.0, -0.0, -0.1)
|
|
|
277
|
//matrix.perspective(Math.PI / 3, trixl.window.w / trixl.window.h, 0, 2000) //*/
|
|
274
|
278
|
);
|
|
275
|
|
gl.uniformMatrix4fv(program.transform, false, matrix.transpose(transform, [4, 4]));
|
|
|
279
|
trixl.debug_pos(matrix.multiply([1,1,1,1], [1, 4], transform, [4, 4]));
|
|
|
280
|
gl.uniformMatrix4fv(program.transform, false, transform);
|
|
276
|
281
|
|
|
277
|
282
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
278
|
283
|
gl.drawArrays(gl.TRIANGLES, 0, 6 * 6);
|
|
279
|
284
|
|
|
280
|
285
|
angle.x += Math.PI / 10;
|
|
281
|
|
angle.y += Math.PI / 30;
|
|
282
|
|
angle.z += Math.PI / 50;
|
|
283
|
|
}, 50);
|
|
|
286
|
angle.y += Math.PI / 10;
|
|
|
287
|
angle.z += Math.PI / 10;
|
|
|
288
|
}
|
|
|
289
|
|
|
|
290
|
trixl.step = function() {
|
|
|
291
|
trixl.redraw();
|
|
|
292
|
trixl.step.reqId = requestAnimationFrame(trixl.step);
|
|
|
293
|
}
|
|
|
294
|
trixl.start = function() {
|
|
|
295
|
trixl.step.reqId = requestAnimationFrame(trixl.step);
|
|
|
296
|
}
|
|
|
297
|
trixl.stop = function() {
|
|
|
298
|
cancelAnimationFrame(trixl.step.reqId);
|
|
|
299
|
trixl.step.reqId = null;
|
|
|
300
|
}
|
|
|
301
|
|
|
|
302
|
trixl.start();
|
|
284
|
303
|
</script>
|
|
285
|
304
|
</body>
|
|
286
|
305
|
</html>
|