diff --git a/Sources/Polygon.swift b/Sources/Polygon.swift index fc30a395..f27c5193 100644 --- a/Sources/Polygon.swift +++ b/Sources/Polygon.swift @@ -161,9 +161,9 @@ public extension Polygon { vertices.contains(where: { $0.texcoord != .zero }) } - /// A Boolean value that indicates whether the polygon includes vertex normals that differ from the face normal. + /// A Boolean value that indicates whether the polygon includes vertex normals. var hasVertexNormals: Bool { - vertices.contains(where: { !$0.normal.isEqual(to: plane.normal) && $0.normal != .zero }) + vertices.contains(where: { $0.normal != .zero }) } /// A Boolean value that indicates whether the polygon includes vertex colors. diff --git a/Tests/MeshExportTests.swift b/Tests/MeshExportTests.swift index e25a342a..e124f5c9 100644 --- a/Tests/MeshExportTests.swift +++ b/Tests/MeshExportTests.swift @@ -193,12 +193,19 @@ class MeshExportTests: XCTestCase { vt 1 0 vt 0 0 - f 1/1 2/2 3/3 4/4 - f 5/1 6/2 7/3 8/4 - f 7/1 4/2 3/3 8/4 - f 5/1 2/2 1/3 6/4 - f 6/1 1/2 4/3 7/4 - f 2/1 5/2 8/3 3/4 + vn 1 0 0 + vn -1 0 0 + vn 0 1 0 + vn 0 -1 0 + vn 0 0 1 + vn 0 0 -1 + + f 1/1/1 2/2/1 3/3/1 4/4/1 + f 5/1/2 6/2/2 7/3/2 8/4/2 + f 7/1/3 4/2/3 3/3/3 8/4/3 + f 5/1/4 2/2/4 1/3/4 6/4/4 + f 6/1/5 1/2/5 4/3/5 7/4/5 + f 2/1/6 5/2/6 8/3/6 3/4/6 """) } diff --git a/Tests/SceneKitTests.swift b/Tests/SceneKitTests.swift index d5edbe82..5cd02b52 100644 --- a/Tests/SceneKitTests.swift +++ b/Tests/SceneKitTests.swift @@ -111,15 +111,15 @@ class SceneKitTests: XCTestCase { func testExportCube() { let cube = Mesh.cube() let geometry = SCNGeometry(polygons: cube) - XCTAssertEqual(geometry.sources.count, 2) - XCTAssertEqual(geometry.sources.first?.vectorCount, 20) + XCTAssertEqual(geometry.sources.count, 3) + XCTAssertEqual(geometry.sources.first?.vectorCount, 24) } func testExportCubeWithoutTexcoords() { let cube = Mesh.cube().withoutTexcoords() let geometry = SCNGeometry(polygons: cube) - XCTAssertEqual(geometry.sources.count, 1) - XCTAssertEqual(geometry.sources.first?.vectorCount, 8) + XCTAssertEqual(geometry.sources.count, 2) + XCTAssertEqual(geometry.sources.first?.vectorCount, 24) } func testExportSphere() { @@ -136,13 +136,6 @@ class SceneKitTests: XCTestCase { XCTAssertEqual(geometry.sources.first?.vectorCount, 151) } - func testExportSphereWithoutTexcoordsOrNormals() { - let sphere = Mesh.sphere().withoutTexcoords().smoothingNormals(forAnglesGreaterThan: .zero) - let geometry = SCNGeometry(polygons: sphere) - XCTAssertEqual(geometry.sources.count, 1) - XCTAssertEqual(geometry.sources.first?.vectorCount, 114) - } - func testExportMeshWithColors() throws { let mesh = Mesh.lathe(.curve([ .point(.unitY, color: .red),