nicklockwood / Euclid

A Swift library for creating and manipulating 3D geometry
MIT License
639 stars 53 forks source link

Loading a Euclid Mesh Directly into a RealityKit ModelEntity #108

Closed Theophania closed 10 months ago

Theophania commented 11 months ago

First of all, thank you for the excellent work, this library is amazing and helped me a lot with my project!

I’ve got a question: I saw in some examples that a mesh from Euclid is loaded directly into a ModelEntity in RealityKit. But it looks like ModelEntity expects a MeshResource. I receive the error message: Cannot convert value of type 'Mesh' to expected argument type 'MeshResource'

let modelEntity = ModelEntity(mesh: euclidMesh)

Can I load a Euclid mesh directly into a RealityKit ModelEntity? Is there a conversion process required to turn a Euclid mesh into a MeshResource? Thank you.

nicklockwood commented 11 months ago

@Theophania if you omit the mesh: argument name and just use:

let entity = try ModelEntity(euclidMesh)

then it should work.