In almost all tutorials of ARKit, it seems that we always use ARPlane for floor.
let planeGeometry = SCNPlane(width:CGFloat(planeAnchor.extent.x), height:CGFloat(planeAnchor.extent.z))
let planeNode = SCNNode(geometry:planeGeometry)
planeNode.position = SCNVector3(x:planeAnchor.center.x, y:0, z:planeAnchor.center.y)
planeNode.transform = SCNMatrix4MakeRotation(-Float.pi / 2, 1.0, 0, 0)
What if you wanted an infinity plane (for casting shadows)? I tried SCNFloor and the result is weird - the floor hung in mid air:
let planeGeometry = SCNFloor()
let planeNode = SCNNode(geometry:planeGeometry)
planeNode.position = SCNVector3(planeAnchor.center.x, 0, planeAnchor.center.z)
I have done a Google search and the only result I have come out with is this (which also does not work): https://github.com/arirawr/ARKit-FloorIsLava/blob/master/FloorIsLava/ViewController.swift
Does SCNFloor() works in ARKit? If not, what can I do to create an big plane?
If you add your floor node into rootNode, your
Y
position should be changed:In this case I used minus one meter ^
You can use surface detection to find your floor surface anchor, and then you'll add your floor into related node for this anchor. World coordinates of the anchor already will be correct (with minus
Y
), so you could useSCNVector3Zero
as position for your floor.