射线不能准确判断交点

Ray does not accurately determine the intersection

我想找到曲线和直线的交点。创建了光线投射,但效果不佳。射线的点与实际交点相距较远

Webgl 1,threejs 0.109

        var sartPoint = new THREE.Vector3( -30, -50, 0 );
        var endPoint = new THREE.Vector3( 50, 80, 0 );
        var geometry = new THREE.Geometry();
        geometry.vertices.push(sartPoint);
        geometry.vertices.push(endPoint);
        var materialTmp = new THREE.LineBasicMaterial( { color: 0xffffff, linewidth: 5 } );
        var itemTmp = new THREE.Line( geometry, materialTmp );
        _this.add( itemTmp, 'lines' );
        scene.updateMatrixWorld()
       var curve = new THREE.EllipseCurve(
          0,  0,            // ax, aY
          10, 10,           // xRadius, yRadius
          0,  2 * Math.PI,  // aStartAngle, aEndAngle
          false,            // aClockwise
          0                 // aRotation
        );

        var points = curve.getPoints( 10 );
        var geometry = new THREE.BufferGeometry().setFromPoints( points );
        var material = new THREE.LineBasicMaterial( { color : 0xff00ff } );
        var ellipse = new THREE.Line( geometry, material );
        scene.add( ellipse );
        var raycaster = new THREE.Raycaster(sartPoint, endPoint.clone().normalize());

        var intersects = raycaster.intersectObject( ellipse );
        console.log(intersects);
        if(intersects.length > 0){
          // FIRST dot of intersect
          var dotGeometry2 = new THREE.Geometry();
          dotGeometry2.vertices.push(intersects[0].point);
          var dotMaterial2 = new THREE.PointsMaterial( { size: 5, color: 0x00ff00 } );
          var dot2 = new THREE.Points( dotGeometry2, dotMaterial2 );
          _this.add( dot2, 'points' );
        }

Raycaster 构造函数的第二个参数是一个方向向量。而不是:

endPoint.clone().normalize()

我想你想要:

endPoint.clone().sub(startPoint).normalize()

如果 curve.getPoints( 10 ); 什么时候 curve.getPoints( 100 ); 那不行。