RFC: RaycasterHelper
See original GitHub issueHey! 👋
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:
- Created a year ago
- Reactions:8
- Comments:5 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks good though! Would be nice to put it in
examples/jsm/helpers/
.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 🤔