I have found out that .rotation is not working for me and I can use .orientation for setting the model in 3D space. I added the toy_biplane.usdz file downloaded from Apple into the Project Navigator. Then I started messing with the code. And reading more and messing more. This is where I am for now. I commented out things as I went along, just in case...
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()
let planeAnchor = AnchorEntity(plane: .horizontal)
// Add the box anchor to the scene
arView.scene.anchors.append(planeAnchor)
// if let box = boxAnchor.findEntity(named: "lid") {
// let radians = -45.0 * Float.pi / 180.0
// box.transform.rotation += simd_quatf(angle: radians * 0, axis: SIMD3<Float>(1,0,0))
// }
let biplane = try? Entity.load(named: "toy_biplane.usdz")
planeAnchor.addChild(biplane!)
// var flyingBiplane = biplane?.transform
let radians = 90.0 * Float.pi / 180.0
biplane?.transform.translation += SIMD3<Float>(0.0, 1.0, 0.0) // This is Meters!!! not CM.
// biplane?.transform.rotation += simd_quatf(angle: radians, axis: SIMD3<Float>(0,1,0))
biplane?.orientation = simd_quatf(angle: radians, axis: SIMD3(x: 0, y: 1, z: 0))
biplane?.transform.scale *= 0.5
}
}
I am starting to get the result I am looking for.
Post
Replies
Boosts
Views
Activity
Greetings, In Blender's export window for USDZ where you name the file, on the right hand side there are some options. Depending upon what I am doing I put check marks in Export Materials and Bake Textures. I usually end up with something close to what I want. Sometimes the textures just don't look properly in Reality Composer.