fix(OrbitControls): guard against undefined second pointer position#432
Open
adamistheanswer wants to merge 1 commit into
Open
fix(OrbitControls): guard against undefined second pointer position#432adamistheanswer wants to merge 1 commit into
adamistheanswer wants to merge 1 commit into
Conversation
getSecondPointerPosition() can return undefined when the internal pointerPositions map lacks an entry for the second pointer. This occurs when a pointerup event is lost during tab suspension/resume, leaving stale entries in the pointers array that no longer have matching tracked positions. Without this guard, callers crash with: TypeError: Cannot read properties of undefined (reading 'x') Add early returns in handleTouchMoveRotate, handleTouchMovePan, and handleTouchMoveDolly to skip the frame rather than crash. Fixes pmndrs#426 Related mrdoob/three.js#32116
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
getSecondPointerPosition()can returnundefinedwhen the internalpointerPositionsmap lacks an entry for the second pointer. This occurs when apointerupevent is lost during tab suspension/resume, leaving stale entries in thepointersarray that no longer have matching tracked positions.Without this guard, callers crash with:
This adds early returns in
handleTouchMoveRotate,handleTouchMovePan, andhandleTouchMoveDollyto skip the frame rather than crash.Reproduction
pointerupduring suspension leaves stale entries in the internalpointers[]array, causinggetSecondPointerPosition()to look up a pointer ID that was never tracked inpointerPositionsFix
Minimal null guard — if the second pointer's position hasn't been tracked, skip the touch-move frame rather than crashing. The next pointer interaction will re-establish clean state.
Fixes #426
Related mrdoob/three.js#32116