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 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 | 28x 28x 28x 28x 28x 28x 13x 13x 13x 13x 6x 6x 6x 6x 4x 4x 4x 4x 2x 2x 2x 2x 3x 3x 3x 3x 28x 28x 28x 28x 17x 17x 17x 17x 17x 9x 9x 4x 4x 2x 2x 1x 1x 1x 1x 17x 4x 8x 8x 8x 3x 1x 2x 2x 3x 3x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 8x 8x 11x 11x 11x 6x 1x 1x 5x 4x 4x 1x 1x 6x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 11x 11x 11x 4x 4x 4x 4x 8x 8x 3x 1x 2x 2x 3x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 8x 11x 11x 11x 11x 4x 4x 4x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11x 11x 11x 10x 10x 10x 6x 1x 1x 5x 4x 4x 1x 1x 6x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 10x 10x 10x 4x 4x 4x 4x | /**
* Advanced Joint Movement System for Korean Martial Arts
*
* Extends the base skeletal animation system with specialized joint movements
* for authentic martial arts technique execution:
* - Hip rotation for kicks (고관절 회전)
* - Shoulder elevation/depression (어깨 들어올림)
* - Ankle articulation (발목 관절)
* - Wrist snap mechanics (손목 스냅)
* - Knee drive positioning (무릎 밀어올림)
* - Spinal flexion/extension (척추 굽힘)
*
* @module systems/animation/AdvancedJointMovements
* @category Animation System
* @korean 고급관절동작시스템
*/
import * as THREE from "three";
/**
* Body side for limb-specific movements
*
* @public
* @korean 신체측면
*/
export type BodySide = 'left' | 'right';
/**
* Kick technique types for hip rotation calculation
*
* Korean terminology:
* - front: 앞차기 (Apchagi)
* - roundhouse: 돌려차기 (Dollyeochagi)
* - side: 옆차기 (Yeopchagi)
* - hook: 후려차기 (Huryeochagi)
* - axe: 내려차기 (Naeryeochagi)
*
* @public
* @korean 차기기술유형
*/
export type KickType = 'front' | 'roundhouse' | 'side' | 'hook' | 'axe';
/**
* Hand strike technique types for wrist snap calculation
*
* Korean terminology:
* - backfist: 등주먹 (Deungjumeok)
* - knife-hand: 수도 (Sudo)
* - palm-heel: 장저 (Jangjeo)
* - ridge-hand: 손날등 (Sonnaldeung)
* - hammer-fist: 망치주먹 (Mangchijumeok)
*
* @public
* @korean 수격기술유형
*/
export type HandStrikeType = 'backfist' | 'knife-hand' | 'palm-heel' | 'ridge-hand' | 'hammer-fist';
/**
* Kick height levels for hip rotation scaling
*
* Korean terminology:
* - 0: 하단 (Hadan) - Low section
* - 1: 중단 (Jungdan) - Middle section
* - 2: 상단 (Sangdan) - High section
*
* @public
* @korean 차기높이
*/
export type KickHeight = 0 | 1 | 2;
/**
* Technique execution phases
*
* Korean terminology:
* - chamber: 준비 (Junbi) - Preparation/chamber
* - extension: 확장 (Hwakjang) - Extension
* - retraction: 회수 (Hoesu) - Retraction
*
* @public
* @korean 기술단계
*/
export type TechniquePhase = 'chamber' | 'extension' | 'retraction';
/**
* Strike execution phases
*
* Korean terminology:
* - wind-up: 예비동작 (Yebi Dongjak) - Wind-up
* - impact: 타격 (Tagyeok) - Impact
* - follow-through: 후속동작 (Husok Dongjak) - Follow-through
*
* @public
* @korean 타격단계
*/
export type StrikePhase = 'wind-up' | 'impact' | 'follow-through';
/**
* Block and overhead technique types for shoulder elevation
*
* Korean terminology:
* - high-block: 상단막기 (Sangdan Makgi)
* - overhead-strike: 상단공격 (Sangdan Gonggyeok)
* - rising-block: 올려막기 (Ollyeo Makgi)
* - shrug: 어깨올리기 (Eokkae Olligi)
* - neutral: 중립 (Jungnip)
*
* @public
* @korean 어깨기술유형
*/
export type ShoulderTechniqueType = 'high-block' | 'overhead-strike' | 'rising-block' | 'shrug' | 'neutral';
/**
* Shoulder and block technique execution phases
*
* Korean terminology:
* - preparation: 준비 (Junbi)
* - execution: 실행 (Silhaeng)
* - recovery: 복귀 (Bokgwi)
*
* @public
* @korean 어깨단계
*/
export type ShoulderPhase = 'preparation' | 'execution' | 'recovery';
/**
* Spinal movement types for dodging and positioning
*
* Korean terminology:
* - duck: 숙이기 (Sugigi) - Duck down
* - lean-back: 뒤로기울기 (Dwiro Giulgi) - Lean back
* - lean-left: 왼쪽기울기 (Oenjjok Giulgi) - Lean left
* - lean-right: 오른쪽기울기 (Oreunjjok Giulgi) - Lean right
* - low-attack: 낮은공격 (Najeun Gonggyeok) - Low attack
* - neutral: 중립 (Jungnip) - Neutral
*
* @public
* @korean 척추동작유형
*/
export type SpinalMovementType = 'duck' | 'lean-back' | 'lean-left' | 'lean-right' | 'low-attack' | 'neutral';
/**
* Knee drive technique types for close-range combat
*
* Korean terminology:
* - knee-strike: 무릎차기 (Mureup Chagi)
* - clinch-control: 붙잡기제어 (Butjapgi Jeeo)
* - push-kick: 밀어차기 (Mireo Chagi)
* - neutral: 중립 (Jungnip)
*
* @public
* @korean 무릎기술유형
*/
export type KneeTechniqueType = 'knee-strike' | 'clinch-control' | 'push-kick' | 'neutral';
/**
* Knee technique execution phases
*
* Korean terminology:
* - wind-up: 예비동작 (Yebi Dongjak)
* - execution: 실행 (Silhaeng)
* - recovery: 복귀 (Bokgwi)
*
* @public
* @korean 무릎단계
*/
export type KneePhase = 'wind-up' | 'execution' | 'recovery';
/**
* Hip rotation state for dynamic kick mechanics
*
* Tracks independent hip rotation in multiple planes for realistic
* high kicks, roundhouse kicks, and hook kicks. Separates hip rotation
* from pelvis rotation for authentic martial arts biomechanics.
*
* Korean: 고관절 회전 상태
*
* @public
*/
export interface HipRotationState {
/**
* Frontal plane rotation (abduction/adduction) in radians
* - Positive: Leg moves away from body centerline (abduction)
* - Negative: Leg moves toward centerline (adduction)
* Range: ±1.8 rad (±103°) for high kicks
*
* @korean 외전각도
*/
readonly frontalRotation: number;
/**
* Sagittal plane rotation (flexion/extension) in radians
* - Positive: Leg moves forward (flexion)
* - Negative: Leg moves backward (extension)
* Range: -1.8 to 1.8 rad for kicks
*
* @korean 굴곡각도
*/
readonly sagittalRotation: number;
/**
* Transverse plane rotation (internal/external rotation) in radians
* - Positive: Thigh rotates inward
* - Negative: Thigh rotates outward
* Range: ±0.8 rad (±46°)
*
* @korean 회전각도
*/
readonly transverseRotation: number;
/**
* Which hip (left or right)
* @korean 측면
*/
readonly side: BodySide;
}
/**
* Shoulder elevation/depression state for blocks and overhead strikes
*
* Tracks vertical shoulder movement independent of arm rotation.
* Essential for authentic blocking mechanics and overhead techniques.
*
* Korean: 어깨 들어올림 상태
*
* @public
*/
export interface ShoulderElevationState {
/**
* Vertical displacement in meters
* - Positive: Shoulder elevated (shrug)
* - Negative: Shoulder depressed (drop)
* Range: ±0.05 m (±5cm)
*
* @korean 수직변위
*/
readonly elevation: number;
/**
* Which shoulder (left or right)
* @korean 측면
*/
readonly side: BodySide;
}
/**
* Ankle articulation state for kick chambers and pivots
*
* Tracks ankle joint positioning crucial for proper kick mechanics
* and pivoting in Korean martial arts.
*
* Korean: 발목 관절 상태
*
* @public
*/
export interface AnkleArticulationState {
/**
* Dorsiflexion/plantarflexion angle in radians
* - Positive: Toes point up (dorsiflexion)
* - Negative: Toes point down (plantarflexion)
* Range: -0.8 to 0.5 rad
*
* @korean 발등굽힘각도
*/
readonly flexion: number;
/**
* Inversion/eversion angle in radians
* Range: ±0.4 rad (±23°)
*
* @korean 안쪽굽힘각도
*/
readonly inversion: number;
/**
* Which ankle (left or right)
* @korean 측면
*/
readonly side: BodySide;
}
/**
* Wrist snap state for rapid hand strikes
*
* Tracks rapid wrist rotation mechanics essential for backfist,
* knife-hand, and other Korean martial arts hand techniques.
*
* Korean: 손목 스냅 상태
*
* @public
*/
export interface WristSnapState {
/**
* Rotation angle in radians
* Range: ±1.5 rad (±86°)
*
* @korean 회전각도
*/
readonly rotation: number;
/**
* Snap velocity in rad/s (for power calculation)
* @korean 회전속도
*/
readonly velocity: number;
/**
* Which wrist (left or right)
* @korean 측면
*/
readonly side: BodySide;
}
/**
* Knee drive state for clinch work and knee strikes
*
* Tracks independent knee positioning crucial for close-range
* combat and knee strike techniques.
*
* Korean: 무릎 밀어올림 상태
*
* @public
*/
export interface KneeDriveState {
/**
* Drive height in meters (vertical displacement)
* Range: 0 to 0.8 m (80cm max lift)
*
* @korean 들어올림높이
*/
readonly height: number;
/**
* Forward drive distance in meters
* Range: 0 to 0.3 m (30cm)
*
* @korean 전방거리
*/
readonly forward: number;
/**
* Which knee (left or right)
* @korean 측면
*/
readonly side: BodySide;
}
/**
* Spinal flexion/extension state for dodges and low attacks
*
* Tracks forward/backward bending of spine for defensive
* movements and low attack positioning.
*
* Korean: 척추 굽힘 상태
*
* @public
*/
export interface SpinalFlexionState {
/**
* Flexion angle in radians (forward/backward bend)
* - Positive: Forward bend
* - Negative: Backward bend
* Range: -0.5 to 0.8 rad
*
* @korean 굽힘각도
*/
readonly flexion: number;
/**
* Lateral bend in radians (side to side)
* Range: ±0.3 rad (±17°)
*
* @korean 측면굽힘각도
*/
readonly lateralBend: number;
}
/**
* Advanced joint movement constraints
*
* Defines anatomically correct limits for all advanced joint movements
* based on human biomechanics and Korean martial arts techniques.
*
* @korean 고급관절제약조건
*/
export const ADVANCED_JOINT_CONSTRAINTS = {
/**
* Hip rotation constraints for kicks
* @korean 고관절제약조건
*/
HIP_ROTATION: {
FRONTAL_MIN: -1.8, // -103° adduction
FRONTAL_MAX: 1.8, // 103° abduction
SAGITTAL_MIN: -1.8, // -103° extension
SAGITTAL_MAX: 1.8, // 103° flexion
TRANSVERSE_MIN: -0.8, // -46° external rotation
TRANSVERSE_MAX: 0.8, // 46° internal rotation
},
/**
* Shoulder elevation constraints
* @korean 어깨들어올림제약조건
*/
SHOULDER_ELEVATION: {
MIN: -0.05, // -5cm depression
MAX: 0.05, // 5cm elevation
},
/**
* Ankle articulation constraints
* @korean 발목관절제약조건
*/
ANKLE_ARTICULATION: {
FLEXION_MIN: -0.8, // -46° plantarflexion
FLEXION_MAX: 0.5, // 29° dorsiflexion
INVERSION_MIN: -0.4, // -23° eversion
INVERSION_MAX: 0.4, // 23° inversion
},
/**
* Wrist snap constraints
* @korean 손목스냅제약조건
*/
WRIST_SNAP: {
ROTATION_MIN: -1.5, // -86°
ROTATION_MAX: 1.5, // 86°
MAX_VELOCITY: 30.0, // 30 rad/s for power strikes
},
/**
* Knee drive constraints
* @korean 무릎밀어올림제약조건
*/
KNEE_DRIVE: {
HEIGHT_MIN: 0, // Ground level
HEIGHT_MAX: 0.8, // 80cm max lift
FORWARD_MIN: 0,
FORWARD_MAX: 0.3, // 30cm forward
},
/**
* Spinal flexion constraints
* @korean 척추굽힘제약조건
*/
SPINAL_FLEXION: {
FLEXION_MIN: -0.5, // -29° extension (backward)
FLEXION_MAX: 0.8, // 46° flexion (forward)
LATERAL_MIN: -0.3, // -17° left bend
LATERAL_MAX: 0.3, // 17° right bend
},
} as const;
/**
* Calculate hip rotation for kick mechanics
*
* Determines optimal hip rotation angles for various kick types,
* ensuring anatomically correct positioning and maximum power generation.
*
* @param kickType - Type of kick being performed
* @param targetHeight - Target height for kick (0=low, 1=medium, 2=high)
* @param side - Which leg is kicking
* @returns Hip rotation state with all three plane rotations
*
* @example
* ```typescript
* const hipState = calculateHipRotationForKick('roundhouse', 2, 'right');
* // Returns frontal: 1.5, sagittal: 1.3, transverse: 0.6 for high roundhouse
* ```
*
* @public
* @korean 차기용고관절회전계산
*/
export function calculateHipRotationForKick(
kickType: KickType,
targetHeight: KickHeight,
side: BodySide
): HipRotationState {
let frontalRotation = 0;
let sagittalRotation = 0;
let transverseRotation = 0;
// Height multiplier (more rotation needed for higher kicks)
const heightMultiplier = targetHeight === 0 ? 0.5 : targetHeight === 1 ? 0.75 : 1.0;
switch (kickType) {
case 'front':
// Front kick: primarily sagittal plane (forward)
sagittalRotation = 1.5 * heightMultiplier;
frontalRotation = 0.2; // Slight abduction for balance
transverseRotation = 0;
break;
case 'roundhouse':
// Roundhouse: combination of frontal abduction and transverse rotation
frontalRotation = 1.5 * heightMultiplier;
sagittalRotation = 0.8 * heightMultiplier;
transverseRotation = 0.6 * heightMultiplier; // Internal rotation for power
break;
case 'side':
// Side kick: primarily frontal plane (abduction)
frontalRotation = 1.6 * heightMultiplier;
sagittalRotation = 0.3;
transverseRotation = -0.4; // External rotation for proper foot alignment
break;
case 'hook':
// Hook kick: high abduction with forward component
frontalRotation = 1.7 * heightMultiplier;
sagittalRotation = 1.2 * heightMultiplier;
transverseRotation = 0.5;
break;
case 'axe':
// Axe kick: maximum sagittal flexion, some abduction
frontalRotation = 0.8 * heightMultiplier;
sagittalRotation = 1.8 * heightMultiplier; // Maximum forward flexion
transverseRotation = 0.2;
break;
}
// Apply constraints
frontalRotation = Math.max(
ADVANCED_JOINT_CONSTRAINTS.HIP_ROTATION.FRONTAL_MIN,
Math.min(ADVANCED_JOINT_CONSTRAINTS.HIP_ROTATION.FRONTAL_MAX, frontalRotation)
);
sagittalRotation = Math.max(
ADVANCED_JOINT_CONSTRAINTS.HIP_ROTATION.SAGITTAL_MIN,
Math.min(ADVANCED_JOINT_CONSTRAINTS.HIP_ROTATION.SAGITTAL_MAX, sagittalRotation)
);
transverseRotation = Math.max(
ADVANCED_JOINT_CONSTRAINTS.HIP_ROTATION.TRANSVERSE_MIN,
Math.min(ADVANCED_JOINT_CONSTRAINTS.HIP_ROTATION.TRANSVERSE_MAX, transverseRotation)
);
return {
frontalRotation,
sagittalRotation,
transverseRotation,
side,
};
}
/**
* Calculate kick power modifier from hip rotation
*
* Determines power bonus based on proper hip rotation technique.
* Greater rotation in the correct planes generates more power.
*
* @param hipState - Current hip rotation state
* @param kickType - Type of kick
* @returns Power multiplier (1.0-1.40x, with kicks getting up to 40% bonus)
*
* @example
* ```typescript
* const hipState = calculateHipRotationForKick('roundhouse', 2, 'right');
* const power = calculateKickPowerFromHipRotation(hipState, 'roundhouse');
* // Returns ~1.35 for properly executed high roundhouse
* ```
*
* @public
* @korean 고관절회전에서차기파워계산
*/
export function calculateKickPowerFromHipRotation(
hipState: HipRotationState,
kickType: KickType
): number {
// Normalize rotations to 0-1 range based on constraints
const normalizedFrontal = Math.abs(hipState.frontalRotation) /
ADVANCED_JOINT_CONSTRAINTS.HIP_ROTATION.FRONTAL_MAX;
const normalizedSagittal = Math.abs(hipState.sagittalRotation) /
ADVANCED_JOINT_CONSTRAINTS.HIP_ROTATION.SAGITTAL_MAX;
const normalizedTransverse = Math.abs(hipState.transverseRotation) /
ADVANCED_JOINT_CONSTRAINTS.HIP_ROTATION.TRANSVERSE_MAX;
// Different kicks benefit from different rotation planes
let powerFactor = 0;
switch (kickType) {
case 'front':
powerFactor = normalizedSagittal * 0.8 + normalizedFrontal * 0.2;
break;
case 'roundhouse':
powerFactor = normalizedFrontal * 0.5 + normalizedTransverse * 0.3 + normalizedSagittal * 0.2;
break;
case 'side':
powerFactor = normalizedFrontal * 0.7 + normalizedTransverse * 0.3;
break;
case 'hook':
powerFactor = normalizedFrontal * 0.4 + normalizedSagittal * 0.4 + normalizedTransverse * 0.2;
break;
case 'axe':
powerFactor = normalizedSagittal * 0.8 + normalizedFrontal * 0.2;
break;
}
// Kicks can get up to 40% power bonus from proper hip rotation
return 1.0 + (powerFactor * 0.40);
}
/**
* Apply hip rotation to Three.js Euler angles
*
* Converts hip rotation state into Three.js Euler angles for rendering.
*
* @param hipState - Hip rotation state
* @returns Three.js Euler angles (X=sagittal, Y=transverse, Z=frontal)
*
* @public
* @korean 고관절회전을오일러각으로적용
*/
export function applyHipRotationToEuler(hipState: HipRotationState): THREE.Euler {
return new THREE.Euler(
hipState.sagittalRotation, // X-axis: forward/backward
hipState.transverseRotation, // Y-axis: twist
hipState.frontalRotation, // Z-axis: side to side
'XYZ'
);
}
/**
* Calculate ankle articulation for kick chamber
*
* Determines proper ankle positioning for kick chambering and extension,
* crucial for proper foot alignment and power transfer in Korean martial arts.
*
* @param kickType - Type of kick being chambered
* @param phase - Kick phase: 'chamber', 'extension', 'retraction'
* @param side - Which ankle
* @returns Ankle articulation state with flexion and inversion angles
*
* @example
* ```typescript
* const ankleState = calculateAnkleArticulation('front', 'extension', 'right');
* // Returns: { flexion: 0.5, inversion: 0, side: 'right' }
* ```
*
* @public
* @korean 차기챔버용발목관절계산
*/
export function calculateAnkleArticulation(
kickType: KickType,
phase: TechniquePhase,
side: BodySide
): AnkleArticulationState {
let flexion = 0;
let inversion = 0;
switch (kickType) {
case 'front':
if (phase === 'chamber') {
flexion = 0.2; // Slight dorsiflexion in chamber
} else if (phase === 'extension') {
flexion = 0.5; // Strong dorsiflexion for striking with ball of foot
} else E{
flexion = 0.1; // Slight flexion during retraction
}
inversion = 0; // Neutral for front kicks
break;
case 'roundhouse':
Iif (phase === 'chamber') {
flexion = -0.3; // Plantarflexion in chamber
} else if (phase === 'extension') {
flexion = -0.5; // Strong plantarflexion for instep strike
inversion = -0.2; // Slight eversion to align instep
} else E{
flexion = -0.2;
inversion = 0;
}
break;
case 'side':
Iif (phase === 'chamber') {
flexion = 0.3; // Dorsiflexion in chamber
} else if (phase === 'extension') {
flexion = 0.4; // Dorsiflexion for heel/blade strike
inversion = 0.3; // Inversion to present blade edge
} else E{
flexion = 0.2;
inversion = 0.1;
}
break;
case 'hook':
Iif (phase === 'chamber') {
flexion = -0.2;
} else if (phase === 'extension') {
flexion = -0.4; // Plantarflexion for heel strike
inversion = -0.15; // Slight eversion
} else E{
flexion = -0.1;
inversion = 0;
}
break;
case 'axe':
Iif (phase === 'chamber') {
flexion = 0.1; // Minimal flexion in high chamber
} else if (phase === 'extension') {
flexion = 0.5; // Strong dorsiflexion for downward strike
} else E{
flexion = 0.2;
}
inversion = 0; // Neutral for axe kicks
break;
}
// Apply constraints
flexion = Math.max(
ADVANCED_JOINT_CONSTRAINTS.ANKLE_ARTICULATION.FLEXION_MIN,
Math.min(ADVANCED_JOINT_CONSTRAINTS.ANKLE_ARTICULATION.FLEXION_MAX, flexion)
);
inversion = Math.max(
ADVANCED_JOINT_CONSTRAINTS.ANKLE_ARTICULATION.INVERSION_MIN,
Math.min(ADVANCED_JOINT_CONSTRAINTS.ANKLE_ARTICULATION.INVERSION_MAX, inversion)
);
return { flexion, inversion, side };
}
/**
* Calculate wrist snap for hand strikes
*
* Determines wrist rotation and velocity for power generation in
* backfist, knife-hand, and other Korean martial arts hand techniques.
*
* @param strikeType - Type of hand strike
* @param phase - Strike phase: 'wind-up', 'impact', 'follow-through'
* @param side - Which wrist
* @returns Wrist snap state with rotation angle and velocity
*
* @example
* ```typescript
* const wristState = calculateWristSnap('backfist', 'impact', 'right');
* // Returns: { rotation: 1.2, velocity: 25.0, side: 'right' }
* ```
*
* @public
* @korean 수격용손목스냅계산
*/
export function calculateWristSnap(
strikeType: HandStrikeType,
phase: StrikePhase,
side: BodySide
): WristSnapState {
let rotation = 0;
let velocity = 0;
switch (strikeType) {
case 'backfist':
if (phase === 'wind-up') {
rotation = -0.8; // Cocked back
velocity = 0;
} else if (phase === 'impact') {
rotation = 1.2; // Snapped forward
velocity = 25.0; // High velocity snap
} else {
rotation = 0.5;
velocity = 5.0;
}
break;
case 'knife-hand':
Iif (phase === 'wind-up') {
rotation = -0.5;
velocity = 0;
} else if (phase === 'impact') {
rotation = 0.8; // Moderate snap for precision
velocity = 20.0;
} else E{
rotation = 0.3;
velocity = 3.0;
}
break;
case 'palm-heel':
Iif (phase === 'wind-up') {
rotation = -0.3; // Minimal wind-up
velocity = 0;
} else if (phase === 'impact') {
rotation = 0.5; // Push through
velocity = 15.0; // Lower velocity, more push
} else E{
rotation = 0.2;
velocity = 2.0;
}
break;
case 'ridge-hand':
Iif (phase === 'wind-up') {
rotation = 0.8; // Opposite direction
velocity = 0;
} else if (phase === 'impact') {
rotation = -1.0; // Reverse snap
velocity = 22.0;
} else E{
rotation = -0.4;
velocity = 4.0;
}
break;
case 'hammer-fist':
Iif (phase === 'wind-up') {
rotation = 0.2; // Minimal rotation
velocity = 0;
} else if (phase === 'impact') {
rotation = 0.3; // Downward strike, less rotation
velocity = 18.0;
} else E{
rotation = 0.1;
velocity = 2.0;
}
break;
}
// Apply constraints
rotation = Math.max(
ADVANCED_JOINT_CONSTRAINTS.WRIST_SNAP.ROTATION_MIN,
Math.min(ADVANCED_JOINT_CONSTRAINTS.WRIST_SNAP.ROTATION_MAX, rotation)
);
velocity = Math.min(ADVANCED_JOINT_CONSTRAINTS.WRIST_SNAP.MAX_VELOCITY, Math.abs(velocity));
return { rotation, velocity, side };
}
/**
* Calculate wrist snap power modifier
*
* Determines power bonus based on wrist snap velocity and rotation.
* Higher velocity generates more power for whipping strikes.
*
* @param wristState - Current wrist snap state
* @returns Power multiplier (1.0-1.25x, with hand strikes getting up to 25% bonus)
*
* @example
* ```typescript
* const wristState = calculateWristSnap('backfist', 'impact', 'right');
* const power = calculateWristSnapPowerModifier(wristState);
* // Returns ~1.20 for proper backfist snap
* ```
*
* @public
* @korean 손목스냅파워배율계산
*/
export function calculateWristSnapPowerModifier(wristState: WristSnapState): number {
// Normalize velocity to 0-1 range
const normalizedVelocity = wristState.velocity / ADVANCED_JOINT_CONSTRAINTS.WRIST_SNAP.MAX_VELOCITY;
// Normalize rotation magnitude to 0-1 range
const normalizedRotation = Math.abs(wristState.rotation) / ADVANCED_JOINT_CONSTRAINTS.WRIST_SNAP.ROTATION_MAX;
// Velocity contributes 70%, rotation contributes 30%
const powerFactor = (normalizedVelocity * 0.7) + (normalizedRotation * 0.3);
// Hand strikes get up to 25% power bonus from wrist snap
return 1.0 + (powerFactor * 0.25);
}
/**
* Calculate shoulder elevation for blocks and overhead strikes
*
* Determines vertical shoulder movement for defensive blocks and
* overhead striking techniques in Korean martial arts.
*
* @param techniqueType - Type of technique requiring shoulder movement
* @param phase - Technique phase
* @param side - Which shoulder
* @returns Shoulder elevation state with vertical displacement
*
* @example
* ```typescript
* const shoulderState = calculateShoulderElevation('high-block', 'execution', 'left');
* // Returns: { elevation: 0.04, side: 'left' }
* ```
*
* @public
* @korean 블록및상단공격용어깨들어올림계산
*/
export function calculateShoulderElevation(
techniqueType: ShoulderTechniqueType,
phase: ShoulderPhase,
side: BodySide
): ShoulderElevationState {
let elevation = 0;
switch (techniqueType) {
case 'high-block':
if (phase === 'preparation') {
elevation = -0.02; // Slight drop before elevation
} else if (phase === 'execution') {
elevation = 0.04; // Elevate for high block
} else E{
elevation = 0.01; // Slight elevation maintained
}
break;
case 'overhead-strike':
Iif (phase === 'preparation') {
elevation = 0.03; // Pre-elevation for wind-up
} else if (phase === 'execution') {
elevation = 0.05; // Maximum elevation for overhead power
} else E{
elevation = 0.01;
}
break;
case 'rising-block':
Iif (phase === 'preparation') {
elevation = -0.03; // Lower for rising motion
} else if (phase === 'execution') {
elevation = 0.04; // Elevate as block rises
} else E{
elevation = 0.02;
}
break;
case 'shrug':
if (phase === 'execution') {
elevation = 0.05; // Maximum elevation for defensive shrug
} else E{
elevation = 0;
}
break;
case 'neutral':
elevation = 0;
break;
}
// Apply constraints
elevation = Math.max(
ADVANCED_JOINT_CONSTRAINTS.SHOULDER_ELEVATION.MIN,
Math.min(ADVANCED_JOINT_CONSTRAINTS.SHOULDER_ELEVATION.MAX, elevation)
);
return { elevation, side };
}
/**
* Calculate spinal flexion for dodges and low attacks
*
* Determines forward/backward and lateral bending of spine for
* defensive movements and low attack positioning.
*
* @param movementType - Type of movement requiring spinal flexion
* @param intensity - Movement intensity (0=minimal, 1=full)
* @returns Spinal flexion state with flexion and lateral bend angles
*
* @example
* ```typescript
* const spineState = calculateSpinalFlexion('duck', 0.8);
* // Returns: { flexion: 0.6, lateralBend: 0 }
* ```
*
* @public
* @korean 회피및하단공격용척추굽힘계산
*/
export function calculateSpinalFlexion(
movementType: SpinalMovementType,
intensity: number = 1.0
): SpinalFlexionState {
let flexion = 0;
let lateralBend = 0;
// Clamp intensity to 0-1 range
intensity = Math.max(0, Math.min(1, intensity));
switch (movementType) {
case 'duck':
flexion = 0.7 * intensity; // Forward bend for ducking
lateralBend = 0;
break;
case 'lean-back':
flexion = -0.4 * intensity; // Backward bend for evasion
lateralBend = 0;
break;
case 'lean-left':
flexion = 0.1 * intensity; // Slight forward component
lateralBend = -0.25 * intensity; // Left lateral bend
break;
case 'lean-right':
flexion = 0.1 * intensity;
lateralBend = 0.25 * intensity; // Right lateral bend
break;
case 'low-attack':
flexion = 0.5 * intensity; // Forward bend for low strikes
lateralBend = 0;
break;
case 'neutral':
flexion = 0;
lateralBend = 0;
break;
}
// Apply constraints
flexion = Math.max(
ADVANCED_JOINT_CONSTRAINTS.SPINAL_FLEXION.FLEXION_MIN,
Math.min(ADVANCED_JOINT_CONSTRAINTS.SPINAL_FLEXION.FLEXION_MAX, flexion)
);
lateralBend = Math.max(
ADVANCED_JOINT_CONSTRAINTS.SPINAL_FLEXION.LATERAL_MIN,
Math.min(ADVANCED_JOINT_CONSTRAINTS.SPINAL_FLEXION.LATERAL_MAX, lateralBend)
);
return { flexion, lateralBend };
}
/**
* Calculate knee drive for knee strikes and clinch
*
* Determines independent knee positioning for close-range combat,
* crucial for knee strike power and clinch work positioning.
*
* @param technique - Technique requiring knee drive
* @param phase - Technique phase
* @param side - Which knee
* @returns Knee drive state with height and forward distance
*
* @example
* ```typescript
* const kneeState = calculateKneeDrive('knee-strike', 'execution', 'right');
* // Returns: { height: 0.7, forward: 0.25, side: 'right' }
* ```
*
* @public
* @korean 무릎차기및클린치용무릎밀어올림계산
*/
export function calculateKneeDrive(
technique: KneeTechniqueType,
phase: KneePhase,
side: BodySide
): KneeDriveState {
let height = 0;
let forward = 0;
switch (technique) {
case 'knee-strike':
if (phase === 'wind-up') {
height = 0.3; // Partial chamber
forward = 0.1;
} else if (phase === 'execution') {
height = 0.7; // Drive upward
forward = 0.25; // Drive forward for power
} else {
height = 0.2;
forward = 0.05;
}
break;
case 'clinch-control':
if (phase === 'execution') {
height = 0.4; // Moderate elevation for control
forward = 0.15; // Forward pressure
} else E{
height = 0.2;
forward = 0.08;
}
break;
case 'push-kick':
Iif (phase === 'wind-up') {
height = 0.5; // High chamber
forward = 0.05;
} else if (phase === 'execution') {
height = 0.6; // Maintain height
forward = 0.3; // Strong forward drive
} else E{
height = 0.3;
forward = 0.1;
}
break;
case 'neutral':
height = 0;
forward = 0;
break;
}
// Apply constraints
height = Math.max(
ADVANCED_JOINT_CONSTRAINTS.KNEE_DRIVE.HEIGHT_MIN,
Math.min(ADVANCED_JOINT_CONSTRAINTS.KNEE_DRIVE.HEIGHT_MAX, height)
);
forward = Math.max(
ADVANCED_JOINT_CONSTRAINTS.KNEE_DRIVE.FORWARD_MIN,
Math.min(ADVANCED_JOINT_CONSTRAINTS.KNEE_DRIVE.FORWARD_MAX, forward)
);
return { height, forward, side };
}
/**
* Calculate knee strike power modifier
*
* Determines power bonus based on knee drive height and forward momentum.
* Greater drive generates more power through proper mechanics.
*
* @param kneeState - Current knee drive state
* @returns Power multiplier (1.0-1.35x, with knee strikes getting up to 35% bonus)
*
* @example
* ```typescript
* const kneeState = calculateKneeDrive('knee-strike', 'execution', 'right');
* const power = calculateKneeStrikePowerModifier(kneeState);
* // Returns ~1.30 for properly executed knee strike
* ```
*
* @public
* @korean 무릎차기파워배율계산
*/
export function calculateKneeStrikePowerModifier(kneeState: KneeDriveState): number {
// Normalize height to 0-1 range
const normalizedHeight = kneeState.height / ADVANCED_JOINT_CONSTRAINTS.KNEE_DRIVE.HEIGHT_MAX;
// Normalize forward drive to 0-1 range
const normalizedForward = kneeState.forward / ADVANCED_JOINT_CONSTRAINTS.KNEE_DRIVE.FORWARD_MAX;
// Height contributes 60%, forward drive contributes 40%
const powerFactor = (normalizedHeight * 0.6) + (normalizedForward * 0.4);
// Knee strikes get up to 35% power bonus from proper drive
return 1.0 + (powerFactor * 0.35);
}
|