2

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

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Dariusz
  • 960
  • 13
  • 36

1 Answers1

2

Use *= compound multiply operator instead of += compound addition.

Here is the explanation.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • 1
    Thank you lots! I got mixer up with other operations somehow and forgot this is quaternions ehh! Evil rotations. On a side note... do you know if there is a way to set working pivot position/rotation for Entity object? I need to rotate my car around either front bumper/back bumper/wheel/window/etc/etc... depending on desire. Does RealityKit offer any sort of pivoting ? – Dariusz Jun 17 '21 at 16:19
  • Nope, RealityKit 2.0 still doesn't provide a pivot. But you may use Reality Composer's methodology to rotate object around its pivot, or around a pivot of other entity. – Andy Jazz Jun 17 '21 at 16:24
  • 1
    Hey, yes true. But I'm trying to match 3D objects to physical objects. Currently, I'm thinking of having few anchors within "simulating pivots" and then rotating each of them separately to "simulate" pivot somehow. Not sure, The idea would be to place x/y/z points on physical object and then the same x/y/z points on 3d object & align them together. This is going to be an adventure! – Dariusz Jun 17 '21 at 16:26