feat(@typegpu/geometry): Raycast against a mesh on the CPU

Đang mở
#3,455 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
computer-graphics, typescript
Lĩnh vực
backend, computer-graphics

Hướng nghiên cứu

Start with the mesh endpoint from #2997 and inspect IndexedGeometry's vertexAt(i), indexAt(i), and topology APIs. The issue proposes meshes.raycast(geometry, origin, direction) for triangle-list meshes, returning the nearest hit with barycentric data and available vertex attributes. Done means callers can raycast indexed and non-indexed geometry synchronously in local space; the back-face and all-hit questions still need decisions.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Use case: world-space UIs (https://github.com/software-mansion/typegpu-kit/issues/15). A UI is rendered to a texture on a plane, and pointer events need the hit UV. Picking on the GPU is async and has no UVs, so this needs a sync CPU raycast against the mesh.

It builds on the mesh endpoint from #2997, which already gives everything needed: vertexAt(i), indexAt(i) on IndexedGeometry, and the topology.

Proposal:

const hit = meshes.raycast(geometry, origin, direction);
// { distance, triangle, barycentric, position, normal, uv } | undefined
  • Works for triangle-list geometry, indexed or not.
  • Returns the nearest hit along the ray, or undefined.
  • triangle and barycentric let you interpolate any attribute of a custom vertex schema. position, normal and uv are filled when the schema has them (the default Vertex does).
  • The ray is in the geometry's local space. Moving it by the inverse of an instance's placement stays with the caller (or a helper in the kit).

Open questions:

  • Hit back faces too, or only front faces by default? A UI plane wants both.
  • One hit, or an option for all hits sorted by distance?
  • No acceleration structure at first: a linear pass over the triangles is fine for UI planes and small meshes. A BVH can come later if someone raycasts big meshes every frame.
Ngôn ngữ chính
TypeScript
Star
3.4k
Fork
151
Merge trung bình
3 ngày 8 giờ
Pull request đã merge (30 ngày)
55

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của software-mansion/TypeGPU

Tất cả issue của software-mansion/TypeGPU

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.