Enabling Gestures in Realitykit

How to installGestures on Reality Composer

Reality Composer 1.5 allows you implement gestures only for running animated behaviours. At the moment there's no way to turn on Tap, Rotation or Pinch gestures in Reality Composer. Only via RealityKit, as you indicated.

arView.installGestures([.all], for: entity)

Change a rotation of AnchorEntity in RealityKit

Try move(...) instance method:

import UIKit
import RealityKit
import SceneKit

class ViewController: UIViewController {

@IBOutlet var arView: ARView!

override func viewDidLoad() {
super.viewDidLoad()

let box = try! Experience.loadBox()
let entity = box.steelBox!

DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {

let currentMatrix = entity.transform.matrix

// Nothing prevents you from using even SceneKit's matrix methods
let rotation = simd_float4x4(SCNMatrix4MakeRotation(.pi/2, 0,1,0))

let transform = simd_mul(currentMatrix, rotation)
entity.move(to: transform, relativeTo: nil, duration: 3.0)
}
arView.scene.anchors.append(box)
}
}

Interact with several ModelEntities

Of course you can. Just create a parent entity for two or more children.

let parentEntity = Entity()
parentEntity.addChild(childEntity01)
parentEntity.addChild(childEntity02)

arView.installGestures([.all], for: parentEntity as! Entity & HasCollision)


Related Topics



Leave a reply



Submit