Created
July 13, 2017 19:54
-
-
Save azamsharp/26beb1677be0a1570f63d673b5a47f29 to your computer and use it in GitHub Desktop.
Plane Height Causing Issues in Positioning the Plane
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am using ARKit to find horizontal plane and then cover the plane with a grid image using SCNPlane geometry. If I use the following code to update my plane extend then it works fine. | |
func update(anchor :ARPlaneAnchor) { | |
self.planeGeometry.width = CGFloat(anchor.extent.x * Float(scaleX)); // scaleX is 10 | |
self.planeGeometry.height = CGFloat(anchor.extent.z); | |
self.position = SCNVector3Make(anchor.center.x, 0, anchor.center.z); | |
let planeNode = self.childNodes.first! | |
planeNode.physicsBody = SCNPhysicsBody(type: .kinematic, shape: SCNPhysicsShape(geometry: self.planeGeometry, options: [:])) | |
} | |
If I adjust the planeGeometry height as shown below: | |
self.planeGeometry.height = CGFloat(anchor.extent.z * Float(10)); | |
Then it displays the plane stretched out on x-axis and z-axix but for some reason the plane is also changed the position in y. Instead of right on top of the found surface it is floating above the surface. | |
Any ideas? I just want the plane to be larger on x-axis and z-axis and still be sitting on the surface. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment