rotation3DEffect(_:axis:anchor:)
Rotates content by an angle about an axis that you specify as a tuple of elements.
Declaration
func rotation3DEffect(_ angle: Angle, axis: (x: CGFloat, y: CGFloat, z: CGFloat), anchor: UnitPoint3D = .center) -> some VisualEffect
Parameters
- angle:
The angle by which to rotate the content.
- axis:
The axis of rotation, specified as a tuple with named elements for each of the three spatial dimensions.
- anchor:
The unit point within the content about which to perform the rotation. The default value is Center.
Return Value
A rotation effect.
Discussion
This effect causes the content to appear rotated, but doesn’t change the content’s frame. The following code applies a rotation of 45° about the y-axis, using the default anchor point at the center of the content:
Model3D(named: "robot")
.visualEffect { content, geometryProxy in
content
.rotation3DEffect(.degrees(45), axis: (x: 0, y: 1, z: 0))
}Model3D(named: "robot")
.rotation3DEffect(Rotation3D(.init(degrees: 45), axis: .y)