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

Method poseFalling

web/observatory/js/pose-system.js:286–322  ·  view source on GitHub ↗
(px, pz, elapsed, progress)

Source from the content-addressed store, hash-verified

284 // Flailing arms, head snap, non-linear easing (cubic ease-in)
285
286 poseFalling(px, pz, elapsed, progress) {
287 const standing = this.poseStanding(px, pz, elapsed, 0, 0);
288 const fallen = this.poseFallen(px, pz, elapsed);
289
290 // Cubic ease-in for realistic acceleration
291 const t = progress * progress * progress;
292
293 // Arm flailing -- sinusoidal perturbation that peaks mid-fall then diminishes
294 const flailIntensity = Math.sin(progress * Math.PI) * 0.15;
295 const flailL = Math.sin(elapsed * 8 + progress * 5) * flailIntensity;
296 const flailR = Math.cos(elapsed * 8 + progress * 5) * flailIntensity;
297
298 // Head snaps back early in the fall
299 const headSnap = progress < 0.4 ? Math.sin(progress * Math.PI / 0.4) * 0.06 : 0;
300
301 const kps = [];
302 for (let i = 0; i < 17; i++) {
303 kps.push([
304 standing[i][0] * (1 - t) + fallen[i][0] * t,
305 standing[i][1] * (1 - t) + fallen[i][1] * t,
306 standing[i][2] * (1 - t) + fallen[i][2] * t,
307 ]);
308 }
309
310 // Apply head snap (tilt backward)
311 kps[0][1] += headSnap;
312 kps[1][1] += headSnap * 0.9;
313 kps[2][1] += headSnap * 0.9;
314
315 // Apply arm flailing
316 kps[7][0] += flailL; kps[7][2] += flailL * 0.5; // left elbow
317 kps[8][0] += flailR; kps[8][2] -= flailR * 0.5; // right elbow
318 kps[9][0] += flailL * 1.5; kps[9][2] += flailL; // left wrist
319 kps[10][0] += flailR * 1.5; kps[10][2] -= flailR; // right wrist
320
321 return kps;
322 }
323
324 // ---- Exercising --------------------------------------------------------
325

Callers 1

generateKeypointsMethod · 0.95

Calls 3

poseStandingMethod · 0.95
poseFallenMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected