1
在相機內放置對象我會想放置2條線路中的當前攝像機視圖的邊界作爲流量:ARkit - 日提交的視圖
源 - SceneKit docs
從ARKit文檔我明白,我需要projectionMatrix,但我如何計算從「zNear」到「zFar」和x \ y的差異?
我開始使用此代碼:
let cameraProjectionMatrix = session.currentFrame?.camera.projectionMatrix
let cameraPosition = SCNVector3.positionFromTransform(cameraProjectionMatrix)
let rightBoxNode = SCNNode(geometry: SCNBox(...))
rightBoxNode.position = SCNVector3(???)
sceneView.scene.rootNode.addChildNode(rightBoxNode)
和左一個我可能會需要
var leftPos = rightboxNode.position
leftPos.x = rightboxNode.position.x * -1
leftBoxNode.position = leftPos
而是試圖計算rightboxNode.position當我失敗:
rightBoxNode.position = SCNVector3(x: x1 ,y: y1 z: zNear)