Basically, I have a folder in ReplicatedStorage that I want to loop through all the models in, and make them viewports. It works, but it doesn’t look very good. Is there a way to make it look better. Doing this requires changing the FieldOfView according to the size of the model, and changing the angle of the camera. How can I do this?
for i, v in pairs(builds:GetChildren()) do
if v:IsA("Model") then
local viewport = viewPortFrame:Clone()
viewport.Parent = buildsFrame
viewport.Visible = true
local ViewportCamera = Instance.new('Camera')
ViewportCamera.Parent = viewport
ViewportCamera.CameraType = Enum.CameraType.Scriptable
ViewportCamera.FieldOfView = 10
viewport.CurrentCamera = ViewportCamera
local model = v:Clone()
model:SetPrimaryPartCFrame(CFrame.new(0, 0, 0))
model.Parent = viewport
end
end
local focusPart = --// model that you want to add
local size = focusPart:GetExtentsSize()
camera.CFrame = focusPart.WorldPivot * CFrame.new(0,size.Y*1.5,size.Z) * CFrame.Angles(math.rad(-45),0,0)
for i, v in ipairs(builds:GetChildren()) do
if v:IsA("Model") then
if not v.PrimaryPart then warn(v.Name) return end
local viewportlabel = viewPortFrame:Clone()
viewportlabel.Parent = buildsFrame
viewportlabel.Visible = true
local viewport = viewportlabel.ViewPort
viewport.Visible = true
local ViewportCamera = Instance.new('Camera')
ViewportCamera.Parent = viewport
ViewportCamera.CameraType = Enum.CameraType.Scriptable
ViewportCamera.FieldOfView = 10
viewport.CurrentCamera = ViewportCamera
local focusPart = v:Clone()
v.Parent = viewport
local size = focusPart:GetExtentsSize()
ViewportCamera.CFrame = focusPart.WorldPivot * CFrame.new(0,size.Y*1.5,size.Z) * CFrame.Angles(math.rad(-45),0,0)
end
end
Also, forgot to mention here, the other issue of the model taking up to much is a problem too. The viewportframe is the size of the little section above the read parts. So I don’t know why this is happening, as well as the problem this entire post is about.