LoginSignup
5
0

More than 1 year has passed since last update.

Mar-09-2022 14-18-06.gif

対象平面との距離を測りたい

ARKitでヒットテストを行う

ARKitでヒットテストを行い、検知した平面の座標と、カメラの距離を計算することができます。

let hitTestResults = sceneView.hitTest(sceneView.center,types:[.existingPlaneUsingGeometry])
guard let result = hitTestResults.first else { return nil }
let hitCoordinates = simd_float3(x: result.worldTransform.columns.3.x, y: result.worldTransform.columns.3.y, z: result.worldTransform.columns.3.z)

let distance = distance(cameraCoordinates,hitCoordinates)

カメラの座標の取得方法はこちら。

🐣


フリーランスエンジニアです。
お仕事のご相談こちらまで
rockyshikoku@gmail.com

Core MLやARKitを使ったアプリを作っています。
機械学習/AR関連の情報を発信しています。

Twitter
Medium
GitHub

5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0