From ec9e24d3204e86ecb34d1bd4d079469fdace70ab Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Fri, 14 Oct 2022 15:06:06 -0400 Subject: [PATCH] remove normal generation for in favor of flat shading --- src/kiri/stack.js | 1 - src/kiri/widget.js | 16 +++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/kiri/stack.js b/src/kiri/stack.js index 5870c0fa..f960cd46 100644 --- a/src/kiri/stack.js +++ b/src/kiri/stack.js @@ -257,7 +257,6 @@ function createStandardMaterial(color, flat) { transparent: color.opacity != 1, opacity: color.opacity || 1, color: color.face, - flatShading: true, side: flat ? THREE.DoubleSide : THREE.FrontSide }); } diff --git a/src/kiri/widget.js b/src/kiri/widget.js index 81126227..adf35f0b 100644 --- a/src/kiri/widget.js +++ b/src/kiri/widget.js @@ -195,16 +195,16 @@ class Widget { if (this.mesh) { let geo = this.mesh.geometry; geo.setAttribute('position', new THREE.BufferAttribute(vertices, 3)); - geo.setAttribute('normal', undefined); + // geo.setAttribute('normal', undefined); geo.attributes.position.needsUpdate = true; - geo.computeVertexNormals(); + // geo.computeVertexNormals(); this.meta.vertices = vertices.length / 3; this.points = null; return this; } else { let geo = new THREE.BufferGeometry(); geo.setAttribute('position', new THREE.BufferAttribute(vertices, 3)); - geo.setAttribute('normal', undefined); + // geo.setAttribute('normal', undefined); this.meta.vertices = vertices.length / 3; this.points = null; return this.loadGeometry(geo); @@ -293,7 +293,8 @@ class Widget { shininess: 120, transparent: true, opacity: solid_opacity, - clipIntersection: false + clipIntersection: false, + flatShading: true }), new THREE.MeshPhongMaterial({ side: THREE.DoubleSide, @@ -301,11 +302,12 @@ class Widget { specular: 0x202020, shininess: 100, transparent: true, - opacity: solid_opacity + opacity: solid_opacity, + flatShading: true }), ]); mesh.renderOrder = 1; - geometry.computeVertexNormals(); + // geometry.computeVertexNormals(); geometry.addGroup(0, Infinity, 0); // mesh.castShadow = true; // mesh.receiveShadow = true; @@ -619,7 +621,7 @@ class Widget { arr[i*3+8] = z; } pos.needsUpdate = true; - geo.computeVertexNormals(); + // geo.computeVertexNormals(); ot.mirror = !ot.mirror; this.setModified(); this.points = null;