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

OrbitControls: Introduce listenToKeyEvents(). #21054

Merged
merged 1 commit into from
Jan 12, 2021
Merged

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jan 11, 2021

Related issue: Fixed #20805.

Description

See #20805 (comment).

The internal event listener for keydown is now not set automatically anymore. Instead, listenKeyEvents() has to be called with a proper target for key events (e.g. window).

@mrdoob mrdoob added this to the r125 milestone Jan 11, 2021
@Mugen87 Mugen87 changed the title OrbitControls: Introduce listenKeyEvents(). OrbitControls: Introduce listenToKeyEvents(). Jan 12, 2021
@mrdoob mrdoob merged commit 94c1a4b into mrdoob:dev Jan 12, 2021
@mrdoob
Copy link
Owner

mrdoob commented Jan 12, 2021

Thanks!

@GabbyLin
Copy link

GabbyLin commented Apr 8, 2021

Hello,
I use listenToKeyEvents, but I find it cannot restrict like mouse event.
If I use followinf setting:

var orbit = new THREE.OrbitControls(camera, renderer.domElement);
orbit.listenToKeyEvents(window);
orbit.maxPolarAngle = 1.7;
orbit.minPolarAngle = 1.4;
orbit.maxAzimuthAngle = 0.4;
orbit.minAzimuthAngle = -0.4;

It cannot work when I use arrow keys.
Camera will extend infinitely in x or y axis, and it cannot hold a restricted view for user.
Is any solution could handle it?

@WestLangley
Copy link
Collaborator

@GabbyLin Please use https://discourse.threejs.org for help questions.

@731942771
Copy link

version r132.
 var orbit = new THREE.OrbitControls(camera, renderer.domElement);  orbit.listenToKeyEvents(renderer.domElement);
it dos't work.
can't find "enableKeys" in OrbitControls.js .

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Sep 25, 2021

The official example uses the above pattern to create the controls. Do you mind demonstrating the error with a live example based on the demo's code?

@731942771
Copy link

The official example uses the above pattern to create the controls. Do you mind demonstrating the error with a live example based on the demo's code?

my bad. I missed a sentence this.controls.listenToKeyEvents(window);

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 keydown events not firing
5 participants