function region3.castPoint(p,g)local J=p.centroid-g return gjk(p.input,{g},p.support,support.point,J)end function region3.castPart(p,g)local J=classify(g)local I=p.centroid-J.centroid return gjk(p.input,J.input,p.support,J.support,I)end function region3.cast(J,g,p)local I=type(g)=="\116\097\098\108\101"and g or{g}local w=p or 100 local k,R={},{}for g,p in next,{Enum.NormalId.Right;Enum.NormalId.Top;Enum.NormalId.Back}do local I=Vector3.FromNormalId(p)insert(k,J.support(-I,unpack(J.input)))insert(R,J.support(I,unpack(J.input)))end k,R=v3(k[1].x,k[2].y,k[3].z),v3(R[1].x,R[2].y,R[3].z)local K=R3(k,R)local W=game.Workspace:FindPartsInRegion3WithIgnoreList(K,I,w)local G={}for g=1,#W,1 do local p=W[g]if J:castPart(p)then insert(G,p)end end return G end
-- public methods

function region3:castPoint(point)
	local direction = self.centroid - point
	return gjk(self.input, { point }, self.support, support.point, direction)
end

function region3:castPart(part)
	local against = classify(part)
	local direction = self.centroid - against.centroid
	return gjk(self.input, against.input, self.support, against.support, direction)
end

function region3:cast(ignore, maxParts)
	local ignore = type(ignore) == "table" and ignore or { ignore }
	local maxParts = maxParts or 100

	local min, max = {}, {}
	for _, enum in next, { Enum.NormalId.Right, Enum.NormalId.Top, Enum.NormalId.Back } do
		local direction = Vector3.FromNormalId(enum)
		insert(min, self.support(-direction, unpack(self.input)))
		insert(max, self.support(direction, unpack(self.input)))
	end
	min, max = v3(min[1].x, min[2].y, min[3].z), v3(max[1].x, max[2].y, max[3].z)

	local allignedR3 = R3(min, max)
	local parts = game.Workspace:FindPartsInRegion3WithIgnoreList(allignedR3, ignore, maxParts)

	-- debug stuff
	--game.Workspace.CurrentCamera:ClearAllChildren();
	--draw.line(min, max, game.Workspace.CurrentCamera);

	local inRegion = {}
	for i = 1, #parts do
		local part = parts[i]
		if self:castPart(part) then
			insert(inRegion, part)
		end
	end
	return inRegion
end
