local F=game:GetService("\080\108\097\121\101\114\115")local O=game:GetService("\086\082\083\101\114\118\105\099\101")local e=(UserSettings()):GetService("\085\115\101\114\071\097\109\101\083\101\116\116\105\110\103\115")local h=require(script.Parent:WaitForChild("\067\097\109\101\114\097\073\110\112\117\116"))local Q=require(script.Parent:WaitForChild("\067\097\109\101\114\097\085\116\105\108\115"))local m=require(script.Parent:WaitForChild("\086\082\066\097\115\101\067\097\109\101\114\097"))local A=setmetatable({},m)A.__index=A local j,f=pcall(function()return(UserSettings()):IsUserFeatureEnabled("\085\115\101\114\070\108\097\103\069\110\097\098\108\101\086\082\085\112\100\097\116\101\051")end)function A.new()local F=setmetatable(m.new(),A)F.lastUpdate=tick()F:Reset()return F end function A.Reset(F)F.needsReset=true F.needsBlackout=true F.motionDetTime=0 F.blackOutTimer=0 F.lastCameraResetPosition=nil F.stepRotateTimeout=0 F.cameraOffsetRotation=0 F.cameraOffsetRotationDiscrete=0 end function A.Update(O,e)local h=workspace.CurrentCamera local Q=h.CFrame local m=h.Focus local A=F.LocalPlayer local j=O:GetHumanoid()local f=h.CameraSubject if O.lastUpdate==nil or e>1 then O.lastCameraTransform=nil end O:StepZoom()O:UpdateFadeFromBlack(e)O:UpdateEdgeBlur(A,e)local b=O.lastSubjectPosition local E=O:GetSubjectPosition()if O.needsBlackout then O:StartFadeFromBlack()O.blackOutTimer=O.blackOutTimer+math.clamp(e,.0001,.1)if O.blackOutTimer>.1 and game:IsLoaded()then O.needsBlackout=false O.needsReset=true end end if E and(A and h)then local F=nil F=O:GetVRFocus(E,e)if O:IsInFirstPerson()then local h,A=O:UpdateFirstPersonTransform(e,Q,F,b,E)Q=h m=A else local h,A=O:UpdateThirdPersonTransform(e,Q,F,b,E)Q=h m=A end O.lastCameraTransform=Q O.lastCameraFocus=m end O.lastUpdate=tick()return Q,m end local b=j or f function A.UpdateFirstPersonTransform(O,Q,m,A,j,f)if O.needsReset then O:StartFadeFromBlack()O.needsReset=false O.stepRotateTimeout=.25 O.VRCameraFocusFrozen=true O.cameraOffsetRotation=0 O.cameraOffsetRotationDiscrete=0 end if(j-f).magnitude>.01 then O:StartVREdgeBlur(F.LocalPlayer)end local E=A.p local x=O:GetCameraLookVector()if O.stepRotateTimeout>0 then O.stepRotateTimeout=O.stepRotateTimeout-Q end local Y=h.getRotation()local W=0 if b and e.VRSmoothRotationEnabled then W=Y.X elseif O.stepRotateTimeout<=0 and math.abs(Y.X)>.03 then W=.5 if Y.X<0 then W=-0.5 end O.needsReset=true end m=CFrame.new(E-.5*O:CalculateNewLookVectorFromArg((Vector3.new(x.X,0,x.Z)).Unit,Vector2.new(W,0)),E)return m,A end function A.UpdateThirdPersonTransform(Q,m,A,j,f,E)local x=Q:GetCameraToSubjectDistance()if x<.5 then x=.5 end if f~=nil and Q.lastCameraFocus~=nil then local Y=(require((F.LocalPlayer:WaitForChild("\080\108\097\121\101\114\083\099\114\105\112\116\115")).PlayerModule:WaitForChild("\067\111\110\116\114\111\108\077\111\100\117\108\101"))):GetMoveVector()local W=true if not((f-E).magnitude>.01)then W=Y.magnitude>.01 end if W then Q.motionDetTime=.1 end Q.motionDetTime=Q.motionDetTime-m if Q.motionDetTime>0 then W=true end if W and not Q.needsReset then j=Q.lastCameraFocus Q.VRCameraFocusFrozen=true return A,j end local X=true if Q.lastCameraResetPosition~=nil then X=(E-Q.lastCameraResetPosition).Magnitude>1 end local k=h.getRotation()local Z=b and k~=Vector2.new()local g=false if Z and k.X~=0 then local F=Q.cameraOffsetRotation+k.X if F<-math.pi then F=math.pi-(F+math.pi)elseif math.pi<F then F=-math.pi+(F-math.pi)end Q.cameraOffsetRotation=math.clamp(F,-math.pi,math.pi)if e.VRSmoothRotationEnabled then Q.cameraOffsetRotationDiscrete=Q.cameraOffsetRotation local F=Q:GetHumanoid()local O=F.Torso and F.Torso.CFrame.lookVector or Vector3.new(1,0,0)local e=j.Position-Vector3.new(O.X,0,O.Z)*x local h=Vector3.new(j.Position.X,e.Y,j.Position.Z)A=CFrame.new(h-(CFrame.new(e,h)*CFrame.fromAxisAngle(Vector3.new(0,1,0),Q.cameraOffsetRotationDiscrete)).LookVector*(h-e).Magnitude,h)else local F=math.floor((Q.cameraOffsetRotation*12)/12)if F~=Q.cameraOffsetRotationDiscrete then Q.cameraOffsetRotationDiscrete=F g=true end end end if not(not Q.VRCameraFocusFrozen)and not(not X)or not(not Q.needsReset)or g then if not g then Q.cameraOffsetRotationDiscrete=0 Q.cameraOffsetRotation=0 end O:RecenterUserHeadCFrame()Q.VRCameraFocusFrozen=false Q.needsReset=false Q.lastCameraResetPosition=E Q:ResetZoom()Q:StartFadeFromBlack()local F=Q:GetHumanoid()local e=F.Torso and F.Torso.CFrame.lookVector or Vector3.new(1,0,0)local h=j.Position-Vector3.new(e.X,0,e.Z)*x local m=Vector3.new(j.Position.X,h.Y,j.Position.Z)if b and Q.cameraOffsetRotation~=0 then h=m-(CFrame.new(h,m)*CFrame.fromAxisAngle(Vector3.new(0,1,0),Q.cameraOffsetRotationDiscrete)).LookVector*(m-h).Magnitude end A=CFrame.new(h,m)end end return A,j end function A.EnterFirstPerson(F)F.inFirstPerson=true F:UpdateMouseBehavior()end function A.LeaveFirstPerson(F)F.inFirstPerson=false F.needsReset=true F:UpdateMouseBehavior()if F.VRBlur then F.VRBlur.Visible=false end end return A


local l__Players__1 = game:GetService("Players");
local l__VRService__2 = game:GetService("VRService");
local l__UserGameSettings__3 = UserSettings():GetService("UserGameSettings");
local v4 = require(script.Parent:WaitForChild("CameraInput"));
local v5 = require(script.Parent:WaitForChild("CameraUtils"));
local v6 = require(script.Parent:WaitForChild("VRBaseCamera"));
local v7 = setmetatable({}, v6);
v7.__index = v7;
local v8, v9 = pcall(function()
	return UserSettings():IsUserFeatureEnabled("UserFlagEnableVRUpdate3");
end);
function v7.new()
	local v10 = setmetatable(v6.new(), v7);
	v10.lastUpdate = tick();
	v10:Reset();
	return v10;
end;
function v7.Reset(p1)
	p1.needsReset = true;
	p1.needsBlackout = true;
	p1.motionDetTime = 0;
	p1.blackOutTimer = 0;
	p1.lastCameraResetPosition = nil;
	p1.stepRotateTimeout = 0;
	p1.cameraOffsetRotation = 0;
	p1.cameraOffsetRotationDiscrete = 0;
end;
function v7.Update(p2, p3)
	local l__CurrentCamera__11 = workspace.CurrentCamera;
	local v12 = l__CurrentCamera__11.CFrame;
	local v13 = l__CurrentCamera__11.Focus;
	local l__LocalPlayer__14 = l__Players__1.LocalPlayer;
	local v15 = p2:GetHumanoid();
	local l__CameraSubject__16 = l__CurrentCamera__11.CameraSubject;
	if p2.lastUpdate == nil or p3 > 1 then
		p2.lastCameraTransform = nil;
	end;
	p2:StepZoom();
	p2:UpdateFadeFromBlack(p3);
	p2:UpdateEdgeBlur(l__LocalPlayer__14, p3);
	local l__lastSubjectPosition__17 = p2.lastSubjectPosition;
	local v18 = p2:GetSubjectPosition();
	if p2.needsBlackout then
		p2:StartFadeFromBlack();
		p2.blackOutTimer = p2.blackOutTimer + math.clamp(p3, 0.0001, 0.1);
		if p2.blackOutTimer > 0.1 and game:IsLoaded() then
			p2.needsBlackout = false;
			p2.needsReset = true;
		end;
	end;
	if v18 and l__LocalPlayer__14 and l__CurrentCamera__11 then
		local v19 = nil;
		v19 = p2:GetVRFocus(v18, p3);
		if p2:IsInFirstPerson() then
			local v20, v21 = p2:UpdateFirstPersonTransform(p3, v12, v19, l__lastSubjectPosition__17, v18);
			v12 = v20;
			v13 = v21;
		else
			local v22, v23 = p2:UpdateThirdPersonTransform(p3, v12, v19, l__lastSubjectPosition__17, v18);
			v12 = v22;
			v13 = v23;
		end;
		p2.lastCameraTransform = v12;
		p2.lastCameraFocus = v13;
	end;
	p2.lastUpdate = tick();
	return v12, v13;
end;
local u1 = v8 or v9;
function v7.UpdateFirstPersonTransform(p4, p5, p6, p7, p8, p9)
	if p4.needsReset then
		p4:StartFadeFromBlack();
		p4.needsReset = false;
		p4.stepRotateTimeout = 0.25;
		p4.VRCameraFocusFrozen = true;
		p4.cameraOffsetRotation = 0;
		p4.cameraOffsetRotationDiscrete = 0;
	end;
	if (p8 - p9).magnitude > 0.01 then
		p4:StartVREdgeBlur(l__Players__1.LocalPlayer);
	end;
	local l__p__24 = p7.p;
	local v25 = p4:GetCameraLookVector();
	if p4.stepRotateTimeout > 0 then
		p4.stepRotateTimeout = p4.stepRotateTimeout - p5;
	end;
	local v26 = v4.getRotation();
	local v27 = 0;
	if u1 and l__UserGameSettings__3.VRSmoothRotationEnabled then
		v27 = v26.X;
	elseif p4.stepRotateTimeout <= 0 and math.abs(v26.X) > 0.03 then
		v27 = 0.5;
		if v26.X < 0 then
			v27 = -0.5;
		end;
		p4.needsReset = true;
	end;
	p6 = CFrame.new(l__p__24 - 0.5 * p4:CalculateNewLookVectorFromArg(Vector3.new(v25.X, 0, v25.Z).Unit, Vector2.new(v27, 0)), l__p__24);
	return p6, p7;
end;
function v7.UpdateThirdPersonTransform(p10, p11, p12, p13, p14, p15)
	local v28 = p10:GetCameraToSubjectDistance();
	if v28 < 0.5 then
		v28 = 0.5;
	end;
	if p14 ~= nil and p10.lastCameraFocus ~= nil then
		local v29 = require(l__Players__1.LocalPlayer:WaitForChild("PlayerScripts").PlayerModule:WaitForChild("ControlModule")):GetMoveVector();
		local v30 = true;
		if not ((p14 - p15).magnitude > 0.01) then
			v30 = v29.magnitude > 0.01;
		end;
		if v30 then
			p10.motionDetTime = 0.1;
		end;
		p10.motionDetTime = p10.motionDetTime - p11;
		if p10.motionDetTime > 0 then
			v30 = true;
		end;
		if v30 and not p10.needsReset then
			p13 = p10.lastCameraFocus;
			p10.VRCameraFocusFrozen = true;
			return p12, p13;
		end;
		local v31 = true;
		if p10.lastCameraResetPosition ~= nil then
			v31 = (p15 - p10.lastCameraResetPosition).Magnitude > 1;
		end;
		local v32 = v4.getRotation();
		local v33 = u1 and v32 ~= Vector2.new();
		local v34 = false;
		if v33 and v32.X ~= 0 then
			local v35 = p10.cameraOffsetRotation + v32.X;
			if v35 < -math.pi then
				v35 = math.pi - (v35 + math.pi);
			elseif math.pi < v35 then
				v35 = -math.pi + (v35 - math.pi);
			end;
			p10.cameraOffsetRotation = math.clamp(v35, -math.pi, math.pi);
			if l__UserGameSettings__3.VRSmoothRotationEnabled then
				p10.cameraOffsetRotationDiscrete = p10.cameraOffsetRotation;
				local v36 = p10:GetHumanoid();
				local v37 = v36.Torso and v36.Torso.CFrame.lookVector or Vector3.new(1, 0, 0);
				local v38 = p13.Position - Vector3.new(v37.X, 0, v37.Z) * v28;
				local v39 = Vector3.new(p13.Position.X, v38.Y, p13.Position.Z);
				p12 = CFrame.new(v39 - (CFrame.new(v38, v39) * CFrame.fromAxisAngle(Vector3.new(0, 1, 0), p10.cameraOffsetRotationDiscrete)).LookVector * (v39 - v38).Magnitude, v39);
			else
				local v40 = math.floor(p10.cameraOffsetRotation * 12 / 12);
				if v40 ~= p10.cameraOffsetRotationDiscrete then
					p10.cameraOffsetRotationDiscrete = v40;
					v34 = true;
				end;
			end;
		end;
		if not (not p10.VRCameraFocusFrozen) and not (not v31) or not (not p10.needsReset) or v34 then
			if not v34 then
				p10.cameraOffsetRotationDiscrete = 0;
				p10.cameraOffsetRotation = 0;
			end;
			l__VRService__2:RecenterUserHeadCFrame();
			p10.VRCameraFocusFrozen = false;
			p10.needsReset = false;
			p10.lastCameraResetPosition = p15;
			p10:ResetZoom();
			p10:StartFadeFromBlack();
			local v41 = p10:GetHumanoid();
			local v42 = v41.Torso and v41.Torso.CFrame.lookVector or Vector3.new(1, 0, 0);
			local v43 = p13.Position - Vector3.new(v42.X, 0, v42.Z) * v28;
			local v44 = Vector3.new(p13.Position.X, v43.Y, p13.Position.Z);
			if u1 and p10.cameraOffsetRotation ~= 0 then
				v43 = v44 - (CFrame.new(v43, v44) * CFrame.fromAxisAngle(Vector3.new(0, 1, 0), p10.cameraOffsetRotationDiscrete)).LookVector * (v44 - v43).Magnitude;
			end;
			p12 = CFrame.new(v43, v44);
		end;
	end;
	return p12, p13;
end;
function v7.EnterFirstPerson(p16)
	p16.inFirstPerson = true;
	p16:UpdateMouseBehavior();
end;
function v7.LeaveFirstPerson(p17)
	p17.inFirstPerson = false;
	p17.needsReset = true;
	p17:UpdateMouseBehavior();
	if p17.VRBlur then
		p17.VRBlur.Visible = false;
	end;
end;
return v7;
