1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! The seam where `PropertyBinding`'s getter/setter half will meet the scene
//! graph.
//!
//! Three's `PropertyBinding` does two separable jobs: it parses a track name
//! (`parseTrackName`, ported in [`crate::animation::property_binding`]) and it
//! resolves that name against a live `Object3D` tree into a `getValue` /
//! `setValue` pair, picking one of sixteen `GetterByBindingType` /
//! `SetterByBindingTypeAndVersioning` closures depending on whether the target
//! property is a number, an array, a `Color`/`Vector`/`Quaternion` with
//! `fromArray`, or a morph-target-influence name, and whether it needs
//! `needsUpdate` or `matrixWorldNeedsUpdate` flagged afterwards.
//!
//! The second job needs an `Object3D` tree with named property access, which
//! this crate does not have yet (it is being built on a parallel branch). So
//! the mixer side is written against these two traits instead:
//!
//! - [`BindingTarget`] is one resolved property: read it into a flat buffer,
//! write it back from one. That is the whole of what `PropertyMixer` and
//! `AnimationAction` ever ask a binding to do — they only ever see
//! `getValue( buffer, offset )` and `setValue( buffer, offset )`.
//! - [`TargetResolver`] is the tree: hand it a parsed track name, get a
//! `BindingTarget` back. `Object3D` implements this once it exists, and
//! `AnimationObjectGroup` implements it by fanning out over its members.
//!
//! `bind` / `unbind` stay on the trait because Three's `Composite` binding and
//! `PropertyBinding.bind()` are lazy: the first `getValue` triggers the
//! resolve, and `unbind` drops it so a re-bound root is re-resolved.
use crateParsedTrackName;
/// One resolved animatable property, as a flat run of `valueSize` f64s.
///
/// The offset is into the caller's buffer, not into the target: Three's
/// `getValue( buffer, offset )` / `setValue( buffer, offset )` read and write
/// `buffer[ offset .. offset + valueSize ]`.
/// The scene-graph side: resolve a parsed track name to a [`BindingTarget`].
///
/// `Object3D` (and `AnimationObjectGroup`, over its members) implements this.
/// `None` is Three's `console.error( 'THREE.PropertyBinding: Trying to update
/// node for track: … but it wasn't found.' )` — a track that does not resolve is
/// skipped, not fatal.
/// A [`BindingTarget`] over a plain buffer, for tests and for the mixer work
/// that cannot wait for the object tree: it behaves exactly as Three's
/// `Direct` + `EntireArray` binding over a `Float64Array` property.