local W=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local w=W:WaitForChild("\099\111\109\109\111\110")local Z=require(w:WaitForChild("\065\115\115\101\116\115"))local d={}local a={HumanoidRootPart=true,Head=true}local function p(W,w,Z,d,p)for W,o in pairs(W:GetChildren())do if o:IsA("\066\097\115\101\080\097\114\116")and not a[o.Name]then o.Color=w or(BrickColor.new("\087\104\105\116\101")).Color o.Material=Z or Enum.Material.Plastic o.Reflectance=d or 0 o.Transparency=p or 0 end end end function d.new(W,w)local a=setmetatable({},{__index=d})a.rig=w a.assetId=W local o=Z.byId[W]if o and o.metadata then p(w,o.metadata.color,o.metadata.material,o.metadata.reflectance,o.metadata.transparency)end return a end function d.update(W) end function d.destroy(W)p(W.rig,nil,nil,nil,nil)W.rig=nil end return d
-- object based material renderer, default renderer for materials.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local common = ReplicatedStorage:WaitForChild("common")
local Assets = require(common:WaitForChild("Assets"))

local MaterialRenderer = {}

local blacklist = {
    HumanoidRootPart = true,
    Head = true,
}

local function applyMaterialToRig(rig,color,material,reflectance,transparency)
    for _,instance in pairs(rig:GetChildren()) do
        if instance:IsA("BasePart") and not blacklist[instance.Name] then
            instance.Color = color or BrickColor.new("White").Color
            instance.Material = material or Enum.Material.Plastic
            instance.Reflectance = reflectance or 0
            instance.Transparency = transparency or 0
        end
    end
end

function MaterialRenderer.new(assetId,rig)
    local self = setmetatable({},{__index = MaterialRenderer})
    self.rig = rig
    self.assetId = assetId
    local materialAsset = Assets.byId[assetId]
    if materialAsset and materialAsset.metadata then
        applyMaterialToRig(
            rig,
            materialAsset.metadata.color,
            materialAsset.metadata.material,
            materialAsset.metadata.reflectance,
            materialAsset.metadata.transparency
        )
    end

    return self
end

function MaterialRenderer:update()
    -- nothing needed here
end

function MaterialRenderer:destroy()
    applyMaterialToRig(self.rig, nil, nil, nil, nil)
    self.rig = nil
end

return MaterialRenderer