nicklockwood / Euclid

A Swift library for creating and manipulating 3D geometry

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Loading a Euclid Mesh Directly into a RealityKit ModelEntity

Theophania opened this issue · comments

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.

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

let entity = try ModelEntity(euclidMesh)

then it should work.