1

I have question about loading/displaying multiple 3D models located in a folder within the art.scnassets folder in Xcode. Please be patient with me as Im new to swift and programming for iOS.

My basic program is that I have a QR code which my application will scan and return a products name.(I have already programmed this and it is working). Once I have the name I would like to have this name be searched to find a folder inside art.scnassets with the same name. This folder will hold 3D models of parts related to the product. What I would like to do is to once this folder is found to load all the 3D models into some kind of table view in a window, and this whole searching and loading into a table of sorts is what I have no idea how to do or where to start.

Could somebody please be able to point me in the right direction. Im not necessarily looking for code (It would be nice to have examples) but some guidance on how to do this or where to look for information. Once I have something working I can upload some code if I get stuck.

If there is something which isn't clear then please let me know and I will try to explain

Thanks for you help in advance

GBSingh
  • 416
  • 5
  • 18
  • I am not sure if we can use `SCNView` in `tableView`. You can instead construct a scene with those models aligned vertically and add `UIPanGestureRecognizer` for scrolling effect. – Alok Subedi Jan 31 '18 at 07:30
  • @GBSingh did you solve this? – Jubei Jun 12 '19 at 23:39

1 Answers1

0

You can retrieve items in a subfolder of the art.scnassets, I have done this in a previous project where i had to group the child-nodes within a folder for organization's sake. When I was loading a node from there, I was specifying it's path with the folder and the item name such as (I was working on Objective-C)

@"art.scnassets/Frame/frame.scn"

And I created my object with the following function

- (void)loadModel {

    SCNScene *virtualObjectScene = [SCNScene sceneNamed:_path];
    SCNNode *wrapperNode = [[SCNNode alloc] init];

    for (SCNNode *child in virtualObjectScene.rootNode.childNodes) {
        [wrapperNode addChildNode:child];
    }

    [self addChildNode:wrapperNode];
}

Now, I'm not sure about looping over everything in the subdirectory (i.e. I've never done that) but that is definitely possible in other directories, such as with the FileManager available with iOS/macOS development.

The following question may help with that:

Iterate through files in a folder and its subfolders using Swift's FileManager

Alan
  • 1,132
  • 7
  • 15