Hi again,
unless you want to do also 2D/3D props, you don’t need to calculate arclengths. Here are more details for 1D, without the part that solves the cubic equation (search google for that, propably on Wikipedia their is a detailed solution). I’m really wondering why you don’t want to use the built-in valueAtTime()…
Xavier.
function valueAtTime(prop, t0)
{
if ( !(prop instanceof Property) || prop.propertyValueType !== PropertyValueType.OneD || prop.expressionEnabled) return “hi”;
var N=prop.numKeys, n, t, t1, t2, DT, easeIn, easeOut, p0,p1,p2,p3, a0,a1,a2,a3, roots, k, u0;
if (N===0) return prop.value;
n = prop.nearestKeyIndex(t0); if (prop.keyTime(n)>t0) n–;
if (n===0) return prop.keyValue(1);
if (n===N) return prop.keyValue(N);
if (t0-prop.keyTime(n)<0.0005 || prop.keyOutInterpolationType(n) === KeyframeInterpolationType.HOLD) return prop.keyValue(n);
t1 = prop.keyTime(n);
t2 = prop.keyTime(n+1);
DT = t2-t1;
t = (t0-t1)/DT;
easeOut = prop.keyOutTemporalEase(n)[0];
easeIn = prop.keyInTemporalEase(n+1)[0];
// time :
// time control points (bezier):
p0 = 0;
p1 = easeOut.influence/100;
p2 = 1-easeIn.influence/100;
p3=1;
// same, standard basis:
a0 = p0; a1 = 3*(p1-p0); a3 = 3*(p2-p1); a2 = a3-a1; a3 = (p3-p0)-a3;
// solve a0 + a1*u + a2*u*u + a3*u*u*u = t and call u0 the unique solution in [0,1]
roots = solve(a0 + a1*u + a2*u*u + a3*u*u*u = t); // not provided
for (k=0; k less than roots.length; k++) {u0=roots[k]; if (0<=u0 && u0<=1) break;};
// value :
// value control points (bezier):
p0 = prop.keyValue(n);
p3 = prop.keyValue(n+1);
p1 = p0 + easeOut.speed * DT * easeOut.influence/100;
p2 = p3 – easeIn.speed * DT * easeIn.influence/100;
// same, standard basis:
a0 = p0; a1 = 3*(p1-p0); a3 = 3*(p2-p1); a2 = a3-a1; a3 = (p3-p0)-a3;
return a0+u0*(a1+u0*(a2+u0*a3));
};