Sometimes generate concave using MeshResource are not correct
The DEMO image describes the error
- This is my code
` public func polygon(points: [simd_float3], name: String, color: UIColor) -> ModelEntity? {
let counts: [UInt8] = [UInt8(points.count)]
var indices: [UInt32] = []
for index in 0..<points.count {
indices.append(UInt32(index))}
primitivesType = .polygons(counts, indices)
var meshDescriptor = MeshDescriptor()
meshDescriptor.positions = .init(positions)
meshDescriptor.primitives = primitivesType
let polygon = try! MeshResource.generate(from: [meshDescriptor])
let entity = ModelEntity(mesh: polygon, materials: [unlitmaterial_])
entity.name = name
return entity
}`
have any way to improve this draw func
MeshResource.generate var meshDescriptor = MeshDescriptor() meshDescriptor.positions = .init(positions) meshDescriptor.primitives = primitivesType let polygon = try! MeshResource.generate(from: [meshDescriptor]) let entity = ModelEntity(mesh: polygon, materials: [unlitmaterial_])
Loi Nguyen Chon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.