It is done in AnimationState:
spine-runtimes/AnimationState.java at 3.7-beta
AnimationState is a beast, as it has to cover a lot of use cases for applying queued and layered animations. In a nutshell, when a track entry is done, it is set on the TrackEntry mixingFrom
field of the new current entry. Later, AnimationState applyMixingFrom
applies the previous mixingFrom
entries first, then the current entry. When the mix is complete, the last time the mixingFrom
entry is applied will set the values back to the setup pose. After that, when the current entry is applied, those values will stay at the setup pose values if the current entry did not key them. Note even if there is no mix, the old entry is still set as the mixingFrom
entry so the values it keys can be reset to the setup pose in applyMixingFrom
.
If you are attempting re-implementation rather than porting, it would be much easier to just port. Please note the Spine Runtimes license applies whether you are doing a direct port or a re-implementation, unless you are doing a clean room implementation (in which case you'd probably want to avoid digging around the Spine Runtimes source so your work is not contaminated).
FWIW, I would not sacrifice matching the official runtime classes for JSON parsing. IMHO, any benefits of doing that are outweighed by keeping closer to the reference implementation. Besides, only JSON parsing is needed (no emitting) and the binary format is likely more useful (smaller files and faster parsing).
Also, I would also not make Skeleton a scene graph node
better to have a scene graph node that has a Skeleton instance. In general the less tied to the scene graph the better, but the main reason is that that coupling is unnecessary and in some cases unwanted. Eg, an army with many hundreds of enemies can be animated by a dozen or so skeletons (when it doesn't matter if each enemy is not unique). Or you can use a skeleton to animate a UI, or otherwise use the skeleton's bone positions and other pose information and you do not need or want the skeleton in the scene graph.