All files / systems/animation/catalogs TaeStanceAnimations.ts

100% Statements 6/6
100% Branches 0/0
100% Functions 0/0
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330                                                            49x                                                                                                       49x                                                                                                                                             49x                                                                                                                               49x                                                                                                                                     49x                                                                       49x                  
/**
 * ☱ Tae (Lake) Stance-Specific Animations
 *
 * Specialized idle, movement, and guard animations for the Tae (태/Lake) trigram.
 * Embodies fluid joint manipulation and circular motion from Hapkido techniques.
 *
 * **Korean Martial Arts Context:**
 * - **무술**: 합기도 관절기 (Hapkido Joint Manipulation)
 * - **특성**: 유동적 관절기 (Fluid Joint Locks), 소원 기술 (Small Circle Techniques)
 * - **철학**: 물처럼 흐르는 힘 (Flowing Power Like Water), 호수의 적응 (Lake's Adaptation)
 * - **대표 기술**: 유수연타 (Flowing Water Strikes), 손목꺾기 (Wrist Lock), 팔꿈치 제어 (Elbow Control)
 *
 * @module systems/animation/catalogs/TaeStanceAnimations
 * @category Animation
 * @korean 태괘자세애니메이션
 */
 
import { BoneName, type SkeletalAnimation } from "@/types/skeletal";
import { MartialArtsAnimationBuilder } from "../builders/MartialArtsAnimationBuilder";
 
/**
 * Anatomical safety constants for Tae (Lake) trigram animations
 *
 * These limits document safe physiological ranges for Korean martial arts movements.
 * The constants serve as reference documentation validated by Korean martial arts experts
 * and inform the design of all Tae animations to ensure realistic, safe joint mechanics.
 *
 * Note: These are documentation constants. The actual animation rotations are designed
 * to stay well within these limits naturally through authentic Hapkido biomechanics.
 */
export const ANATOMICAL_LIMITS_TAE_STANCE = {
  /**
   * Maximum safe wrist flexion/extension: ±70° (±1.22 radians)
   * 
   * Typical wrist range is 70-90° flexion/extension. We use 70° as a safe
   * threshold for joint lock techniques without risking constraint violations.
   */
  MAX_WRIST_BEND: 1.22, // ±70° in radians
  
  /**
   * Maximum safe elbow flexion: 145° (2.53 radians)
   * 
   * Full elbow flexion is approximately 145-150°, allowing natural
   * guard positions and joint manipulation techniques.
   */
  MAX_ELBOW_FLEXION: 2.53, // 145° in radians
  
  /**
   * Maximum safe shoulder rotation: ±90° (±1.57 radians)
   * 
   * Safe shoulder rotation range for circular Hapkido movements
   * without risking impingement or constraint violations.
   */
  MAX_SHOULDER_ROTATION: 1.57, // ±90° in radians
} as const;
 
// ═══════════════════════════════════════════════════════════════════════════
// ☱ TAE IDLE FLOWING ANIMATION (태괘 유동 자세)
// ═══════════════════════════════════════════════════════════════════════════
 
/**
 * Tae Idle Flowing Animation
 *
 * **Korean**: 태괘 유동 자세 (Tae-gwae Yudong Jase)
 * **Philosophy**: Embodying lake's fluidity through gentle circular breathing
 *
 * Characteristics:
 * - Gentle circular shoulder movement
 * - Relaxed mid-level guard position
 * - Weight centered and stable
 * - Hands open and ready to grasp
 *
 * Animation Cycle:
 * - 0ms: Neutral position with mid-level guard
 * - 1250ms: Circular shift (left shoulder forward, right back)
 * - 2500ms: Return to neutral (complete cycle)
 *
 * @korean 태괘유동자세
 * @duration 2500ms (2.5 second cycle)
 * @category Idle Animation
 */
export const TAE_IDLE_FLOWING: SkeletalAnimation =
  MartialArtsAnimationBuilder.create(
    "tae_idle_flowing",
    "태괘 유동 자세"
  )
    .asIdle(2.5, true)
    // Keyframe 0ms: Neutral mid-level guard (baseline)
    .at(0)
    .rotate(BoneName.PELVIS, 0, 0, 0) // Neutral pelvis
    .rotate(BoneName.SPINE_UPPER, 0, 0, 0) // Neutral spine
    .rotate(BoneName.SHOULDER_L, -0.52, -0.17, 0.26) // -30°, -10°, 15° (mid-level flexible guard)
    .rotate(BoneName.SHOULDER_R, -0.52, 0.17, -0.26) // -30°, 10°, -15°
    .rotate(BoneName.ELBOW_L, 0, 0, -1.4) // -80° (flexed guard)
    .rotate(BoneName.ELBOW_R, 0, 0, 1.4) // 80° (flexed guard)
    .rotate(BoneName.WRIST_L, 0, 0, 0) // Neutral wrists
    .rotate(BoneName.WRIST_R, 0, 0, 0)
    .rotate(BoneName.HEAD, 0, 0, 0) // Head neutral, aware
    .position(BoneName.PELVIS, 0, 0, 0)
    .done<MartialArtsAnimationBuilder>()
    // Keyframe 1250ms: Circular shift (subtle flowing motion)
    .at(1.25)
    .rotate(BoneName.SPINE_UPPER, 0, 0.09, 0) // 0°, 5° (slight rotation creating circular feel)
    .rotate(BoneName.SHOULDER_L, -0.48, -0.09, 0.17) // -27.5°, -5°, 10° (left forward slightly)
    .rotate(BoneName.SHOULDER_R, -0.57, 0.26, -0.17) // -32.5°, 15°, -10° (right back slightly)
    .rotate(BoneName.ELBOW_L, 0, 0, -1.31) // -75° (slight extension)
    .rotate(BoneName.ELBOW_R, 0, 0, 1.48) // 85° (slight flexion)
    .rotate(BoneName.WRIST_L, 0, 0.09, 0) // 0°, 5° (gentle circular motion)
    .rotate(BoneName.WRIST_R, 0, -0.09, 0) // 0°, -5°
    .rotate(BoneName.PELVIS, 0, 0.05, 0) // 0°, 3° (subtle weight shift)
    .position(BoneName.PELVIS, -0.02, 0, 0) // Minimal lateral shift
    .done<MartialArtsAnimationBuilder>()
    // Keyframe 2500ms: Return to neutral (complete cycle)
    .at(2.5)
    .rotate(BoneName.SPINE_UPPER, 0, 0, 0)
    .rotate(BoneName.SHOULDER_L, -0.52, -0.17, 0.26)
    .rotate(BoneName.SHOULDER_R, -0.52, 0.17, -0.26)
    .rotate(BoneName.ELBOW_L, 0, 0, -1.4)
    .rotate(BoneName.ELBOW_R, 0, 0, 1.4)
    .rotate(BoneName.WRIST_L, 0, 0, 0)
    .rotate(BoneName.WRIST_R, 0, 0, 0)
    .rotate(BoneName.HEAD, 0, 0, 0)
    .rotate(BoneName.PELVIS, 0, 0, 0)
    .position(BoneName.PELVIS, 0, 0, 0)
    .done<MartialArtsAnimationBuilder>()
    .build();
 
// ═══════════════════════════════════════════════════════════════════════════
// ☱ TAE CIRCULAR SIDESTEP (원형 측면보)
// ═══════════════════════════════════════════════════════════════════════════
 
/**
 * Tae Circular Sidestep Animation
 *
 * **Korean**: 원형 측면보 (Wonhyeong Cheukmyeonbo) - Circular Sidestep
 * **Technique**: Arc-shaped lateral movement, hip-led
 *
 * Characteristics:
 * - Circular arc path (not straight lateral)
 * - Hip leads the movement
 * - Maintains flexible guard throughout
 * - Weight shifts smoothly
 *
 * Animation Phases:
 * - 0-180ms: Weight shift and hip initiation
 * - 180-400ms: Circular arc movement
 * - 400-550ms: Landing and settling
 *
 * @korean 원형측면보
 * @duration 550ms
 * @category Movement Animation
 */
export const TAE_CIRCULAR_SIDESTEP: SkeletalAnimation =
  MartialArtsAnimationBuilder.create(
    "tae_circular_sidestep",
    "원형 측면보"
  )
    .asMovement(0.55, false)
    // Phase 1: Initial weight shift (0ms)
    .at(0)
    .rotate(BoneName.PELVIS, 0, -0.17, 0) // 0°, -10° (hip begins rotation)
    .rotate(BoneName.KNEE_R, -0.26, 0, 0) // -15° (rear leg loads)
    .rotate(BoneName.KNEE_L, -0.35, 0, 0) // -20° (lead leg ready)
    .rotate(BoneName.SHOULDER_L, -0.52, -0.17, 0.26) // Guard maintained
    .rotate(BoneName.SHOULDER_R, -0.52, 0.17, -0.26)
    .rotate(BoneName.ELBOW_L, 0, 0, -1.4)
    .rotate(BoneName.ELBOW_R, 0, 0, 1.4)
    .position(BoneName.PELVIS, 0, 0, 0)
    .done<MartialArtsAnimationBuilder>()
    // Phase 2: Circular arc movement (275ms)
    .at(0.275)
    .rotate(BoneName.PELVIS, 0, -0.35, 0) // 0°, -20° (maximum hip rotation)
    .rotate(BoneName.KNEE_R, -0.17, 0, 0) // -10° (rear leg extends)
    .rotate(BoneName.KNEE_L, -0.44, 0, 0) // -25° (lead leg pushes)
    .rotate(BoneName.SHOULDER_L, -0.52, -0.17, 0.26) // Guard stable
    .rotate(BoneName.SHOULDER_R, -0.52, 0.17, -0.26)
    .position(BoneName.PELVIS, -0.18, 0.02, -0.03) // Arc trajectory (lateral + slight back)
    .done<MartialArtsAnimationBuilder>()
    // Phase 3: Landing and settling (550ms)
    .at(0.55)
    .rotate(BoneName.PELVIS, 0, -0.26, 0) // 0°, -15° (settled)
    .rotate(BoneName.KNEE_R, -0.26, 0, 0) // -15° (stable)
    .rotate(BoneName.KNEE_L, -0.35, 0, 0) // -20° (grounded)
    .rotate(BoneName.SHOULDER_L, -0.52, -0.17, 0.26) // Guard maintained
    .rotate(BoneName.SHOULDER_R, -0.52, 0.17, -0.26)
    .rotate(BoneName.ELBOW_L, 0, 0, -1.4)
    .rotate(BoneName.ELBOW_R, 0, 0, 1.4)
    .position(BoneName.PELVIS, -0.25, 0, 0) // Final lateral position
    .done<MartialArtsAnimationBuilder>()
    .build();
 
// ═══════════════════════════════════════════════════════════════════════════
// ☱ TAE DIAGONAL CIRCULAR APPROACH (대각선 원형 접근)
// ═══════════════════════════════════════════════════════════════════════════
 
/**
 * Tae Diagonal Circular Approach Animation
 *
 * **Korean**: 대각선 원형 접근 (Daegakseon Wonhyeong Jeobgeun)
 * **Technique**: 45° curved approach with hands extending
 *
 * Characteristics:
 * - 45° diagonal angle with curved path
 * - Hands extend forward for joint control
 * - Hip rotation coordinates with step
 * - Smooth weight transfer
 *
 * Animation Phases:
 * - 0-233ms: Initial diagonal pivot
 * - 233-500ms: Curved approach with extending hands
 * - 500-667ms: Landing in engagement position
 *
 * @korean 대각선원형접근
 * @duration 667ms
 * @category Movement Animation
 */
export const TAE_DIAGONAL_CIRCULAR_APPROACH: SkeletalAnimation =
  MartialArtsAnimationBuilder.create(
    "tae_diagonal_circular_approach",
    "대각선 원형 접근"
  )
    .asMovement(0.667, false)
    // Phase 1: Initial diagonal pivot (0ms)
    .at(0)
    .rotate(BoneName.PELVIS, 0, -0.79, 0) // 0°, -45° (diagonal rotation)
    .rotate(BoneName.KNEE_R, -0.35, 0, 0) // -20° (rear leg ready)
    .rotate(BoneName.KNEE_L, -0.26, 0, 0) // -15° (lead leg ready)
    .rotate(BoneName.SHOULDER_L, -0.44, -0.26, 0.35) // -25°, -15°, 20° (hands begin extending)
    .rotate(BoneName.SHOULDER_R, -0.44, 0.26, -0.35) // -25°, 15°, -20°
    .rotate(BoneName.ELBOW_L, 0, 0, -1.05) // -60° (extending)
    .rotate(BoneName.ELBOW_R, 0, 0, 1.05) // 60° (extending)
    .position(BoneName.PELVIS, 0, 0, 0)
    .done<MartialArtsAnimationBuilder>()
    // Phase 2: Curved approach with extending hands (361ms)
    .at(0.361)
    .rotate(BoneName.PELVIS, 0, -0.61, 0) // 0°, -35° (unwinding)
    .rotate(BoneName.KNEE_R, -0.17, 0, 0) // -10° (extending)
    .rotate(BoneName.KNEE_L, -0.44, 0, 0) // -25° (pushing)
    .rotate(BoneName.SHOULDER_L, -0.35, -0.35, 0.44) // -20°, -20°, 25° (reaching)
    .rotate(BoneName.SHOULDER_R, -0.35, 0.35, -0.44) // -20°, 20°, -25°
    .rotate(BoneName.ELBOW_L, 0, 0, -0.7) // -40° (extending more)
    .rotate(BoneName.ELBOW_R, 0, 0, 0.7) // 40° (extending more)
    .position(BoneName.PELVIS, -0.2, 0.02, 0.2) // Curved diagonal path
    .done<MartialArtsAnimationBuilder>()
    // Phase 3: Landing in engagement position (667ms)
    .at(0.667)
    .rotate(BoneName.PELVIS, 0, -0.79, 0) // 0°, -45° (settled diagonal)
    .rotate(BoneName.KNEE_R, -0.26, 0, 0) // -15° (stable)
    .rotate(BoneName.KNEE_L, -0.35, 0, 0) // -20° (grounded)
    .rotate(BoneName.SHOULDER_L, -0.26, -0.44, 0.52) // -15°, -25°, 30° (hands extended)
    .rotate(BoneName.SHOULDER_R, -0.26, 0.44, -0.52) // -15°, 25°, -30°
    .rotate(BoneName.ELBOW_L, 0, 0, -0.52) // -30° (ready to engage)
    .rotate(BoneName.ELBOW_R, 0, 0, 0.52) // 30° (ready to engage)
    .rotate(BoneName.WRIST_L, 0.09, 0, -0.09) // 5°, 0°, -5° (hands ready to grasp)
    .rotate(BoneName.WRIST_R, 0.09, 0, 0.09) // 5°, 0°, 5°
    .position(BoneName.PELVIS, -0.3, 0, 0.3) // Diagonal 45° position
    .done<MartialArtsAnimationBuilder>()
    .build();
 
// ═══════════════════════════════════════════════════════════════════════════
// ☱ TAE FLEXIBLE GUARD TRANSITION (호수 방어 전환)
// ═══════════════════════════════════════════════════════════════════════════
 
/**
 * Tae Flexible Guard Transition Animation
 *
 * **Korean**: 호수 방어 전환 (Hosu Bangeo Jeonhwan) - Lake Guard Transition
 * **Technique**: Transition into Tae's characteristic flexible mid-level guard
 *
 * Characteristics:
 * - Smooth transition to mid-level guard
 * - Hands at chest/solar plexus height
 * - Elbows bent at 80° for flexibility
 * - Weight evenly distributed
 *
 * Animation Phases:
 * - 0-150ms: Begin transition
 * - 150-300ms: Settle into Tae guard
 *
 * @korean 호수방어전환
 * @duration 300ms
 * @category Stance Animation
 */
export const TAE_FLEXIBLE_GUARD_TRANSITION: SkeletalAnimation =
  MartialArtsAnimationBuilder.create(
    "tae_flexible_guard_transition",
    "호수 방어 전환"
  )
    .asStance(0.3, false)
    // Phase 1: Begin transition (0ms)
    .at(0)
    .rotate(BoneName.SHOULDER_L, -0.44, -0.09, 0.22) // -25°, -5°, 12.5° (moving toward guard)
    .rotate(BoneName.SHOULDER_R, -0.44, 0.09, -0.22) // -25°, 5°, -12.5°
    .rotate(BoneName.ELBOW_L, 0, 0, -1.22) // -70° (transitioning)
    .rotate(BoneName.ELBOW_R, 0, 0, 1.22) // 70° (transitioning)
    .rotate(BoneName.PELVIS, 0, 0, 0) // Neutral pelvis
    .position(BoneName.PELVIS, 0, 0, 0)
    .done<MartialArtsAnimationBuilder>()
    // Phase 2: Settle into Tae guard (300ms)
    .at(0.3)
    .rotate(BoneName.SHOULDER_L, -0.52, -0.17, 0.26) // -30°, -10°, 15° (Tae guard)
    .rotate(BoneName.SHOULDER_R, -0.52, 0.17, -0.26) // -30°, 10°, -15°
    .rotate(BoneName.ELBOW_L, 0, 0, -1.4) // -80° (Tae guard angle)
    .rotate(BoneName.ELBOW_R, 0, 0, 1.4) // 80° (Tae guard angle)
    .rotate(BoneName.WRIST_L, 0, 0, 0) // Neutral wrists
    .rotate(BoneName.WRIST_R, 0, 0, 0)
    .rotate(BoneName.KNEE_L, -0.26, 0, 0) // -15° (stable stance)
    .rotate(BoneName.KNEE_R, -0.26, 0, 0) // -15° (stable stance)
    .position(BoneName.PELVIS, 0, 0, 0)
    .done<MartialArtsAnimationBuilder>()
    .build();
 
// ═══════════════════════════════════════════════════════════════════════════
// EXPORTS
// ═══════════════════════════════════════════════════════════════════════════
 
/**
 * Map of all Tae stance-specific animations for easy access
 * @korean 태괘자세애니메이션맵
 */
export const TAE_STANCE_ANIMATIONS: ReadonlyMap<string, SkeletalAnimation> = new Map([
  // Idle & Movement
  ["tae_idle_flowing", TAE_IDLE_FLOWING],
  ["tae_circular_sidestep", TAE_CIRCULAR_SIDESTEP],
  ["tae_diagonal_circular_approach", TAE_DIAGONAL_CIRCULAR_APPROACH],
  
  // Stance Transitions
  ["tae_flexible_guard_transition", TAE_FLEXIBLE_GUARD_TRANSITION],
]);