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

I want to reset the camera's starting position and disable the left and right buttons #259

Open
smart4654154 opened this issue Aug 1, 2024 · 1 comment

Comments

@smart4654154
Copy link

At present, the default starting position of the camera is (3, 3, 3), and users can move it freely.
Now I want to set the default camera starting position at (a, b, c), and users can move it freely. Simultaneously I want to disable the left and right key functions of the keyboard(Stop rotation function). May I ask where to modify it? Thank you very much.

@brentyi
Copy link
Collaborator

brentyi commented Aug 3, 2024

Hello!

The initial camera pose is set here:

camera={{ position: [-3.0, 3.0, -3.0], near: 0.05 }}

You can also change it from Python via something like:

server = viser.ViserServer()

@server.on_client_connect
def _(client: viser.ClientHandle) -> None:
    client.camera.position = (1., 1., 1.)

For the left/right keys, the code is here:

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,
);
});

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

2 participants