function ClassicCamera.SetCameraMovementMode(a,l)BaseCamera.SetCameraMovementMode(a,l)a.isFollowCamera=l==Enum.ComputerCameraMovementMode.Follow end function ClassicCamera.Test(l)print("\067\108\097\115\115\105\099\067\097\109\101\114\097\058\084\101\115\116\040\041")end function ClassicCamera.Update(l)local a=tick()local d=a-l.lastUpdate local u=workspace.CurrentCamera local n=u.CFrame local K=u.Focus local X=nil if l.resetCameraAngle then local a=l:GetHumanoidRootPart()if a then X=(a.CFrame*INITIAL_CAMERA_ANGLE).lookVector else X=INITIAL_CAMERA_ANGLE.lookVector end l.resetCameraAngle=false end local U=PlayersService.LocalPlayer local E=l:GetHumanoid()local I=u.CameraSubject local W=I and I:IsA("\086\101\104\105\099\108\101\083\101\097\116")local w=I and I:IsA("\083\107\097\116\101\098\111\097\114\100\080\108\097\116\102\111\114\109")local y=E and E:GetState()==Enum.HumanoidStateType.Climbing if l.lastUpdate==nil or d>1 then l.lastCameraTransform=nil end if l.lastUpdate then local a=l:UpdateGamepad()if l:ShouldUseVRRotation()then l.rotateInput=l.rotateInput+l:GetVRRotationInput()else local u=math.min(.1,d)if a~=ZERO_VECTOR2 then l.rotateInput=l.rotateInput+a*u end local n=0 if not(W or w)then n=n+(l.turningLeft and-120 or 0)n=n+(l.turningRight and 120 or 0)end if n~=0 then l.rotateInput=l.rotateInput+Vector2.new(math.rad(n*u),0)end end end if l.userPanningTheCamera then tweenSpeed=0 l.lastUserPanCamera=tick()end local G=a-l.lastUserPanCamera<TIME_BEFORE_AUTO_ROTATE local L=l:GetSubjectPosition()if L and(U and u)then local a=l:GetCameraToSubjectDistance()if a<.5 then a=.5 end if l:GetIsMouseLocked()and not l:IsInFirstPerson()then local a=l:CalculateNewLookCFrame(X)local d=l:GetMouseLockOffset()local u=(d.X*a.rightVector+d.Y*a.upVector)+d.Z*a.lookVector if Util.IsFiniteVector3(u)then L=L+u end else if not l.userPanningTheCamera and l.lastCameraTransform then local a=l:IsInFirstPerson()if(W or w or l.isFollowCamera and y)and(l.lastUpdate and(E and E.Torso))then if a then if l.lastSubjectCFrame and((W or w)and I:IsA("\066\097\115\101\080\097\114\116"))then local a=-Util.GetAngleBetweenXZVectors(l.lastSubjectCFrame.lookVector,I.CFrame.lookVector)if Util.IsFinite(a)then l.rotateInput=l.rotateInput+Vector2.new(a,0)end tweenSpeed=0 end elseif not G then local a=E.Torso.CFrame.lookVector if w then a=I.CFrame.lookVector end tweenSpeed=Util.Clamp(0,tweenMaxSpeed,tweenSpeed+tweenAcceleration*d)local u=Util.Clamp(0,1,tweenSpeed*d)if l:IsInFirstPerson()and not(l.isFollowCamera and l.isClimbing)then u=1 end local n=Util.GetAngleBetweenXZVectors(a,l:GetCameraLookVector())if Util.IsFinite(n)and math.abs(n)>.0001 then l.rotateInput=l.rotateInput+Vector2.new(n*u,0)end end elseif l.isFollowCamera and(not(a or G)and not VRService.VREnabled)then local a=-(l.lastCameraTransform.p-L)local u=Util.GetAngleBetweenXZVectors(a,l:GetCameraLookVector())local n=.4 if Util.IsFinite(u)and(math.abs(u)>.0001 and math.abs(u)>n*d)then l.rotateInput=l.rotateInput+Vector2.new(u,0)end end end end if not l.isFollowCamera then local U=VRService.VREnabled if U then K=l:GetVRFocus(L,d)else K=CFrame.new(L)end local E=K.p if U and not l:IsInFirstPerson()then local d=l:GetCameraHeight()local K=L-u.CFrame.p local X=K.magnitude if X>a or l.rotateInput.x~=0 then local U=math.min(X,a)K=l:CalculateNewLookVectorVR()*U local I=E-K local W=u.CFrame.lookVector if l.rotateInput.x~=0 then W=K end local w=Vector3.new(I.x+W.x,I.y,I.z+W.z)l.rotateInput=ZERO_VECTOR2 n=CFrame.new(I,w)+Vector3.new(0,d,0)end else local d=l:CalculateNewLookVector(X)l.rotateInput=ZERO_VECTOR2 n=CFrame.new(E-a*d,E)end else local u=l:CalculateNewLookVector(X)l.rotateInput=ZERO_VECTOR2 if VRService.VREnabled then K=l:GetVRFocus(L,d)else K=CFrame.new(L)end n=CFrame.new(K.p-a*u,K.p)+Vector3.new(0,l:GetCameraHeight(),0)end l.lastCameraTransform=n l.lastCameraFocus=K if(W or w)and I:IsA("\066\097\115\101\080\097\114\116")then l.lastSubjectCFrame=I.CFrame else l.lastSubjectCFrame=nil end end l.lastUpdate=a return n,K end function ClassicCamera.EnterFirstPerson(l)l.inFirstPerson=true l:UpdateMouseBehavior()end function ClassicCamera.LeaveFirstPerson(l)l.inFirstPerson=false l:UpdateMouseBehavior()end return ClassicCamera

function ClassicCamera:SetCameraMovementMode( cameraMovementMode )
	BaseCamera.SetCameraMovementMode(self,cameraMovementMode)
	self.isFollowCamera = cameraMovementMode == Enum.ComputerCameraMovementMode.Follow
end

function ClassicCamera:Test()
	print("ClassicCamera:Test()")
end

function ClassicCamera:Update()
	local now = tick()
	local timeDelta = (now - self.lastUpdate)

	local camera = 	workspace.CurrentCamera
	local newCameraCFrame = camera.CFrame
	local newCameraFocus = camera.Focus
	local overrideCameraLookVector = nil
	if self.resetCameraAngle then
		local rootPart = self:GetHumanoidRootPart()
		if rootPart then
			overrideCameraLookVector = (rootPart.CFrame * INITIAL_CAMERA_ANGLE).lookVector
		else
			overrideCameraLookVector = INITIAL_CAMERA_ANGLE.lookVector
		end
		self.resetCameraAngle = false
	end

	local player = PlayersService.LocalPlayer
	local humanoid = self:GetHumanoid()
	local cameraSubject = camera.CameraSubject
	local isInVehicle = cameraSubject and cameraSubject:IsA('VehicleSeat')
	local isOnASkateboard = cameraSubject and cameraSubject:IsA('SkateboardPlatform')
	local isClimbing = humanoid and humanoid:GetState() == Enum.HumanoidStateType.Climbing

	if self.lastUpdate == nil or timeDelta > 1 then
		self.lastCameraTransform = nil
	end

	if self.lastUpdate then
		local gamepadRotation = self:UpdateGamepad()

		if self:ShouldUseVRRotation() then
			self.rotateInput = self.rotateInput + self:GetVRRotationInput()
		else
			-- Cap out the delta to 0.1 so we don't get some crazy things when we re-resume from
			local delta = math.min(0.1, timeDelta)

			if gamepadRotation ~= ZERO_VECTOR2 then
				self.rotateInput = self.rotateInput + (gamepadRotation * delta)
			end

			local angle = 0
			if not (isInVehicle or isOnASkateboard) then
				angle = angle + (self.turningLeft and -120 or 0)
				angle = angle + (self.turningRight and 120 or 0)
			end

			if angle ~= 0 then
				self.rotateInput = self.rotateInput +  Vector2.new(math.rad(angle * delta), 0)
			end
		end
	end

	-- Reset tween speed if user is panning
	if self.userPanningTheCamera then
		tweenSpeed = 0
		self.lastUserPanCamera = tick()
	end

	local userRecentlyPannedCamera = now - self.lastUserPanCamera < TIME_BEFORE_AUTO_ROTATE
	local subjectPosition = self:GetSubjectPosition()

	if subjectPosition and player and camera then
		local zoom = self:GetCameraToSubjectDistance()
		if zoom < 0.5 then
			zoom = 0.5
		end

		if self:GetIsMouseLocked() and not self:IsInFirstPerson() then
			-- We need to use the right vector of the camera after rotation, not before
			local newLookCFrame = self:CalculateNewLookCFrame(overrideCameraLookVector)

			local offset = self:GetMouseLockOffset()
			local cameraRelativeOffset = offset.X * newLookCFrame.rightVector + offset.Y * newLookCFrame.upVector + offset.Z * newLookCFrame.lookVector

			--offset can be NAN, NAN, NAN if newLookVector has only y component
			if Util.IsFiniteVector3(cameraRelativeOffset) then
				subjectPosition = subjectPosition + cameraRelativeOffset
			end
		else
			if not self.userPanningTheCamera and self.lastCameraTransform then

				local isInFirstPerson = self:IsInFirstPerson()

				if (isInVehicle or isOnASkateboard or (self.isFollowCamera and isClimbing)) and self.lastUpdate and humanoid and humanoid.Torso then
					if isInFirstPerson then
						if self.lastSubjectCFrame and (isInVehicle or isOnASkateboard) and cameraSubject:IsA('BasePart') then
							local y = -Util.GetAngleBetweenXZVectors(self.lastSubjectCFrame.lookVector, cameraSubject.CFrame.lookVector)
							if Util.IsFinite(y) then
								self.rotateInput = self.rotateInput + Vector2.new(y, 0)
							end
							tweenSpeed = 0
						end
					elseif not userRecentlyPannedCamera then
						local forwardVector = humanoid.Torso.CFrame.lookVector
						if isOnASkateboard then
							forwardVector = cameraSubject.CFrame.lookVector
						end

						tweenSpeed = Util.Clamp(0, tweenMaxSpeed, tweenSpeed + tweenAcceleration * timeDelta)

						local percent = Util.Clamp(0, 1, tweenSpeed * timeDelta)
						if self:IsInFirstPerson() and not (self.isFollowCamera and self.isClimbing) then
							percent = 1
						end

						local y = Util.GetAngleBetweenXZVectors(forwardVector, self:GetCameraLookVector())
						if Util.IsFinite(y) and math.abs(y) > 0.0001 then
							self.rotateInput = self.rotateInput + Vector2.new(y * percent, 0)
						end
					end

				elseif self.isFollowCamera and (not (isInFirstPerson or userRecentlyPannedCamera) and not VRService.VREnabled) then
					-- Logic that was unique to the old FollowCamera module
					local lastVec = -(self.lastCameraTransform.p - subjectPosition)

					local y = Util.GetAngleBetweenXZVectors(lastVec, self:GetCameraLookVector())

					-- This cutoff is to decide if the humanoid's angle of movement,
					-- relative to the camera's look vector, is enough that
					-- we want the camera to be following them. The point is to provide
					-- a sizable dead zone to allow more precise forward movements.
					local thetaCutoff = 0.4

					-- Check for NaNs
					if Util.IsFinite(y) and math.abs(y) > 0.0001 and math.abs(y) > thetaCutoff * timeDelta then
						self.rotateInput = self.rotateInput + Vector2.new(y, 0)
					end
				end
			end
		end

		if not self.isFollowCamera then
			local VREnabled = VRService.VREnabled

			if VREnabled then
				newCameraFocus = self:GetVRFocus(subjectPosition, timeDelta)
			else
				newCameraFocus = CFrame.new(subjectPosition)
			end

			local cameraFocusP = newCameraFocus.p
			if VREnabled and not self:IsInFirstPerson() then
				local cameraHeight = self:GetCameraHeight()
				local vecToSubject = (subjectPosition - camera.CFrame.p)
				local distToSubject = vecToSubject.magnitude

				-- Only move the camera if it exceeded a maximum distance to the subject in VR
				if distToSubject > zoom or self.rotateInput.x ~= 0 then
					local desiredDist = math.min(distToSubject, zoom)
					vecToSubject = self:CalculateNewLookVectorVR() * desiredDist
					local newPos = cameraFocusP - vecToSubject
					local desiredLookDir = camera.CFrame.lookVector
					if self.rotateInput.x ~= 0 then
						desiredLookDir = vecToSubject
					end
					local lookAt = Vector3.new(newPos.x + desiredLookDir.x, newPos.y, newPos.z + desiredLookDir.z)
					self.rotateInput = ZERO_VECTOR2

					newCameraCFrame = CFrame.new(newPos, lookAt) + Vector3.new(0, cameraHeight, 0)
				end
			else
				local newLookVector = self:CalculateNewLookVector(overrideCameraLookVector)
				self.rotateInput = ZERO_VECTOR2
				newCameraCFrame = CFrame.new(cameraFocusP - (zoom * newLookVector), cameraFocusP)
			end
		else -- is FollowCamera
			local newLookVector = self:CalculateNewLookVector(overrideCameraLookVector)
			self.rotateInput = ZERO_VECTOR2

			if VRService.VREnabled then
				newCameraFocus = self:GetVRFocus(subjectPosition, timeDelta)
			else
				newCameraFocus = CFrame.new(subjectPosition)
			end
			newCameraCFrame = CFrame.new(newCameraFocus.p - (zoom * newLookVector), newCameraFocus.p) + Vector3.new(0, self:GetCameraHeight(), 0)
		end

		self.lastCameraTransform = newCameraCFrame
		self.lastCameraFocus = newCameraFocus
		if (isInVehicle or isOnASkateboard) and cameraSubject:IsA('BasePart') then
			self.lastSubjectCFrame = cameraSubject.CFrame
		else
			self.lastSubjectCFrame = nil
		end
	end

	self.lastUpdate = now
	return newCameraCFrame, newCameraFocus
end

function ClassicCamera:EnterFirstPerson()
	self.inFirstPerson = true
	self:UpdateMouseBehavior()
end

function ClassicCamera:LeaveFirstPerson()
	self.inFirstPerson = false
	self:UpdateMouseBehavior()
end

return ClassicCamera
