local d=require(cameraModule)d.UpVector=Vector3.new(0,1,0)d.TransitionRate=.15 d.UpCFrame=IDENTITYCF function d.GetUpVector(R,d)return d end function d.CalculateUpCFrame(d)local R=d.UpVector local v=d:GetUpVector(R)local b=game.Workspace.CurrentCamera.CFrame.RightVector local x=getRotationBetween(R,v,b)local i=IDENTITYCF:Lerp(x,d.TransitionRate)d.UpVector=i*R d.UpCFrame=i*d.UpCFrame end function d.Update(R,d)if R.activeCameraController then local v,b=R.activeCameraController:Update(d)R.activeCameraController:ApplyVRTransform()R:CalculateUpCFrame()R.activeCameraController:UpdateUpCFrame(R.UpCFrame)local x=b:Inverse()*v v=(b*R.UpCFrame)*x if R.activeOcclusionModule then v,b=R.activeOcclusionModule:Update(d,v,b)end game.Workspace.CurrentCamera.CFrame=v game.Workspace.CurrentCamera.Focus=b if R.activeTransparencyController then R.activeTransparencyController:Update()end end end
-- Camera mod

local Camera = require(cameraModule)

Camera.UpVector = Vector3.new(0, 1, 0)
Camera.TransitionRate = 0.15
Camera.UpCFrame = IDENTITYCF

function Camera:GetUpVector(oldUpVector)
	return oldUpVector
end

function Camera:CalculateUpCFrame()
	local oldUpVector = self.UpVector
	local newUpVector = self:GetUpVector(oldUpVector)

	local backup = game.Workspace.CurrentCamera.CFrame.RightVector
	local transitionCF = getRotationBetween(oldUpVector, newUpVector, backup)
	local vecSlerpCF = IDENTITYCF:Lerp(transitionCF, self.TransitionRate)

	self.UpVector = vecSlerpCF * oldUpVector
	self.UpCFrame = vecSlerpCF * self.UpCFrame
end

function Camera:Update(dt)
	if self.activeCameraController then
		local newCameraCFrame, newCameraFocus = self.activeCameraController:Update(dt)
		self.activeCameraController:ApplyVRTransform()

		self:CalculateUpCFrame()
		self.activeCameraController:UpdateUpCFrame(self.UpCFrame)

		local offset = newCameraFocus:Inverse() * newCameraCFrame
		newCameraCFrame = newCameraFocus * self.UpCFrame * offset

		if self.activeOcclusionModule then
			newCameraCFrame, newCameraFocus = self.activeOcclusionModule:Update(dt, newCameraCFrame, newCameraFocus)
		end

		game.Workspace.CurrentCamera.CFrame = newCameraCFrame
		game.Workspace.CurrentCamera.Focus = newCameraFocus

		if self.activeTransparencyController then
			self.activeTransparencyController:Update()
		end
	end
end
