Hello @Icemonster13
I have made some changes to your logic. Now it works once when I use left/right or up/down
for the transition from x to y-axis (or vice versa) an additional query must be made. I haven't found this yet, but I hope this helps a bit
struct HomeView: View {
@State private var isRotating: Bool = false
@State private var angle = 0.0 //: Angle = Angle(degrees: 0)
@State private var x: Double = 0.0
@State private var y: Double = 0.0
@State private var z: Double = 0.0
var body: some View {
Image(systemName: "trash")
.font(.system(size: 96))
.rotation3DEffect(
.degrees(angle),
axis: (x: x, y: y, z: z))/*,
anchor: .center,
anchorZ: 0,
perspective: 1)
*/
.animation(.easeOut(duration: 10), value: isRotating)
.gesture(DragGesture(minimumDistance: 3.0, coordinateSpace: .local)
.onEnded { value in
print(value.translation)
switch(value.translation.width, value.translation.height) {
case (...0, -30...30):
print("left swipe")
//x = 0.0
y = -1.0
//z = 0.0
angle += 360
case (0..., -30...30):
print("right swipe")
//x = 0.0
y = -1.0
//z = 0.0
angle -= 360
case (-100...100, ...0):
print("up swipe")
x = -1.0
// y = 0.0
//z = 0.0
angle -= 360
case (-100...100, 0...):
print("down swipe")
x = -1.0
// y = 0
//z = 0
angle += 360
//y = 0.0
//z = 0.0
default:
print("Do Nothing")
}
//angle += Angle(degrees: 360)
//angle += 360
isRotating.toggle()
}
)
}
}
Sorry but somehow I never get the examples transferred so nicely