import Foundation import RealityKit extension VertexPositionNormal { static var vertexAttributes: [LowLevelMesh.Attribute] = [ .init(semantic: .position, format: .float3, offset: MemoryLayout.offset(of: \.position)!), .init(semantic: .normal, format: .float3, offset: MemoryLayout.offset(of: \.normal)!) ] static var vertexLayouts: [LowLevelMesh.Layout] = [ .init(bufferIndex: 0, bufferStride: MemoryLayout.stride) ] static var descriptor: LowLevelMesh.Descriptor { var desc = LowLevelMesh.Descriptor() desc.vertexAttributes = VertexPositionNormal.vertexAttributes desc.vertexLayouts = VertexPositionNormal.vertexLayouts desc.indexType = .uint32 return desc } @MainActor static func initializeMesh(vertexCapacity: Int, indexCapacity: Int) throws -> LowLevelMesh { var desc = VertexPositionNormal.descriptor desc.vertexCapacity = vertexCapacity desc.indexCapacity = indexCapacity return try LowLevelMesh(descriptor: desc) } }