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

Fix morph crash. #379

Merged
merged 3 commits into from
Dec 13, 2012
Merged

Fix morph crash. #379

merged 3 commits into from
Dec 13, 2012

Conversation

bagnell
Copy link
Contributor

@bagnell bagnell commented Dec 12, 2012

Prevent an animation duration of 0ms. In Tween.js, the elapsed time is computed as (time - startTime) / duration and clamped at one. This is fine for the most common case where time > startTime which gets divided by zero to equal infinity and clamped to one. In the case where time == startTime (which explains why it was so hard to reproduce), the elapsed time will be NaN and cause a crash.

This fixes the original problem in #319.
#338 is unrelated.

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
@emackey
Copy link
Contributor

emackey commented Dec 13, 2012

Instead of partialDuration === 0 maybe we should put partialDuration < 1e-5 to handle rounding errors and negative numbers if they ever crop up.

@bagnell
Copy link
Contributor Author

bagnell commented Dec 13, 2012

@emackey Good idea. I changed the vector comparison to use an epsilon as well. Anything else?

@mramato
Copy link
Contributor

mramato commented Dec 13, 2012

I was going to nag you for tests, but it looks like there are 0 SceneTransitioner tests right now, so we'll let it slide ;)

Am I correct in that this has nothing to do with #377

@bagnell
Copy link
Contributor Author

bagnell commented Dec 13, 2012

You are correct. I know what the problem is for #377 and it is separate.

// If the camera and frustum are already in position for the switch to
// a perspective projection, nothing needs to be animated.
camera.position = endPos2D;
camera.frustum = frustumCV.clone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not frustumCV.clone(camera.frustum);? Which will re-use the existing instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camera.frustum is an OrthographicFrustum. frustumCV is a PerspectiveFrustum.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Merging.

mramato added a commit that referenced this pull request Dec 13, 2012
@mramato mramato merged commit 8470ccd into master Dec 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants