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

Update cameraController.ts #40

Closed
wants to merge 1 commit into from

Conversation

DecDumplings
Copy link

Added Middle Mouse Button (MMB) and Scroll Wheel Controls for Camera Movement

Panning: Modified the pan method to use the middle mouse button (MMB) for panning the camera. Added event listeners to handle mouse down, mouse move, and mouse up events to track the MMB state and pan accordingly.
Rotating: Adjusted the rotate method to allow camera rotation using the MMB. In SketchUp, it requires holding Shift while pressing the MMB. In Blender, it only requires pressing the MMB. Event listeners were added to handle the rotation logic.
Zooming: Updated the zoom method to use the scroll wheel for zooming in and out. Added an event listener to detect the scroll wheel events and adjust the camera position based on the scroll direction.
Detailed Changes
Event Listeners:

Added event listeners for mousedown, mouseup, mousemove, and wheel events.
Implemented logic to handle panning, rotating, and zooming based on the middle mouse button and scroll wheel actions.
Panning Logic:

Modified the pan method to be triggered by the middle mouse button.
Calculated the panning direction and distance based on the mouse movement.
Rotating Logic:

Adjusted the rotate method to account for both SketchUp and Blender styles.
Added logic to start rotation when the middle mouse button is pressed with or without the Shift key.
Zooming Logic:

Updated the zoom method to respond to the scroll wheel events.
Adjusted the camera position and target based on the scroll direction.
Impact
These changes enhance the user experience by aligning the camera controls with familiar behaviors from popular 3D modeling software like SketchUp and Blender. Users can now pan, rotate, and zoom the camera more intuitively using the middle mouse button and scroll wheel.

@xiangechen
Copy link
Owner

This part of the logic has already been implemented in ThreeViewHandler, and CameraController only contains methods for controlling the camera. Additionally, there are errors in the code, so the PR was rejected. I apologize for this.

@xiangechen xiangechen closed this Jan 8, 2025
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.

2 participants