Thursday, June 8, 2023
HomeiOS Developmentios - Recreating RoomPlan from CapturedRoom.partitions with SceneKit

ios – Recreating RoomPlan from CapturedRoom.partitions with SceneKit

I’m comparatively new to swift, and attempting 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 knowledge given. This fashion I can modify the room at-will within the app. Nonetheless, the partitions are displaying up in random locations? Undecided the place I’m going flawed:

//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 top = scannedWall.dimensions.y
   let newWall = SCNBox(
      width: CGFloat(width),
      top: CGFloat(top),
      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.rework


That is what the CapturedRoom seems like

However this what my code is outputting



Please enter your comment!
Please enter your name here

Most Popular