Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the dumbest possible fix for #4855, much hackier than @kring's abandoned fix, but hear me out.
Basically, the camera "target" is decided when the zoom begins, and is not recalculated every frame of the zoom (for UX reasons). As such it is possible to get the camera into a situation where it is zooming close to and then past a small entity, such as the Aircraft model in the 3D models sandcastle demo.
@duvifn deserves the credit for finding the spot where the problem begins. He isolates a place where a dot product flips over, this indicates that the camera has already zoomed past its own target in the previous frame of zoom, and is about to flip to the other side of the planet (due to Math.acos being applied to the flipped dot product).
When this "error condition" is detected, the camera is already just barely past its target, and a decision needs to be made: Other than flipping to the opposite side of the Earth, what can we do?
Math.abs
and pretend that the target is still in front of us? No, that leads to Earthquake Cam.This PR takes the last option above, so the camera halts one frame after passing the target, and waits for the user to start a new zoom action.