我有完整的等矩形图像,可与Three.js配合使用:
scene = new THREE.Scene();
geometry = new THREE.SphereBufferGeometry( 500, 60, 40 );
geometry.scale(-1, 1, 1);
material = new THREE.MeshBasicMaterial({ map: texture });
mesh = new THREE.Mesh(geometry, material);
mesh.rotation.y = Math.PI;
scene.add( mesh );
但是我的图像实际上只包含180x180度(球体的一半),所以我试图在不将图像拉伸到整个球体上的情况下,将正方形纹理部分地应用到球形网格物体上。我认为这与texture.offset.xyz参数有关,但是我没有成功。虽然我可以继续填充图像以符合2x1等矩形标准,但我宁愿从处理工作流程中省去这一步。
在下面,您将找到完整的等矩形图像和我要开始使用的正方形图像。有人对如何实现这一目标有任何线索吗?谢谢!
最佳答案
SphereBufferGeometry具有更多可选参数:
SphereBufferGeometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength)
radius — sphere radius. Default is 50.
widthSegments — number of horizontal segments. Minimum value is 3, and the default is 8.
heightSegments — number of vertical segments. Minimum value is 2, and the default is 6.
phiStart — specify horizontal starting angle. Default is 0.
phiLength — specify horizontal sweep angle size. Default is Math.PI * 2.
thetaStart — specify vertical starting angle. Default is 0.
thetaLength — specify vertical sweep angle size. Default is Math.PI.
您可以使用phiStart,phiLength,thetaStart和thetaLength定义部分球体
因此,要做一个半球形,您可以尝试如下操作:
geometry = new THREE.SphereBufferGeometry( 500, 60, 40, 0, Math.PI, 0, Math.PI );
参考http://threejs.org/docs/#Reference/Extras.Geometries/SphereBufferGeometry