I am starting with a default ARKit program that just displays the Steel Box. When I add code to rotate the box 45° it also shrinks the box along the x axis. The cube gets flattened about half way.
Is there a way to rotate without it scaling at the same time?
Code Block import UIKit import RealityKit class ViewController: UIViewController { @IBOutlet var arView: ARView! override func viewDidLoad() { super.viewDidLoad() // Load the "Box" scene from the "Experience" Reality File let boxAnchor = try! Experience.loadBox() // Add the box anchor to the scene arView.scene.anchors.append(boxAnchor) if let box = boxAnchor.findEntity(named: "lid") { let radians = -45.0 * Float.pi / 180.0 box.transform.rotation += simd_quatf(angle: radians, axis: SIMD3<Float>(1,0,0)) } } }
I have tried adding the "if let box =" part to above the "arView.scene.anchors.append(boxAnchor)" part and that doesn't help.
I decided to go for the default code and work my way up to getting this to work with a touch to the box on the screen. Touching anywhere else should not rotate the box. Setting up a rotation animation inside Reality Composer is working, but I want a tap to rotate and a another tap to un-rotate. It will be opening a lid and closing a lid.
I am on Catalina and xCode12.
I have also noticed that the box is referred to as an object, entity, or element in the different pages of the documentation. This makes it difficult to we search for the issue I am having.