Vector 如何得到一条直线的端点,旋转三次,js?

Vector 如何得到一条直线的端点,旋转三次,js?,vector,three.js,Vector,Three.js,我试图计算一条线的端点,并应用旋转,但似乎无法得到正确的结果 我目前正在以以下方式进行尝试: function createLine(x, y, z, length, zrad, xrad) { var points = [ new THREE.Vector3(0, 0, 0), new THREE.Vector3(length/8, length*0.75, 0), new THREE.Vector3(0, length, 0), ]; var splin

我试图计算一条线的端点,并应用旋转,但似乎无法得到正确的结果

我目前正在以以下方式进行尝试:

function createLine(x, y, z, length, zrad, xrad)
{
  var points = [
    new THREE.Vector3(0, 0, 0),
    new THREE.Vector3(length/8, length*0.75, 0),
    new THREE.Vector3(0, length, 0),
  ];

  var spline = new THREE.SplineCurve3(points);

  var material = new THREE.LineBasicMaterial({
      color: 0xff00f0,
  });

  var geometry = new THREE.Geometry();
  var splinePoints = spline.getPoints(numPoints);

  for(var i = 0; i < splinePoints.length; i++){
      geometry.vertices.push(splinePoints[i]);  
  }

  var line = new THREE.Line(geometry, material);

  line.position.x = x;
  line.position.y = y;
  line.position.z = z;

  line.rotateZ(zrad);
  line.rotateX(xrad);

  // This is probably not the proper way to store the length of the Line
  line.length = length;

  return line;
}

function splitLine(line){
  var lines = [];

  var vector = new THREE.Vector3(0, line.length, 0);
  vector.applyAxisAngle(new THREE.Vector3(0, 0, 1), line.rotation.z);
  vector.applyAxisAngle(new THREE.Vector3(1, 0, 0), line.rotation.x);

  var endPoint = vector.add(line.position);

  console.log(endPoint);

  lines.push(createLine(endPoint.x, endPoint.y, endPoint.z, line.length/1.3, line.rotation.z - 45 * (Math.PI/180),  line.rotation.x - 45 * (Math.PI/180))) //line.rotation.y - 45 * (Math.PI/180)));
  lines.push(createLine(endPoint.x, endPoint.y, endPoint.z, line.length/1.3, line.rotation.z + 45 * (Math.PI/180),  line.rotation.x + 45 * (Math.PI/180))) //line.rotation.y + 45 * (Math.PI/180)));

  return lines;
}
函数createLine(x,y,z,length,zrad,xrad)
{
变量点=[
新的三个矢量3(0,0,0),
新的三矢量3(长度/8,长度*0.75,0),
新的三个矢量3(0,长度,0),
];
var spline=新的三个。SplineCurve3(点);
var材料=新的三线基本材料({
颜色:0xff00f0,
});
var geometry=new THREE.geometry();
var splinePoints=spline.getPoints(numPoints);
对于(变量i=0;i
其中
var endPoint=vector.add(line.position)给出了错误的位置。
奇怪的是,如果
line.rotation.x=0,它给出了正确的坐标