我想在用户点击相机正前方的屏幕时创建一个 SCNPlane,我可以创建平面但它不平行于相机
guard let sceneView = sender.view as? ARSCNView else {return}
guard let currentFrame = sceneView.session.currentFrame else {return}
let camera = currentFrame.camera
let transform = camera.transform
var translationMatrix = matrix_identity_float4x4
translationMatrix.columns.3.z = -0.1
var modifiedMatrix = simd_mul(transform, translationMatrix)
let plane = SCNNode(geometry: SCNPlane(width: 0.42, height: 0.63))
plane.geometry?.firstMaterial?.diffuse.contents = UIColor.yellow
plane.simdTransform = modifiedMatrix
self.sceneView.scene.rootNode.addChildNode(sphere)
我如何定位平行于相机的平面? 感谢您的帮助
只需旋转你的飞机
guard let sceneView = sender.view as? ARSCNView else {return}
guard let currentFrame = sceneView.session.currentFrame else {return}
let camera = currentFrame.camera
let transform = SCNMatrix4(camera.transform)
let translationMatrix = SCNMatrix4Rotate(
SCNMatrix4MakeTranslation(0, 0, -0.1),
Float.pi / 2,
1, 0, 0)
let modifiedMatrix = SCNMatrix4Mult(transform, translationMatrix)
let plane = SCNNode(geometry: SCNPlane(width: 0.42, height: 0.63))
plane.geometry?.firstMaterial?.diffuse.contents = UIColor.yellow
plane.transform = modifiedMatrix
self.sceneView.scene.rootNode.addChildNode(plane)
关于ios - 创建与相机平行的垂直 SCNPlane,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48097081/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |