-
Notifications
You must be signed in to change notification settings - Fork 197
HARP-13852 Increase precision, otherwise tilt is too inaccurate #2062
Conversation
nzjony
commented
Jan 19, 2021
•
edited
Loading
edited
- Improve the epsilon used when comparing the dot product.
- When the tilt animation has finished, a final check is done to see if the targeted tilt is reached, and if not, we apply the delta needed to reach the desired tilt.
Codecov Report
@@ Coverage Diff @@
## master #2062 +/- ##
=======================================
Coverage 66.63% 66.63%
=======================================
Files 297 297
Lines 26338 26341 +3
Branches 5951 5952 +1
=======================================
+ Hits 17550 17552 +2
- Misses 8788 8789 +1
Continue to review full report at Codecov.
|
d25868c
to
dcf7298
Compare
// There may be some numerical inaccuracies in the application of the | ||
// `deltaAngle` during the animation, hence we check one last time to see if we | ||
// need to fix the tilt | ||
const mapViewTiltRad = THREE.MathUtils.degToRad(this.mapView.tilt); | ||
const deltaAngle = (this.m_targetedTilt ?? mapViewTiltRad) - mapViewTiltRad; | ||
if (deltaAngle !== 0) { | ||
MapViewUtils.orbitAroundScreenPoint( | ||
this.mapView, | ||
0, | ||
0, | ||
0, | ||
deltaAngle, | ||
this.m_maxTiltAngle | ||
); | ||
this.updateMapView(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the call to this.stopTilt() is done to soon. It sets:
this.m_targetedTilt = this.m_currentTilt = undefined;
Then later we pass to easeOutCubic() as target value this.targetedTilt, which returns the current mapView.tilt if this.m_targetedTilt is undefined.
If the stopTilt() call is done after easOutCubic, together with your epsilon changes, it works fine for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @atomicsulfate. I have pushed a fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. It'd be even better if we add a unit test to check we actually reach 0 tilt.
@atomicsulfate , I agree, I will put the test in a separate PR, so we can at least get this into the release. |
retest this please |
- Improve the epsilon used when comparing the dot product. - When the tilt animation has finished, a final check is done to see if the targeted tilt is reached, and if not, we apply the delta needed to reach the desired tilt. Signed-off-by: Jonathan Stichbury <[email protected]>