onKey is called when an OnKeyDown/OnKeyRepeat event is received.
(evname string, ev interface{})
| 279 | |
| 280 | // onKey is called when an OnKeyDown/OnKeyRepeat event is received. |
| 281 | func (oc *OrbitControl) onKey(evname string, ev interface{}) { |
| 282 | |
| 283 | // If keyboard control is disabled ignore event |
| 284 | if oc.enabled&OrbitKeys == 0 { |
| 285 | return |
| 286 | } |
| 287 | |
| 288 | kev := ev.(*window.KeyEvent) |
| 289 | if kev.Mods == 0 && oc.enabled&OrbitRot != 0 { |
| 290 | switch kev.Key { |
| 291 | case window.KeyUp: |
| 292 | oc.Rotate(0, -oc.KeyRotSpeed) |
| 293 | case window.KeyDown: |
| 294 | oc.Rotate(0, oc.KeyRotSpeed) |
| 295 | case window.KeyLeft: |
| 296 | oc.Rotate(-oc.KeyRotSpeed, 0) |
| 297 | case window.KeyRight: |
| 298 | oc.Rotate(oc.KeyRotSpeed, 0) |
| 299 | } |
| 300 | } |
| 301 | if kev.Mods == window.ModControl && oc.enabled&OrbitZoom != 0 { |
| 302 | switch kev.Key { |
| 303 | case window.KeyUp: |
| 304 | oc.Zoom(-oc.KeyZoomSpeed) |
| 305 | case window.KeyDown: |
| 306 | oc.Zoom(oc.KeyZoomSpeed) |
| 307 | } |
| 308 | } |
| 309 | if kev.Mods == window.ModShift && oc.enabled&OrbitPan != 0 { |
| 310 | switch kev.Key { |
| 311 | case window.KeyUp: |
| 312 | oc.Pan(0, oc.KeyPanSpeed) |
| 313 | case window.KeyDown: |
| 314 | oc.Pan(0, -oc.KeyPanSpeed) |
| 315 | case window.KeyLeft: |
| 316 | oc.Pan(oc.KeyPanSpeed, 0) |
| 317 | case window.KeyRight: |
| 318 | oc.Pan(-oc.KeyPanSpeed, 0) |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | // winSize returns the window height or width based on the camera reference axis. |
| 324 | func (oc *OrbitControl) winSize() float32 { |