UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

rotation3DEffect weird behavior

Forums > SwiftUI

I'm playing around with rotation3DEffect trying to have a text "orbiting" around an axis while having the text always facing me.

I realized I could apply rotation3DEffect twice: first time before offsetting the text so it rotates on itself and the second time after the the offsetting so it rotates around an axis with the offset as radius.

While it works with the Z axis, it doesn't work with the others. As if as soon as the angle is 90° the text has to be "flat".

Can't figure out why. I looked everywhere and saw no mention of this so I might have missed something. Any help appreciated thanks!

struct ContentView: View {
    @State private var rot = 0.0
    var body: some View {
            VStack{
                  Text("BLABL fsdfsqfsfq ZBLA ")
                        .frame(width: 40)                 
                        .rotation3DEffect(.degrees(-rot), axis: (x: 0, y: 0, z: 1), perspective: 0.10)
                        .offset(x: 0, y: 180)
                        .rotation3DEffect(.degrees(rot), axis: (x: 0, y: 0, z: 1), perspective: 0.10)

                  Slider(value: $rot, in: 0...360).frame(width: 300).padding(.vertical, -10)
               }

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.