I am trying to get my head around ARKit and augment apples ARKitInteraction example which can be found here. My models load correctly however, the objects aren't listed in alphabetical order. I have put my objects in order inside the models.scnassets but that doesn't seem to fix it.
Lets say the model names are: A,B,C,D,E The list is being ordered like this: E,A,B,D,C
How would I sort the order of the models?
The model names are derived from here:
var modelName: String {
return referenceURL.lastPathComponent.replacingOccurrences(of: ".scn", with: "")
}
And the model objects are being loaded from here:
static let availableObjects: [VirtualObject] = {
let modelsURL = Bundle.main.url(forResource: "Models.scnassets", withExtension: nil)!
let fileEnumerator = FileManager().enumerator(at: modelsURL, includingPropertiesForKeys: [])!
return fileEnumerator.compactMap { element in
let url = element as! URL
guard url.pathExtension == "scn" && !url.path.contains("lighting") else { return nil }
return VirtualObject(url: url)
}
}()