Unable to rotate around the Z axis in RealityKit / ARKit

Viewed 24

I'm creating an app using RealityKit and I'm having trouble rotating an element around the Z axis.

The element is an eyelid - which is essentially a sphere cut in half. My hope is to update the Z axis so it rotates. But no matter what I do, it does not move at all.

I am able to successfully rotate it around the x and y axis. But the z-axis seems to be stuck.

robot.topLidL?.orientation = simd_mul(
            simd_quatf(angle: deg2rad(-80 + (130 * eyeBlinkLeft)), axis: [1, 0, 0]), // this line handles the blinking as expected
            simd_quatf(angle: deg2rad((130 * browLeft) - (60 * browInnerUp)), axis: [0, 0, 1])) // this should rotate the eyelid around the z axis but it does not move at all.

I get 0 movement at all around the z-axis. I confirmed that I am getting values from browLeft and browInnerUp. I looked at the assets in Reality Composer and all looks well. An interesting note is if I change the Z value in Reality Composer, I do see the rotation in Composer as I would expect. But when I hardcode that value in my code, it still doesn't change rotation position.

I also just tried

robot.topLidL?.orientation = simd_quatf(angle: deg2rad((130 * browLeft) - (60 * browInnerUp)), axis: [0, 0, 1])

and that doesn't work either. I even just hardcoded:

robot.topLidL?.orientation = simd_quatf(angle: deg2rad(50), axis: [0, 0, 1])

And even that didn't cause any change.

Simply put, I'm getting no movement at all around the z-axis.

Do you have any ideas why this might be the case?

Additional code:

private func deg2rad(_ value: Float) -> Float {
        value * .pi / 180
    }
0 Answers
Related