In my code, I am currently loading an Entity using the .loadAsync(named: String)
method, then adding to my existing AnchorEntity
. As a test, I am then rotating my Entity 90°, and would like to determine how to then get the current angle of rotation.
The long-term intent is that I am going to allow users to rotate a model, but want to limit the rotation to a certain degree (I.E., the user can rotate the pitch of the model to 90° or -90°, but no further than that). Without being able to know the current angle of rotation for the Entity, I am unsure what logic I could use to limit this.
Entity.loadAsync(named: "myModel.usdz")
.receive(on: RunLoop.main)
.sink { completion in
// ...
} receiveValue: { [weak self] entity in
guard let self = self else { return }
self.objectAnchor.addChild(entity)
scene.addAnchor(objectAnchor)
let transform = Transform(pitch: .pi / 2,
yaw: .zero,
roll: .zero)
entity.setOrientation(transform.rotation,
relativeTo: nil)
print(entity.orientation)
// Sample Output: simd_quatf(real: 0.7071069,
// imag: SIMD3<Float>(0.7071067, 0.0, 0.0))
}
.store(in: &subscriptions)
I would have expected entity.orientation
to give me something like 90.0
or 1.57
(.pi / 2
), but unsure how I can get the current rotation of the Entity in a form that would align with expected angles.