Pārlūkot izejas kodu

fixed UVs removal in .mergeVertices()

zz85 13 gadi atpakaļ
vecāks
revīzija
84d1be3618

+ 1 - 1
examples/webgl_geometries2.html

@@ -19,7 +19,7 @@
 
 		<script src="js/Detector.js"></script>
 		<script src="js/Stats.js"></script>
-
+		<script src="../src/core/Geometry.js"></script>
 		<script src="js/CurveExtras.js"></script>
 
 		<script src="js/UVsUtils.js"></script>

+ 8 - 3
src/core/Geometry.js

@@ -574,7 +574,7 @@ THREE.Geometry.prototype = {
 		var precisionPoints = 4; // number of decimal points, eg. 4 for epsilon of 0.0001
 		var precision = Math.pow( 10, precisionPoints );
 		var i,il, face;
-		var abcd = 'abcd', o, k;
+		var abcd = 'abcd', o, k, j, jl, u;
 
 		for ( i = 0, il = this.vertices.length; i < il; i ++ ) {
 
@@ -623,8 +623,12 @@ THREE.Geometry.prototype = {
 						// console.log('faces', face.a, face.b, face.c, face.d, 'dup at', k);
 						o.splice(k, 1);
 						this.faces[ i ] = new THREE.Face3(o[0], o[1], o[2]);
-						this.faceVertexUvs[0][i].splice(k, 1);
+						for (j=0,jl=this.faceVertexUvs.length;j<jl;j++) {
+							u = this.faceVertexUvs[j][i];
+							if (u) u.splice(k, 1);
+						}
 						
+						break;
 					}
 				}
 
@@ -634,8 +638,9 @@ THREE.Geometry.prototype = {
 		}
 
 		// Use unique set of vertices
-
+		var diff = this.vertices.length - unique.length;
 		this.vertices = unique;
+		return diff;
 
 	}
 

+ 3 - 2
src/extras/geometries/ParametricGeometry.js

@@ -63,8 +63,9 @@ THREE.ParametricGeometry = function ( slices, stacks, func ) {
 	console.log(this);
 
 	// magic bullet
-	this.mergeVertices();
-
+	var diff = this.mergeVertices();
+	console.log('removed ', diff, ' vertices by merging')
+	
 	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeVertexNormals();