I’m attempting to access the geometry from a ModelEntity
loaded from a .usdz file. I’ve been able to get to the various AnyMeshBuffer
s for normals, positions, etc using the following code:
let meshModels = modelEntity.model!.mesh.contents.models
for model in meshModels {
for part in parts {
for (identifier, buffer) in part.buffers {
}
}
}
Inside the loop I can print out the AnyMeshBuffer
in the debugger and see something like this:
▿ AnyMeshBuffer
▿ buffer : BufferEntry<FloatVector3Packed>
▿ id : "primvars:normals"
- name : "primvars:normals"
- isCustom : true
- count : 10968
- rate : RealityFoundation.MeshBuffers.Rate.vertex
- elementType : RealityFoundation.MeshBuffers.ElementType.simd3Float
- packed : true
▿ buffer : MeshBuffer<FloatVector3Packed>
▿ closure : Closures
- getArray : (Function)
- getIndices : (Function)
- getData : (Function)
- chunk : (Function)
- elementType : RealityFoundation.MeshBuffers.ElementType.simd3Float
- packed : true
- count : 10968
- rate : RealityFoundation.MeshBuffers.Rate.vertex
However, I haven’t been able to actually go any further. There’s a get
function in AnyMeshBuffer
that returns a MeshBuffer
but I haven’t been able figure out what type to use.
Does anyone have an example showing how to access the actual geometry from a ModelEntity
?