0
votes

I developed a POC using iOS 11 ARKit(Scenekit- https://developer.apple.com/sample-code/wwdc/2017/PlacingObjects.zip). When i try to place a 3D object using camera, it detects horizontal planes and placing it.

But i am able to place the object anywhere(like in the air) even if it doesn't detect proper horizontal plane which is not an ideal scenario.

Is it possible to restrict user such that the object can be placed only in valid horizontal planes like floor and not anywhere else? That is i want to detect the level of the floor and place objects only above valid planes and not on the air.

1

1 Answers

1
votes

You can limit ARHitTestResult of user touch event by specifying hit test option ARHitTestResultTypeExistingPlaneUsingExtent.

CGPoint tapPoint = [recognizer locationInView:self.sceneView];
NSArray<ARHitTestResult *> *result = [self.sceneView hitTest:tapPoint types:ARHitTestResultTypeExistingPlaneUsingExtent];

Then place object selected at position specifying in ARHitTestResult.worldTransform. This will ensure user can only place object on planes ARKit has detected.