setupScene = gl4.regl({
uniforms: {
aspect: ctx => [ctx.viewportWidth / ctx.viewportHeight, 1],
eye: gl3.regl.prop('eye'),
at: [0,0,0],
up: [0,1,0],
rotateX: [
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
],
/*
Array "rotateY" describes matrix
[
Math.cos(ay), 0, Math.sin(ay), 0,
0, 1, 0, 0,
-Math.sin(ay), 0, Math.cos(ay), 0,
0, 0, 0, 1,
],
which with the right-multiplication (M*v) describes a counterclockwise rotation
in a right-handed coordinate system, or a clockwise rotation in a left-handed system.
*/
rotateY: [
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
],
/*
Array "rotateZ" describes matrix
[
Math.cos(az), -Math.sin(az), 0, 0,
Math.sin(az), Math.cos(az), 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
],
which with the right-multiplication (M*v) describes a counterclockwise rotation
in a right-handed coordinate system, or a clockwise rotation in a left-handed system.
*/
rotateZ: [
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
],
// This matrix is compatible with the column-major notation and
// the right-multiplication M*v used in the vertex shader.
translate: [
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
],
// Orthographic projection (column major order)
// Note that there is symmetry between x, y and the z direction. Setting entry [2,2] to -2/(far-near),
// as suggested in the wikipedia, has the effect to flip the system handedness, but the camera eye
// position seems not consistent anymore (probably the camere basis has to change as well).
projection: [
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 0.1, 0,
0, 0, 0, 1,
],
},
})