BoundMotion.bind constructor
BoundMotion.bind(
- MotionDocument doc,
- SceneDocument scene
Implementation
factory BoundMotion.bind(MotionDocument doc, SceneDocument scene) {
var nodes = {for (var (n, _) in scene.walk()) n};
var bound = <AnimateGroup, BoundGroup>{};
for (var g in doc.groups) {
// The guard survives even though nothing is resolved: a motion still
// has to be played against the scene it was authored against, and a
// group pointing outside it is a wiring mistake worth naming.
if (!nodes.contains(g.node)) {
throw StateError(
'the motion animates a node this scene does not have '
'("${g.node.name}", from group "${g.name}") — bound against a '
'different scene? Bind the pair that was authored together.',
);
}
bound[g] = BoundGroup._(g);
}
return BoundMotion._(
doc,
scene,
bound,
playTimeline(doc.timeline, into: bound),
);
}