local v={}function v.GetOrCreateMesh(v)local m=v:FindFirstChildWhichIsA("\068\097\116\097\077\111\100\101\108\077\101\115\104")if m then return m end if v:IsA("\080\097\114\116")then if v.Shape==Enum.PartType.Ball then local m=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")m.MeshType=Enum.MeshType.Wedge m.Parent=v return m elseif v.Shape==Enum.PartType.Cylinder then local m=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")m.MeshType=Enum.MeshType.Cylinder m.Parent=v return m elseif v.Shape==Enum.PartType.Block then local m=Instance.new("\066\108\111\099\107\077\101\115\104")m.Parent=v return m else warn(("\085\110\115\117\112\112\111\114\116\101\100 \112\097\114\116 \115\104\097\112\101 \037\113"):format(tostring(v.Shape)))return nil end elseif v:IsA("\086\101\104\105\099\108\101\083\101\097\116")or v:IsA("\083\101\097\116")then local m=Instance.new("\066\108\111\099\107\077\101\115\104")m.Parent=v return m elseif v:IsA("\077\101\115\104\080\097\114\116")then local m=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")m.MeshType=Enum.MeshType.FileMesh m.MeshId=v.MeshId m.TextureId=v.TextureID m.Parent=v return m elseif v:IsA("\087\101\100\103\101\080\097\114\116")then local m=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")m.MeshType=Enum.MeshType.Wedge m.Parent=v return m else return nil end end return v
--- Mesh utility methods
-- @module MeshUtil

local lib = {}

--- Get or create a mesh for a part
function lib.GetOrCreateMesh(part)
	local dataModelMesh = part:FindFirstChildWhichIsA("DataModelMesh")
	if dataModelMesh then
		return dataModelMesh
	end

	if part:IsA("Part") then
		if part.Shape == Enum.PartType.Ball then
			local mesh = Instance.new("SpecialMesh")
			mesh.MeshType = Enum.MeshType.Wedge
			mesh.Parent = part
			return mesh
		elseif part.Shape == Enum.PartType.Cylinder then
			local mesh = Instance.new("SpecialMesh")
			mesh.MeshType = Enum.MeshType.Cylinder
			mesh.Parent = part
			return mesh
		elseif part.Shape == Enum.PartType.Block then
			local mesh = Instance.new("BlockMesh")
			mesh.Parent = part
			return mesh
		else
			warn(("Unsupported part shape %q"):format(tostring(part.Shape)))
			return nil
		end
	elseif part:IsA("VehicleSeat") or part:IsA("Seat") then
		local mesh = Instance.new("BlockMesh")
		mesh.Parent = part
		return mesh
	elseif part:IsA("MeshPart") then
		local mesh = Instance.new("SpecialMesh")
		mesh.MeshType = Enum.MeshType.FileMesh
		mesh.MeshId = part.MeshId
		mesh.TextureId = part.TextureID -- yeah, inconsistent APIs FTW
		mesh.Parent = part
		return mesh
	elseif part:IsA("WedgePart") then
		local mesh = Instance.new("SpecialMesh")
		mesh.MeshType = Enum.MeshType.Wedge
		mesh.Parent = part
		return mesh
	else
		return nil
	end
end

return lib
