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

More control keys? #268

Open
LaFeuilleMorte opened this issue Aug 16, 2024 · 2 comments
Open

More control keys? #268

LaFeuilleMorte opened this issue Aug 16, 2024 · 2 comments

Comments

@LaFeuilleMorte
Copy link

I write a small client followed overwrite this method:
def viewer_render_fn(camera_state: nerfview.CameraState, img_wh: Tuple[int, int]):
....
However I can only use WASDQE to move along x,y,z axis, and up down lef right arrow key to rotate along x and z axis. But there's no key for to control camera rotate along Y axis (Yaw angle). By the way, will the viser support more controlling methods like in an FPS game?

@brentyi
Copy link
Collaborator

brentyi commented Aug 16, 2024

Hi, thanks for the issue!

Yeah, this is on our radar. We'd like to improve the camera controls, but it might take some time. @mehdikhfifi has been looking into it and might be able to comment.

If you'd like to maintain a fork in the meantime with your preferred camera controls, here's where the keys are bound:

const wKey = new holdEvent.KeyboardKeyHold("KeyW", 20);
const aKey = new holdEvent.KeyboardKeyHold("KeyA", 20);
const sKey = new holdEvent.KeyboardKeyHold("KeyS", 20);
const dKey = new holdEvent.KeyboardKeyHold("KeyD", 20);
const qKey = new holdEvent.KeyboardKeyHold("KeyQ", 20);
const eKey = new holdEvent.KeyboardKeyHold("KeyE", 20);
// TODO: these event listeners are currently never removed, even if this
// component gets unmounted.
aKey.addEventListener("holding", (event) => {
cameraControls.truck(-0.002 * event?.deltaTime, 0, true);
});
dKey.addEventListener("holding", (event) => {
cameraControls.truck(0.002 * event?.deltaTime, 0, true);
});
wKey.addEventListener("holding", (event) => {
cameraControls.forward(0.002 * event?.deltaTime, true);
});
sKey.addEventListener("holding", (event) => {
cameraControls.forward(-0.002 * event?.deltaTime, true);
});
qKey.addEventListener("holding", (event) => {
cameraControls.elevate(-0.002 * event?.deltaTime, true);
});
eKey.addEventListener("holding", (event) => {
cameraControls.elevate(0.002 * event?.deltaTime, true);
});
const leftKey = new holdEvent.KeyboardKeyHold("ArrowLeft", 20);
const rightKey = new holdEvent.KeyboardKeyHold("ArrowRight", 20);
const upKey = new holdEvent.KeyboardKeyHold("ArrowUp", 20);
const downKey = new holdEvent.KeyboardKeyHold("ArrowDown", 20);
leftKey.addEventListener("holding", (event) => {
cameraControls.rotate(
-0.05 * THREE.MathUtils.DEG2RAD * event?.deltaTime,
0,
true,
);
});
rightKey.addEventListener("holding", (event) => {
cameraControls.rotate(
0.05 * THREE.MathUtils.DEG2RAD * event?.deltaTime,
0,
true,
);
});
upKey.addEventListener("holding", (event) => {
cameraControls.rotate(
0,
-0.05 * THREE.MathUtils.DEG2RAD * event?.deltaTime,
true,
);
});
downKey.addEventListener("holding", (event) => {
cameraControls.rotate(
0,
0.05 * THREE.MathUtils.DEG2RAD * event?.deltaTime,
true,
);
});

@mehdikhfifi
Copy link
Collaborator

mehdikhfifi commented Aug 27, 2024

I write a small client followed overwrite this method: def viewer_render_fn(camera_state: nerfview.CameraState, img_wh: Tuple[int, int]): .... However I can only use WASDQE to move along x,y,z axis, and up down lef right arrow key to rotate along x and z axis. But there's no key for to control camera rotate along Y axis (Yaw angle). By the way, will the viser support more controlling methods like in an FPS game?

I've recently just finished implementing FPS camera controls. Pull from #274 and you should be able to press p(lowercase) and you should be able to switch between orbit controls and first person controls. Let me know if there are any issues.

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

No branches or pull requests

3 participants