问题
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