From aeac9a80ef3fa6291a6627e96f6d956756e2f237 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Fri, 6 Oct 2017 22:21:31 -0700 Subject: [PATCH] fix nurbs rendering --- web/app/3d/scene/brep-scene-object.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/web/app/3d/scene/brep-scene-object.js b/web/app/3d/scene/brep-scene-object.js index ccba998b..41aa74ff 100644 --- a/web/app/3d/scene/brep-scene-object.js +++ b/web/app/3d/scene/brep-scene-object.js @@ -104,7 +104,11 @@ export function triangulateToThree(shell, geom) { const polygons = brepTess(brepFace); const stitchedSurface = brepFace.data[FACE_CHUNK]; const nurbs = stitchedSurface ? stitchedSurface.origin : undefined; - let normalOrNormals = threeV(brepFace.surface.normalInMiddle()); + const isPlane = brepFace.surface.data.degree === 1; + let normalOrNormals; + if (isPlane) { + normalOrNormals = threeV(brepFace.surface.normalInMiddle()); + } for (let p = 0; p < polygons.length; ++p) { const off = geom.vertices.length; const poly = polygons[p]; @@ -119,16 +123,8 @@ export function triangulateToThree(shell, geom) { const b = i - 1 + off; const c = i + off; - if (nurbs && SMOOTH_RENDERING) { - function normal(v) { - const uv = nurbs.closestParam(v.data()); - const vec = new THREE.Vector3(); - vec.set.apply(vec, nurbs.normal(uv[0], uv[1])); - vec.normalize(); - return vec; - } - - normalOrNormals = [firstVertex, poly[i - 1], poly[i]].map(v => normal(v)); + if (!isPlane) { + normalOrNormals = [firstVertex, poly[i - 1], poly[i]].map(v => brepFace.surface.normal(v)); } const face = new THREE.Face3(a, b, c, normalOrNormals); addFace(face);