Drag and drop
Next up on the feature list was to implement drag and drop.
This was relatively simple to be honest. I followed along with a three.js demo where you can move objects around. Since I already had all the raycast stuff figured out I could just hook into that to detect objects, check if they're draggable — I set a variable to true on the object to enable it — and then just attach the object to the controller for as long as the trigger is pressed.
I was able to add this as quickly as I did because I had already set up the raycast code and just had to add the drag and drop code.
Another thing that I didn't know existed was the .attach() method that — you guessed it — attaches an object to another, in this case making the object being dragged a child of the controller element.