Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tween.end occasionally does not finish a tween #283

Closed
mikebolt opened this issue Aug 11, 2016 · 4 comments
Closed

Tween.end occasionally does not finish a tween #283

mikebolt opened this issue Aug 11, 2016 · 4 comments
Assignees

Comments

@mikebolt
Copy link
Contributor

Tween.end() has an issue caused by floating point inaccuracy errors. The problem is that (_startTime + _duration - _startTime) / _duration is occasionally slightly more than and occasionally slightly less than 1. In the case that it is less than 1, it will not properly complete the tween and call the onComplete callback.

When run in browsers, the two test cases that test Tween.end fail at random.

I think a good fix would be to not use Tween.update in Tween.end, but instead just set the end values and call onComplete manually.

@mikebolt mikebolt changed the title Tween.end does occasionally does not finish a tween Tween.end occasionally does not finish a tween Aug 11, 2016
@dalisoft
Copy link
Collaborator

dalisoft commented Aug 16, 2016

maybe i wrong, but i have some idea.

this.end = function () {
_startTime = TWEEN.now() + _duration + _delay;
return this.update(_startTime);
}

Check the code, then let me know works or not. I can't check, because i'm temporarily not in code-made state. Sorry :(

UPDATE: When we not use update method, calculation of tweens will not be, and users may get wrong values, we need Force calculate (exactly with fake update call) to get end value then finish as default (legal way)

Thanks,
@dalisoft

@sole
Copy link
Member

sole commented Oct 3, 2016

@mikebolt or we should use an epsilon comparison instead: if the difference is less than a small value epsilon, the comparison is true.

Do you have test cases for this? ta!

@mikebolt mikebolt self-assigned this Jun 15, 2017
@yarivdev
Copy link

yarivdev commented Nov 8, 2017

Bumping..
Great piece of software btw, thanks!

@mikebolt
Copy link
Contributor Author

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants