model-viewer
model-viewer copied to clipboard
Code changes re. Keyboard controls #3484
Description
This relates to discussion Keyboard controls #3484 In working this though there are some code changes in SmoothControl.ts that you can have if you want them. These extend the keyboard controls from orbit changes to orbit, pan, step size & preset views and also remove the null hit behavior. The removal of null hit behavior should really be conditional on an exposed state, but I didn't know how to do that. They are contained entirely within SmoothControls.ts.
Keyboard controls are: Arrows - orbit Shift + Arrows - pan Ctrl + Arrows - orbit at small step (ratio from unmodified set as a const, but could ideally be passed in) Ctrl + Shift + Arrows - pan at small steps
Pressing Shift displays the same spot cursor as used on mouse-pan. Shift now behaves as a defacto 'about to pan' indicator. It also accidentally solved a user comment that they didn't really know where it was orbiting around.
Keys 1, 2, 3, 4 (and Numpad 1, 2, 3, 4) set theta to 0, 90, 180, 270 degrees at current phi and radius Keys 7, 8, 9 (and Numpad 7, 8, 9) set phi to +45, 0 and -45 degrees at current theta and radius This gives the ability to 'square up' a view which works in conjunction with the orbit keys.
Only experimental testing has been done. No automated test.
Live Demo
Video clips in Keyboard controls #3484
Version
- model-viewer: v1.12.0
Browser Affected
- [ 1 ] Chrome, version: xx.x.xxxx.xx
- [ 1] Edge
- [ 1] Firefox
- [ 0] IE
- [ 0] Safari
OS
- [ 0] Android
- [ 0] iOS
- [ 0] Linux
- [ 0] MacOS
- [ 1] Windows
AR
- [ ] WebXR
- [ ] SceneViewer
- [ ] QuickLook
Please open a PR so I can review these changes; it sounds like this could be quite useful. Thanks!
No problem, but I've fallen at the first hurdle - I don't know what I'm doing! If PR is pull request then what do I choose for base & compare? If there is a noob PR raising 101 then send me that way. In the words of an unnamed poet there are non so blind as those that have read the documentation a thousand times.
This is a good place to get started: https://docs.github.com/en/get-started/quickstart/github-flow
Once you have a fork, make a branch, make changes, and push it, when you come to our Pull Requests tab, Github will have a green button like "do you want to make a PR for the branch you just pushed"? Their default behavior should work just fine.
Thank you. I've done what I think is the right thing. If so then this one is closed.