Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

293
Views
Raycasting mouse position to draw on 3D mesh

I want to draw on a 3D object, and the way I do it is to raycast hits from the mouse position and paint the closest 3D vertex to that hit.

However, when I am moving the mouse really fast, the hits are not registering, and there are big gaps in my drawing:

Missing drawing

What could be the issue?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The issue is pretty clearly that you are not sampling inputs quickly enough for your given painting strategy. This may be because the time between samples is unusually slow (perhaps because your raycasts are taking too much time) or because the speed of the mouse simply exceeds any reasonable sampling rate. This is a fundamental flaw in your painting strategy, which is to paint one vertex for each input sample.

A more robust approach would involve some sort of interpolation. Here are two approaches that come to mind:

  1. Interpolate the input samples. I.e., if one mouse input is sampled at coordinates (x1, y1) and the next input is sampled at (x2, y2), you could add imaginary samples along the line segment from (x1, y1) to (x2, y2) and raycast those as well. If your raycasts are costly, this may not be a performant option. Also you would have to somehow determine a good number of extra points to introduce.
  2. Interpolate along the mesh. In this case, you raycast two consecutive input samples to find two corresponding vertices on the mesh. Then you also paint all vertices along a path between those two vertices. The shortest path seems reasonable, but perhaps there are better strategies for your case.
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!