Hello guys,
i’m ported “panAngle or tiltAngle logic” to distance
new set disatnce():
public function set distance(val:Number):void
{
val = Math.max(_minDistance, Math.min(_maxDistance, val))
if (_distance == val)
return;
_distance = val;
notifyUpdate();
}
new update() function:
public override function update():void
{
if (_tiltAngle != _currentTiltAngle || _panAngle != _currentPanAngle || _distance != _currentDistance) {
notifyUpdate();
if (_wrapPanAngle) {
if (_panAngle < 0)
_panAngle = (_panAngle % 360) + 360;
else
_panAngle = _panAngle % 360;
if (_panAngle - _currentPanAngle < -180)
_currentPanAngle -= 360;
else if (_panAngle - _currentPanAngle > 180)
_currentPanAngle += 360;
}
_currentTiltAngle += (_tiltAngle - _currentTiltAngle)/(steps + 1);
_currentPanAngle += (_panAngle - _currentPanAngle)/(steps + 1);
_currentDistance += (_distance - _currentDistance)/(steps +1)
//snap coords if angle differences are close
if ((Math.abs(tiltAngle - _currentTiltAngle) < 0.01) && (Math.abs(_panAngle - _currentPanAngle) < 0.01) && (Math.abs(_distance - _currentDistance)< 0.01)) {
_currentTiltAngle = _tiltAngle;
_currentPanAngle = _panAngle;
_currentDistance = _distance;
}
}
var pos:Vector3D = (lookAtObject)? lookAtObject.position : (lookAtPosition)? lookAtPosition: _origin;
targetObject.x = pos.x + _currentDistance*Math.sin(_currentPanAngle*MathConsts.DEGREES_TO_RADIANS)*Math.cos(_currentTiltAngle*MathConsts.DEGREES_TO_RADIANS);
targetObject.z = pos.z + _currentDistance*Math.cos(_currentPanAngle*MathConsts.DEGREES_TO_RADIANS)*Math.cos(_currentTiltAngle*MathConsts.DEGREES_TO_RADIANS);
targetObject.y = pos.y + _currentDistance*Math.sin(_currentTiltAngle*MathConsts.DEGREES_TO_RADIANS)*yFactor;
super.update();
}
new constructor function declaration:
public function HoverController(targetObject:Entity = null, lookAtObject:ObjectC panAngle:Number = 0, tiltAngle:Number = 90, distance:Number = 1000, minTiltAngle:Number = -90, maxTiltAngle:Number = 90, minPanAngle:Number = NaN, maxPanAngle:Number = NaN, steps:uint = 8, yFactor:Number = 2, wrapPanAngle:Boolean = false, minDistance:Number = 0, maxDistance:Number = Infinity)
and i also created distance max/min setter and getter functions
it would be cool if you add this upgrade to new version
Note: this is not fully complete class, when i complete it all i will post it to github.