Extract OrbitConstraint from OrbitControls
OrbitControls takes care of the DOM, input binding and event handling. OrbitConstraint is responsible for keeping the camera on an orbit, maintaining its orientation towards the target and updating the camera and target position. There is only one insignificant API change. Before, dolly / rotate functions could be called without parameters to engage autoRotate / autoSpeed. OrbitConstraint does not support that. Now, OrbitControls must provide these parameter explicitly to OrbitConstraint. As far as I can tell, those methods were only used internally and should not be part of the control API. OrbitControls extends OrbitConstraint. In my ideal implementation, OrbitConstraint should be a property of the OrbitControls, but using inheritence help preserve the existing interface. OrbitConstraint is not included in the `THREE` namespace. It is defined in a closure and private to this file. It could also the placed in `extras\constraints`, along with other contraints that could be extracted from the current controls, and maybe other type of constraints on the object position/displacement (constrain movement to plane, to path, collision). These constraints should not necessarily be limited to cameras; they could apply to any objects. It's not clear to me how all this will shape up, but this is a nice place to pause and ask for feedback before going forward.
Showing
想要评论请 注册 或 登录