local j=require(cameraModule)local F=IDENTITYCF j.UpVector=Vector3.new(0,1,0)j.TransitionRate=.15 j.UpCFrame=IDENTITYCF function j.GetUpVector(F,j)return j end function j.CalculateUpCFrame(j)local I=j.UpVector local n=j:GetUpVector(I)local w=game.Workspace.CurrentCamera.CFrame.RightVector local W=getRotationBetween(I,n,w)local A=IDENTITYCF:Lerp(W,j.TransitionRate)j.UpVector=A*I j.UpCFrame=A*j.UpCFrame F=j.UpCFrame end function j.Update(F,j)if F.activeCameraController then local I,n=F.activeCameraController:Update(j)F.activeCameraController:ApplyVRTransform()F:CalculateUpCFrame()F.activeCameraController:UpdateUpCFrame(F.UpCFrame)local w=n:Inverse()*I I=(n*F.UpCFrame)*w if F.activeCameraController.lastCameraTransform then F.activeCameraController.lastCameraTransform=I F.activeCameraController.lastCameraFocus=n end if F.activeOcclusionModule then I,n=F.activeOcclusionModule:Update(j,I,n)end game.Workspace.CurrentCamera.CFrame=I game.Workspace.CurrentCamera.Focus=n if F.activeTransparencyController then F.activeTransparencyController:Update()end end end
-- Camera mod

local Camera = require(cameraModule)

local lastUpCFrame = IDENTITYCF

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

	lastUpCFrame = 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.activeCameraController.lastCameraTransform then
			self.activeCameraController.lastCameraTransform = newCameraCFrame
			self.activeCameraController.lastCameraFocus = newCameraFocus
		end

		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
