ios - ARKit API by example -


i'm trying wrap head around apple's arkit api , have pushed example arkitexample project github.

in demo/sample project, move phone camera around environment, , appears automatically detect flat surfaces , place set of "focus squares" on camera centered on surface. if press "+" ui button , select 1 of several objects (lamp, cups, vase, etc.) , render virtual object in place of focus squares. can see of in action right here better me trying explain it!

i'm trying find place in code virtual object invoked , rendered onscreen. after selected, think takes place here:

@ibaction func chooseobject(_ button: uibutton) {     // abort if load object avoid concurrent modifications of scene.     if isloadingobject { return }      textmanager.cancelscheduledmessage(fortype: .contentplacement)     performsegue(withidentifier: segueidentifier.showobjects.rawvalue, sender: button) } 

but essentially, user selects virtual object , gets rendered wherever focus square located @ -- i'm looking happens, ideas?

it adds virtualobject instance (which subclass of scnnode) child of scnscene's root node:

    func virtualobjectselectionviewcontroller(_: virtualobjectselectionviewcontroller, didselectobjectat index: int) {     guard let cameratransform = session.currentframe?.camera.transform else {         return     }      let definition = virtualobjectmanager.availableobjects[index]     let object = virtualobject(definition: definition)     let position = focussquare?.lastposition ?? float3(0)     virtualobjectmanager.loadvirtualobject(object, to: position, cameratransform: cameratransform)     if object.parent == nil {         serialqueue.async {             self.sceneview.scene.rootnode.addchildnode(object)         }     } } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -