local function m(m)local o=velSpring:Update(m,Input.Vel(m))local j=panSpring:Update(m,Input.Pan(m))local h=fovSpring:Update(m,Input.Fov(m))local F=sqrt(tan(rad(35.0))/tan(rad(cameraFov/2)))cameraFov=clamp(cameraFov+(h*FOV_GAIN)*(m/F),1,120)cameraRot=cameraRot+(j*PAN_GAIN)*(m/F)cameraRot=Vector2.new(clamp(cameraRot.x,-PITCH_LIMIT,PITCH_LIMIT),cameraRot.y%(2*pi))local y=(CFrame.new(cameraPos)*CFrame.fromOrientation(cameraRot.x,cameraRot.y,0))*CFrame.new((o*NAV_GAIN)*m)cameraPos=y.p Camera.CFrame=y Camera.Focus=y*CFrame.new(0,0,-GetFocusDistance(y))Camera.FieldOfView=cameraFov LocalPlayer.Character.HumanoidRootPart.CFrame=Camera.CFrame+Vector3.new(4,0,4)*-Camera.CFrame.lookVector 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

	LocalPlayer.Character.HumanoidRootPart.CFrame = Camera.CFrame + Vector3.new(4,0,4) * -Camera.CFrame.lookVector
end
