0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

HTML上の描画(p5.js + WebGL)を iOSアプリの平面検出・AR表示と組み合わせる機能の調査などのメモ

0
Last updated at Posted at 2026-07-26

今回の内容

今回の記事は、以下の動画で示しているシンプルな iOS用の ARアプリを試作した中で調べたりした、機能・API まわりのちょっとしたメモです。

上記アプリの主な機能は、「平面の検出」や「平面に対するタップで HTML の描画を出現させる」、「出現させた描画に対するピンチ操作での描画領域の拡大・縮小」です。

また、平面に貼り付けている描画は、以下でポストしていた過去の自分の作品(HTML + JavaScript の Webアプリで描画を実装)を用いています。

以下で、冒頭のアプリを作るにあたって調べたことや検討したことなどを記載していきます。

自分が iOSアプリ開発に詳しくないので、現在進行形で色々と確認・再検討中です

機能実装について調べたことなど

関連する処理・API

関連する処理・API について、調査をした内容を以下に書いていきます。

HTML の描画を iOSアプリ内で利用する

HTML の描画を iOSアプリ内で利用する部分に関して、調べた内容などを記載します。

  • 実装に用いる内容
    • p5.js での描画処理を含む HTML を実行: WKWebView
    • WebView の画像化: WKWebView.takeSnapshot()
    • スナップショット設定: WKSnapshotConfiguration

●WKWebView | Apple Developer Documentation
 https://developer.apple.com/documentation/webkit/wkwebview

●takeSnapshot(with:completionHandler:) | Apple Developer Documentation
 https://developer.apple.com/documentation/webkit/wkwebview/takesnapshot(with:completionhandler:)

●WKSnapshotConfiguration | Apple Developer Documentation
 https://developer.apple.com/documentation/webkit/wksnapshotconfiguration

AR関連

AR周りのところを調査をして出てきた SceneKit を用いた処理があったのですが、WWDC 2025 で deprecated となっているようでした。例えば見かけたものは、以下がありました。

  • AR で配置する長方形: SCNPlane
  • 画像を平面に貼る: SCNMaterial.diffuse.contents
  • 3Dオブジェクトとして管理: SCNNode
  • タップ位置から平面を検索: ARSCNView.raycastQuery()

上記の SCNPlane を公式ドキュメントで見てみると、Deprecated と明記されています。

●SCNPlane | Apple Developer Documentation
 https://developer.apple.com/documentation/scenekit/scnplane

2026-07-26_12-46-47.jpg

●ARSCNView | Apple Developer Documentation
 https://developer.apple.com/documentation/arkit/arscnview

今は、以下の RealityKit を用いた実装にするのが良さそうです。

●RealityKit | Apple Developer Documentation
 https://developer.apple.com/documentation/realitykit

ざっくり調べてみたところ、以下のような構成になるようでした。

【SceneKit】
ARSCNView → SCNNode → SCNPlane → SCNMaterial

【RealityKit】
ARView → AnchorEntity → ModelEntity
                      ├─ MeshResource
                      └─ UnlitMaterial

AR関連でトラッキングや平面検出という部分もありますが、それについては以下が出てきました。

  • ARトラッキング設定: ARWorldTrackingConfiguration
  • 水平・垂直面の検出指定: planeDetection

●ARWorldTrackingConfiguration | Apple Developer Documentation
 https://developer.apple.com/documentation/arkit/arworldtrackingconfiguration

●planeDetection | Apple Developer Documentation
 https://developer.apple.com/documentation/arkit/arobjectscanningconfiguration/planedetection

タップ・ピンチ操作関連

以下は、タップ・ピンチ操作関連です。

  • タップ検出: UITapGestureRecognizer
  • ピンチ検出: UIPinchGestureRecognizer
  • タップ座標取得: gesture.location(in:)

●UITapGestureRecognizer | Apple Developer Documentation
 https://developer.apple.com/documentation/uikit/uitapgesturerecognizer

●UIPinchGestureRecognizer | Apple Developer Documentation
 https://developer.apple.com/documentation/uikit/uipinchgesturerecognizer

●location(in:) | Apple Developer Documentation
 https://developer.apple.com/documentation/UIKit/UIGestureRecognizer/location(in:)

気になった情報

以下は、冒頭のアプリ試作に用いてないものの、調査の過程で見かけて気になったもののメモです。

AR関連の部分で気になったこと

平面検出に関連して、それが床であるかや壁であるかなどを区別できるようでした(※ 今回は特に利用していないです)。

●ARPlaneAnchor.Classification | Apple Developer Documentation
 https://developer.apple.com/documentation/arkit/arplaneanchor/classification-swift.enum

2026-07-26_13-05-11.jpg

その他

直近で行った iOSアプリの試作など

直近で以下の内容を試したり、それに関する記事を書いたりしていました。

●LiDAR と RGBカメラ のそれぞれの取得データを 1画面で表示する iOSアプリ を雑に作った時のメモ(調査・検証の一部は途中段階) - Qiita
 https://qiita.com/youtoy/items/997476e2696dd6c2fa05

今回の内容も上記の記事も、今まで気になっていて技術情報はちょこちょこ見ていたものの、実装を試すことまではできていなかったことを、実際に試してみたというものです。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?