Javascript 如何使用three.js在球体上绘制圆弧

Javascript 如何使用three.js在球体上绘制圆弧,javascript,3d,geometry,three.js,Javascript,3d,Geometry,Three.js,在2点之间的球体上画圆弧有些困难。 我的做法是: 以球体半径从0开始在P1和P2之间绘制一个角度的圆弧 绕X轴旋转 绕Z轴旋转 绕Y轴旋转 我的职能是: // compute angle between p1 and p2 var angle = Math.acos(p1.dot(p2)/(p1.length()*p2.length())); // create arc var geometry = new THREE.CircleGeometry(earthRadius, earthBan

在2点之间的球体上画圆弧有些困难。 我的做法是:

  • 以球体半径从0开始在P1和P2之间绘制一个角度的圆弧
  • 绕X轴旋转
  • 绕Z轴旋转
  • 绕Y轴旋转
我的职能是:

// compute angle between p1 and p2
var angle = Math.acos(p1.dot(p2)/(p1.length()*p2.length()));
// create arc
var geometry = new THREE.CircleGeometry(earthRadius, earthBands, 0, angle);
// remove center vertex
geometry.vertices.splice(0,1);
// rotate around x axis
geometry.applyMatrix(new THREE.Matrix4().makeRotationX(Math.atan((p2.z-p1.z) / (p2.y-p1.y))));
// rotate around z axis
geometry.applyMatrix(new THREE.Matrix4().makeRotationZ(-Math.atan(p1.y / p1.x)));
// rotate around y axis
geometry.applyMatrix(new THREE.Matrix4().makeRotationY(Math.atan(p1.z / p1.y)));
这是在球体上画圆弧的好方法吗?
为什么圆弧旋转不正确?

请在此处查找球体贴图的正确方程式。顺便问一下,您现在的输出是什么(它有什么问题)?图像将是最好的…如果您经常使用角度公式,您可以使用THREE.Vector3方法,即:
var angle=p1.angleTo(p2)