Skip to content

Commit 211a109

Browse files
committed
fix Perspective Not Being Applied
1 parent f6ec16a commit 211a109

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

Diff for: Sources/Decomposed/CATransform3DExtensions.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public extension CATransform3D {
256256
set {
257257
var decomposed = _decomposed()
258258
decomposed.perspective = newValue.storage
259-
self = CATransform3D(_decomposed().recomposed())
259+
self = CATransform3D(decomposed.recomposed())
260260
}
261261
}
262262

Diff for: Tests/DecomposedTests/DoubleTests.swift

+12-3
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,19 @@ final class DoubleTests: XCTestCase {
9494

9595
func testSkew() {
9696
// CA doesn't really provide any default Skew manipulations so, just make sure that the skew works as intended.
97-
let transform1 = CATransform3DIdentity.skewedBy(XY: 0.25, XZ: 0.25, YZ: 0.25)
98-
XCTAssertEqual(transform1.m21, 0.25, accuracy: CGFloat(SupportedAccuracy))
97+
let transform1 = CATransform3DIdentity.skewedBy(XY: 0.20, XZ: 0.25, YZ: 0.30)
98+
XCTAssertEqual(transform1.m21, 0.20, accuracy: CGFloat(SupportedAccuracy))
9999
XCTAssertEqual(transform1.m31, 0.25, accuracy: CGFloat(SupportedAccuracy))
100-
XCTAssertEqual(transform1.m32, 0.25, accuracy: CGFloat(SupportedAccuracy))
100+
XCTAssertEqual(transform1.m32, 0.30, accuracy: CGFloat(SupportedAccuracy))
101+
}
102+
103+
func testPerspective() {
104+
// CA doesn't really provide any default Skew manipulations so, just make sure that the skew works as intended.
105+
let transform1 = CATransform3DIdentity.applyingPerspective(m14: 0.11, m24: 0.22, m34: 0.33, m44: 0.44)
106+
XCTAssertEqual(transform1.m14, 0.11, accuracy: CGFloat(SupportedAccuracy))
107+
XCTAssertEqual(transform1.m24, 0.22, accuracy: CGFloat(SupportedAccuracy))
108+
XCTAssertEqual(transform1.m34, 0.33, accuracy: CGFloat(SupportedAccuracy))
109+
XCTAssertEqual(transform1.m44, 0.44, accuracy: CGFloat(SupportedAccuracy))
101110
}
102111

103112
func testDecompose() {

Diff for: Tests/DecomposedTests/FloatTests.swift

+9
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ final class FloatTests: XCTestCase {
100100
XCTAssertEqual(transform1.m32, 0.25, accuracy: CGFloat(SupportedAccuracy))
101101
}
102102

103+
func testPerspective() {
104+
// CA doesn't really provide any default Skew manipulations so, just make sure that the skew works as intended.
105+
let transform1 = CATransform3DIdentity.applyingPerspective(m14: 0.11, m24: 0.22, m34: 0.33, m44: 0.44)
106+
XCTAssertEqual(transform1.m14, 0.11, accuracy: CGFloat(SupportedAccuracy))
107+
XCTAssertEqual(transform1.m24, 0.22, accuracy: CGFloat(SupportedAccuracy))
108+
XCTAssertEqual(transform1.m34, 0.33, accuracy: CGFloat(SupportedAccuracy))
109+
XCTAssertEqual(transform1.m44, 0.44, accuracy: CGFloat(SupportedAccuracy))
110+
}
111+
103112
func testDecompose() {
104113
let translationTransform = CATransform3DMakeTranslation(1.0, 2.0, 3.0)
105114
let decomposedTranslationTransform = translationTransform.decomposed()

0 commit comments

Comments
 (0)