浏览代码

Compute flat normals when detail is zero

WestLangley 8 年之前
父节点
当前提交
cd71783f75
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      src/geometries/PolyhedronGeometry.js

+ 10 - 1
src/geometries/PolyhedronGeometry.js

@@ -74,7 +74,16 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 	this.addAttribute( 'position', new Float32BufferAttribute( vertexBuffer, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( vertexBuffer.slice(), 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvBuffer, 2 ) );
-	this.normalizeNormals();
+
+	if ( detail === 0 ) {
+
+		BufferGeometry.prototype.computeVertexNormals.call( this ); // flat normals
+
+	} else {
+
+		this.normalizeNormals(); // smooth normals
+
+	}
 
 	// helper functions