Im finding difficult to caste a shadow on invisible plane in scenekit , firstly I am trying to create an invisible plane under my AR Object and casting shadow on it , so far failed to do both
One thing Im doing right is that my object has the shadow on other AR object but not on ground (because I think Im unable to create the invisible plane on which shadow will be casted)
Note : Im using apple's demo project code for my project
Kindly Help , Thanks in advance
didAdd node delegate
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
guard let planeAnchor = anchor as? ARPlaneAnchor else { return }
DispatchQueue.main.async {
self.statusViewController.cancelScheduledMessage(for: .planeEstimation)
self.statusViewController.showMessage("SURFACE DETECTED")
if self.virtualObjectLoader.loadedObjects.isEmpty {
self.statusViewController.scheduleMessage("TAP ON SCREEN TO PLACE AN OBJECT", inSeconds: 7.5, messageType: .contentPlacement)
}
}
updateQueue.async {
for object in self.virtualObjectLoader.loadedObjects {
object.adjustOntoPlaneAnchor(planeAnchor, using: node)
}
}
}
didUpdate node delegate
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) {
guard let planeAnchor = anchor as? ARPlaneAnchor ,
let planeNode = node.childNodes.first,let plane = planeNode.geometry as? SCNPlane else { return }
// 2
let width = CGFloat(planeAnchor.extent.x)
let height = CGFloat(planeAnchor.extent.z)
plane.width = width
plane.height = height
// 3
let x = CGFloat(planeAnchor.center.x)
let y = CGFloat(planeAnchor.center.y)
let z = CGFloat(planeAnchor.center.z)
planeNode.position = SCNVector3(x, y, z)
updateQueue.async {
for object in self.virtualObjectLoader.loadedObjects {
object.adjustOntoPlaneAnchor(planeAnchor, using: node)
}
}
}
casting shadow on other object