浏览代码

Fixed MarchingCubes bug introduced by previous commit. Added flat shaded material to marching cubes example.

alteredq 13 年之前
父节点
当前提交
5d5f92d641
共有 2 个文件被更改,包括 16 次插入0 次删除
  1. 10 0
      examples/js/MarchingCubes.js
  2. 6 0
      examples/webgl_marching_cubes.html

+ 10 - 0
examples/js/MarchingCubes.js

@@ -52,6 +52,7 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs ) {
 
 
 		this.maxCount = 4096; // TODO: find the fastest size for this buffer
 		this.maxCount = 4096; // TODO: find the fastest size for this buffer
 		this.count = 0;
 		this.count = 0;
+
 		this.hasPos = false;
 		this.hasPos = false;
 		this.hasNormal = false;
 		this.hasNormal = false;
 		this.hasUv = false;
 		this.hasUv = false;
@@ -394,6 +395,15 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs ) {
 		for ( var i = this.count * 3; i < this.positionArray.length; i ++ )
 		for ( var i = this.count * 3; i < this.positionArray.length; i ++ )
 			this.positionArray[ i ] = 0.0;
 			this.positionArray[ i ] = 0.0;
 
 
+		this.hasPos = true;
+		this.hasNormal = true;
+
+		if ( this.enableUvs ) {
+
+			this.hasUv = true;
+
+		}
+
 		renderCallback( this );
 		renderCallback( this );
 
 
 	};
 	};

+ 6 - 0
examples/webgl_marching_cubes.html

@@ -316,6 +316,12 @@
 				h: 0, s: 0, v: 1
 				h: 0, s: 0, v: 1
 			},
 			},
 
 
+			"flat" :
+			{
+				m: new THREE.MeshPhongMaterial( { color: 0x000000, specular: 0x111111, shininess: 1, shading: THREE.FlatShading, perPixel: true } ),
+				h: 0, s: 0, v: 1
+			},
+
 			"textured" :
 			"textured" :
 			{
 			{
 				m: new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 1, map: texture, perPixel: true } ),
 				m: new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 1, map: texture, perPixel: true } ),