RPE Chart Utils
    Preparing search index...

    Function findClosestNote

    • Find the note closest to a given scene position at a specific beat.

      Useful for implementing click-to-select in a chart editor.

      Parameters

      • chart: RpeJson

        The parsed RPE chart.

      • target: Vec2

        Target position in scene pixels.

      • beat: number

        Current beat.

      • chartFlipping: number = 0

        Chart flipping flags (0–3).

      • maxDistance: number = Infinity

        Only consider notes within this pixel radius (default: Infinity).

      Returns
          | {
              lineIndex: number;
              noteIndex: number;
              position: NotePosition;
              distance: number;
          }
          | null

      The closest note's info, or null if none found within maxDistance.

      // On mouse click at (mouseX, mouseY):
      const hit = findClosestNote(chart, { x: mouseX, y: mouseY }, currentBeat, 0, 30);
      if (hit) {
      console.log(`Clicked line ${hit.lineIndex}, note ${hit.noteIndex}`);
      }