blend method
This pose blended from a towards b by t (0 = a, 1 = b):
translations and scales linearly, rotations along the shorter way.
Implementation
void blend(Pose a, Pose b, double t) {
final u = 1 - t;
for (var i = 0; i < translations.length; i++) {
translations[i] = a.translations[i] * u + b.translations[i] * t;
scales[i] = a.scales[i] * u + b.scales[i] * t;
}
for (var n = 0; n < nodeCount; n++) {
final o = n * 4;
final ra = a.rotations, rb = b.rotations;
final dot =
ra[o] * rb[o] +
ra[o + 1] * rb[o + 1] +
ra[o + 2] * rb[o + 2] +
ra[o + 3] * rb[o + 3];
final sign = dot < 0 ? -1.0 : 1.0;
var x = ra[o] * u + rb[o] * t * sign;
var y = ra[o + 1] * u + rb[o + 1] * t * sign;
var z = ra[o + 2] * u + rb[o + 2] * t * sign;
var w = ra[o + 3] * u + rb[o + 3] * t * sign;
final length = math.sqrt(x * x + y * y + z * z + w * w);
if (length > 1e-12) {
x /= length;
y /= length;
z /= length;
w /= length;
}
rotations[o] = x;
rotations[o + 1] = y;
rotations[o + 2] = z;
rotations[o + 3] = w;
}
}