我想为 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, 1, 2, 3 );
face.normal.copy( normal );
face.vertexNormals.push( normal.clone(), normal.clone(), normal.clone(), normal.clone() );
this.faces.push( face );
var uvs = [
new THREE.UV( 1.0, 0.0 ),
new THREE.UV( 0.0, 0.0 ),
new THREE.UV( 0.0, 1.0 ),
new THREE.UV( 1.0, 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;
通过应用此纹理:
我得到了这个结果:
可以做些什么来消除红点和绿点之间的失真?对于极点,一个顶点使用两次,但它可能会更好,知道吗?