From 6186c60cd9d8b4a347b0bca303633d7b8cc5c4fd Mon Sep 17 00:00:00 2001 From: Sukolsak Sakshuwong <sukolsak@gmail.com> Date: Sat, 8 May 2021 00:03:42 -0700 Subject: [PATCH] fix normals in sheet caps --- src/mol-geo/geometry/mesh/builder/sheet.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/mol-geo/geometry/mesh/builder/sheet.ts b/src/mol-geo/geometry/mesh/builder/sheet.ts index 2de26f847..a0fc0fd8a 100644 --- a/src/mol-geo/geometry/mesh/builder/sheet.ts +++ b/src/mol-geo/geometry/mesh/builder/sheet.ts @@ -43,14 +43,14 @@ function addCap(offset: number, state: MeshBuilder.State, controlPoints: ArrayLi const { vertices, normals, indices } = state; const vertexCount = vertices.elementCount; - v3fromArray(verticalLeftVector, normalVectors, offset); - v3scale(verticalLeftVector, verticalLeftVector, leftHeight); + v3fromArray(tA, normalVectors, offset); + v3scale(verticalLeftVector, tA, leftHeight); + v3scale(verticalRightVector, tA, rightHeight); - v3fromArray(verticalRightVector, normalVectors, offset); - v3scale(verticalRightVector, verticalRightVector, rightHeight); + v3fromArray(tB, binormalVectors, offset); + v3scale(horizontalVector, tB, width); - v3fromArray(horizontalVector, binormalVectors, offset); - v3scale(horizontalVector, horizontalVector, width); + v3cross(normalVector, tB, tA); v3fromArray(positionVector, controlPoints, offset); @@ -73,8 +73,6 @@ function addCap(offset: number, state: MeshBuilder.State, controlPoints: ArrayLi v3copy(verticalVector, verticalLeftVector); } - v3cross(normalVector, horizontalVector, verticalVector); - for (let i = 0; i < 4; ++i) { caAdd3(normals, normalVector[0], normalVector[1], normalVector[2]); } -- GitLab