local s=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local D=s:WaitForChild("\099\111\109\109\111\110")local G=s:WaitForChild("\108\105\098")local w=require(D:WaitForChild("\068\105\099\116\105\111\110\097\114\121"))local Y=require(G:WaitForChild("\082\111\097\099\116"))local j=Y.Component:extend("\077\111\100\101\108\086\105\101\119\070\114\097\109\101")local function m(s)if not s then return end local D=s:Clone()D.CFrame=CFrame.new(0,0,0)return D end function j.init(D,s)D.state={modelCopy=m(s.model);modelExtent=s.model.Size.Magnitude/2;thumbCamRef=Y.createRef(),viewportRef=Y.createRef()}end function j.didMount(s)local D=s.state.viewportRef.current local G=s.state.thumbCamRef.current D.CurrentCamera=G if not s.state.modelCopy then return end s.state.modelCopy.Parent=D end function j.render(s)local D=Y.createElement("\067\097\109\101\114\097",{CFrame=CFrame.new((Vector3.new(.3,.3,-1)).Unit*(s.state.modelExtent+4),Vector3.new(0,0,0));FieldOfView=45;[Y.Ref]=s.state.thumbCamRef})return Y.createElement("\086\105\101\119\112\111\114\116\070\114\097\109\101",{LightDirection=Vector3.new(-1,-2,1),LightColor=Color3.fromRGB(200,200,200),Ambient=Color3.fromRGB(180,180,180),BackgroundTransparency=1,ImageColor3=s.props.ImageColor3;LayoutOrder=s.props.LayoutOrder or 0,Size=s.props.Size or UDim2.new(0,64,0,64);Position=s.props.Position,AnchorPoint=s.props.AnchorPoint;[Y.Ref]=s.state.viewportRef},w.merge(s.props[Y.Children],{D}))end return j
-- ez viewport

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local common = ReplicatedStorage:WaitForChild("common")
local lib = ReplicatedStorage:WaitForChild("lib")


local Dictionary = require(common:WaitForChild("Dictionary"))
local Roact = require(lib:WaitForChild("Roact"))

local ModelViewFrame = Roact.Component:extend("ModelViewFrame")

local function getCopy(model)
	if not model then return end
	local newCopy = model:Clone()
	newCopy.CFrame = CFrame.new(0,0,0)
	return newCopy
end

function ModelViewFrame:init(props)
    self.state = {
        modelCopy = getCopy(props.model),
		modelExtent = props.model.Size.Magnitude/2,
		thumbCamRef = Roact.createRef(),
		viewportRef = Roact.createRef(),
    }
end

function ModelViewFrame:didMount()
	local viewport = self.state.viewportRef.current
	local thumbCam = self.state.thumbCamRef.current

	viewport.CurrentCamera = thumbCam

	if not self.state.modelCopy then return end
	self.state.modelCopy.Parent = viewport
end

function ModelViewFrame:render()
    local thumbCamElement = Roact.createElement("Camera",{
        CFrame = CFrame.new(
            (Vector3.new(0.3,0.3,-1).Unit)*
            (self.state.modelExtent+4),
            Vector3.new(0,0,0)),
		FieldOfView = 45,
		[Roact.Ref] = self.state.thumbCamRef,
    })
    return Roact.createElement("ViewportFrame", {
		LightDirection = Vector3.new(-1, -2, 1),
		LightColor = Color3.fromRGB(200, 200, 200),
		Ambient = Color3.fromRGB(180,180,180),

		BackgroundTransparency = 1,
		ImageColor3 = self.props.ImageColor3,
		LayoutOrder = self.props.LayoutOrder or 0,
		Size = self.props.Size or UDim2.new(0,64,0,64),
		Position = self.props.Position,
		AnchorPoint = self.props.AnchorPoint,
		[Roact.Ref] = self.state.viewportRef
	},
		Dictionary.merge(self.props[Roact.Children], {
			thumbCamElement,
		})
	)
end

return ModelViewFrame