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

Method Zoom

camera/orbit_control.go:172–186  ·  view source on GitHub ↗

Zoom moves the camera closer or farther from the target the specified amount and also updates the camera's orthographic size to match.

(delta float32)

Source from the content-addressed store, hash-verified

170// Zoom moves the camera closer or farther from the target the specified amount
171// and also updates the camera's orthographic size to match.
172func (oc *OrbitControl) Zoom(delta float32) {
173
174 // Compute direction vector from target to camera
175 tcam := oc.cam.Position()
176 tcam.Sub(&oc.target)
177
178 // Calculate new distance from target and apply limits
179 dist := tcam.Length() * (1 + delta/10)
180 dist = math32.Max(oc.MinDistance, math32.Min(oc.MaxDistance, dist))
181 tcam.SetLength(dist)
182
183 // Update orthographic size and camera position with new distance
184 oc.cam.UpdateSize(tcam.Length())
185 oc.cam.SetPositionVec(oc.target.Clone().Add(&tcam))
186}
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) {

Callers 3

onCursorMethod · 0.95
onScrollMethod · 0.95
onKeyMethod · 0.95

Calls 10

MaxFunction · 0.92
MinFunction · 0.92
UpdateSizeMethod · 0.80
SetPositionVecMethod · 0.80
PositionMethod · 0.65
CloneMethod · 0.65
SubMethod · 0.45
LengthMethod · 0.45
SetLengthMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected