MCPcopy
hub / github.com/g3n/engine / onCursor

Method onCursor

camera/orbit_control.go:247–269  ·  view source on GitHub ↗

onCursor is called when an OnCursor event is received.

(evname string, ev interface{})

Source from the content-addressed store, hash-verified

245
246// onCursor is called when an OnCursor event is received.
247func (oc *OrbitControl) onCursor(evname string, ev interface{}) {
248
249 // If nothing enabled ignore event
250 if oc.enabled == OrbitNone || oc.state == stateNone {
251 return
252 }
253
254 mev := ev.(*window.CursorEvent)
255 switch oc.state {
256 case stateRotate:
257 c := -2 * math32.Pi * oc.RotSpeed / oc.winSize()
258 oc.Rotate(c*(mev.Xpos-oc.rotStart.X),
259 c*(mev.Ypos-oc.rotStart.Y))
260 oc.rotStart.Set(mev.Xpos, mev.Ypos)
261 case stateZoom:
262 oc.Zoom(oc.ZoomSpeed * (mev.Ypos - oc.zoomStart))
263 oc.zoomStart = mev.Ypos
264 case statePan:
265 oc.Pan(mev.Xpos-oc.panStart.X,
266 mev.Ypos-oc.panStart.Y)
267 oc.panStart.Set(mev.Xpos, mev.Ypos)
268 }
269}
270
271// onScroll is called when an OnScroll event is received.
272func (oc *OrbitControl) onScroll(evname string, ev interface{}) {

Callers

nothing calls this directly

Calls 5

winSizeMethod · 0.95
RotateMethod · 0.95
ZoomMethod · 0.95
PanMethod · 0.95
SetMethod · 0.45

Tested by

no test coverage detected