Skip to content

Solver-agnostic ray/line picking on the physicsData seam - #157

Merged
krisnye merged 2 commits into
mainfrom
krisnye/3d-picking
Jul 26, 2026
Merged

Solver-agnostic ray/line picking on the physicsData seam#157
krisnye merged 2 commits into
mainfrom
krisnye/3d-picking

Conversation

@krisnye

@krisnye krisnye commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds a pluggable, solver-agnostic spatial-query seam for picking on
@adobe/data-gpu/physics, fulfilled interchangeably by both reference solvers.

  • physicsQuery resource + pickRay / pickRayEach actions on the
    physicsData seam. The active solver publishes its engine-backed
    implementation once its WASM world is live; consumers pick without knowing
    which solver is running.
  • With or without radius — a thin ray, or a sphere of radius swept along
    the segment, behind one option.
  • pickRay returns the nearest collider as a fresh, retainable PhysicsHit
    (entity, parametric α ∈ [0,1] matching graphics PickHit, world point,
    ray-opposing normal).
  • pickRayEach visits every collider along the segment, nearest first, with
    early-out, passing a single reused (zero-allocation) hit.
  • Backed by each engine's native cast — Rapier castRayAndGetNormal /
    castShape / intersectionsWithRay; Jolt NarrowPhaseQuery.CastRay /
    CastShape with all-hit collectors. Entity resolved via body userData.

Radius all-hits is native on Jolt; the Rapier compat binding has no swept-shape
all-hits query, so a radius pickRayEach degrades to the nearest hit there
(documented on the interface). Graphics picking (renderable-Model AABB) is
left untouched — physics picking is collider-based and separate.

Testing

  • Abstract conformance suite (pick-ray-conformance.test.ts) run against both
    solvers: entity/α/point/normal, nearest-of-several, clean miss, with/without
    radius, all-hits ordering + early-out, and the zero-alloc scratch-reuse vs.
    fresh-castRay contract.
  • Unit test for the shared orientNormalAgainstRay helper.
  • Full physics suite passes (39 tests); monorepo lint + typecheck clean.

🤖 Generated with Claude Code

krisnye and others added 2 commits July 26, 2026 16:03
Add a pluggable physicsQuery resource + pickRay/pickRayEach actions fulfilled
by both rapierSolver and joltSolver. Supports picking with or without radius
(thin ray or swept sphere), nearest-hit and zero-alloc all-hits iteration,
verified by an abstract conformance suite run against both engines.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@krisnye
krisnye merged commit 24f3288 into main Jul 26, 2026
4 checks passed
@krisnye
krisnye deleted the krisnye/3d-picking branch July 26, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant