pmndrs / pmndrs/three-stdlib

TypeError when interacting with OrbitControls with touch and mouse

Open
#411 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
858
Forks
144
PR merge metrics
No merged PRs in 30d

Description

  • three version: v174
  • Chrome, Windows
Problem description:

This is triggered:

OrbitControls.js:932 Uncaught TypeError: Cannot read properties of undefined (reading 'x')
    at OrbitControls._handleTouchStartDolly (OrbitControls.js:932:37)
    at OrbitControls._handleTouchStartDollyPan (OrbitControls.js:943:31)
    at OrbitControls.onTouchStart (OrbitControls.js:1428:11)
    at OrbitControls.onPointerDown (OrbitControls.js:1172:8)
Suggested solution:

OrbitControls seems to maintain pointers array using onPointerDown and other pointer events, but maintains pointerPositions using only touch events. Not all pointer events are touch events, so those two arrays are not in sync, and that is why getSecondPointerPosition returns undefined.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in the linked misc_controls_orbit.html example using a touchscreen PC and mouse. Then inspect OrbitControls.js around onPointerDown, onTouchStart, _handleTouchStartDolly and getSecondPointerPosition, focusing on how pointers and pointerPositions are updated. Done means the mixed mouse-and-touch interaction no longer raises the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, three.js
Domain
computer-graphics, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.