1 Reply
      Latest reply on Aug 29, 2017 4:37 PM by TonyPham
      Yaali Level 1 Level 1 (0 points)

        I am working on a AR based POC using the sample given by apple https://developer.apple.com/sample-code/wwdc/2017/PlacingObjects.zip.

        Is there a way to place a 3D object above another 3D object in Scenekit?

        For example i have placed a table above which i have to place something else like a flower vase. How to achieve this?

        Because as far as i know, ARKit is detecting only floor surface and if i try to place the flower vase over the already kept table, it is placing it under the table overlapping the existing 3D object. Is this doable?

        • Re: How to place one 3D object above the other using ARKit - Scenekit of iOS 11?
          TonyPham Level 2 Level 2 (80 points)

          To see the vase as it is placed on the table you should set its position by the right value.


          One of the simplest way is to add the vase as a table's child node since you don't need to update vase position whenever the table moves:




          Set position of the vase to the middle of the table face. You have to calculate y or set it manually:


          vaseNode.position = SCNVector3(0, y, 0)


          The following code is to calculate y:


          let tableHeight = tableNode.boundingBox.max.y - tableNode.boundingBox.min.y

          let vaseHeight = vaseNode.boundingBox.max.y - vaseNode.boundingBox.min.y


          Now you can set the vase as it is on the table face:

          vaseNode.position = SCNVector3(0, (tableHeight + vaseHeight) / 2, 0)