1

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
    }
Alan Scarpa
  • 3,352
  • 4
  • 26
  • 48
  • Hi Alan. You should rotate an eyelid about the X axis to open/close it, not Z axis, shouldn't you? – Andy Jazz Sep 06 '22 at 06:22
  • 1
    @AndyJazz Yep, and I'm able to do that successfully. I'm rotating aroudn the z-axis just a little bit so it tilts inward/outward in a cartoonish way to show anger/sadness. – Alan Scarpa Sep 06 '22 at 20:20
  • 1
    @AndyJazz I know this a roundabout way, but your help from this question has led to a new question that I would love if you had a look: https://stackoverflow.com/questions/75573165/custom-arkit-object-made-in-blender-not-appearing-on-screen-where-expected – Alan Scarpa Feb 26 '23 at 15:54

0 Answers0