sample method

void sample(
  1. double time,
  2. Pose pose
)

Writes every channel's value at time (seconds, clamped to the keys) into pose. Nodes the clip doesn't move are left as they are.

Implementation

void sample(double time, Pose pose) {
  final value = _scratch;
  for (final channel in data.channels) {
    if (channel.node >= pose.nodeCount) continue;
    final sampler = data.samplers[channel.sampler];
    _sampleInto(channel.sampler, sampler, time, value);
    final n = channel.node;
    switch (channel.path) {
      case AnimationPath.translation:
        pose.translations[n * 3] = value[0];
        pose.translations[n * 3 + 1] = value[1];
        pose.translations[n * 3 + 2] = value[2];
      case AnimationPath.rotation:
        pose.rotations[n * 4] = value[0];
        pose.rotations[n * 4 + 1] = value[1];
        pose.rotations[n * 4 + 2] = value[2];
        pose.rotations[n * 4 + 3] = value[3];
      case AnimationPath.scale:
        pose.scales[n * 3] = value[0];
        pose.scales[n * 3 + 1] = value[1];
        pose.scales[n * 3 + 2] = value[2];
      case AnimationPath.weights:
        break;
    }
  }
}