MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / poseWalking

Method poseWalking

web/observatory/js/pose-system.js:96–142  ·  view source on GitHub ↗
(px, pz, elapsed, ms, bp)

Source from the content-addressed store, hash-verified

94 // Torso rotation, head bob, natural arm pendulum with elbow bend
95
96 poseWalking(px, pz, elapsed, ms, bp) {
97 const speed = Math.min(ms / 100, 2.5);
98 const wp = elapsed * speed * 1.8;
99 const sFactor = Math.min(speed, 1);
100
101 // Leg stride
102 const legStride = Math.sin(wp) * 0.25 * sFactor;
103 const legBack = Math.sin(wp + Math.PI) * 0.25 * sFactor;
104 const kneeAmt = Math.abs(Math.sin(wp)) * 0.08;
105
106 // Natural arm pendulum -- opposite to legs, with elbow bend
107 const armPhase = Math.sin(wp);
108 const armSwingL = -armPhase * 0.3 * sFactor; // left arm opposite right leg
109 const armSwingR = armPhase * 0.3 * sFactor;
110 const elbowBendL = Math.max(0, -armPhase) * 0.12 * sFactor; // bend on backswing
111 const elbowBendR = Math.max(0, armPhase) * 0.12 * sFactor;
112
113 // Torso twist (shoulders rotate opposite to hips)
114 const torsoTwist = Math.sin(wp) * 0.03 * sFactor;
115
116 // Vertical bob (double frequency -- peak at mid-stance)
117 const bob = Math.abs(Math.sin(wp)) * 0.025;
118
119 // Head bob -- slight lag behind body
120 const headBob = Math.abs(Math.sin(wp - 0.2)) * 0.015;
121 const headLean = Math.sin(wp) * 0.008;
122
123 return [
124 [px + headLean, 1.72 + bp + bob + headBob, pz], // 0 nose
125 [px - 0.03 + headLean, 1.74 + bp + bob + headBob, pz - 0.02], // 1 left eye
126 [px + 0.03 + headLean, 1.74 + bp + bob + headBob, pz - 0.02], // 2 right eye
127 [px - 0.07, 1.72 + bp + bob + headBob, pz], // 3 left ear
128 [px + 0.07, 1.72 + bp + bob + headBob, pz], // 4 right ear
129 [px - 0.22 - torsoTwist, 1.48 + bp + bob, pz], // 5 left shoulder (twist)
130 [px + 0.22 - torsoTwist, 1.48 + bp + bob, pz], // 6 right shoulder
131 [px - 0.28 + armSwingL * 0.3, 1.18 + bp + bob - elbowBendL, pz + armSwingL * 0.3], // 7 left elbow
132 [px + 0.28 + armSwingR * 0.3, 1.18 + bp + bob - elbowBendR, pz + armSwingR * 0.3], // 8 right elbow
133 [px - 0.26 + armSwingL * 0.6, 0.92 + bp + bob - elbowBendL * 1.5, pz + armSwingL * 0.5], // 9 left wrist
134 [px + 0.26 + armSwingR * 0.6, 0.92 + bp + bob - elbowBendR * 1.5, pz + armSwingR * 0.5], // 10 right wrist
135 [px - 0.11 + torsoTwist * 0.5, 0.98 + bp + bob, pz], // 11 left hip (counter-twist)
136 [px + 0.11 + torsoTwist * 0.5, 0.98 + bp + bob, pz], // 12 right hip
137 [px - 0.12 + legStride * 0.3, 0.52 + kneeAmt, pz + legStride], // 13 left knee
138 [px + 0.12 + legBack * 0.3, 0.52 + kneeAmt, pz + legBack], // 14 right knee
139 [px - 0.12 + legStride * 0.6, 0.04, pz + legStride * 1.5], // 15 left ankle
140 [px + 0.12 + legBack * 0.6, 0.04, pz + legBack * 1.5], // 16 right ankle
141 ];
142 }
143
144 // ---- Lying -------------------------------------------------------------
145 // Subtle micro-movements, differentiate supine vs side-lying via elapsed hash

Callers 1

generateKeypointsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected