Skip to content

fix(RWInteractor): async requestPointerLock #3205

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ function vtkMouseCameraTrackballFirstPersonManipulator(publicAPI, model) {

if (model.usePointerLock && !interactor.isPointerLocked()) {
Object.assign(internal, { interactor, renderer });
interactor.requestPointerLock();
publicAPI.startPointerLockInteraction();
Promise.resolve(interactor.requestPointerLock()).then(() => {
publicAPI.startPointerLockInteraction();
});
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@ function vtkMouseRangeManipulator(publicAPI, model) {
// we don't interfere with other events such as doubleClick,
// for this reason we don't call this from `onButtonDown`
if (model.usePointerLock && !interactor.isPointerLocked()) {
interactor.requestPointerLock();
publicAPI.startPointerLockEvent(interactor, renderer);
Promise.resolve(interactor.requestPointerLock()).then(() => {
publicAPI.startPointerLockEvent(interactor, renderer);
});
}

if (!position) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Rendering/Core/RenderWindowInteractor/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ export interface vtkRenderWindowInteractor extends vtkObject {
/**
*
*/
requestPointerLock(): void;
requestPointerLock(): Promise<void> | undefined;

/**
*
Expand Down
3 changes: 2 additions & 1 deletion Sources/Rendering/Core/RenderWindowInteractor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,9 @@ function vtkRenderWindowInteractor(publicAPI, model) {
//----------------------------------------------------------------------
publicAPI.requestPointerLock = () => {
if (model.container) {
model.container.requestPointerLock();
return model.container.requestPointerLock();
}
return undefined;
};

//----------------------------------------------------------------------
Expand Down