public static ClampAngleX ( float angle, float min, float max ) : float | ||
angle | float | |
min | float | |
max | float | |
Résultat | float |
private void ProcessOrbit() { Vector2 incomingInputDelta = new Vector2(); incomingInputDelta.x = _catcher.PointerEventDataList[0].delta.x * _xSpeed * .02f; incomingInputDelta.y = _catcher.PointerEventDataList[0].delta.y * _ySpeed * .02f; //dont remember specifics of this float momentumWait = Mathf.Clamp(incomingInputDelta.magnitude / 8f, 0f, MaxMomentumWait); //if( Mathf.Abs( incomingInputDelta.x ) > Mathf.Abs( inputDelta.x ) ) if ((_orbitDelta.x > 0 && incomingInputDelta.x > _orbitDelta.x) || (_orbitDelta.x < 0 && incomingInputDelta.x < _orbitDelta.x) || _orbitDelta.x == 0) { _orbitDelta.x = incomingInputDelta.x; _orbitMomentumTimer.x = momentumWait; } else if (_orbitMomentumTimer.x <= 0) { _orbitDelta.x = incomingInputDelta.x; } if ((_orbitDelta.y > 0 && incomingInputDelta.y > _orbitDelta.y) || (_orbitDelta.y < 0 && incomingInputDelta.y < _orbitDelta.y) || _orbitDelta.y == 0) { _orbitDelta.y = incomingInputDelta.y; _orbitMomentumTimer.y = momentumWait; } else if (_orbitMomentumTimer.y <= 0) { _orbitDelta.y = incomingInputDelta.y; } Vector3 newRotation = transform.eulerAngles; newRotation.y += _orbitDelta.x; if (_xMaxLimit != 0 && _xMinLimit != 0) { newRotation.y = ClampUtility.ClampAngleX(newRotation.y, _xMinLimit, _xMaxLimit); } transform.eulerAngles = newRotation; Vector3 newLocalRotation = transform.localEulerAngles; newLocalRotation.x -= _orbitDelta.y; newLocalRotation.x = ClampUtility.ClampAngleY(newLocalRotation.x, _yMinLimit, _yMaxLimit); transform.localEulerAngles = newLocalRotation; }
private void NoInput() { _orbitDelta = Vector2.Lerp(_orbitDelta, Vector2.zero, Time.deltaTime * 8); _zoomDelta = Mathf.Lerp(_zoomDelta, 0f, Time.deltaTime * 8); _panDelta = Vector3.Lerp(_panDelta, Vector3.zero, Time.deltaTime * 8); //zoom Vector3 vector3 = _orbitView.transform.localPosition; vector3.z += _zoomDelta; if (vector3.z > _maxZoom) { vector3.z = _maxZoom; } else if (vector3.z < _minZoom) { vector3.z = _minZoom; } _orbitView.transform.localPosition = vector3; //rotate turntable vector3 = transform.eulerAngles; vector3.y += _orbitDelta.x; if (_xMaxLimit != 0 && _xMinLimit != 0) { vector3.y = ClampUtility.ClampAngleX(vector3.y, _xMinLimit, _xMaxLimit); } transform.eulerAngles = vector3; vector3 = transform.localEulerAngles; vector3.x -= _orbitDelta.y; vector3.x = ClampUtility.ClampAngleY(vector3.x, _yMinLimit, _yMaxLimit); transform.localEulerAngles = vector3; Vector3 newPos = transform.position; switch (_strafeAxis) { case Axis.X: PanAxis(ref newPos.x, _panDelta.x, _minStrafe.x, _maxStrafe.x); break; case Axis.Y: PanAxis(ref newPos.y, _panDelta.y, _minStrafe.y, _maxStrafe.y); break; case Axis.Z: PanAxis(ref newPos.z, _panDelta.z, _minStrafe.z, _maxStrafe.z); break; case Axis.XY: PanAxis(ref newPos.x, _panDelta.x, _minStrafe.x, _maxStrafe.x); PanAxis(ref newPos.y, _panDelta.y, _minStrafe.y, _maxStrafe.y); break; case Axis.YZ: PanAxis(ref newPos.y, _panDelta.y, _minStrafe.y, _maxStrafe.y); PanAxis(ref newPos.z, _panDelta.z, _minStrafe.z, _maxStrafe.z); break; } transform.position = newPos; }