Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual: Fix OrbitControls usage in Offscreen Canvas demo. #29983

Merged
merged 2 commits into from
Jan 2, 2025

Conversation

Arecsu
Copy link
Contributor

@Arecsu Arecsu commented Nov 27, 2024

  • Picking doesn't work properly (sometimes at all) in touchscreens due to the lack of clientX and clientY values in the proxy event. Added those.

  • Added a event.preventDefault() in touchEventHandler() because, for some unknown reason, mouse events get fired in touchscreens when doing a simple tap. Happens only at Offscreen Canvas. Tested on Chrome for Android and Firefox for Android. Same behavior both. Might be intended per specification? This is the best fix I found to handle it.

  • 2 or more fingers don't get fully handled in OrbitControls, resulting in a black screen when trying to pinch-to-zoom, among other scenarios. It expects a pointerId with our custom Pointer Event proxy. To be specific, it gets called here:

_getSecondPointerPosition( event ) {
const pointerId = ( event.pointerId === this._pointers[ 0 ] ) ? this._pointers[ 1 ] : this._pointers[ 0 ];
return this._pointerPositions[ pointerId ];
}

Fixed that as well :)

Also, wanted to express how good it is to have a fully working example of Offscreen Canvas + OrbitControls. I've learned so much about workers and code structuring with it. Offscreen Canvas are desperately needed in a website I maintain to keep a javascript horizontal slider to move smoothly while loading and presenting a 3D object. Without this example, I don't think I would have been able to do it.

Thank you so much!

@mrdoob mrdoob added this to the r172 milestone Dec 12, 2024
@mrdoob mrdoob modified the milestones: r172, r173 Dec 31, 2024
@Mugen87 Mugen87 merged commit 575cc3a into mrdoob:dev Jan 2, 2025
11 checks passed
@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 2, 2025

Your PR indeed fixes the issue! Sorry for the delay.

@Mugen87 Mugen87 changed the title docs: Offscreen Canvas fix touch pick and 2 fingers interactions Manual: Offscreen Canvas fix touch pick and 2 fingers interactions: Jan 2, 2025
@Mugen87 Mugen87 changed the title Manual: Offscreen Canvas fix touch pick and 2 fingers interactions: Manual: Fix OrbitControls usage in Offscreen Canvas demo. Jan 2, 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