Published
Edited
Apr 4, 2019
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
firstStep = clearDB( )
Insert cell
Insert cell
secondStep = {
firstStep; // force evaluation of firstStep cell
let f = await fetch("https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/models/bvh/pirouette.bvh");
let bvhText = await f.text();
let nframes = add2DB(bvhText);
return nframes
}
Insert cell
Insert cell
thirdStep = {
// Number of keyframes used in the projection
let nframes = secondStep;
let nkfs = ~~(nframes*0.05); // 5% of all frames are to be keyframes
// Allocate a buffer for receiving the projected keyframes
let projArray = cArray(nkfs*3);
// Call function to compute keyframes
let n = computeKFs (projArray.offset, nkfs, 500);
// Retrieve the projection points and store into a global array
let proj = [];
let data = projArray.getArray();
console.assert (data.length == projArray.size);
for (let i = 0; i < data.length; i+=3) {
proj.push ([data[i], data[i+1], data[i+2]])
}
projArray.dispose();
return proj
}
Insert cell
Insert cell
Insert cell
fourthStep = {
let nframes = secondStep;
thirdStep; // make sure keyframe projections were computed
let projArray = cArray(nframes*3);
getRBFP(projArray.offset, 0, nframes);
let data = projArray.getArray();
let proj = [];
let tmp = [];
for (let i = 0; i < data.length; i+=3) {
proj.push ([data[i], data[i+1], data[i+2]]);
if (data[i+2]==1) tmp.push([i/3].concat(proj[i/3]))
}
//console.log(tmp);
projArray.dispose();
return proj;
}
Insert cell
Insert cell
Insert cell
fifthStep = {
let nkfs = thirdStep.length;
let projArray = cArray(nkfs*3);
let data = projArray.getArray();
for (let i = 0; i < data.length; i+=3) {
let row = thirdStep[i/3];
data[i] = row[0];
data[i+1] = row[1];
data[i+2] = row[2];
}
// changing X and Y for the first keyframe
//let tmp = data[0];
//data[0] = data[1];
//data[1] = tmp;
data[1] = 0.25 + data[1];
data[2] = 0.25 + data[2];
//
setKFs (projArray.offset, nkfs);
projArray.dispose();
//
let nframes = secondStep;
let projArray2 = cArray(nframes*3);
getRBFP(projArray2.offset, 0, nframes);
let data2 = projArray2.getArray();
let proj = [];
for (let i = 0; i < data2.length; i+=3) {
proj.push ([data2[i], data2[i+1], data2[i+2]]);
}
projArray2.dispose();
return proj;
}
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more