computeFrameData = {
const data = new Uint8Array(canvas.width * canvas.height * 4);
let view = mat4.lookAt([], [0, 0, 4], [0, 0, 0], [0, 1, 0]);
let projection = mat4.perspective([], (45 * Math.PI) / 180, 1, 0.01, 100);
let model = mat4.identity([]);
let xrot = interpolator(
(rot.xStart / 180) * Math.PI,
(rot.xEnd / 180) * Math.PI
);
let yrot = interpolator(
(rot.yStart / 180) * Math.PI,
(rot.yEnd / 180) * Math.PI
);
let drawFunction = function(obj) {
let triMesh = triangleMesh(obj, false);
let drawFaces = makeTriMeshDraw(triMesh);
let scaleFactor = Math.sqrt(3) / obj.radius;
return function(model, view, projection) {
regl.clear({
color: [0.9, 0.9, 0.9, 1.0],
depth: 1
});
let conf = {
modelview: mat4.mul([], view, model),
projection,
scaleFactor
};
drawFaces(conf);
};
};
return function computeFrameData(frame) {
regl.poll();
let u = frame / frames;
let model = mat4.mul(
[],
mat4.fromXRotation([], xrot(u)),
mat4.fromYRotation([], yrot(u))
);
let draw = drawFunction(obj(frame));
draw(model, view, projection);
regl.read(data);
if (renderParam) blitText(mutable params.map(x => x.toFixed(3)), data);
return data;
};
}