import OrderedCollections


public struct Model: Resource
{
	public let meshes: [Mesh]
}

public struct Mesh: Resource
{
	public typealias Index = UInt16

	public struct Vertex: Equatable
	{
		public let position: Vec3f
		public let normal: Vec3f
		public let texCoord: Vec2f

		public init(position: Vec3f, normal: Vec3f, texCoord: Vec2f)
		{
			self.position = position
			self.normal = normal
			self.texCoord = texCoord
		}
	}

	public struct SubMesh
	{
		public let start, length: Int

		public init(start: Int, length: Int)
		{
			self.start = start
			self.length = length
		}
	}

	public let vertices: [Vertex]
	public let indices: [Index]
	public let subMeshes: OrderedDictionary<String, SubMesh>
}

public extension Mesh
{
	static let empty = Self(vertices: .init(), indices: .init(), subMeshes: .init())

	init(vertices: [Vertex], indices: [Index])
	{
		self.init(
			vertices: vertices,
			indices: indices,
			subMeshes: .init())
	}
}
