MCPcopy Index your code
hub / github.com/g3n/engine / Pan

Method Pan

camera/orbit_control.go:189–209  ·  view source on GitHub ↗

Pan pans the camera and target the specified amount on the plane perpendicular to the viewing direction.

(deltaX, deltaY float32)

Source from the content-addressed store, hash-verified

187
188// Pan pans the camera and target the specified amount on the plane perpendicular to the viewing direction.
189func (oc *OrbitControl) Pan(deltaX, deltaY float32) {
190
191 // Compute direction vector from camera to target
192 position := oc.cam.Position()
193 vdir := oc.target.Clone().Sub(&position)
194
195 // Conversion constant between an on-screen cursor delta and its projection on the target plane
196 c := 2 * vdir.Length() * math32.Tan((oc.cam.Fov()/2.0)*math32.Pi/180.0) / oc.winSize()
197
198 // Calculate pan components, scale by the converted offsets and combine them
199 var pan, panX, panY math32.Vector3
200 panX.CrossVectors(&oc.up, vdir).Normalize()
201 panY.CrossVectors(vdir, &panX).Normalize()
202 panY.MultiplyScalar(c * deltaY)
203 panX.MultiplyScalar(c * deltaX)
204 pan.AddVectors(&panX, &panY)
205
206 // Add pan offset to camera and target
207 oc.cam.SetPositionVec(position.Add(&pan))
208 oc.target.Add(&pan)
209}
210
211// onMouse is called when an OnMouseDown/OnMouseUp event is received.
212func (oc *OrbitControl) onMouse(evname string, ev interface{}) {

Callers 2

onCursorMethod · 0.95
onKeyMethod · 0.95

Calls 13

winSizeMethod · 0.95
CrossVectorsMethod · 0.95
MultiplyScalarMethod · 0.95
AddVectorsMethod · 0.95
TanFunction · 0.92
FovMethod · 0.80
SetPositionVecMethod · 0.80
PositionMethod · 0.65
CloneMethod · 0.65
SubMethod · 0.45
LengthMethod · 0.45
NormalizeMethod · 0.45

Tested by

no test coverage detected