RealityKit, unable to rotate Entity/ AnchorEntity object!

Hey

I'm out of ideas... here is my code:

let radians = val * Float.pi / 180

/// object.mEntity = usd Entity.loadModel()
object.mEntity.orientation += simd_quatf(angle: radians, axis: SIMD3<Float>(1,0,0)

object.mEntity.transform.rotation += simd_quatf(angle: radians, axis: SIMD3<Float>(1,0,0)

object.anchorParent.transform.rotation+= simd_quatf(angle: radians, axis: SIMD3<Float>(1,0,0)

the object is a struct that holds my Entity + anchor it was attached to. I have few anchors in general, like the "initial click" position anchor, then shadow anchor on top of it, and then model entity after that. So that I can move the model with shadow/etc.

In any case, I cant rotate it, I always get "weird" rotation as output. Have a look at video > https://www.youtube.com/watch?v=9_WOfLivKvI&ab_channel=DariuszM%C4%85kowski

Answered by Dariusz1989 in 679398022

Hey Thank toy for the ping! I ended up getting some help from Andy Fedoroff on StackOverflow where he suggested using *= instead of +=, seems to work! I've no idea why & diving more into matrix operations now.

Thank you for your post & help

Final solution = object.mEntity.transform.rotation *= simd_quatf(angle: radians, axis: SIMD3<Float>(1,0,0)

Hi! you shouldn't need to update the anchor's parent. Can you try adding something like:

object.mEntity.orientation = simd_quatf(angle: radians, axis: SIMD3<Float>(1,0,0)

You will need to update radians every frame, which you can by updating val. simd_quatf works a bit differently from something like simd_float3, you shouldn't be adding multiple simd_quatf values together.

Accepted Answer

Hey Thank toy for the ping! I ended up getting some help from Andy Fedoroff on StackOverflow where he suggested using *= instead of +=, seems to work! I've no idea why & diving more into matrix operations now.

Thank you for your post & help

Final solution = object.mEntity.transform.rotation *= simd_quatf(angle: radians, axis: SIMD3<Float>(1,0,0)

RealityKit, unable to rotate Entity/ AnchorEntity object!
 
 
Q