AFathi / ARVideoKit

Capture & record ARKit videos 📹, photos 🌄, Live Photos 🎇, and GIFs 🎆.
Apache License 2.0
1.62k stars 226 forks source link

Plane detection is shown blank #125

Open Anu150030170 opened 3 years ago

Anu150030170 commented 3 years ago

After recording the sceneview it shows blank plane. IMG_8369 .. Can you please tell me solution for this...

digitallysavvy commented 3 years ago

How are you adding the planes to the scene graph?

Anu150030170 commented 3 years ago

It is something similar to this I did with reference https://developer.apple.com/documentation/arkit/world_tracking/tracking_and_visualizing_planes

        func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
       guard let planeAnchor = anchor as? ARPlaneAnchor, planeAnchor.alignment == .horizontal else { return }
        let grid = Grid(anchor: planeAnchor,textureImageName:floorTextureImageName)
        self.grids.append(grid)
        node.name = "Floornode parent"
        node.addChildNode(grid)
        }

In class Grid : SCNNode we perform this in init method --

    planeGeometry = SCNPlane(width: CGFloat(anchor.width), height: CGFloat(anchor.length))
    let material = SCNMaterial()
    material.diffuse.contents = UIImage(named: textureImageName ?? "")
    planeGeometry?.materials = [material]
    let planeNode = SCNNode(geometry: self.planeGeometry)
    planeNode.position = SCNVector3Make(anchor.center.x, 0, anchor.center.z);
    planeNode.transform = SCNMatrix4MakeRotation(Float(-Double.pi / 2.0), 1.0, 0.0, 0.0);
    planeNode.name = "FloorNode"
    addChildNode(planeNode)

I stop detection of horizontal plane after detecting required area using self.configuration.planeDetection = []

Later in my app I add a button for recording which when tapped records the sceneview using this framework arvideokit..