Three.JS Object following a spline path - rotation / tanget issues & constant speed issue

后端 未结 1 621
深忆病人
深忆病人 2020-12-09 06:42

I think my issue is similar to: Orient object's rotation to a spline point tangent in THREE.JS but I can\'t access the jsfiddle\'s properly and I struggled with the seco

相关标签:
1条回答
  • 2020-12-09 07:12

    To maintain a constant speed, you use .getPointAt( t ) instead of .getPoint( t ).

    To get the box to remain tangent to the curve, you follow the same logic as explained in the answer to Orient object's rotation to a spline point tangent in THREE.JS.

        box.position.copy( spline.getPointAt(counter) );
    
        tangent = spline.getTangentAt(counter).normalize();
    
        axis.crossVectors( up, tangent ).normalize();
    
        var radians = Math.acos( up.dot( tangent ) );
    
        box.quaternion.setFromAxisAngle( axis, radians );
    

    EDIT: Updated fiddle: http://jsfiddle.net/qGPTT/509/

    three.js r.88

    0 讨论(0)
提交回复
热议问题