LoginSignup
0
0

More than 1 year has passed since last update.

大迫力の3Dオブジェクトを操作する方法

コンピュータのパワーでよりパワフルなコンテンツを

ARってなんだか難しそうな印象ありますか?

ARKitを使ってスマホでかんたん表示

実はかんたんだったりします。
AppleがARをかんたんに扱えるフレームワークを出してくれています。

手順

アップルのサイトからUSDZモデルを手に入れます。
https://developer.apple.com/jp/augmented-reality/quick-look/

ロボットという名前のUSDZファイルを読み込んでシーンに追加します。

guard let robot = try? Entity.load(named: "robot") else { return }
let anchor = AnchorEntity(plane: .horizontal) // 平面に配置する
anchor.addChild(robot)
arView.scene.addAnchor(anchor)

ロボットを100倍のスケールに大きくします。

robot.setScale([100,100,100], relativeTo: robot)

ロボットを動かします。

for animation in robot.availableAnimations {
    robot.playAnimation(animation.repeat()) // 歩行アニメーション
}

robot.move(to: Transform(translation: [0,0,20]), relativeTo: robot, duration: 4, timingFunction: .easeInOut) // 実際に移動させる

詳しいサンプルコードはこちら

ゲームや、映像、舞台インタラクションなど様々なコンテンツに

ARコンテンツを表示するのは意外とかんたんです。色々な表現の可能性を探りたいですね。

🐣


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

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

Twitter
Medium

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