Skip to content

Conversation

@Mostafa-Khairy0
Copy link

Problem

OrbitControls crashes intermittently on touch devices during two-finger gestures.
The error occurs when one finger is lifted while the other remains, causing _getSecondPointerPosition() to return undefined and trigger:
TypeError: Cannot read properties of undefined (reading 'x')

Solution

  • Added null checks in _getSecondPointerPosition()
  • Updated all touch handlers (rotate, pan, dolly) to safely handle single-finger lift
  • Prevents crash when one finger is removed mid-gesture

Related Issue

Closes #32116

- Added null checks in _getSecondPointerPosition()
- Updated all touch handlers (rotate, pan, dolly) to handle single-finger lift
- Prevents TypeError when one finger is lifted during pinch-to-zoom
@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 28, 2025

The error occurs when one finger is lifted while the other remains, causing _getSecondPointerPosition() to return undefined and trigger:

There is actually a logic in place that should correct the state when a pointer is lifted. It has been added via #27445.

// minimal placeholder event - allows state correction on pointer-up
this._onTouchStart( { pointerId: pointerId, pageX: position.x, pageY: position.y } );

We have to find out why the existing logic does not work. The PR in its current state more of a bandage that does not fix the root cause in the controls.

@sciecode I'm not sure you have the bandwidth but could you help us here (see #32116)?

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 31, 2025

Closing. A potential issue needs to be fixed differently. Let's continue the discussion in #32116.

@Mugen87 Mugen87 closed this Oct 31, 2025
@Mugen87 Mugen87 added this to the r181 milestone Oct 31, 2025
@Mostafa-Khairy0 Mostafa-Khairy0 deleted the fix/orbitcontrols-touch-crash branch October 31, 2025 10:34
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.

OrbitControls: Touch event crash - "Cannot read properties of undefined (reading 'x')"

2 participants