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 | 123x 123x 123x 123x | /**
* Physics and collision detection type definitions for Black Trigram combat system.
*
* **Korean**: 물리 및 충돌 타입 정의
*
* This module provides type definitions for the collision detection system, including
* bounding boxes, attack reach calculations, and raycasting results.
*
* @module types/physics
* @category Type Definitions
* @korean 물리타입
*/
import type {
Position,
TrigramStance,
VitalPointCategory,
VitalPointSeverity,
} from "./common";
/**
* Anatomical regions for collision detection.
*
* **Korean**: 해부학적 영역
*
* The five main body regions used for bounding box collision detection.
* Each region contains multiple vital points.
*
* @public
* @category Collision Types
* @korean 해부영역
*/
export type AnatomicalRegionPhysics =
| "head" // 머리 (Meori)
| "neck" // 목 (Mok)
| "torso" // 몸통 (Momtong)
| "arms" // 팔 (Pal)
| "legs"; // 다리 (Dari)
/**
* Bounding box shape types for collision detection.
*
* **Korean**: 경계 상자 형태
*
* @public
* @category Collision Types
* @korean 경계형태
*/
export type BoundingBoxType = "sphere" | "box" | "capsule";
/**
* Body part source for reach calculation.
*
* **Korean**: 신체 부위
*
* Defines which body part's length is used for reach calculation.
*
* @public
* @category Combat Types
* @korean 신체부위
*/
export type ReachBodyPart = "arm" | "leg" | "torso";
/**
* Specific limb types for exposure tracking.
*
* **Korean**: 노출된 사지 부위
*
* Granular limb identification for counter-attack and breaking techniques.
* Each limb can be targeted during its extension phase.
*
* @public
* @category Combat Types
* @korean 사지부위
*/
export type ExposedLimbType =
| "left_arm" // 왼팔 (Oenpal)
| "right_arm" // 오른팔 (Oreunpal)
| "left_leg" // 왼다리 (Oendari)
| "right_leg" // 오른다리 (Oreundari)
| "left_ankle" // 왼발목 (Oenbalmok)
| "right_ankle" // 오른발목 (Oreunbalmok)
| "left_knee" // 왼무릎 (Oenmureup)
| "right_knee" // 오른무릎 (Oreunmureup)
| "left_elbow" // 왼팔꿈치 (Oenpalkkumchi)
| "right_elbow" // 오른팔꿈치 (Oreunpalkkumchi)
| "left_wrist" // 왼손목 (Oensomok)
| "right_wrist"; // 오른손목 (Oreunsomok)
/**
* Limb exposure window during technique execution.
*
* **Korean**: 사지 노출 시간
*
* Defines when and how a limb becomes vulnerable during attack execution.
* Used for counter-attacks, breaking techniques, and defensive opportunities.
*
* @public
* @category Combat Types
* @korean 사지노출시간
*/
export interface LimbExposureWindow {
/**
* Which limb is exposed during the technique.
* @korean 노출된사지
*/
readonly exposedLimb: ExposedLimbType;
/**
* Start time of exposure as fraction of execution time (0.0-1.0).
* Example: 0.3 means exposure starts at 30% into the animation.
* @korean 노출시작시간
*/
readonly startTime: number;
/**
* Duration of exposure window in milliseconds.
* This is the vulnerable period where counter-attacks can target the limb.
* @korean 노출지속시간
*/
readonly duration: number;
/**
* Vulnerability multiplier for damage to this limb (1.0-3.0).
* Higher values indicate greater vulnerability:
* - 1.0-1.3: Minor exposure (quick jabs)
* - 1.4-1.8: Moderate exposure (standard strikes)
* - 1.9-3.0: Critical exposure (overextended kicks, spinning techniques)
* @korean 취약성배수
*/
readonly vulnerabilityMultiplier: number;
/**
* Whether this exposure allows breaking techniques.
* True for fully extended limbs (kicks, lunging punches).
* @korean 파쇄기술가능
*/
readonly allowsBreaking: boolean;
}
/**
* Physical reach configuration for techniques.
*
* **Korean**: 물리적 도달 설정
*
* Defines how a technique's reach is calculated using physical attributes
* rather than a fixed distance value. The actual reach depends on:
* - Body part length from archetype physical attributes
* - Animation extension multiplier from hit timing
* - Stance modifiers from Eight Trigrams
*
* **NEW**: Now includes limb exposure tracking for counter-attack opportunities.
*
* Formula: `effectiveReach = (limbLength/100) × extensionMultiplier × stanceModifier`
*
* @example
* ```typescript
* // Punch technique using arm length with exposure
* const punchReach: PhysicalReachConfig = {
* bodyPart: "arm",
* techniqueType: "punch",
* baseExtension: 0.95, // 95% arm extension at peak
* exposureWindow: {
* exposedLimb: "right_arm",
* startTime: 0.4,
* duration: 300,
* vulnerabilityMultiplier: 1.3,
* allowsBreaking: false
* }
* };
*
* // Kick using leg length - high vulnerability
* const kickReach: PhysicalReachConfig = {
* bodyPart: "leg",
* techniqueType: "kick",
* baseExtension: 1.1, // 110% leg extension (high reach)
* exposureWindow: {
* exposedLimb: "right_leg",
* startTime: 0.5,
* duration: 400,
* vulnerabilityMultiplier: 2.2,
* allowsBreaking: true
* }
* };
* ```
*
* @public
* @category Combat Types
* @korean 물리적도달설정
*/
export interface PhysicalReachConfig {
/**
* Body part used for reach calculation.
* Determines which physical attribute length is used.
* @korean 신체부위
*/
readonly bodyPart: ReachBodyPart;
/**
* Technique type for classification.
* @korean 기술유형
*/
readonly techniqueType: TechniqueType;
/**
* Base extension multiplier (0.0 - 1.5).
* - 0.4-0.5: Close range (elbows, knees)
* - 0.9-1.0: Standard reach (punches)
* - 1.1-1.5: Extended reach (kicks, spinning techniques)
* @korean 기본확장배수
*/
readonly baseExtension: number;
/**
* Optional limb exposure window for counter-attack opportunities.
* Defines when and how the attacking limb becomes vulnerable.
* @korean 사지노출설정
*/
readonly exposureWindow?: LimbExposureWindow;
}
/**
* Runtime validation helper for base extension multiplier.
*
* Ensures that the provided baseExtension value respects the documented range
* of 0.0 to 1.5. This should be used when loading or constructing technique
* configurations from dynamic sources (e.g. JSON, network, editors).
*
* **Korean**: 기본 확장 배수 검증
*
* @param baseExtension - The base extension multiplier to validate.
* @returns `true` if the value is within the inclusive range [0.0, 1.5], otherwise `false`.
* @public
* @category Combat Types
* @korean 기본확장배수검증
*/
export function isValidBaseExtension(baseExtension: number): boolean {
return baseExtension >= 0.0 && baseExtension <= 1.5;
}
/**
* Asserts that a PhysicalReachConfig has a valid baseExtension value.
*
* Throws a RangeError if the configuration's baseExtension is outside the
* allowed range of 0.0 to 1.5. This provides a canonical runtime check that
* can be used by reach calculators or technique loaders.
*
* **Korean**: 물리적 도달 설정 검증
*
* @param config - The PhysicalReachConfig instance to validate.
* @throws RangeError If baseExtension is outside [0.0, 1.5].
* @public
* @category Combat Types
* @korean 물리적도달설정검증
*/
export function assertValidPhysicalReachConfig(
config: PhysicalReachConfig
): void {
if (!isValidBaseExtension(config.baseExtension)) {
throw new RangeError(
`Invalid baseExtension ${config.baseExtension}. ` +
"Expected a value between 0.0 and 1.5 inclusive."
);
}
}
/**
* Technique types for attack reach calculation.
*
* **Korean**: 기술 유형
*
* @public
* @category Combat Types
* @korean 기술유형
*/
export type TechniqueType =
| "punch" // 주먹 (Jumeok)
| "kick" // 발차기 (Balchagi)
| "elbow" // 팔꿈치 (Palkkumchi)
| "knee" // 무릎 (Mureup)
| "pressure_point"; // 급소 (Geupso)
/**
* Bounding box definition for an anatomical region.
*
* **Korean**: 경계 상자
*
* Defines the collision volume for an anatomical region using either a sphere,
* box, or capsule shape. Used for broad-phase collision detection.
*
* @example
* ```typescript
* const headBox: BoundingBox = {
* type: "sphere",
* center: { x: 0, y: 1.7, z: 0 },
* dimensions: { x: 0.125, y: 0, z: 0 }, // radius only
* region: "head"
* };
* ```
*
* @public
* @category Collision Types
* @korean 경계상자
*/
export interface BoundingBox {
/** Shape type of the bounding box */
readonly type: BoundingBoxType;
/** Center position of the bounding box in 3D space */
readonly center: Position3D;
/** Dimensions: radius for sphere, width/height/depth for box, radius/height for capsule */
readonly dimensions: Position3D;
/** Anatomical region this bounding box represents */
readonly region: AnatomicalRegionPhysics;
}
/**
* Position in 3D space.
*
* **Korean**: 3D 위치
*
* Extends the 2D Position type with a z-coordinate for Three.js integration.
*
* @public
* @category Core Types
* @korean 3D위치
*/
export interface Position3D {
/** X coordinate in meters */
readonly x: number;
/** Y coordinate in meters */
readonly y: number;
/** Z coordinate in meters */
readonly z: number;
}
/**
* Attack reach calculation result.
*
* **Korean**: 공격 범위
*
* Contains the effective attack range considering technique type and stance modifiers.
*
* @example
* ```typescript
* const kickReach: AttackReach = {
* technique: "kick",
* baseReach: 1.0,
* stance: TrigramStance.LI,
* stanceModifier: 1.20,
* effectiveReach: 1.2
* };
* ```
*
* @public
* @category Combat Types
* @korean 공격범위
*/
export interface AttackReach {
/** Type of technique being used */
readonly technique: TechniqueType;
/** Base reach in meters without modifiers */
readonly baseReach: number;
/** Current trigram stance */
readonly stance: TrigramStance;
/** Stance-specific reach modifier (0.9 - 1.2) */
readonly stanceModifier: number;
/** Final effective reach: baseReach × stanceModifier */
readonly effectiveReach: number;
}
/**
* Collision detection result.
*
* **Korean**: 충돌 결과
*
* Contains comprehensive information about a collision, including whether it hit,
* which region and vital point were struck, distance, and accuracy.
*
* @example
* ```typescript
* const result: CollisionResult = {
* hit: true,
* region: "head",
* vitalPoint: templePoint,
* distance: 0.8,
* accuracy: 0.95
* };
* ```
*
* @public
* @category Collision Types
* @korean 충돌결과
*/
export interface CollisionResult {
/** Whether the attack hit */
readonly hit: boolean;
/** Anatomical region hit (if any) */
readonly region?: AnatomicalRegionPhysics;
/** Specific vital point hit (if any) */
readonly vitalPoint?: CollisionVitalPoint;
/** Actual distance from attacker to target in meters */
readonly distance: number;
/** Hit accuracy (0-1), based on targeting precision */
readonly accuracy: number;
/** 3D point of intersection (if hit) */
readonly hitPoint?: Position3D;
}
/**
* Minimal vital point shape for collision results to avoid deep cross-module
* dependencies. Full vital point data lives in the vitalpoint system.
*/
export interface CollisionVitalPoint {
readonly id: string;
readonly names: {
readonly korean: string;
readonly english: string;
readonly romanized: string;
};
readonly position: Position;
readonly category: VitalPointCategory;
readonly severity: VitalPointSeverity;
}
/**
* Counter-attack opportunity during opponent's technique execution.
*
* **Korean**: 반격 기회
*
* Represents a window of opportunity to counter-attack when the opponent
* has exposed a limb during their technique execution.
*
* @example
* ```typescript
* const counterOpportunity: CounterOpportunity = {
* exposedLimb: "right_leg",
* windowStart: 450, // ms into opponent's kick
* windowDuration: 300, // 300ms counter window
* vulnerabilityMultiplier: 2.0,
* allowsBreaking: true,
* recommendedCounters: ["ankle_break", "knee_strike", "leg_sweep"]
* };
* ```
*
* @public
* @category Combat Types
* @korean 반격기회
*/
export interface CounterOpportunity {
/**
* The exposed limb that can be targeted.
* @korean 노출된사지
*/
readonly exposedLimb: ExposedLimbType;
/**
* Start time of counter window in milliseconds (from technique start).
* @korean 반격시작시간
*/
readonly windowStart: number;
/**
* Duration of counter window in milliseconds.
* @korean 반격지속시간
*/
readonly windowDuration: number;
/**
* Vulnerability multiplier for damage during this window.
* @korean 취약성배수
*/
readonly vulnerabilityMultiplier: number;
/**
* Whether limb breaking techniques are effective during this window.
* @korean 파쇄기술가능
*/
readonly allowsBreaking: boolean;
/**
* Recommended counter-technique IDs for this opportunity.
* @korean 추천반격기술
*/
readonly recommendedCounters?: readonly string[];
}
/**
* Breaking technique target types.
*
* **Korean**: 파쇄 기술 목표
*
* Specific joint and bone targets for breaking techniques.
* Used for limb-breaking counter-attacks.
*
* @public
* @category Combat Types
* @korean 파쇄목표
*/
export type BreakingTarget =
| "ankle" // 발목 (Balmok)
| "knee" // 무릎 (Mureup)
| "elbow" // 팔꿈치 (Palkkumchi)
| "wrist" // 손목 (Sonmok)
| "shoulder" // 어깨 (Eokkae)
| "hip"; // 엉덩이/골반 (Eongdeongi)
/**
* Breaking technique result.
*
* **Korean**: 파쇄 결과
*
* Result of a breaking technique attempt, including injury severity
* and status effects applied to the broken limb.
*
* @public
* @category Combat Types
* @korean 파쇄결과
*/
export interface BreakingResult {
/**
* Whether the breaking technique succeeded.
* @korean 파쇄성공
*/
readonly success: boolean;
/**
* Target limb/joint that was broken.
* @korean 파쇄목표
*/
readonly target: BreakingTarget;
/**
* Severity of the break (fracture, dislocation, etc.).
* Range: 0.0 (failed) to 1.0 (complete break).
* @korean 파쇄심각도
*/
readonly severity: number;
/**
* Damage dealt to the limb.
* @korean 피해량
*/
readonly damage: number;
/**
* Mobility reduction percentage (0.0-1.0).
* Affects movement speed and technique execution.
* @korean 이동력감소
*/
readonly mobilityReduction: number;
/**
* IDs of status effects applied (pain, bleeding, disabled_limb, etc.).
* @korean 상태효과
*/
readonly statusEffects: readonly string[];
}
/**
* Raycast query parameters.
*
* **Korean**: 레이캐스트 쿼리
*
* Defines the parameters for a raycasting operation from attacker to target.
*
* @public
* @category Collision Types
* @korean 레이캐스트쿼리
*/
export interface RaycastQuery {
/** Origin point of the ray (attacker position) */
readonly origin: Position3D;
/** Direction vector of the ray (normalized) */
readonly direction: Position3D;
/** Maximum distance to check in meters */
readonly maxDistance: number;
/** Target anatomical region (optional, for filtering) */
readonly targetRegion?: AnatomicalRegionPhysics;
}
/**
* Base reach values for different technique types.
*
* **Korean**: 기본 범위 값
*
* @public
* @category Combat Constants
* @korean 기본범위값
*/
export const BASE_REACH: Record<TechniqueType, number> = {
punch: 0.7, // 70cm - Standard punch range
kick: 1.0, // 100cm - Longer leg reach
elbow: 0.4, // 40cm - Close-range strike
knee: 0.4, // 40cm - Close-range strike
pressure_point: 0.5, // 50cm - Precise targeting
};
/**
* Stance reach modifiers for the Eight Trigrams.
*
* **Korean**: 팔괘 범위 수정자
*
* Each stance affects attack range differently based on its combat philosophy:
* - Aggressive stances (Fire, Thunder) extend reach
* - Defensive stances (Mountain) reduce reach
* - Balanced stances (Heaven, Earth) have minor adjustments
*
* @public
* @category Combat Constants
* @korean 팔괘범위수정자
*/
export const STANCE_REACH_MODIFIERS: Record<TrigramStance, number> = {
li: 1.2, // ☲ Fire (리): +20% reach (aggressive)
jin: 1.15, // ☳ Thunder (진): +15% reach (explosive)
geon: 1.1, // ☰ Heaven (건): +10% reach (balanced)
son: 1.05, // ☴ Wind (손): +5% reach (continuous)
tae: 1.0, // ☱ Lake (태): neutral reach
gam: 1.0, // ☵ Water (감): neutral reach (adaptive)
gon: 0.95, // ☷ Earth (곤): -5% reach (grounded)
gan: 0.9, // ☶ Mountain (간): -10% reach (defensive)
};
/**
* Korean terminology for collision detection concepts.
*
* **Korean**: 충돌 감지 용어
*
* @public
* @category Korean Terms
* @korean 충돌용어
*/
export const COLLISION_KOREAN_TERMS = {
collisionDetection: "충돌감지", // Chungdol Gamji
attackRange: "타격범위", // Tagyeok Beomwi
preciseHit: "정밀타격", // Jeongmil Tagyeok
boundingBox: "경계상자", // Gyeonggye Sangja
raycast: "광선투사", // Gwangseon Tusa
hitAccuracy: "타격정확도", // Tagyeok Jeonghwakdo
effectiveReach: "유효범위", // Yuhyo Beomwi
} as const;
/**
* Anatomical region dimensions in meters.
*
* **Korean**: 해부 영역 치수
*
* Standard dimensions for adult human anatomical regions used for bounding box creation.
*
* @public
* @category Collision Constants
* @korean 해부영역치수
*/
export const ANATOMICAL_DIMENSIONS = {
head: {
type: "sphere" as const,
radius: 0.125, // 머리 구 반경 (Meori sphere radius) – 12.5cm radius for head sphere
center: { x: 0, y: 1.7, z: 0 }, // 머리 중심 높이 (Meori center height) – Average adult head height
},
neck: {
type: "capsule" as const,
radius: 0.075, // 목 캡슐 반경 (Mok capsule radius) – 7.5cm radius for neck cylinder
height: 0.15, // 목 캡슐 높이 (Mok capsule height) – 15cm height
center: { x: 0, y: 1.5, z: 0 }, // 목 중심 높이 (Mok center height)
},
torso: {
type: "box" as const,
width: 0.4, // 몸통 상자 가로 (Momtong box width) – 40cm width (shoulder to shoulder)
height: 0.6, // 몸통 상자 세로 (Momtong box height) – 60cm height (neck to waist)
depth: 0.25, // 몸통 상자 깊이 (Momtong box depth) – 25cm depth (front to back)
center: { x: 0, y: 1.1, z: 0 }, // 몸통 중심 높이 (Momtong center height)
},
arms: {
type: "capsule" as const,
radius: 0.05, // 팔 캡슐 반경 (Pal capsule radius) – 5cm radius for arm cylinder
height: 0.6, // 팔 캡슐 길이 (Pal capsule length) – 60cm length (shoulder to hand)
center: { x: 0.3, y: 1.1, z: 0 }, // 팔 위치 오프셋 (Pal position offset) – Offset for arm position
},
legs: {
type: "capsule" as const,
radius: 0.06, // 다리 캡슐 반경 (Dari capsule radius) – 6cm radius for leg cylinder
height: 0.8, // 다리 캡슐 길이 (Dari capsule length) – 80cm length (hip to foot)
center: { x: 0.15, y: 0.4, z: 0 }, // 다리 위치 오프셋 (Dari position offset) – Offset for leg position
},
} as const;
|