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
scene.rootNode.addChildNode(newNode)
}