question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC: RaycasterHelper

See original GitHub issue

Hey! 👋
I made a very simple raycaster helper for myself, was wondering if it isn’t worth adding this along the other existing helpers.

https://user-images.githubusercontent.com/1862172/162688071-4993e811-2fe0-4b8a-99c6-99c38214d78e.mov

Try it here https://6tc01w.csb.app/

It displays:

  • a segment going from origin to near + near to far
  • the two near/far points
  • optionally displays any hit via instances - this could just be points tbh
  • optionally displays wether or not any hit exists

The style is halfway between @gkjohnson 's bvh ray visualizations and three’s directional light helper

API is:

const raycaster = new Raycaster(origin, direction, near, far)
const helper = new RaycasterHelper( raycaster, 5 ) // raycaster + max number of hits to display

// in your loop
const hits = raycaster.intersectObjects( scene.children )
helper.hits = hits;

Some boring nuance:

  • all the elements created by the helper have their raycast set as null, otherwise they’d always be hit by the ray they are visualizing 😓
  • there’s some inefficiency in the way lines are updated, but that should be easily fixed if it’s worth doing
  • all the components of the visualization are exposed as properties of the object, so they can be easily overridden, eg.
const helper = new RaycasterHelper( raycaster )
// make the hits red instead of white
helper.hitsVisualization.material.color = "#ff005b"

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:8
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mrdoobcommented, Apr 11, 2022

Looks good though! Would be nice to put it in examples/jsm/helpers/.

0reactions
mrdoobcommented, Apr 14, 2022

Ah I see…

Yeah, sounds good to me!

By the way, I just noticed that CapsuleGeometry’s normals seem to have something wrong at the poles 🤔

Screen Shot 2022-04-14 at 11 12 25 AM
Read more comments on GitHub >

github_iconTop Results From Across the Web

Raycaster – three.js docs
This class is designed to assist with raycasting. Raycasting is used for mouse picking (working out what objects in the 3d space the...
Read more >
Issues · mrdoob/three.js · GitHub
RFC : RaycasterHelper Enhancement. #23877 opened Apr 11, 2022 by gsimone r145 · 5 · Opacity issue when using SSAARenderPass in r139 Enhancement...
Read more >
Setup RFC Connections - YouTube
Your browser can't play this video. Learn more. Switch camera.
Read more >
How to cast a visible ray threejs - Stack Overflow
You can add a crosshair constructed from simple geometry to your camera like this: var material = new THREE.LineBasicMaterial({ color: 0xAAFFAA }); ...
Read more >
Raycaster - Three.js Tutorials - sbcode.net
Raycasting allows you to create a vector from a 3D point in the scene, and detect which object(s) the vector intersects. The raycasting...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found