Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Split TransformControls into an adaptor that switches between three separate Rotate/Translate/ScaleControls classes? #3402
I am concerned that Three.TransformControls tries to do too much and thus it is overly complex. I've been looking at the code for a while this morning and it is pretty involved.
I was wondering if it is possible to split most of the functionality of TransformControls into three separate classes such as ScaleControls, TranslateControls and RotationControls. If there is some shared functionality one could create a base class that each of these three share.
This would focus the code to each of these three specific use cases.
TransformControls would then become a means to switch between these more specific controls, rather than being all three of these complex controls.
Besides making it a lot simpler, it would also enable me to use just TranslateControls in some cases instead of always having to use all three controls as TransformControls and then trying to build in some filtering on top (which will make it even more complex.)
I agree this is a good idea. It also needs to be cleaned up quite a bit. There is a lot of shared functionality for different transform modes so I would definitely avoid having too much redundant code for the sake of easy maintenance. Perhaps put it all in TransformUtils?
Also, we should keep in mind features that we might want to add in the future and design accordingly. For example, attachment to multiple objects or geometry components, compatibility with multiple viewports, touch events, etc.
@arodic, we actually need the multiple object and geometry components, multiple viewports, and touch events support for a project we will be open sourcing in the near future, so it isn't that far of a future need but rather an immediate need. :-)
We actually have a lot of this working already in a separate code base but really why should we keep it separate when we can combine effort and get the best solution together.