Give cross-body bars a true 3D axis and fix the goblet squat hold

The orbit was always a real camera orbit — figure and props share one
rigid rotation — but a bar's screen-space angle authored the wrong 3D
rod: the default horizontal encoded a rod along the body axis, so
barbells hovered fixed on screen and vanished at the head-on view
where they should span widest. Line props now take "axis": "z" (both
renderers in lockstep, fixture-pinned): the world left-right direction
projects through the camera pitch like the floor quad — end-on plates
in profile, full span face-on, swinging with the hands in between.
Applied to the ten cross-body bars; vertical handles were already
orbit-invariant.

Goblet Squat's hand pins sat so close to the shoulders that the
two-bone IK was degenerate, flipping between a chicken-wing and an
elbow-behind solve; re-pinned level with the shoulders so the elbows
tuck straight down through the whole rep.

Claude-Session: https://claude.ai/code/session_01HJDQQDA9QdP8zByg43H5v3
This commit is contained in:
2026-07-08 12:49:35 -04:00
parent 60927b5d1f
commit fd2deaa9c7
79 changed files with 190 additions and 143 deletions
@@ -178,6 +178,10 @@ struct MotionProp: Codable {
/// Fixed world angle (degrees, y-up). Default: bars are horizontal;
/// dumbbells/pads sit perpendicular to the lower bone.
let angle: Double?
/// True 3D axis, superseding `angle`: `"z"` marks a cross-body rod
/// (barbell, pull-up bar) whose projection foreshortens naturally
/// end-on in a profile view, full span face-on.
let axis: String?
let halfLen: Double?
let w: Double?
/// End-disc radius (dumbbell plates default 4.5; bars none).
+23 -9
View File
@@ -576,10 +576,13 @@ enum MotionSolver {
/// `anchor` the frame's root canvas anchor, and `rotation` the `propRotation`
/// between them. Joint positions come from `geo`; everything authored scene
/// points, cable anchors, bar angles, pad perpendiculars, roller offsets
/// resolves against `authored` and rotates. Kept 1:1 with the reference
/// renderer's `resolve_props` change them in lockstep.
/// resolves against `authored` and rotates. `pitch` is the camera elevation,
/// needed by `axis` props whose world-space direction projects through it
/// (like the floor quad). Kept 1:1 with the reference renderer's
/// `resolve_props` change them in lockstep.
static func resolveProps(_ props: [MotionProp], geo: FigureGeometry, authored: FigureGeometry,
anchor: CGPoint, rotation: Mat3?) -> (bg: [PropPrimitive], fg: [PropPrimitive]) {
anchor: CGPoint, rotation: Mat3?,
pitch: Double = MotionSolver.defaultPitch) -> (bg: [PropPrimitive], fg: [PropPrimitive]) {
/// Authored canvas point (+ depth toward the camera) drawn canvas.
func place(_ x: Double, _ y: Double, _ z: Double) -> CGPoint {
guard let rotation else { return CGPoint(x: x, y: y) }
@@ -654,13 +657,23 @@ enum MotionSolver {
}
guard let at = prop.at, let now = jointAnchor(geo, at),
let auth = jointAnchor(authored, at) else { continue }
let axis: CGVector
if prop.type == "bar" || prop.angle != nil {
axis = direction(prop.angle ?? 0) // fixed authored-view angle
let u: CGVector
if prop.axis == "z" {
// A cross-body rod (barbell, pull-up bar): its true 3D axis
// is the world left-right axis, projected through the camera
// elevation like the floor quad a small vertical sliver
// end-on in a profile view (the plates read nearly
// concentric, seen from slightly above), full span face-on,
// swinging with the figure in between, symmetric at 0 and 180.
let pr = pitch * .pi / 180
let axis = Vec3(0, -sin(pr), cos(pr))
let v = rotation?.apply(axis) ?? axis
u = CGVector(dx: v.x, dy: -v.y)
} else if prop.type == "bar" || prop.angle != nil {
u = swing(direction(prop.angle ?? 0)) // fixed authored-view angle, foreshortens under orbit
} else {
axis = CGVector(dx: -auth.direction.dy, dy: auth.direction.dx)
u = swing(CGVector(dx: -auth.direction.dy, dy: auth.direction.dx))
}
let u = swing(axis) // foreshortens under orbit
let h = prop.halfLen ?? defaults.halfLen
let a = CGPoint(x: now.point.x - u.dx * h, y: now.point.y - u.dy * h)
let b = CGPoint(x: now.point.x + u.dx * h, y: now.point.y + u.dy * h)
@@ -764,7 +777,8 @@ struct MotionTimeline {
guard !props.isEmpty else { return geo }
let rotation = MotionSolver.propRotation(pitch: pitch, yawOffset: yawOffset)
(geo.propsBackground, geo.propsForeground) = MotionSolver.resolveProps(
props, geo: geo, authored: authored, anchor: frame.rootPos, rotation: rotation)
props, geo: geo, authored: authored, anchor: frame.rootPos, rotation: rotation,
pitch: pitch)
return geo
}
}
@@ -4,7 +4,7 @@
"camera": {"zoom": 0.7},
"working": ["leg_r", "leg_l"],
"props": [
{"type": "bar", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 14}
{"type": "bar", "axis": "z", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 14}
],
"frames": [
{
@@ -8,7 +8,7 @@
{"kind": "line", "pts": [[78, 129], [78, 150]], "w": 4},
{"kind": "line", "pts": [[144, 129], [144, 150]], "w": 4}
]},
{"type": "bar", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 12}
{"type": "bar", "axis": "z", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 12}
],
"frames": [
{
@@ -4,7 +4,7 @@
"camera": {"zoom": 0.7},
"working": ["leg_r", "leg_l", "spine"],
"props": [
{"type": "bar", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 16}
{"type": "bar", "axis": "z", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 16}
],
"frames": [
{
@@ -12,24 +12,24 @@
"root": {"pos": [160, 66], "pitch": 5},
"spine": [0, 0],
"neck": 2, "head": -6,
"shoulder_r": 38, "elbow_r": 125,
"shoulder_l": 38, "elbow_l": 125,
"shoulder_r": 5, "elbow_r": 140,
"shoulder_l": 5, "elbow_l": 140,
"hip_r": 5, "knee_r": 4, "ankle_r": 0,
"hip_l": 5, "knee_l": 4, "ankle_l": 0,
"pins": {"foot_r": [162, 148], "foot_l": [166, 150],
"hand_r": [176, -2], "hand_l": [180, 0]}
"hand_r": [185, -8], "hand_l": [189, -6]}
},
{
"hold": 0.4, "tween": 1.0,
"root": {"pos": [150, 104], "pitch": 22},
"spine": [0, -4],
"neck": 4, "head": -18,
"shoulder_r": 46, "elbow_r": 120,
"shoulder_l": 46, "elbow_l": 120,
"shoulder_r": 15, "elbow_r": 135,
"shoulder_l": 15, "elbow_l": 135,
"hip_r": 96, "knee_r": 116, "ankle_r": 20,
"hip_l": 96, "knee_l": 116, "ankle_l": 20,
"pins": {"foot_r": [162, 148], "foot_l": [166, 150],
"hand_r": [190, 40], "hand_l": [194, 42]}
"hand_r": [196, 36], "hand_l": [200, 38]}
}
]
}
@@ -7,7 +7,7 @@
{"kind": "line", "pts": [[50, 122], [88, 122]], "w": 9, "depth": 8},
{"kind": "line", "pts": [[68, 127], [68, 150]], "w": 5}
]},
{"type": "bar", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 13}
{"type": "bar", "axis": "z", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 13}
],
"frames": [
{
@@ -9,7 +9,7 @@
{"kind": "line", "pts": [[140, 130], [166, 127]], "w": 8, "depth": 8},
{"kind": "line", "pts": [[152, 133], [152, 150]], "w": 5}
]},
{"type": "bar", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 12}
{"type": "bar", "axis": "z", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 12}
],
"frames": [
{
@@ -9,7 +9,7 @@
{"kind": "circle", "c": [272, 19], "r": 4, "fill": true, "color": "prop"}
]},
{"type": "cable", "from": [272, 19], "to": ["hand_r", "hand_l"], "w": 4},
{"type": "bar", "at": ["hand_r", "hand_l"], "halfLen": 24}
{"type": "bar", "axis": "z", "at": ["hand_r", "hand_l"], "halfLen": 24}
],
"frames": [
{
@@ -4,7 +4,7 @@
"camera": {"zoom": 0.7},
"working": ["arm_r", "arm_l"],
"props": [
{"type": "bar", "at": ["hand_r", "hand_l"], "halfLen": 24}
{"type": "bar", "axis": "z", "at": ["hand_r", "hand_l"], "halfLen": 24}
],
"frames": [
{
@@ -4,7 +4,7 @@
"camera": {"zoom": 0.7},
"working": ["leg_r", "leg_l", "spine"],
"props": [
{"type": "bar", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 13}
{"type": "bar", "axis": "z", "at": ["hand_r", "hand_l"], "halfLen": 26, "plateR": 13}
],
"frames": [
{
@@ -9,7 +9,7 @@
{"kind": "line", "pts": [[126, 143], [126, 151]], "w": 5},
{"kind": "line", "pts": [[110, 151], [142, 151]], "w": 4, "depth": 5}
]},
{"type": "bar", "at": ["hand_r", "hand_l"], "halfLen": 10}
{"type": "bar", "axis": "z", "at": ["hand_r", "hand_l"], "halfLen": 10}
],
"frames": [
{
@@ -8,7 +8,7 @@
{"kind": "circle", "c": [186, -58], "r": 4, "fill": true, "color": "prop"}
]},
{"type": "cable", "from": [186, -58], "to": ["hand_r", "hand_l"], "w": 3},
{"type": "bar", "at": ["hand_r", "hand_l"], "halfLen": 10}
{"type": "bar", "axis": "z", "at": ["hand_r", "hand_l"], "halfLen": 10}
],
"frames": [
{