Black Trigram (흑괘) - Korean Martial Arts Combat Simulator API - v0.7.0
    Preparing search index...

    Class CollisionDetection

    Collision Detection Engine for combat physics.

    Korean: 충돌 감지 엔진

    Provides efficient collision detection for combat using bounding boxes and raycasting. Optimized for 60fps performance with multiple simultaneous collision checks.

    충돌감지엔진

    Index

    Constructors

    Methods

    • Private

      Calculates effective attack reach for a technique.

      Korean: 공격 범위 계산

      Applies stance modifiers to base technique reach.

      Parameters

      Returns {
          baseReach: number;
          effectiveReach: number;
          stance: TrigramStance;
          stanceModifier: number;
          technique: TechniqueType;
      }

      Attack reach with all modifiers applied

      공격범위계산

    • Private

      Calculates hit accuracy based on distance to vital point center.

      Korean: 타격 정확도 계산

      Accuracy decreases linearly with distance from vital point center. Perfect accuracy (1.0) at center, decreasing to 0 at 5cm radius.

      Parameters

      Returns number

      Accuracy value from 0 to 1

      타격정확도계산

    • Checks if an attack hits the defender.

      Korean: 공격 타격 확인

      Performs two-phase collision detection:

      1. Calculate effective attack reach based on technique and stance
      2. Broad-phase: Check if defender is within reach
      3. Broad-phase: Check if target region's AABB is within reach
      4. Narrow-phase: Raycast to find precise vital point hit

      Parameters

      • attackerPosition: Position3D

        3D position of the attacker

      • defenderPosition: Position3D

        3D position of the defender

      • technique: { type?: string; [key: string]: any }

        Technique being used with type information

      • attackerStance: TrigramStance

        Attacker's current trigram stance

      • targetRegion: AnatomicalRegionPhysics

        Anatomical region being targeted

      Returns CollisionResult

      Collision result with hit status, vital point, distance, and accuracy

      const result = collision.checkAttackHit(
      { x: 0, y: 0, z: 5 },
      { x: 0, y: 0, z: 6 },
      { type: "punch" },
      TrigramStance.GEON,
      "head"
      );

      공격타격확인

    • Private

      Creates Three.js geometry for a bounding box.

      Helper method for geometry cache initialization.

      Parameters

      Returns BufferGeometry

      Three.js geometry

      경계상자지오메트리생성

    • Cleans up Three.js resources.

      Korean: 자원 정리

      Disposes of cached geometries and releases memory to prevent leaks. Should be called when the CollisionDetection instance is no longer needed.

      Returns void

      자원정리

    • Private

      Initializes bounding boxes for all anatomical regions.

      Creates collision volumes for the 5 anatomical regions using the ANATOMICAL_DIMENSIONS constants from the physics types module.

      Returns void

      경계상자초기화

    • Private

      Initializes geometry cache for object pooling.

      Pre-creates all geometries needed for raycasting to avoid repeated allocations during combat. Critical for maintaining 60fps with up to 100 collision checks per frame.

      Returns void

      지오메트리캐시초기화

    • Private

      Organizes vital points by anatomical region for efficient lookup.

      NOTE: This categorization currently uses y-coordinate thresholds that assume positions are in meters. However, VITAL_POINTS_DATA uses pixel coordinates (e.g., y: 50), which will cause incorrect categorization. Most vital points will end up in the "legs" region since pixel y-coordinates are typically less than 0.8.

      TODO: After implementing 2D→3D coordinate mapping, update this method to use the converted 3D positions, or use the anatomical region data that may already exist in the vital points data structure.

      Categorizes the 70 vital points into their respective regions:

      • Head: 10 vital points
      • Neck: 8 vital points
      • Torso: 20 vital points
      • Arms: 16 vital points
      • Legs: 16 vital points

      Returns void

      급소영역별정리

    • Private

      Performs raycasting against a bounding box.

      Korean: 경계 상자 광선 투사

      Uses cached geometries from object pool to avoid repeated allocations during combat. Creates a Three.js mesh for the bounding box and performs raycasting to detect intersection points.

      Uses object pooling for Vector3 allocations to reduce GC pressure.

      Parameters

      Returns { point: Position3D } | null

      Intersection point or null if no hit

      경계상자광선투사

    Properties

    boundingBoxes: Map<AnatomicalRegionPhysics, BoundingBox> = ...
    coordinateMapper: CoordinateMapper
    geometryCache: Map<
        string,
        BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>,
    > = ...
    raycaster: Raycaster = ...
    vitalPointsByRegion: Map<AnatomicalRegionPhysics, VitalPoint[]> = ...