Selva Compute API Reference - v2.1.0
    Preparing search index...

    Function snapToVertex

    • Snap a raycast hit to the nearest geometry vertex within snapPixels on screen; otherwise return the raw hit point. Works for meshes (triangle vertices), lines (segment endpoints), and points (the vertex itself). Pure (no DOM) so it's unit-testable: it takes the screen size explicitly rather than reading the canvas. Exported for that reason.

      Falls back to the raw point for hits without usable vertex indices or positions.

      Parameters

      • hit: Intersection
      • camera: Camera
      • screenSize: { height: number; width: number }
      • snapPixels: number

      Returns Vector3