RealityKit, placing object - remove placement rotation?

Hai!

When I place an object in scene, the object is always parallel(I think) to the rotation of device(ipad). How can I disable that rotation and have it align with world axis?

I'm trying to place an object/anchor in scene but every time I do it has a rotation. I can not find where the rotation is set as printing our matrices gives me 0,0,0 on rotation so I'm a little lost :

        let point = CGPoint(x: frame.midX, y: frame.midY);
        if let result = raycast(from: point, allowing: .estimatedPlane, alignment: .any).first {
            mLastObject = name
            var transform = simd_float4x4()
            transform.toIdentity()
            transform.columns.3 = result.worldTransform.columns.3
            let resultAnchor = AnchorEntity(world: transform) // world ping
            let shadow = AnchorEntity(plane: AnchoringComponent.Target.Alignment.horizontal) // shadow ping
            resultAnchor.addChild(shadow)
            scene.anchors.append(resultAnchor)
            print("result : \(resultAnchor.transform)")
            print("result2 : \(resultAnchor.orientation)")
            
            print("shadow : \(shadow.transform)")
            print("shadow2 : \(shadow.orientation)")

Perhaps, while I'm at it, how can I align object rotation to another object rotation? so they both face the same direction/axis/etc

Regards

Dariusz

Just to clarify, the shadow object has wrong rotation, and thus any of its children/geometry objects are rotated. Setting orientation to 0,etcetc does not work.

Just applying the translation component of the result transform should give you want. How is your toIdentity() method implemented, is it possible that you accidentally apply a rotation in there?

As an alternative to the simd types, you could work with RealityKit's Transform type (https://developer.apple.com/documentation/realitykit/transform). This makes it easier to access and set the translation, rotation, and scale components separately (which may also help with your second question regarding aligning the rotation of multiple objects).

RealityKit, placing object - remove placement rotation?
 
 
Q