SelectionBox: Add support for pixel-perfect selection.
See original GitHub issueP.S. it is not question, it is feature request for frustum.intersectsGeometry(mesh.geometry)
I mean not bounding box and bounding sphere, but exactly pixel perfect, I mean.
Maybe shader or special renderer? Give different colors to different meshes, and by rendered colors detect what objects were selected?
After three days of googling, I haven’t found a single answer on the Internet.
For example, this Box should not be selected:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
Is it possible to use the Raycaster with a selection box?
Pixel-perfect selection support for SelectionBox was discussed GitHub some time ago. The conclusion was to not add support to it considering the related ......
Read more >Pixel Perfect Selections in Affinity Photo - YouTube
Enroll in the course here: https://affinity.sale/ pixelperfect * ... This course is designed to help you become a selection master.
Read more >Tweak selection bounding box - PDFTron Community
I'm building a tool which relies on the user selecting text, and having that text extracted and piped into other features. Some PDFs...
Read more >Selecting 3D surfaces with a selection box (in two different ways)
You set up the selection rectangle as the scissor rectangle, and render all ... buffer) and add any new selected object to selected...
Read more >Intermediate Tutorial 4 - Ogre Wiki - Ogre3D
This is so it doesn't get covered up by the objects we are trying to select. Add the following to the body of...
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
In terms of alternatives in other projects something similar (lasso selection of individual triangles) was requested a bit ago in three-mesh-bvh and I’ve created an example for it here. It uses the bounds tree to accelerate selection but you can disable it to see the difference in performance (ms displayed in bottom left). The core the approach involves projecting the triangles to screen space and performing the line-crossing algorithm to determine triangle intersection so you don’t need an acceleration structure to implement it. If you’re limiting selection to a box you can use the projected frustum shape and check every triangle, instead, which might be a bit faster / simpler.
Anyway it might be at least a start for someone looking to implement this in a project. Other relevant discussions in three-mesh-bvh issues 109 and 166.
This would make selection asynchronous which might not be desirable. Copying render target data from the GPU to to the CPU can also be a slow operation and will scale based on canvas size / pixel density. GPU picking for raycasting is a bit more consistent because you only need to render / copy a single pixel.
Blender may have extra underlying acceleration data structures to facilitate performant interactions like this that three.js doesn’t provide out of the box. With simple geometry performance may not be all that bad though. For all the meshes you want to check selection for you could perform a triangle / selectionbox frustum intersection for every triangle in the mesh to see if it is selected. If the bounding box / sphere of a mesh is completely contained in the frustum you could skip the triangle check and just mark it as selected. Supporting all the corner cases of instanced, skinned, etc meshes may get complicated, though.
If performance turns out to be an issue you could only run the selection check when the user releases the mouse rather than on every frame. For particularly complex meshes you could use some kind of spatially indexed data structure like a quad tree or bvh which there are some libraries for.