調べるとよくそう書かれている。
let col3 = frame.camera.transform.columns.3
let cameraPosition = SCNVector3(col3.x, col3.y, col3.z)
このtransform.columns.3
とは一体何なのか、、
ARCamera.transform
は世界座標系における回転/移動を表した変換行列である。
The position and orientation of the camera in world coordinate space.
ARCamera / transform
ちなみに、このtranslation
はもちろんSCNNode
も持っており、ARCamera
と異なるのはスケール成分も含んでいる点だ。
The transformation is the combination of the node’s
rotation
,position
, andscale
properties.
SCNNode / transform
ARCamera
とSCNNode
のtransform
の違いはこの他にも型にあり、前者がsimd_float4x4
、後者がSCNMatrix4
によって表現されるが、どちらも4x4の行列を表す。
ARCamera.transform
の場合、この行列が次のように回転成分と移動成分を含んでいるから、このうち(0…2, 3)要素がシーン空間におけるカメラ座標(x, y, z)に対応している。だからcamera.transform.coulmns.3
を用いるのだ。

ちなみに、ARKitを触っていると、SCNMatrix4
やSCNVector3
に混じってsimd_float4x4
が入り乱れてややこしい。SCN
接頭辞は名前の通りSceneKit由来、いっぽう後者のsimd
接頭辞は、Accelerateという大規模数理計算や画像処理を扱うフレームワーク由来で、ARKit内ではこちらを用いているようだ。