Question: I am trying to manually identify/correct trees using LiDAR data (1.7 GB object) and a `tree tops` object via the `locate_trees` function. Part of the problem is:

1. Rgl is rendering very slow even though the `4 GB Nvidia 3050` should be able to handle it.
2. The tree tops (red 3D dots) are not even showing in the rgl window. When I close the rgl window, the tree tops start popping up (red dots appear and disappear resulting in a blank white window) in a new rgl window. And if I close that window, a new tree top window opens up so I stop the process to prevent this from happening.

Does rgl automatically use the `GPU` or does it default to the integrated graphics on the motherboard? Is there a way to fasten up the rendering?

My other system specs are Corei9 (14 threads) and 64 GB RAM. Moreover, I am using `R` `4.2.1`.

Code:

```
library(lidR)

# Import LiDAR data
LiDAR_File = readLAS("path/file_name.las")

# Find tree tops
TTops = find_trees(LiDAR_File , lmf(ws = 15, hmin = 5))

# Manually correct tree identification
TTops_Manual = locate_trees(LiDAR_File , manual(TTops)) # This is where rgl rendering becomes too slow if there are too many points involved. 

```

Answer: 
Here is my version with the recommended ways of delegating and setting and getting data attribute

A user cannot click what is not visible so no need to initiate the button, just unhide it

```js
document.addEventListener("click", function(e) {
  let btn = e.target
  if (btn.matches("#btn1")) {
    let targetBTN = document.getElementById(btn.dataset.target);
    targetBTN.hidden = false;
  } else if (btn.matches("#btn2")) {
    console.log(btn.dataset.field);
  }
});
```

```html
<button id="btn1" data-target="btn2">Initiate</button>
<button id="btn2" data-field="ok2" hidden>Send data</button>
```
It looks like the one goal is to only allow the second button to be able to be used when the first button is clicked.

So, I attached an event listener to the document. Then used data attributes on the buttons to determine if the start button can be used or not. And just for display I used CSS to hide the start button if its not allowed to be used just yet

```js
document.addEventListener("click",function(e){
  let btn = e.target
  if(btn.matches(".btn-start")){
    let targetBTN = document.querySelector(`[data-id='${btn.dataset.target}']`)
    targetBTN.setAttribute("data-initiated","true");
  }
  else if(btn.dataset.initiated == "true"){
    console.log(btn.dataset.field);
  }
});
```

```css
[data-initiated="false"]{
 display:none
}

[data-initiated="true"]{
 display:inline-block
}
```

```html
<button data-target="send2" class="btn-start">Initiate</button>
<button data-initiated="false" data-field="ok2" data-id="send2" class="btn-send">Send data</button>
```