Allow flexibility on DragControls for multi-part GLTF models & other hierarchical objects #26134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I haven't raised a related issue - I can do so if required
Description
DragControls doesn't offer the flexibility needed to use DragControls with multi-part GLTF models (or other smilar hierarchical objects).
DragControls can be configured on an array of object3Ds. The drag behaviour then operates on all these objects, and all their descendants.
When dragging happens, it is applied to the object3D that the raycaster hit. If this is a descendant of an object specified in the array, then the descendant will be dragged independently of the ancestor object.
So if I have a multi-part GLTF, which gets mapped into a hierarchy of object3Ds, I can't use DragControls to move the GLTF as a whole. If I click and drag on it, I'll end up dragging the part of the model I clicked on, rather than the whole model.
DragControls does have a config option
transformGroup
which results in the entire group of objects being transformed (ignoring where the raycaster hit completely). However this can only be used when DragControls is being used on a single object. It can't be used when I want a single instance of DragControls to allow dragging of multiple objects.Proposed fix is another flag, "transformDescendants". This is set to "true" by defult, preserving current behaviour.
When this is set to "false" (and transformGroup is also "false"), then the logic for which object to move is as follows:
So far this fix has been tested in various A-Frame contexts: SeregPie/aframe-drag-controls#2
However the same issue exists for vanilla Three.js when using multi-part GLTF models. Happy to create a pure Three.js example to illustrate the problem if that would be helpful.