I'm trying to overlay detected plane by some images
so I trying to use renderer(_:nodeFor:)
Inside that method some bloggers wrote code like this
guard let anchor = anchor as? ARPlaneAnchor else { return nil }
let anchorNode = SCNNode()
let planeNode = SCNNode()
let material = SCNMaterial()
material.diffuse.contents = UIColor.gray.withAlphaComponent(0.6)
let plane = SCNPlane(width: CGFloat(anchor.extent.x), height: CGFloat(anchor.extent.z))
plane.materials = [material]
planeNode.geometry = plane
planeNode.position = SCNVector3(anchor.center.x, 0, anchor.center.z)
planeNode.eulerAngles = SCNVector3(-Float.pi / 2, 0, 0)
anchorNode.addChildNode(planeNode)
return anchorNode
why they add child node to Empty node?
why just doesn't rotate itself
Of course I read documentation about it
they said :
You can implement this method to provide a new SCNNode object (or instance of an SCNNode subclass) containing any attachments you plan to use as a visual representation of the anchor. Note that ARKit controls the node's visibility and its transform property, so you may find it useful to add child nodes or adjust the node's pivot property to maintain any changes to position or orientation that you make.
what is the logic behind the scene?
then how to rotate node itself using pivot?