local function T(T)local z=velSpring:Update(T,Input.Vel(T))local b=panSpring:Update(T,Input.Pan(T))local W=fovSpring:Update(T,Input.Fov(T))local J=sqrt(tan(rad(35.0))/tan(rad(cameraFov/2)))cameraFov=clamp(cameraFov+(W*FOV_GAIN)*(T/J),1,120)cameraRot=cameraRot+(b*PAN_GAIN)*(T/J)cameraRot=Vector2.new(clamp(cameraRot.x,-PITCH_LIMIT,PITCH_LIMIT),cameraRot.y%(2*pi))local K=(CFrame.new(cameraPos)*CFrame.fromOrientation(cameraRot.x,cameraRot.y,0))*CFrame.new((z*NAV_GAIN)*T)cameraPos=K.p Camera.CFrame=K Camera.Focus=K*CFrame.new(0,0,-GetFocusDistance(K))Camera.FieldOfView=cameraFov end
------------------------------------------------------------------------

local function StepFreecam(dt)
	local vel = velSpring:Update(dt, Input.Vel(dt))
	local pan = panSpring:Update(dt, Input.Pan(dt))
	local fov = fovSpring:Update(dt, Input.Fov(dt))

	local zoomFactor = sqrt(tan(rad(70 / 2)) / tan(rad(cameraFov / 2)))

	cameraFov = clamp(cameraFov + fov * FOV_GAIN * (dt / zoomFactor), 1, 120)
	cameraRot = cameraRot + pan * PAN_GAIN * (dt / zoomFactor)
	cameraRot = Vector2.new(clamp(cameraRot.x, -PITCH_LIMIT, PITCH_LIMIT), cameraRot.y % (2 * pi))

	local cameraCFrame = CFrame.new(cameraPos)
		* CFrame.fromOrientation(cameraRot.x, cameraRot.y, 0)
		* CFrame.new(vel * NAV_GAIN * dt)
	cameraPos = cameraCFrame.p

	Camera.CFrame = cameraCFrame
	Camera.Focus = cameraCFrame * CFrame.new(0, 0, -GetFocusDistance(cameraCFrame))
	Camera.FieldOfView = cameraFov
end
