-- Decompiled with the Synapse X Luau decompiler.


local v1 = Vector3.new(1, 0, 0);
local v2 = Vector3.new(0, 1, 0);
local v3 = Vector3.new(0, 0, 1);
local v4 = Vector3.new(0, -3, 0);
local v5 = {
	InitialDistance = 25, 
	MinDistance = 10, 
	MaxDistance = 100, 
	InitialElevation = 35, 
	MinElevation = 35, 
	MaxElevation = 35, 
	ReferenceAzimuth = -45, 
	CWAzimuthTravel = 90, 
	CCWAzimuthTravel = 90, 
	UseAzimuthLimits = false
};
local v6 = require(script.Parent:WaitForChild("BaseCamera"));
local v7 = setmetatable({}, v6);
v7.__index = v7;
function v7.new()
	local v8 = setmetatable(v6.new(), v7);
	v8.lastUpdate = tick();
	v8.changedSignalConnections = {};
	v8.refAzimuthRad = nil;
	v8.curAzimuthRad = nil;
	v8.minAzimuthAbsoluteRad = nil;
	v8.maxAzimuthAbsoluteRad = nil;
	v8.useAzimuthLimits = nil;
	v8.curElevationRad = nil;
	v8.minElevationRad = nil;
	v8.maxElevationRad = nil;
	v8.curDistance = nil;
	v8.minDistance = nil;
	v8.maxDistance = nil;
	v8.r3ButtonDown = false;
	v8.l3ButtonDown = false;
	v8.gamepadDollySpeedMultiplier = 1;
	v8.lastUserPanCamera = tick();
	v8.externalProperties = {};
	v8.externalProperties.InitialDistance = 25;
	v8.externalProperties.MinDistance = 10;
	v8.externalProperties.MaxDistance = 100;
	v8.externalProperties.InitialElevation = 35;
	v8.externalProperties.MinElevation = 35;
	v8.externalProperties.MaxElevation = 35;
	v8.externalProperties.ReferenceAzimuth = -45;
	v8.externalProperties.CWAzimuthTravel = 90;
	v8.externalProperties.CCWAzimuthTravel = 90;
	v8.externalProperties.UseAzimuthLimits = false;
	v8:LoadNumberValueParameters();
	return v8;
end;
function v7.LoadOrCreateNumberValueParameter(p1, p2, p3, p4)
	local v9 = script:FindFirstChild(p2);
	if v9 and v9:isA(p3) then
		p1.externalProperties[p2] = v9.Value;
	else
		if p1.externalProperties[p2] == nil then
			print("externalProperties table has no entry for ", p2);
			return;
		end;
		v9 = Instance.new(p3);
		v9.Name = p2;
		v9.Parent = script;
		v9.Value = p1.externalProperties[p2];
	end;
	if p4 then
		if p1.changedSignalConnections[p2] then
			p1.changedSignalConnections[p2]:Disconnect();
		end;
		p1.changedSignalConnections[p2] = v9.Changed:Connect(function(p5)
			p1.externalProperties[p2] = p5;
			p4(p1);
		end);
	end;
end;
function v7.SetAndBoundsCheckAzimuthValues(p6)
	p6.minAzimuthAbsoluteRad = math.rad(p6.externalProperties.ReferenceAzimuth) - math.abs(math.rad(p6.externalProperties.CWAzimuthTravel));
	p6.maxAzimuthAbsoluteRad = math.rad(p6.externalProperties.ReferenceAzimuth) + math.abs(math.rad(p6.externalProperties.CCWAzimuthTravel));
	p6.useAzimuthLimits = p6.externalProperties.UseAzimuthLimits;
	if p6.useAzimuthLimits then
		p6.curAzimuthRad = math.max(p6.curAzimuthRad, p6.minAzimuthAbsoluteRad);
		p6.curAzimuthRad = math.min(p6.curAzimuthRad, p6.maxAzimuthAbsoluteRad);
	end;
end;
function v7.SetAndBoundsCheckElevationValues(p7)
	local v10 = math.max(p7.externalProperties.MinElevation, -80);
	local v11 = math.min(p7.externalProperties.MaxElevation, 80);
	p7.minElevationRad = math.rad(math.min(v10, v11));
	p7.maxElevationRad = math.rad(math.max(v10, v11));
	p7.curElevationRad = math.max(p7.curElevationRad, p7.minElevationRad);
	p7.curElevationRad = math.min(p7.curElevationRad, p7.maxElevationRad);
end;
function v7.SetAndBoundsCheckDistanceValues(p8)
	p8.minDistance = p8.externalProperties.MinDistance;
	p8.maxDistance = p8.externalProperties.MaxDistance;
	p8.curDistance = math.max(p8.curDistance, p8.minDistance);
	p8.curDistance = math.min(p8.curDistance, p8.maxDistance);
end;
function v7.LoadNumberValueParameters(p9)
	p9:LoadOrCreateNumberValueParameter("InitialElevation", "NumberValue", nil);
	p9:LoadOrCreateNumberValueParameter("InitialDistance", "NumberValue", nil);
	p9:LoadOrCreateNumberValueParameter("ReferenceAzimuth", "NumberValue", p9.SetAndBoundsCheckAzimuthValue);
	p9:LoadOrCreateNumberValueParameter("CWAzimuthTravel", "NumberValue", p9.SetAndBoundsCheckAzimuthValues);
	p9:LoadOrCreateNumberValueParameter("CCWAzimuthTravel", "NumberValue", p9.SetAndBoundsCheckAzimuthValues);
	p9:LoadOrCreateNumberValueParameter("MinElevation", "NumberValue", p9.SetAndBoundsCheckElevationValues);
	p9:LoadOrCreateNumberValueParameter("MaxElevation", "NumberValue", p9.SetAndBoundsCheckElevationValues);
	p9:LoadOrCreateNumberValueParameter("MinDistance", "NumberValue", p9.SetAndBoundsCheckDistanceValues);
	p9:LoadOrCreateNumberValueParameter("MaxDistance", "NumberValue", p9.SetAndBoundsCheckDistanceValues);
	p9:LoadOrCreateNumberValueParameter("UseAzimuthLimits", "BoolValue", p9.SetAndBoundsCheckAzimuthValues);
	p9.curAzimuthRad = math.rad(p9.externalProperties.ReferenceAzimuth);
	p9.curElevationRad = math.rad(p9.externalProperties.InitialElevation);
	p9.curDistance = p9.externalProperties.InitialDistance;
	p9:SetAndBoundsCheckAzimuthValues();
	p9:SetAndBoundsCheckElevationValues();
	p9:SetAndBoundsCheckDistanceValues();
end;
function v7.GetModuleName(p10)
	return "OrbitalCamera";
end;
local u1 = require(script.Parent:WaitForChild("CameraUtils"));
function v7.SetInitialOrientation(p11, p12)
	if not p12 or not p12.RootPart then
		warn("OrbitalCamera could not set initial orientation due to missing humanoid");
		return;
	end;
	local l__unit__12 = (p12.RootPart.CFrame.lookVector - Vector3.new(0, 0.23, 0)).unit;
	local v13 = u1.GetAngleBetweenXZVectors(l__unit__12, p11:GetCameraLookVector());
	local v14 = math.asin(p11:GetCameraLookVector().y) - math.asin(l__unit__12.y);
	if not u1.IsFinite(v13) then
		v13 = 0;
	end;
	if not u1.IsFinite(v14) then
		v14 = 0;
	end;
	p11.rotateInput = Vector2.new(v13, v14);
end;
function v7.GetCameraToSubjectDistance(p13)
	return p13.curDistance;
end;
local l__Players__2 = game:GetService("Players");
function v7.SetCameraToSubjectDistance(p14, p15)
	print("OrbitalCamera SetCameraToSubjectDistance ", p15);
	if l__Players__2.LocalPlayer then
		p14.currentSubjectDistance = u1.Clamp(p14.minDistance, p14.maxDistance, p15);
		p14.currentSubjectDistance = math.max(p14.currentSubjectDistance, p14.FIRST_PERSON_DISTANCE_THRESHOLD);
	end;
	p14.inFirstPerson = false;
	p14:UpdateMouseBehavior();
	return p14.currentSubjectDistance;
end;
local u3 = Vector3.new(0, 0, 0);
function v7.CalculateNewLookVector(p16, p17, p18)
	local v15 = p17 or p16:GetCameraLookVector();
	local v16 = math.asin(v15.y);
	local v17 = Vector2.new(p18.x, (u1.Clamp(v16 - 1.3962634015954636, v16 - -1.3962634015954636, p18.y)));
	return (CFrame.Angles(0, -v17.x, 0) * CFrame.new(u3, v15) * CFrame.Angles(-v17.y, 0, 0)).lookVector;
end;
local u4 = Vector2.new(0, 0);
function v7.GetGamepadPan(p19, p20, p21, p22)
	if p22.UserInputType == p19.activeGamepad and p22.KeyCode == Enum.KeyCode.Thumbstick2 then
		if not p19.r3ButtonDown and not p19.l3ButtonDown then
			if p21 == Enum.UserInputState.Cancel then
				p19.gamepadPanningCamera = u4;
				return;
			elseif Vector2.new(p22.Position.X, -p22.Position.Y).magnitude > 0.2 then
				p19.gamepadPanningCamera = Vector2.new(p22.Position.X, -p22.Position.Y);
				return;
			else
				p19.gamepadPanningCamera = u4;
				return;
			end;
		end;
	else
		return;
	end;
	if p22.Position.Y > 0.2 then
		p19.gamepadDollySpeedMultiplier = 0.96;
		return;
	end;
	if p22.Position.Y < -0.2 then
		p19.gamepadDollySpeedMultiplier = 1.04;
		return;
	end;
	p19.gamepadDollySpeedMultiplier = 1;
end;
function v7.DoGamepadZoom(p23, p24, p25, p26)
	if p26.UserInputType == p23.activeGamepad and (p26.KeyCode == Enum.KeyCode.ButtonR3 or p26.KeyCode == Enum.KeyCode.ButtonL3) then
		if p25 == Enum.UserInputState.Begin then
			p23.r3ButtonDown = p26.KeyCode == Enum.KeyCode.ButtonR3;
			p23.l3ButtonDown = p26.KeyCode == Enum.KeyCode.ButtonL3;
			return;
		end;
		if p25 == Enum.UserInputState.End then
			if p26.KeyCode == Enum.KeyCode.ButtonR3 then
				p23.r3ButtonDown = false;
			elseif p26.KeyCode == Enum.KeyCode.ButtonL3 then
				p23.l3ButtonDown = false;
			end;
			if not p23.r3ButtonDown and not p23.l3ButtonDown then
				p23.gamepadDollySpeedMultiplier = 1;
			end;
		end;
	end;
end;
function v7.BindGamepadInputActions(p27)
	local l__ContextActionService__18 = game:GetService("ContextActionService");
	l__ContextActionService__18:BindAction("OrbitalCamGamepadPan", function(p28, p29, p30)
		p27:GetGamepadPan(p28, p29, p30);
	end, false, Enum.KeyCode.Thumbstick2);
	l__ContextActionService__18:BindAction("OrbitalCamGamepadZoom", function(p31, p32, p33)
		p27:DoGamepadZoom(p31, p32, p33);
	end, false, Enum.KeyCode.ButtonR3);
	l__ContextActionService__18:BindAction("OrbitalCamGamepadZoomAlt", function(p34, p35, p36)
		p27:DoGamepadZoom(p34, p35, p36);
	end, false, Enum.KeyCode.ButtonL3);
end;
local u5 = 0;
local l__VRService__6 = game:GetService("VRService");
local u7 = Vector3.new(1, 0, 1);
local u8 = 2 * math.pi;
function v7.Update(p37, p38)
	local v19 = tick();
	local v20 = v19 - p37.lastUpdate;
	local v21 = p37.UserPanningTheCamera == true;
	local l__CurrentCamera__22 = workspace.CurrentCamera;
	local v23 = l__CurrentCamera__22.CFrame;
	local l__Focus__24 = l__CurrentCamera__22.Focus;
	local v25 = p37:GetHumanoid();
	local v26 = l__CurrentCamera__22 and l__CurrentCamera__22.CameraSubject;
	local v27 = v26 and v26:IsA("VehicleSeat");
	local v28 = v26 and v26:IsA("SkateboardPlatform");
	if p37.lastUpdate == nil or v20 > 1 then
		p37.lastCameraTransform = nil;
	end;
	if p37.lastUpdate then
		local v29 = p37:UpdateGamepad();
		if p37:ShouldUseVRRotation() then
			p37.RotateInput = p37.RotateInput + p37:GetVRRotationInput();
		else
			local v30 = math.min(0.1, v20);
			if v29 ~= u4 then
				v21 = true;
				p37.rotateInput = p37.rotateInput + v29 * v30;
			end;
			local v31 = 0;
			if not v27 and not v28 then
				if p37.TurningLeft then
					local v32 = -120;
				else
					v32 = 0;
				end;
				if p37.TurningRight then
					local v33 = 120;
				else
					v33 = 0;
				end;
				v31 = v31 + v32 + v33;
			end;
			if v31 ~= 0 then
				p37.rotateInput = p37.rotateInput + Vector2.new(math.rad(v31 * v30), 0);
				v21 = true;
			end;
		end;
	end;
	if v21 then
		u5 = 0;
		p37.lastUserPanCamera = tick();
	end;
	if not (v19 - p37.lastUserPanCamera < 2) then

	end;
	local v34 = p37:GetSubjectPosition();
	if v34 and l__Players__2.LocalPlayer and l__CurrentCamera__22 then
		if p37.gamepadDollySpeedMultiplier ~= 1 then
			p37:SetCameraToSubjectDistance(p37.currentSubjectDistance * p37.gamepadDollySpeedMultiplier);
		end;
		local l__VREnabled__35 = l__VRService__6.VREnabled;
		local v36 = l__VREnabled__35 and p37:GetVRFocus(v34, v20) or CFrame.new(v34);
		if l__VREnabled__35 and not p37:IsInFirstPerson() then
			local v37 = p37:GetCameraHeight();
			local v38 = v34 - l__CurrentCamera__22.CFrame.p;
			local l__magnitude__39 = v38.magnitude;
			if p37.currentSubjectDistance < l__magnitude__39 or p37.rotateInput.x ~= 0 then
				local v40 = p37:CalculateNewLookVector(v38.unit * u7, Vector2.new(p37.rotateInput.x, 0)) * math.min(l__magnitude__39, p37.currentSubjectDistance);
				local v41 = v36.p - v40;
				local v42 = l__CurrentCamera__22.CFrame.lookVector;
				if p37.rotateInput.x ~= 0 then
					v42 = v40;
				end;
				p37.RotateInput = u4;
				v23 = CFrame.new(v41, (Vector3.new(v41.x + v42.x, v41.y, v41.z + v42.z))) + Vector3.new(0, v37, 0);
			end;
		else
			p37.curAzimuthRad = p37.curAzimuthRad - p37.rotateInput.x;
			if p37.useAzimuthLimits then
				p37.curAzimuthRad = u1.Clamp(p37.minAzimuthAbsoluteRad, p37.maxAzimuthAbsoluteRad, p37.curAzimuthRad);
			else
				p37.curAzimuthRad = p37.curAzimuthRad ~= 0 and math.sign(p37.curAzimuthRad) * (math.abs(p37.curAzimuthRad) % u8) or 0;
			end;
			p37.curElevationRad = u1.Clamp(p37.minElevationRad, p37.maxElevationRad, p37.curElevationRad + p37.rotateInput.y);
			v23 = CFrame.new(v34 + p37.currentSubjectDistance * (CFrame.fromEulerAnglesYXZ(-p37.curElevationRad, p37.curAzimuthRad, 0) * v3), v34);
			p37.rotateInput = u4;
		end;
		p37.lastCameraTransform = v23;
		p37.lastCameraFocus = l__Focus__24;
		if (v27 or v28) and v26:IsA("BasePart") then
			p37.lastSubjectCFrame = v26.CFrame;
		else
			p37.lastSubjectCFrame = nil;
		end;
	end;
	p37.lastUpdate = v19;
	return v23, l__Focus__24;
end;
return v7;

