ios – Recreating RoomPlan from CapturedRoom.partitions with SceneKit

I’m comparatively new to swift, and making an attempt to make use of Apple’s RoomPlan API to create a rendering of a room with none objects inside. To do that I am taking the listing of partitions given by CapturedRoom.partitions and making a collection of SCNNodes utilizing the data given. This manner I can modify the room at-will within the app. Nevertheless, the partitions are exhibiting up in random locations? Undecided the place I’m going fallacious:

//roomScan is a CapturedRoom object, scene is an SCNScene
for i in 0...(roomScan.partitions.endIndex-1) {
   //Generate new wall geometry
   let scannedWall = roomScan.partitions[i]
   let size = scannedWall.dimensions.x
   let width = 0.2
   let peak = scannedWall.dimensions.y
   let newWall = SCNBox(
      width: CGFloat(width),
      peak: CGFloat(peak),
      size: CGFloat(size),
      chamferRadius: 0
   newWall.firstMaterial?.diffuse.contents = UIColor.white
   newWall.firstMaterial?.transparency = 0.5
   //Generate new SCNNode
   let newNode = SCNNode(geometry: newWall)
   newNode.simdTransform = scannedWall.remodel


That is what the CapturedRoom appears like

However this what my code is outputting

Leave a Reply

Your email address will not be published.