Handling 3D Interaction and UI Controls in Augmented Reality

瘦欲@ 提交于 2020-01-25 07:30:08

问题


I'm playing with this Code example.

And I'm having trouble finding where can I replace the existing 3d objects with my own 3d objects programmatically created?

I want to keep all the existing functionality in the code example but with my own objects!

Creating of 3d object.

 self.geometry = SCNBox(width: width!/110, 
                       height: height!/110, 
                       length: 57 / 700, 
                chamferRadius: 0.008)

 self.geometry.firstMaterial?.diffuse.contents = UIColor.red
 self.geometry.firstMaterial?.specular.contents = UIColor.white
 self.geometry.firstMaterial?.emission.contents = UIColor.blue
 boxnode = SCNNode(geometry: self.geometry)
 boxnode.position = position
 boxnode.rotation = rotation


回答1:


Download the updated sample project "Placing Objects and Handling 3D Interaction" from Apple, to remove the build warnings, if you are using iOS 13.0+ & Xcode 11.0+

From VirtualObjectLoader.swift file, you can see the app first loads all the *.scn files within Models.scnassets.

Add a new SceneKit (.scn) File

Rename it to an appropriate name, example Boxy you can then add your virtual image example a box to your sceneKit file, Then run the app, your custom virtual object will show up in the list of objects to add.



来源:https://stackoverflow.com/questions/59699361/handling-3d-interaction-and-ui-controls-in-augmented-reality

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!