Picks the adapter for a value by inspecting its structure. Returns
undefined when no adapter fits, so callers decide whether that is an error
(createBinding throws) or a reason to fall back.
Detection is by instanceof for the math classes and by typeof for the
primitives. Two deliberate exclusions:
Discrete is never detected. Every value that reaches here is "some
object", so a discrete fallback would swallow typos — a binding to a
misspelled property that happens to hold a Transform would silently
step-animate it. Discrete is opt-in: pass discreteAdapterFor to
createBinding.
null and undefined are not detected. There is nothing to inspect,
and a track whose value type only becomes known later is a bug at binding
time, not a case to guess at.
The number[4] ambiguity
A four-number array is reported as "color" even when the author meant a
plain numeric quadruple (a generic parameter block, a UV rect). The ambiguity
is unresolvable from structure alone — the two are the same runtime shape —
so it is resolved by consequence: colorAdapter is a plain
component-wise lerp with no clamping and no color-space handling, which is
exactly what a generic number[4] wants too. The two interpretations
therefore differ only in the reported ValueKind, and a caller who
needs that distinction (a diagnostic, a serializer) passes an explicit
adapter instead of relying on detection. Arrays of any other length, and
4-arrays with a non-number element, are not detected at all.
Picks the adapter for a value by inspecting its structure. Returns
undefinedwhen no adapter fits, so callers decide whether that is an error (createBinding throws) or a reason to fall back.Detection is by
instanceoffor the math classes and bytypeoffor the primitives. Two deliberate exclusions:Transformwould silently step-animate it. Discrete is opt-in: pass discreteAdapterFor tocreateBinding.nullandundefinedare not detected. There is nothing to inspect, and a track whose value type only becomes known later is a bug at binding time, not a case to guess at.The
number[4]ambiguityA four-number array is reported as
"color"even when the author meant a plain numeric quadruple (a generic parameter block, a UV rect). The ambiguity is unresolvable from structure alone — the two are the same runtime shape — so it is resolved by consequence: colorAdapter is a plain component-wise lerp with no clamping and no color-space handling, which is exactly what a genericnumber[4]wants too. The two interpretations therefore differ only in the reported ValueKind, and a caller who needs that distinction (a diagnostic, a serializer) passes an explicit adapter instead of relying on detection. Arrays of any other length, and 4-arrays with a non-number element, are not detected at all.