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

Function NewOrbitControl

camera/orbit_control.go:69–99  ·  view source on GitHub ↗

NewOrbitControl creates and returns a pointer to a new orbit control for the specified camera.

(cam *Camera)

Source from the content-addressed store, hash-verified

67
68// NewOrbitControl creates and returns a pointer to a new orbit control for the specified camera.
69func NewOrbitControl(cam *Camera) *OrbitControl {
70
71 oc := new(OrbitControl)
72 oc.Dispatcher.Initialize()
73 oc.cam = cam
74 oc.target = *math32.NewVec3()
75 oc.up = *math32.NewVector3(0, 1, 0)
76 oc.enabled = OrbitAll
77
78 oc.MinDistance = 1.0
79 oc.MaxDistance = float32(math.Inf(1))
80 oc.MinPolarAngle = 0
81 oc.MaxPolarAngle = math32.Pi // 180 degrees as radians
82 oc.MinAzimuthAngle = float32(math.Inf(-1))
83 oc.MaxAzimuthAngle = float32(math.Inf(1))
84 oc.RotSpeed = 1.0
85 oc.ZoomSpeed = 0.1
86 oc.KeyRotSpeed = 15 * math32.Pi / 180 // 15 degrees as radians
87 oc.KeyZoomSpeed = 2.0
88 oc.KeyPanSpeed = 35.0
89
90 // Subscribe to events
91 gui.Manager().SubscribeID(window.OnMouseUp, &oc, oc.onMouse)
92 gui.Manager().SubscribeID(window.OnMouseDown, &oc, oc.onMouse)
93 gui.Manager().SubscribeID(window.OnScroll, &oc, oc.onScroll)
94 gui.Manager().SubscribeID(window.OnKeyDown, &oc, oc.onKey)
95 gui.Manager().SubscribeID(window.OnKeyRepeat, &oc, oc.onKey)
96 oc.SubscribeID(window.OnCursor, &oc, oc.onCursor)
97
98 return oc
99}
100
101// Dispose unsubscribes from all events.
102func (oc *OrbitControl) Dispose() {

Callers

nothing calls this directly

Calls 5

NewVec3Function · 0.92
NewVector3Function · 0.92
ManagerFunction · 0.92
SubscribeIDMethod · 0.65
InitializeMethod · 0.45

Tested by

no test coverage detected