Skip to content

Conversation

@sunlin0oo
Copy link

@sunlin0oo sunlin0oo commented Apr 19, 2025

Description
Problem:
When the developer tools are opened, the rotation of TrackballControls becomes very sticky.
Slove:
When the developer tools are opened, the browser increases the frequency of event triggers.
To solve this problem, a throttle function is added to reduce the number of times the move event is triggered, maintaining the same frequency as when the developer tools are not open.
Video:
https://github.com/user-attachments/assets/92047286-ce6d-402e-882c-a51e57208880

@sunlin0oo sunlin0oo closed this Apr 19, 2025
@sunlin0oo sunlin0oo reopened this Apr 19, 2025
// event listeners

this._onPointerMove = onPointerMove.bind( this );
this._onPointerMove = throttle(onPointerMove.bind( this ),16);
Copy link
Owner

Choose a reason for hiding this comment

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

Why 16?

Copy link
Author

Choose a reason for hiding this comment

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

Because most devices have a 60Hz refresh rate, the browser has to complete rendering work for each frame within 16ms.

Copy link
Owner

Choose a reason for hiding this comment

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

What about devices with 120Hz, or 240Hz, or 30Hz, ...?

Copy link
Author

Choose a reason for hiding this comment

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

I’ve thought about this before. I tested it by switching from a 60Hz screen to a 144Hz one (test video is 144Hz), and no lag occurred. But I don’t have devices with refresh rates below 60Hz for testing. I’ll try to find a way to get the screen resolution.
Video:
https://github.com/user-attachments/assets/92047286-ce6d-402e-882c-a51e57208880

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 23, 2025

If the controls are only affected when the developer tools are open, and I don't think it's necessary to apply a patch, tbh.

@mrdoob
Copy link
Owner

mrdoob commented Apr 23, 2025

Agreed. The issue should be reported the DevTools instead...

@mrdoob mrdoob closed this Apr 23, 2025
@Mugen87 Mugen87 added this to the r176 milestone Apr 23, 2025
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.

3 participants