我想给一个THREE.js球体的每个面都是它自己的纹理.所以我让SphereGeometry计算顶点并使用面的顶点将每个面转换为PlaneGeometry.
THREE.SpherePlaneGeometry = function ( v1,v2,v3,v4 ) { THREE.Geometry.call( this ); var normal = new THREE.Vector3( 0,1,0 ); this.vertices.push( v1.clone() ); this.vertices.push( v2.clone() ); this.vertices.push( v3.clone() ); this.vertices.push( v4.clone() ); var face = new THREE.Face4( 0,2,3 ); face.normal.copy( normal ); face.vertexNormals.push( normal.clone(),normal.clone(),normal.clone() ); this.faces.push( face ); var uvs = [ new THREE.UV( 1.0,0.0 ),new THREE.UV( 0.0,1.0 ),new THREE.UV( 1.0,]; this.faceVertexUvs[ 0 ].push( uvs ); };
确保以后使用返回的几何体运行所有这些:
geometry.computeCentroids(); geometry.computeFaceNormals(); geometry.verticesNeedUpdate = true; geometry.uvsNeedUpdate = true; geometry.normalsNeedUpdate = true; geometry.tangentsNeedUpdate = true; geometry.elementsNeedUpdate = true; geometry.dynamic = true;
通过应用此纹理:
我得到了这个结果:
如何消除红点和绿点之间的失真?对于极点,一个顶点使用两次,但它可能更好,任何想法?