I am trying to implement a function that allows the user to tap and add a node to the to a scene at the location where the user clicked. I would like this to be on a plane. I did some research and found the following function, but I get the warning Value of type 'simd_float4x4' has no member 'translation'
on the line let translation = hitTestResult.worldTransform.translation
Does anyone know how I can change this so I am not getting the warning?
@objc func addRoomToSceneView(withGestureRecognizer recognizer: UIGestureRecognizer) {
let tapLocation = recognizer.location(in: sceneView)
let hitTestResults = sceneView.hitTest(tapLocation, types: .existingPlaneUsingExtent)
guard let hitTestResult = hitTestResults.first else { return }
//THE FOLLOWING LINE HAS THE warning: Value of type 'simd_float4x4' has no member 'translation'
let translation = hitTestResult.worldTransform.translation
let x = translation.x
let y = translation.y
let z = translation.z
let room = createMaskedRectangleRoom(width: 4, height: 4, depth: 4, color: .white)
room.scale = SCNVector3(2, 2, 2)
room.position = SCNVector3(x,y,z)
sceneView.scene.rootNode.addChildNode(room)
}