Excellent work.

I thought it was simpler to do this near line 156 of HoverCamera3D.as:

/*
if ((x == gx) && (y == gy) && (z == gz))
      return false;
*/
if ( Math.abs( x - gx ) < 0.1 && Math.abs( y - gy ) < 0.1 &&
Math.abs( z - gz ) < 0.1 )
      return false;

Thanks,

Joe


On Jan 9, 5:08 am, nlorut <[email protected]> wrote:
> Weird right?
> Here is a temporary fix, using angle and position tresholds :
>
> public functionhover(jumpTo:Boolean =false):Boolean
> {
>
>         var angleTreshold:Number = 0.1;
>         var positionTreshold:Number = 0.1;
>
>         var camUpdated =false;
>
>         if (tiltAngle != _currentTiltAngle || panAngle != _currentPanAngle) {
>
>                 tiltAngle = Math.max(minTiltAngle, Math.min(maxTiltAngle,
> tiltAngle));
>
>                 panAngle = Math.max(minPanAngle, Math.min(maxPanAngle, 
> panAngle));
>
>                 if (wrapPanAngle) {
>                         if (panAngle < 0)
>                                 panAngle = (panAngle % 360) + 360;
>                         else
>                                 panAngle = panAngle % 360;
>
>                         if (panAngle - _currentPanAngle < -180)
>                                 panAngle += 360;
>                         else if (panAngle - _currentPanAngle > 180)
>                                 panAngle -= 360;
>                 }
>
>                 if (jumpTo) {
>                         _currentTiltAngle = tiltAngle;
>                         _currentPanAngle = panAngle;
>                 } else {
>                         _currentTiltAngle += (tiltAngle - 
> _currentTiltAngle)/(steps + 1);
>                         _currentPanAngle += (panAngle - 
> _currentPanAngle)/(steps + 1);
>                 }
>
>                 //snap coords if angle differences are close
>                 if ((Math.abs(tiltAngle - _currentTiltAngle) < angleTreshold) 
> &&
> (Math.abs(panAngle - _currentPanAngle) < angleTreshold)) {
>                         _currentTiltAngle = tiltAngle;
>                         _currentPanAngle = panAngle;
>                 }
>
>                 camUpdated = true;
>         }
>
>         var gx:Number = target.x +
> distance*Math.sin(_currentPanAngle*toRADIANS)*Math.cos(_currentTiltAngle*to 
> RADIANS);
>         var gz:Number = target.z +
> distance*Math.cos(_currentPanAngle*toRADIANS)*Math.cos(_currentTiltAngle*to 
> RADIANS);
>         var gy:Number = target.y +
> distance*Math.sin(_currentTiltAngle*toRADIANS)*yfactor;
>
>         if ((Math.abs(x - gx) >= positionTreshold) || (Math.abs(y - gy) >=
> positionTreshold) || (Math.abs(z - gz) >= positionTreshold)) {
>                 x = gx;
>                 y = gy;
>                 z = gz;
>                 camUpdated = true;
>         }
>
>         return camUpdated;
>
> }
>
> Not perfect but hey it works.
> Waiting for an opinion... thanks.
>
> Nicolas
>
> On 7 jan, 20:23, nlorut <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi,
> > Congrats for your amazing work.
> > I have recently updated the trunk, and it seems HoverCamera3D.hover()
> > doesn't return 'false' anymore.
> > In order to figure this out, here are a few test lines i wrote in
> > HoverCamera3D.as :
>
> > "[...]
> > var gx:Number = target.x +
> > distance*Math.sin(_currentPanAngle*toRADIANS)*Math.cos(_currentTiltAngle*to 
> > RADIANS);
> > var gz:Number = target.z +
> > distance*Math.cos(_currentPanAngle*toRADIANS)*Math.cos(_currentTiltAngle*to 
> > RADIANS);
> > var gy:Number = target.y +
> > distance*Math.sin(_currentTiltAngle*toRADIANS)*yfactor;
>
> > //test//  trace ("x (" + x + ") == gx (" + gx + ") ?");
> > //test//  trace ("y (" + y + ") == gy (" + gy + ") ?");
> > //test//  trace ("z (" + z + ") == gz (" + gz + ") ?");
>
> > if ((x == gx) && (y == gy) && (z == gz))
> >         returnfalse;
>
> > x = gx;
> > y = gy;
> > z = gz;
>
> > //test//  trace ("x final = " + x);
> > //test//  trace ("y final = " + y);
> > //test//  trace ("z final = " + z);
>
> > return true;
> > [...]"
>
> > And here is what i get in the output, as the camera is no longer
> > updated :
>
> > "[...]
> > x (7852.2958984375) == gx (7852.296056215698) ?
> > y (6446.26171875) == gy (6446.2618632336935) ?
> > z (9358.001953125) == gz (9358.002035108404) ?
> > x final = 7852.2958984375
> > y final = 6446.26171875
> > z final = 9358.001953125
> > camHasMoved ? true
> > x (7852.2958984375) == gx (7852.296056215698) ?
> > y (6446.26171875) == gy (6446.2618632336935) ?
> > z (9358.001953125) == gz (9358.002035108404) ?
> > x final = 7852.2958984375
> > y final = 6446.26171875
> > z final = 9358.001953125
> > camHasMoved ? true
> > ..."
>
> > It seems there is a decimal precision problem between gx/gy/gz Numbers
> > (12) and x/y/z cam properties (10).
>
> > What do you think?
> > Thanks in advance for your help.
> > Nicolas

Reply via email to