There is a case:
I know it’s hard to drag a group of objects. So I make one object as the child of another, which means that objectParent.add(objectChildren).
However, the dragStart function always takes objectChilren as the target, not the objectParent.
Do you just have to drag a single group or possibly multiple groups in your scene? Besides, how do you organize the objects array which you pass into DragControls? I mean does the array hold only a single group object?
I’ve noticed that multiple users in the past had this feature request. It’s actually easy to implement if only one root object is present in drag_objects. The approach does not work if more than one object is present in this array.
Can you please test if these versions of DragControls work for you? The first one is the replacement for examples/js/controls/DragControls.js, the second one for examples/jsm/controls/DragControls.js.
When creating the controls, you have to set the new property transformRoot to true. Otherwise the controls transform individual objects.
If you assign a new instance of Array in your raycast() function to drag_obj, then DragControls won’t notice this change. The controls only holds a reference to the initial array passed to the ctor.
So instead of drag_obj = [];, try drag_obj.length = 0;.
I check the dragControls from the console. The draggable object is one and will change according to the raycaster. However, the problem is that when I drag a mesh, the Edge and mesh will be dragged separately. Do you have any suggestion?
Keep in mind that raycasting against lines always works with a tolerance value. Since this approach is an approximation, it’s not so exact like raycasting against meshes.
Besides, try to avoid to invoke init() multiple times. Only setup DragControls once.
If you select more than one object, you can now drag’n’drop the entire group.
The solution is not perfect since only a single group is supported right now. However, it’s a start and better than manually modifying THREE.DragControls .