Kaynağa Gözat

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

alteredq 13 yıl önce
ebeveyn
işleme
5d5f92d641

+ 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.count = 0;
+
 		this.hasPos = false;
 		this.hasNormal = 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 ++ )
 			this.positionArray[ i ] = 0.0;
 
+		this.hasPos = true;
+		this.hasNormal = true;
+
+		if ( this.enableUvs ) {
+
+			this.hasUv = true;
+
+		}
+
 		renderCallback( this );
 
 	};

+ 6 - 0
examples/webgl_marching_cubes.html

@@ -316,6 +316,12 @@
 				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" :
 			{
 				m: new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 1, map: texture, perPixel: true } ),