瀏覽代碼

Fixed uvs creating on Sphere.
Fixed uv handling on Projector (forcing channel 0 by now)

Mr.doob 14 年之前
父節點
當前提交
f03db768cb
共有 3 個文件被更改,包括 16 次插入12 次删除
  1. 1 1
      examples/misc_ubiquity_test.html
  2. 4 2
      src/extras/geometries/Sphere.js
  3. 11 9
      src/renderers/Projector.js

+ 1 - 1
examples/misc_ubiquity_test.html

@@ -97,7 +97,7 @@
 		<script type="text/javascript" src="../src/extras/geometries/TorusKnot.js"></script>
 		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
 		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
-		
+
 		<script type="text/javascript" src="obj/Qrcode.js"></script>
 
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>

+ 4 - 2
src/extras/geometries/Sphere.js

@@ -45,6 +45,8 @@ var Sphere = function ( radius, segmentsWidth, segmentsHeight ) {
 
 	var n1, n2, n3, iVerNum = aVtc.length;
 
+	this.faceVertexUvs[ 0 ] = [];
+
 	for ( j = 0; j < iVerNum; j++ ) {
 
 		var iHorNum = aVtc[ j ].length;
@@ -80,7 +82,7 @@ var Sphere = function ( radius, segmentsWidth, segmentsHeight ) {
 
 					this.faces.push( new THREE.Face3( aP1, aP2, aP3, [ new THREE.Vector3( n1.x, n1.y, n1.z ), new THREE.Vector3( n2.x, n2.y, n2.z ), new THREE.Vector3( n3.x, n3.y, n3.z ) ] ) );
 
-					this.faceVertexUvs.push( [ aP1uv, aP2uv, aP3uv ] );
+					this.faceVertexUvs[ 0 ].push( [ aP1uv, aP2uv, aP3uv ] );
 
 				}
 
@@ -95,7 +97,7 @@ var Sphere = function ( radius, segmentsWidth, segmentsHeight ) {
 
 					this.faces.push( new THREE.Face3( aP1, aP3, aP4, [ new THREE.Vector3( n1.x, n1.y, n1.z ), new THREE.Vector3( n2.x, n2.y, n2.z ), new THREE.Vector3( n3.x, n3.y, n3.z ) ] ) );
 
-					this.faceVertexUvs.push( [ aP1uv, aP3uv, aP4uv ] );
+					this.faceVertexUvs[ 0 ].push( [ aP1uv, aP3uv, aP4uv ] );
 
 				}
 

+ 11 - 9
src/renderers/Projector.js

@@ -99,7 +99,7 @@ THREE.Projector = function() {
 		objectMatrix, objectMaterials,
 		objectMatrixRotation,
 		geometry, vertices, vertex, vertexPositionScreen,
-		faces, face, faceVertexNormals, normal, v1, v2, v3, v4;
+		faces, face, faceVertexNormals, faceVertexUvs, normal, v1, v2, v3, v4;
 
 		_face3Count = 0;
 		_lineCount = 0;
@@ -192,19 +192,21 @@ THREE.Projector = function() {
 
 								}
 
-								_face3.z = _face3.centroidScreen.z;
+								faceVertexUvs = geometry.faceVertexUvs[ 0 ][ f ];
 
-								_face3.meshMaterials = objectMaterials;
-								_face3.faceMaterials = face.materials;
+								if ( faceVertexUvs ) {
 
-								if ( object.geometry.faceUvs[ f ] ) {
-
-									_face3.uvs[ 0 ] = object.geometry.faceUvs[ f ][ 0 ];
-									_face3.uvs[ 1 ] = object.geometry.faceUvs[ f ][ 1 ];
-									_face3.uvs[ 2 ] = object.geometry.faceUvs[ f ][ 2 ];
+									_face3.uvs[ 0 ] = faceVertexUvs[ 0 ];
+									_face3.uvs[ 1 ] = faceVertexUvs[ 1 ];
+									_face3.uvs[ 2 ] = faceVertexUvs[ 2 ];
 
 								}
 
+								_face3.meshMaterials = objectMaterials;
+								_face3.faceMaterials = face.materials;
+
+								_face3.z = _face3.centroidScreen.z;
+
 								renderList.push( _face3 );
 
 							}