Skip to content

fix viewer rotating on any mouse movement #48

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 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class AppController {
// desktop rotate
v.set(0, 0, 0);
const mouseRotate = new Vec3(mouse[0], mouse[1], 0);
v.add(mouseRotate.mulScalar((1 - this._mouse[2]) * this.orbitSpeed * dt));
v.add(mouseRotate.mulScalar(this._mouse[0] * (1 - this._mouse[2]) * this.orbitSpeed * dt));
Copy link
Preview

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix incorrectly multiplies by this._mouse[0] (X position) instead of checking mouse button state. This will scale rotation by the X coordinate rather than enabling/disabling it based on button press. Consider using a boolean mouse button state or the appropriate mouse button index.

Suggested change
v.add(mouseRotate.mulScalar(this._mouse[0] * (1 - this._mouse[2]) * this.orbitSpeed * dt));
if (this._mouseButtonPressed) { // Check if the mouse button is pressed
v.add(mouseRotate.mulScalar((1 - this._mouse[2]) * this.orbitSpeed * dt));
}

Copilot uses AI. Check for mistakes.

deltas.rotate.append([v.x, v.y, v.z]);

// mobile move
Expand Down