ModelController.cs
Handles rotation and zoom interactions for a 3D model in Unity, including touch/mouse input, pinch-to-zoom, and rotation inertia.
Handles rotation and zoom interactions for a 3D model in Unity, including touch/mouse input, pinch-to-zoom, and rotation inertia.
The target 3D model to control.
The UI zone that allows rotation interactions.
Controls the rotation speed.
Default: 0.1f
Determines how quickly rotation inertia slows down.
Default: 0.9f
The minimum velocity required to apply rotation inertia.
Default: 0.01f
Enables or disables rotation functionality.
Default: true
Tracks whether rotation is disabled due to UI interactions.
(Exposed as the property UIRaycastHack.)
The minimum scale factor for zoom.
Default: 0.5f
The maximum scale factor for zoom.
Default: 2.0f
The Z-axis offset for zoom progression.
Default: 0.5f
Interpolation speed for smooth zooming.
Default: 10f
Tracks the current rotation velocity of the model.
(Exposed as the property RotationVelocity.)
The initial position of the target.
The initial rotation of the target.
The initial scale of the target.
The current zoom scale factor.
Default: 1f
Indicates if the model is being dragged.
Indicates if a pinch-to-zoom gesture is in progress.
Distance between touch points at the start of a pinch gesture.
Zoom factor at the start of a pinch gesture.
Resets the target's transform and internal state to the specified initial values.
Vector3 initPos: Initial position of the target.
Quaternion initRot: Initial rotation of the target.
Vector3 initScale: Initial scale of the target.
Handles single-touch input for model rotation.
Handles mouse input for model rotation.
Applies rotation to the target using the current rotation velocity.
Determines if a given screen position is over the rotation interaction zone.
Vector2 position: The screen position to check.
Returns: true if over the interaction zone; otherwise false.
Handles pinch gestures for zooming in/out of the model.
Updates the target's scale and position based on the current zoom factor.