I am new to AR and i want to create a square or rectangle overlay based on the given width and height over camera using iOS 11 ARKit- Scenekit.
I tried using https://developer.apple.com/sample-code/wwdc/2017/PlacingObjects.zip and it shows a focus square at the centre using which we can position any 3D model. But it is really unstable.
Is it possible to create a plane similar to the focus square in the above sample based on the size of 3D model that we are going to place, so that
1) We can drag the plane anywhere
2) Rotate the plane
3) Place a 3D model over the focus square(Plane)
Something similar to this http://www.madewitharkit.com/post/163259313638/arkit-furniture-dropping-app-by
A simple way to implement your need: prepare a rectangle icon, and generate a SCNNode
with the method:
func geometryNodeFromImage(named name: String, width: CGFloat, height: CGFloat, length: CGFloat) -> SCNNode {
let box = SCNBox(width: width, height: height, length: length, chamferRadius: 0)
let rectangleMaterial = SCNMaterial()
rectangleMaterial.diffuse.contents = UIImage(named: name)
box.materials = [rectangleMaterial]
return SCNNode(geometry: box)
}