# \[vtk.js\] Implementing cell selection with the HardwareSelector

**URL:** https://discourse.vtk.org/t/vtk-js-implementing-cell-selection-with-the-hardwareselector/1439
**Category:** Web
**Created:** [July 29, 2019, 3:04pm UTC](https://discourse.vtk.org/t/vtk-js-implementing-cell-selection-with-the-hardwareselector/1439 "2019-07-29T15:04:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rvilums](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rvilums/32/688_2.png) [@rvilums](https://discourse.vtk.org/u/rvilums)
#### Post date: [July 29, 2019, 3:04pm UTC](https://discourse.vtk.org/t/vtk-js-implementing-cell-selection-with-the-hardwareselector/1439/1 "2019-07-29T15:04:58Z")

</div>

Would it be a pain to implement cell selection in HardwareSelector? Maybe you could suggest some key points and locations. I was looking to the current source code for a while but still could not get to the root.

I have polyData with cells. Cells are grouped via additional field data (let’s call it faceId). Usually, there are up to 100 faces for an object. If a user clicks on an image, I need to determine faceId of the clicked cell. I have done it with vtkCellPicker, but it is painfully slow.

Or, would it be feasible to create a separate actor for every face and use HardwareSelector on them instead?

---

<div class="post-metadata">

### Author: ![ken-martin](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ken-martin/32/884_2.png) [@ken-martin](https://discourse.vtk.org/u/ken-martin)
#### Post date: [August 5, 2019, 4:39pm UTC](https://discourse.vtk.org/t/vtk-js-implementing-cell-selection-with-the-hardwareselector/1439/2 "2019-08-05T16:39:55Z")

</div>

It could be done the same way (or slightly simpler) as it is done in VTK C++. Basically add another pass to the selection process. Color that pass by the cell ID, then convert the webgl cell ID to the VTK cell ID for each actor. Not a trivial piece of code (and the implementation in VTK C++ is way more complex) but not super hard either.

---

<div class="post-metadata">

### Author: ![rvilums](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rvilums/32/688_2.png) [@rvilums](https://discourse.vtk.org/u/rvilums)
#### Post date: [August 19, 2019, 8:22am UTC](https://discourse.vtk.org/t/vtk-js-implementing-cell-selection-with-the-hardwareselector/1439/3 "2019-08-19T08:22:10Z")

</div>

Thanks for the tips. As I did not fully understand all this “pass” thing, I went for a solution with many actors. Unfortunately, I hit another problem as posted [here](https://discourse.vtk.org/t/vtk-js-is-there-actor-limit-for-hardwareselector/1572).

It seems I will have to dig the code anyway 🙂
